diff --git a/README.md b/README.md index 75d558e..d1351a5 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Index a repo first. The architecture tab is the full typed graph plus `loadpath. ### Impact graph -Toggle **This review** (impact subgraph) vs **Indexed architecture** (the repo map). Dashed edges are inferred (URL/Zod overlap); solid edges are extracted or generated-client stitches. 2D is the default; 3D is available when WebGL is. +Toggle **This review** (impact subgraph) vs **Indexed architecture** (the repo map). Dashed edges are inferred (URL/Zod overlap); solid edges are extracted or generated-client stitches. 2D is the default. 3D uses the same layout algorithms, puts bounded context on the depth axis, and is available when WebGL is. ![Impact graph, this review](docs/screenshots/graph.png) diff --git a/src/loadpath/static/assets/LayeredGraph3D-BCjRMvyT.js b/src/loadpath/static/assets/LayeredGraph3D-BCjRMvyT.js deleted file mode 100644 index ff8a61e..0000000 --- a/src/loadpath/static/assets/LayeredGraph3D-BCjRMvyT.js +++ /dev/null @@ -1,4116 +0,0 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-DuTMxUNT.js";/** - * @license - * Copyright 2010-2026 Three.js Authors - * SPDX-License-Identifier: MIT - */const ya="185",Mi={ROTATE:0,DOLLY:1,PAN:2},vi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ac=0,eo=1,oc=2,ys=1,lc=2,Gi=3,Nn=0,It=1,nn=2,xn=0,Si=1,to=2,no=3,io=4,cc=5,Xn=100,hc=101,uc=102,dc=103,fc=104,pc=200,mc=201,_c=202,gc=203,Pr=204,Dr=205,xc=206,vc=207,Mc=208,Sc=209,Ec=210,yc=211,bc=212,Tc=213,Ac=214,Lr=0,Ir=1,Ur=2,bi=3,Nr=4,Fr=5,Or=6,Br=7,hl=0,Rc=1,wc=2,on=0,ul=1,dl=2,fl=3,pl=4,ml=5,_l=6,gl=7,xl=300,Zn=301,Ti=302,Ks=303,Zs=304,Gs=306,zr=1e3,gn=1001,Gr=1002,bt=1003,Cc=1004,Zi=1005,wt=1006,$s=1007,qn=1008,Bt=1009,vl=1010,Ml=1011,ki=1012,ba=1013,cn=1014,rn=1015,Mn=1016,Ta=1017,Aa=1018,Wi=1020,Sl=35902,El=35899,yl=1021,bl=1022,qt=1023,Sn=1026,Kn=1027,Tl=1028,Ra=1029,$n=1030,wa=1031,Ca=1033,bs=33776,Ts=33777,As=33778,Rs=33779,Vr=35840,Hr=35841,kr=35842,Wr=35843,Xr=36196,Yr=37492,qr=37496,Kr=37488,Zr=37489,Ps=37490,$r=37491,Jr=37808,Qr=37809,jr=37810,ea=37811,ta=37812,na=37813,ia=37814,sa=37815,ra=37816,aa=37817,oa=37818,la=37819,ca=37820,ha=37821,ua=36492,da=36494,fa=36495,pa=36283,ma=36284,Ds=36285,_a=36286,Pc=3200,ga=0,Dc=1,Ln="",Vt="srgb",Ls="srgb-linear",Is="linear",je="srgb",ti=7680,so=519,Lc=512,Ic=513,Uc=514,Pa=515,Nc=516,Fc=517,Da=518,Oc=519,xa=35044,ro="300 es",an=2e3,Xi=2001;function Bc(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Us(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function zc(){const i=Us("canvas");return i.style.display="block",i}const ao={};function Ns(...i){const e="THREE."+i.shift();console.log(e,...i)}function Al(i){const e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Pe(...i){i=Al(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Xe(...i){i=Al(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Ei(...i){const e=i.join(" ");e in ao||(ao[e]=!0,Pe(...i))}function Gc(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const Vc={[Lr]:Ir,[Ur]:Or,[Nr]:Br,[bi]:Fr,[Ir]:Lr,[Or]:Ur,[Br]:Nr,[Fr]:bi};class Bn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const s=n[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let r=0,a=s.length;r>8&255]+At[i>>16&255]+At[i>>24&255]+"-"+At[e&255]+At[e>>8&255]+"-"+At[e>>16&15|64]+At[e>>24&255]+"-"+At[t&63|128]+At[t>>8&255]+"-"+At[t>>16&255]+At[t>>24&255]+At[n&255]+At[n>>8&255]+At[n>>16&255]+At[n>>24&255]).toLowerCase()}function Ve(i,e,t){return Math.max(e,Math.min(t,i))}function Hc(i,e){return(i%e+e)%e}function Js(i,e,t){return(1-t)*i+t*e}function sn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function tt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const kc={DEG2RAD:ws},Ga=class Ga{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,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,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: 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("THREE.Vector2: 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,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,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,t){return this.x=e.x-t.x,this.y=e.y-t.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 t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+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,t){return this.x=Ve(this.x,e.x,t.x),this.y=Ve(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ve(this.x,e,t),this.y=Ve(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ve(n,e,t))}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 t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ve(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Ga.prototype.isVector2=!0;let Re=Ga;class Fn{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let c=n[s+0],l=n[s+1],f=n[s+2],m=n[s+3],h=r[a+0],_=r[a+1],v=r[a+2],S=r[a+3];if(m!==S||c!==h||l!==_||f!==v){let p=c*h+l*_+f*v+m*S;p<0&&(h=-h,_=-_,v=-v,S=-S,p=-p);let u=1-o;if(p<.9995){const A=Math.acos(p),R=Math.sin(A);u=Math.sin(u*A)/R,o=Math.sin(o*A)/R,c=c*u+h*o,l=l*u+_*o,f=f*u+v*o,m=m*u+S*o}else{c=c*u+h*o,l=l*u+_*o,f=f*u+v*o,m=m*u+S*o;const A=1/Math.sqrt(c*c+l*l+f*f+m*m);c*=A,l*=A,f*=A,m*=A}}e[t]=c,e[t+1]=l,e[t+2]=f,e[t+3]=m}static multiplyQuaternionsFlat(e,t,n,s,r,a){const o=n[s],c=n[s+1],l=n[s+2],f=n[s+3],m=r[a],h=r[a+1],_=r[a+2],v=r[a+3];return e[t]=o*v+f*m+c*_-l*h,e[t+1]=c*v+f*h+l*m-o*_,e[t+2]=l*v+f*_+o*h-c*m,e[t+3]=f*v-o*m-c*h-l*_,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,t,n,s){return this._x=e,this._y=t,this._z=n,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,t=!0){const n=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),f=o(s/2),m=o(r/2),h=c(n/2),_=c(s/2),v=c(r/2);switch(a){case"XYZ":this._x=h*f*m+l*_*v,this._y=l*_*m-h*f*v,this._z=l*f*v+h*_*m,this._w=l*f*m-h*_*v;break;case"YXZ":this._x=h*f*m+l*_*v,this._y=l*_*m-h*f*v,this._z=l*f*v-h*_*m,this._w=l*f*m+h*_*v;break;case"ZXY":this._x=h*f*m-l*_*v,this._y=l*_*m+h*f*v,this._z=l*f*v+h*_*m,this._w=l*f*m-h*_*v;break;case"ZYX":this._x=h*f*m-l*_*v,this._y=l*_*m+h*f*v,this._z=l*f*v-h*_*m,this._w=l*f*m+h*_*v;break;case"YZX":this._x=h*f*m+l*_*v,this._y=l*_*m+h*f*v,this._z=l*f*v-h*_*m,this._w=l*f*m-h*_*v;break;case"XZY":this._x=h*f*m-l*_*v,this._y=l*_*m-h*f*v,this._z=l*f*v+h*_*m,this._w=l*f*m+h*_*v;break;default:Pe("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],f=t[6],m=t[10],h=n+o+m;if(h>0){const _=.5/Math.sqrt(h+1);this._w=.25/_,this._x=(f-c)*_,this._y=(r-l)*_,this._z=(a-s)*_}else if(n>o&&n>m){const _=2*Math.sqrt(1+n-o-m);this._w=(f-c)/_,this._x=.25*_,this._y=(s+a)/_,this._z=(r+l)/_}else if(o>m){const _=2*Math.sqrt(1+o-n-m);this._w=(r-l)/_,this._x=(s+a)/_,this._y=.25*_,this._z=(c+f)/_}else{const _=2*Math.sqrt(1+m-n-o);this._w=(a-s)/_,this._x=(r+l)/_,this._y=(c+f)/_,this._z=.25*_}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ve(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);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,t){const n=e._x,s=e._y,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,f=t._w;return this._x=n*f+a*o+s*l-r*c,this._y=s*f+a*c+r*o-n*l,this._z=r*f+a*l+n*c-s*o,this._w=a*f-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),f=Math.sin(l);c=Math.sin(c*l)/f,t=Math.sin(t*l)/f,this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),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}}const Va=class Va{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: 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("THREE.Vector3: 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,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,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,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.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,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(oo.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(oo.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*s-o*n),f=2*(o*t-r*s),m=2*(r*n-a*t);return this.x=t+c*l+a*m-o*f,this.y=n+c*f+o*l-r*m,this.z=s+c*m+r*f-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[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,t){return this.x=Ve(this.x,e.x,t.x),this.y=Ve(this.y,e.y,t.y),this.z=Ve(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ve(this.x,e,t),this.y=Ve(this.y,e,t),this.z=Ve(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ve(n,e,t))}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,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,s=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Qs.copy(this).projectOnVector(e),this.sub(Qs)}reflect(e){return this.sub(Qs.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ve(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+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,t,n){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*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,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Va.prototype.isVector3=!0;let U=Va;const Qs=new U,oo=new Fn,Ha=class Ha{constructor(e,t,n,s,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l)}set(e,t,n,s,r,a,o,c,l){const f=this.elements;return f[0]=e,f[1]=s,f[2]=o,f[3]=t,f[4]=r,f[5]=c,f[6]=n,f[7]=a,f[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],f=n[4],m=n[7],h=n[2],_=n[5],v=n[8],S=s[0],p=s[3],u=s[6],A=s[1],R=s[4],M=s[7],T=s[2],y=s[5],w=s[8];return r[0]=a*S+o*A+c*T,r[3]=a*p+o*R+c*y,r[6]=a*u+o*M+c*w,r[1]=l*S+f*A+m*T,r[4]=l*p+f*R+m*y,r[7]=l*u+f*M+m*w,r[2]=h*S+_*A+v*T,r[5]=h*p+_*R+v*y,r[8]=h*u+_*M+v*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],f=e[8];return t*a*f-t*o*l-n*r*f+n*o*c+s*r*l-s*a*c}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],f=e[8],m=f*a-o*l,h=o*c-f*r,_=l*r-a*c,v=t*m+n*h+s*_;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const S=1/v;return e[0]=m*S,e[1]=(s*l-f*n)*S,e[2]=(o*n-s*a)*S,e[3]=h*S,e[4]=(f*t-s*c)*S,e[5]=(s*r-o*t)*S,e[6]=_*S,e[7]=(n*c-l*t)*S,e[8]=(a*t-n*r)*S,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-s*l,s*c,-s*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return Ei("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(js.makeScale(e,t)),this}rotate(e){return Ei("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(js.makeRotation(-e)),this}translate(e,t){return Ei("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(js.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Ha.prototype.isMatrix3=!0;let Ie=Ha;const js=new Ie,lo=new Ie().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),co=new Ie().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Wc(){const i={enabled:!0,workingColorSpace:Ls,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===je&&(s.r=vn(s.r),s.g=vn(s.g),s.b=vn(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===je&&(s.r=yi(s.r),s.g=yi(s.g),s.b=yi(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Ln?Is:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].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,r){return Ei("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ei("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Ls]:{primaries:e,whitePoint:n,transfer:Is,toXYZ:lo,fromXYZ:co,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Vt},outputColorSpaceConfig:{drawingBufferColorSpace:Vt}},[Vt]:{primaries:e,whitePoint:n,transfer:je,toXYZ:lo,fromXYZ:co,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Vt}}}),i}const Ye=Wc();function vn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function yi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ni;class Xc{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ni===void 0&&(ni=Us("canvas")),ni.width=e.width,ni.height=e.height;const s=ni.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=ni}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Us("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(tr).x}get height(){return this.source.getSize(tr).y}get depth(){return this.source.getSize(tr).z}get image(){return this.source.data}set image(e){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,t){this.updateRanges.push({start:e,count:t})}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.normalized=e.normalized,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 t in e){const n=e[t];if(n===void 0){Pe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Pe(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={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,normalized:this.normalized,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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==xl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case zr:e.x=e.x-Math.floor(e.x);break;case gn:e.x=e.x<0?0:1;break;case Gr: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 zr:e.y=e.y-Math.floor(e.y);break;case gn:e.y=e.y<0?0:1;break;case Gr: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++}}Ct.DEFAULT_IMAGE=null;Ct.DEFAULT_MAPPING=xl;Ct.DEFAULT_ANISOTROPY=1;const ka=class ka{constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,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,t,n,s){return this.x=e,this.y=t,this.z=n,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,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: 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("THREE.Vector4: 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,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,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,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.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 t=this.x,n=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*r,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 t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r;const c=e.elements,l=c[0],f=c[4],m=c[8],h=c[1],_=c[5],v=c[9],S=c[2],p=c[6],u=c[10];if(Math.abs(f-h)<.01&&Math.abs(m-S)<.01&&Math.abs(v-p)<.01){if(Math.abs(f+h)<.1&&Math.abs(m+S)<.1&&Math.abs(v+p)<.1&&Math.abs(l+_+u-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const R=(l+1)/2,M=(_+1)/2,T=(u+1)/2,y=(f+h)/4,w=(m+S)/4,g=(v+p)/4;return R>M&&R>T?R<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(R),s=y/n,r=w/n):M>T?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=y/s,r=g/s):T<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(T),n=w/r,s=g/r),this.set(n,s,r,t),this}let A=Math.sqrt((p-v)*(p-v)+(m-S)*(m-S)+(h-f)*(h-f));return Math.abs(A)<.001&&(A=1),this.x=(p-v)/A,this.y=(m-S)/A,this.z=(h-f)/A,this.w=Math.acos((l+_+u-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[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,t){return this.x=Ve(this.x,e.x,t.x),this.y=Ve(this.y,e.y,t.y),this.z=Ve(this.z,e.z,t.z),this.w=Ve(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ve(this.x,e,t),this.y=Ve(this.y,e,t),this.z=Ve(this.z,e,t),this.w=Ve(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ve(n,e,t))}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,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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}};ka.prototype.isVector4=!0;let ut=ka;class Kc extends Bn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ut(0,0,e,t),this.scissorTest=!1,this.viewport=new ut(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new Ct(s),a=n.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}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 t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),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 r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.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=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,f=c.length;l0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),f.length>0&&(n.images=f),m.length>0&&(n.shapes=m),h.length>0&&(n.skeletons=h),_.length>0&&(n.animations=_),v.length>0&&(n.nodes=v)}return n.object=s,n;function a(o){const c=[];for(const l in o){const f=o[l];delete f.metadata,c.push(f)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!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.pivot=e.pivot!==null?e.pivot.clone():null,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.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n_+v?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=_-v&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(nh)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Vi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const wl={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},An={h:0,s:0,l:0},Qi={h:0,s:0,l:0};function sr(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class Oe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===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,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Vt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ye.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Ye.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ye.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Ye.workingColorSpace){if(e=Hc(e,1),t=Ve(t,0,1),n=Ve(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=sr(a,r,e+1/3),this.g=sr(a,r,e),this.b=sr(a,r,e-1/3)}return Ye.colorSpaceToWorking(this,s),this}setStyle(e,t=Vt){function n(r){r!==void 0&&parseFloat(r)<1&&Pe("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Pe("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Pe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Vt){const n=wl[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Pe("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=vn(e.r),this.g=vn(e.g),this.b=vn(e.b),this}copyLinearToSRGB(e){return this.r=yi(e.r),this.g=yi(e.g),this.b=yi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Vt){return Ye.workingToColorSpace(Rt.copy(this),e),Math.round(Ve(Rt.r*255,0,255))*65536+Math.round(Ve(Rt.g*255,0,255))*256+Math.round(Ve(Rt.b*255,0,255))}getHexString(e=Vt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ye.workingColorSpace){Ye.workingToColorSpace(Rt.copy(this),t);const n=Rt.r,s=Rt.g,r=Rt.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let c,l;const f=(o+a)/2;if(o===a)c=0,l=0;else{const m=a-o;switch(l=f<=.5?m/(a+o):m/(2-a-o),a){case n:c=(s-r)/m+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Xt=new U,fn=new U,rr=new U,pn=new U,ai=new U,oi=new U,xo=new U,ar=new U,or=new U,lr=new U,cr=new ut,hr=new ut,ur=new ut;class kt{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),Xt.subVectors(e,t),s.cross(Xt);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){Xt.subVectors(s,t),fn.subVectors(n,t),rr.subVectors(e,t);const a=Xt.dot(Xt),o=Xt.dot(fn),c=Xt.dot(rr),l=fn.dot(fn),f=fn.dot(rr),m=a*l-o*o;if(m===0)return r.set(0,0,0),null;const h=1/m,_=(l*c-o*f)*h,v=(a*f-o*c)*h;return r.set(1-_-v,v,_)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,pn)===null?!1:pn.x>=0&&pn.y>=0&&pn.x+pn.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,pn)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,pn.x),c.addScaledVector(a,pn.y),c.addScaledVector(o,pn.z),c)}static getInterpolatedAttribute(e,t,n,s,r,a){return cr.setScalar(0),hr.setScalar(0),ur.setScalar(0),cr.fromBufferAttribute(e,t),hr.fromBufferAttribute(e,n),ur.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(cr,r.x),a.addScaledVector(hr,r.y),a.addScaledVector(ur,r.z),a}static isFrontFacing(e,t,n,s){return Xt.subVectors(n,t),fn.subVectors(e,t),Xt.cross(fn).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),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 Xt.subVectors(this.c,this.b),fn.subVectors(this.a,this.b),Xt.cross(fn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return kt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return kt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return kt.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return kt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return kt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,s=this.b,r=this.c;let a,o;ai.subVectors(s,n),oi.subVectors(r,n),ar.subVectors(e,n);const c=ai.dot(ar),l=oi.dot(ar);if(c<=0&&l<=0)return t.copy(n);or.subVectors(e,s);const f=ai.dot(or),m=oi.dot(or);if(f>=0&&m<=f)return t.copy(s);const h=c*m-f*l;if(h<=0&&c>=0&&f<=0)return a=c/(c-f),t.copy(n).addScaledVector(ai,a);lr.subVectors(e,r);const _=ai.dot(lr),v=oi.dot(lr);if(v>=0&&_<=v)return t.copy(r);const S=_*l-c*v;if(S<=0&&l>=0&&v<=0)return o=l/(l-v),t.copy(n).addScaledVector(oi,o);const p=f*v-_*m;if(p<=0&&m-f>=0&&_-v>=0)return xo.subVectors(r,s),o=(m-f)/(m-f+(_-v)),t.copy(s).addScaledVector(xo,o);const u=1/(p+S+h);return a=S*u,o=h*u,t.copy(n).addScaledVector(ai,a).addScaledVector(oi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class wi{constructor(e=new U(1/0,1/0,1/0),t=new U(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=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,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(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,Yt),Yt.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Di),es.subVectors(this.max,Di),li.subVectors(e.a,Di),ci.subVectors(e.b,Di),hi.subVectors(e.c,Di),Rn.subVectors(ci,li),wn.subVectors(hi,ci),Gn.subVectors(li,hi);let t=[0,-Rn.z,Rn.y,0,-wn.z,wn.y,0,-Gn.z,Gn.y,Rn.z,0,-Rn.x,wn.z,0,-wn.x,Gn.z,0,-Gn.x,-Rn.y,Rn.x,0,-wn.y,wn.x,0,-Gn.y,Gn.x,0];return!dr(t,li,ci,hi,es)||(t=[1,0,0,0,1,0,0,0,1],!dr(t,li,ci,hi,es))?!1:(ts.crossVectors(Rn,wn),t=[ts.x,ts.y,ts.z],dr(t,li,ci,hi,es))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Yt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Yt).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:(mn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),mn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),mn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),mn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),mn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),mn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),mn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),mn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(mn),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 mn=[new U,new U,new U,new U,new U,new U,new U,new U],Yt=new U,ji=new wi,li=new U,ci=new U,hi=new U,Rn=new U,wn=new U,Gn=new U,Di=new U,es=new U,ts=new U,Vn=new U;function dr(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Vn.fromArray(i,r);const o=s.x*Math.abs(Vn.x)+s.y*Math.abs(Vn.y)+s.z*Math.abs(Vn.z),c=e.dot(Vn),l=t.dot(Vn),f=n.dot(Vn);if(Math.max(-Math.max(c,l,f),Math.min(c,l,f))>o)return!1}return!0}const _t=new U,ns=new Re;let sh=0;class Kt extends Bn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:sh++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=xa,this.updateRanges=[],this.gpuType=rn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.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,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}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;Li.subVectors(e,this.center);const t=Li.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Li,s/n),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):(fr.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Li.copy(e.center).add(fr)),this.expandByPoint(Li.copy(e.center).sub(fr))),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}}let ah=0;const Gt=new lt,pr=new Et,ui=new U,Ot=new wi,Ii=new wi,St=new U;class Ut extends Bn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ah++}),this.uuid=Un(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Bc(e)?Pl:Cl)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Ie().getNormalMatrix(e);n.applyNormalMatrix(r),n.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._transformed=!0,this}applyQuaternion(e){return Gt.makeRotationFromQuaternion(e),this.applyMatrix4(Gt),this}rotateX(e){return Gt.makeRotationX(e),this.applyMatrix4(Gt),this}rotateY(e){return Gt.makeRotationY(e),this.applyMatrix4(Gt),this}rotateZ(e){return Gt.makeRotationZ(e),this.applyMatrix4(Gt),this}translate(e,t,n){return Gt.makeTranslation(e,t,n),this.applyMatrix4(Gt),this}scale(e,t,n){return Gt.makeScale(e,t,n),this.applyMatrix4(Gt),this}lookAt(e){return pr.lookAt(e),pr.updateMatrix(),this.applyMatrix4(pr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ui).negate(),this.translate(ui.x,ui.y,ui.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let s=0,r=e.length;st.count&&Pe("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Xe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const s={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],f=[];for(let m=0,h=l.length;m0&&(s[c]=f,r=!0)}r&&(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 t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const s=e.attributes;for(const l in s){const f=s[l];this.setAttribute(l,f.clone(t))}const r=e.morphAttributes;for(const l in r){const f=[],m=r[l];for(let h=0,_=m.length;h<_;h++)f.push(m[h].clone(t));this.morphAttributes[l]=f}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,f=a.length;l0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){Pe(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Pe(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Si&&(n.blending=this.blending),this.side!==Nn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Pr&&(n.blendSrc=this.blendSrc),this.blendDst!==Dr&&(n.blendDst=this.blendDst),this.blendEquation!==Xn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==bi&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==so&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ti&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ti&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ti&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Oe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Re().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Re().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}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 t=e.clippingPlanes;let n=null;if(t!==null){const s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,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.allowOverride=e.allowOverride,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 Dl extends Jn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Oe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let di;const Ui=new U,fi=new U,pi=new U,mi=new Re,Ni=new Re,Ll=new lt,is=new U,Fi=new U,ss=new U,vo=new Re,mr=new Re,Mo=new Re;class ch extends Et{constructor(e=new Dl){if(super(),this.isSprite=!0,this.type="Sprite",di===void 0){di=new Ut;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new oh(t,5);di.setIndex([0,1,2,0,2,3]),di.setAttribute("position",new Fs(n,3,0,!1)),di.setAttribute("uv",new Fs(n,2,3,!1))}this.geometry=di,this.material=e,this.center=new Re(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Xe('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),fi.setFromMatrixScale(this.matrixWorld),Ll.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),pi.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&fi.multiplyScalar(-pi.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;rs(is.set(-.5,-.5,0),pi,a,fi,s,r),rs(Fi.set(.5,-.5,0),pi,a,fi,s,r),rs(ss.set(.5,.5,0),pi,a,fi,s,r),vo.set(0,0),mr.set(1,0),Mo.set(1,1);let o=e.ray.intersectTriangle(is,Fi,ss,!1,Ui);if(o===null&&(rs(Fi.set(-.5,.5,0),pi,a,fi,s,r),mr.set(0,1),o=e.ray.intersectTriangle(is,ss,Fi,!1,Ui),o===null))return;const c=e.ray.origin.distanceTo(Ui);ce.far||t.push({distance:c,point:Ui.clone(),uv:kt.getInterpolation(Ui,is,Fi,ss,vo,mr,Mo,new Re),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function rs(i,e,t,n,s,r){mi.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(Ni.x=r*mi.x-s*mi.y,Ni.y=s*mi.x+r*mi.y):Ni.copy(mi),i.copy(e),i.x+=Ni.x,i.y+=Ni.y,i.applyMatrix4(Ll)}const _n=new U,_r=new U,as=new U,Cn=new U,gr=new U,os=new U,xr=new U;class Hs{constructor(e=new U,t=new U(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.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,_n)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=_n.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_n.copy(this.origin).addScaledVector(this.direction,t),_n.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){_r.copy(e).add(t).multiplyScalar(.5),as.copy(t).sub(e).normalize(),Cn.copy(this.origin).sub(_r);const r=e.distanceTo(t)*.5,a=-this.direction.dot(as),o=Cn.dot(this.direction),c=-Cn.dot(as),l=Cn.lengthSq(),f=Math.abs(1-a*a);let m,h,_,v;if(f>0)if(m=a*c-o,h=a*o-c,v=r*f,m>=0)if(h>=-v)if(h<=v){const S=1/f;m*=S,h*=S,_=m*(m+a*h+2*o)+h*(a*m+h+2*c)+l}else h=r,m=Math.max(0,-(a*h+o)),_=-m*m+h*(h+2*c)+l;else h=-r,m=Math.max(0,-(a*h+o)),_=-m*m+h*(h+2*c)+l;else h<=-v?(m=Math.max(0,-(-a*r+o)),h=m>0?-r:Math.min(Math.max(-r,-c),r),_=-m*m+h*(h+2*c)+l):h<=v?(m=0,h=Math.min(Math.max(-r,-c),r),_=h*(h+2*c)+l):(m=Math.max(0,-(a*r+o)),h=m>0?r:Math.min(Math.max(-r,-c),r),_=-m*m+h*(h+2*c)+l);else h=a>0?-r:r,m=Math.max(0,-(a*h+o)),_=-m*m+h*(h+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,m),s&&s.copy(_r).addScaledVector(as,h),_}intersectSphere(e,t){_n.subVectors(e.center,this.origin);const n=_n.dot(this.direction),s=_n.dot(_n)-n*n,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,a,o,c;const l=1/this.direction.x,f=1/this.direction.y,m=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,s=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,s=(e.min.x-h.x)*l),f>=0?(r=(e.min.y-h.y)*f,a=(e.max.y-h.y)*f):(r=(e.max.y-h.y)*f,a=(e.min.y-h.y)*f),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a=0?(o=(e.min.z-h.z)*m,c=(e.max.z-h.z)*m):(o=(e.max.z-h.z)*m,c=(e.min.z-h.z)*m),n>c||o>s)||((o>n||n!==n)&&(n=o),(c=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,_n)!==null}intersectTriangle(e,t,n,s,r){gr.subVectors(t,e),os.subVectors(n,e),xr.crossVectors(gr,os);let a=this.direction.dot(xr),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Cn.subVectors(this.origin,e);const c=o*this.direction.dot(os.crossVectors(Cn,os));if(c<0)return null;const l=o*this.direction.dot(gr.cross(Cn));if(l<0||c+l>a)return null;const f=-o*Cn.dot(xr);return f<0?null:this.at(f/a,r)}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 Ua extends Jn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Oe(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 On,this.combine=hl,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 So=new lt,Hn=new Hs,ls=new Vs,Eo=new U,cs=new U,hs=new U,us=new U,vr=new U,ds=new U,yo=new U,fs=new U;class Zt extends Et{constructor(e=new Ut,t=new Ua){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),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 t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(So.copy(r).invert(),Hn.copy(e.ray).applyMatrix4(So),!(n.boundingBox!==null&&Hn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Hn)))}_computeIntersections(e,t,n){let s;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,f=r.attributes.uv1,m=r.attributes.normal,h=r.groups,_=r.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,S=h.length;vt.far?null:{distance:l,point:fs.clone(),object:i}}function ps(i,e,t,n,s,r,a,o,c,l){i.getVertexPosition(o,cs),i.getVertexPosition(c,hs),i.getVertexPosition(l,us);const f=hh(i,e,t,n,cs,hs,us,yo);if(f){const m=new U;kt.getBarycoord(yo,cs,hs,us,m),s&&(f.uv=kt.getInterpolatedAttribute(s,o,c,l,m,new Re)),r&&(f.uv1=kt.getInterpolatedAttribute(r,o,c,l,m,new Re)),a&&(f.normal=kt.getInterpolatedAttribute(a,o,c,l,m,new U),f.normal.dot(n.direction)>0&&f.normal.multiplyScalar(-1));const h={a:o,b:c,c:l,normal:new U,materialIndex:0};kt.getNormal(cs,hs,us,h.normal),f.face=h,f.barycoord=m}return f}class uh extends Ct{constructor(e=null,t=1,n=1,s,r,a,o,c,l=bt,f=bt,m,h){super(null,a,o,c,l,f,s,r,m,h),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Mr=new U,dh=new U,fh=new Ie;class Dn{constructor(e=new U(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const s=Mr.subVectors(n,t).cross(dh.subVectors(e,t)).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,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const s=e.delta(Mr),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||fh.getNormalMatrix(e),s=this.coplanarPoint(Mr).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const kn=new Vs,ph=new Re(.5,.5),ms=new U;class Na{constructor(e=new Dn,t=new Dn,n=new Dn,s=new Dn,r=new Dn,a=new Dn){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=an,n=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],f=r[4],m=r[5],h=r[6],_=r[7],v=r[8],S=r[9],p=r[10],u=r[11],A=r[12],R=r[13],M=r[14],T=r[15];if(s[0].setComponents(l-a,_-f,u-v,T-A).normalize(),s[1].setComponents(l+a,_+f,u+v,T+A).normalize(),s[2].setComponents(l+o,_+m,u+S,T+R).normalize(),s[3].setComponents(l-o,_-m,u-S,T-R).normalize(),n)s[4].setComponents(c,h,p,M).normalize(),s[5].setComponents(l-c,_-h,u-p,T-M).normalize();else if(s[4].setComponents(l-c,_-h,u-p,T-M).normalize(),t===an)s[5].setComponents(l+c,_+h,u+p,T+M).normalize();else if(t===Xi)s[5].setComponents(c,h,p,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),kn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),kn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(kn)}intersectsSprite(e){kn.center.set(0,0,0);const t=ph.distanceTo(e.center);return kn.radius=.7071067811865476+t,kn.applyMatrix4(e.matrixWorld),this.intersectsSphere(kn)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)0?e.max.x:e.min.x,ms.y=s.normal.y>0?e.max.y:e.min.y,ms.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(ms)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Il extends Jn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Os=new U,Bs=new U,bo=new lt,Oi=new Hs,_s=new Vs,Sr=new U,To=new U;class mh extends Et{constructor(e=new Ut,t=new Il){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let s=1,r=t.count;s0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;rn)return;Sr.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Sr);if(!(le.far))return{distance:l,point:To.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const Ao=new U,Ro=new U;class _h extends mh{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let s=0,r=t.count;s0?1:-1,f.push(j.x,j.y,j.z),m.push(_e/w),m.push(1-re/g),H+=1}}for(let re=0;re0)&&_.push(R,M,y),(u!==n-1||c0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new Oe().setHex(s.value);break;case"v2":this.uniforms[n].value=new Re().fromArray(s.value);break;case"v3":this.uniforms[n].value=new U().fromArray(s.value);break;case"v4":this.uniforms[n].value=new ut().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Ie().fromArray(s.value);break;case"m4":this.uniforms[n].value=new lt().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class yh extends hn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class bh extends Jn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Oe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ga,this.normalScale=new Re(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new On,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Th extends Jn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Pc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ah extends Jn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Ol extends Et{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Oe(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}const Er=new lt,Co=new U,Po=new U;class Rh{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Re(512,512),this.mapType=Bt,this.map=null,this.mapPass=null,this.matrix=new lt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Na,this._frameExtents=new Re(1,1),this._viewportCount=1,this._viewports=[new ut(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Co.setFromMatrixPosition(e.matrixWorld),t.position.copy(Co),Po.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Po),t.updateMatrixWorld(),Er.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Er,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Xi||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Er)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const xs=new U,vs=new Fn,jt=new U;class Bl extends Et{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new lt,this.projectionMatrix=new lt,this.projectionMatrixInverse=new lt,this.coordinateSystem=an,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),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.matrixWorld.decompose(xs,vs,jt),jt.x===1&&jt.y===1&&jt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xs,vs,jt.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(xs,vs,jt),jt.x===1&&jt.y===1&&jt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xs,vs,jt.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Pn=new U,Do=new Re,Lo=new Re;class Ht extends Bl{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),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 t=.5*this.getFilmHeight()/e;this.fov=va*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ws*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return va*2*Math.atan(Math.tan(ws*.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,t,n){Pn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Pn.x,Pn.y).multiplyScalar(-e/Pn.z),Pn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Pn.x,Pn.y).multiplyScalar(-e/Pn.z)}getViewSize(e,t){return this.getViewBounds(e,Do,Lo),t.subVectors(Lo,Do)}setViewOffset(e,t,n,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(ws*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,t-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Ba extends Bl{constructor(e=-1,t=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=s+t,c=s-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,f=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=f*this.view.offsetY,c=o-f*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class wh extends Rh{constructor(){super(new Ba(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ch extends Ol{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.shadow=new wh}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class Ph extends Ol{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}const _i=-90,gi=1;class Dh extends Et{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new Ht(_i,gi,e,t);s.layers=this.layers,this.add(s);const r=new Ht(_i,gi,e,t);r.layers=this.layers,this.add(r);const a=new Ht(_i,gi,e,t);a.layers=this.layers,this.add(a);const o=new Ht(_i,gi,e,t);o.layers=this.layers,this.add(o);const c=new Ht(_i,gi,e,t);c.layers=this.layers,this.add(c);const l=new Ht(_i,gi,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===an)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Xi)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,f]=this.children,m=e.getRenderTarget(),h=e.getActiveCubeFace(),_=e.getActiveMipmapLevel(),v=e.xr.enabled;e.xr.enabled=!1;const S=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let p=!1;e.isWebGLRenderer===!0?p=e.state.buffers.depth.getReversed():p=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=S,e.setRenderTarget(n,5,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,f),e.setRenderTarget(m,h,_),e.xr.enabled=v,n.texture.needsPMREMUpdate=!0}}class Lh extends Ht{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Io=new lt;class Ih{constructor(e,t,n=0,s=1/0){this.ray=new Hs(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new Ia,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Xe("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Io.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Io),this}intersectObject(e,t=!0,n=[]){return Ma(e,this,n,t),n.sort(Uo),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s_.start-v.start);let h=0;for(let _=1;_ 0 - vec4 plane; - #ifdef ALPHA_TO_COVERAGE - float distanceToPlane, distanceGradient; - float clipOpacity = 1.0; - #pragma unroll_loop_start - for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; - distanceGradient = fwidth( distanceToPlane ) / 2.0; - clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); - if ( clipOpacity == 0.0 ) discard; - } - #pragma unroll_loop_end - #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES - float unionClipOpacity = 1.0; - #pragma unroll_loop_start - for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; - distanceGradient = fwidth( distanceToPlane ) / 2.0; - unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); - } - #pragma unroll_loop_end - clipOpacity *= 1.0 - unionClipOpacity; - #endif - diffuseColor.a *= clipOpacity; - if ( diffuseColor.a == 0.0 ) discard; - #else - #pragma unroll_loop_start - for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; - } - #pragma unroll_loop_end - #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES - bool clipped = true; - #pragma unroll_loop_start - for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; - } - #pragma unroll_loop_end - if ( clipped ) discard; - #endif - #endif -#endif`,jh=`#if NUM_CLIPPING_PLANES > 0 - varying vec3 vClipPosition; - uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`,eu=`#if NUM_CLIPPING_PLANES > 0 - varying vec3 vClipPosition; -#endif`,tu=`#if NUM_CLIPPING_PLANES > 0 - vClipPosition = - mvPosition.xyz; -#endif`,nu=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) - diffuseColor *= vColor; -#endif`,iu=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) - varying vec4 vColor; -#endif`,su=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) - varying vec4 vColor; -#endif`,ru=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) - vColor = vec4( 1.0 ); -#endif -#ifdef USE_COLOR_ALPHA - vColor *= color; -#elif defined( USE_COLOR ) - vColor.rgb *= color; -#endif -#ifdef USE_INSTANCING_COLOR - vColor.rgb *= instanceColor.rgb; -#endif -#ifdef USE_BATCHING_COLOR - vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); -#endif`,au=`#define PI 3.141592653589793 -#define PI2 6.283185307179586 -#define PI_HALF 1.5707963267948966 -#define RECIPROCAL_PI 0.3183098861837907 -#define RECIPROCAL_PI2 0.15915494309189535 -#define EPSILON 1e-6 -#ifndef saturate -#define saturate( a ) clamp( a, 0.0, 1.0 ) -#endif -#define whiteComplement( a ) ( 1.0 - saturate( a ) ) -float pow2( const in float x ) { return x*x; } -vec3 pow2( const in vec3 x ) { return x*x; } -float pow3( const in float x ) { return x*x*x; } -float pow4( const in float x ) { float x2 = x*x; return x2*x2; } -float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } -float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } -highp float rand( const in vec2 uv ) { - const highp float a = 12.9898, b = 78.233, c = 43758.5453; - highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); - return fract( sin( sn ) * c ); -} -#ifdef HIGH_PRECISION - float precisionSafeLength( vec3 v ) { return length( v ); } -#else - float precisionSafeLength( vec3 v ) { - float maxComponent = max3( abs( v ) ); - return length( v / maxComponent ) * maxComponent; - } -#endif -struct IncidentLight { - vec3 color; - vec3 direction; - bool visible; -}; -struct ReflectedLight { - vec3 directDiffuse; - vec3 directSpecular; - vec3 indirectDiffuse; - vec3 indirectSpecular; -}; -#ifdef USE_ALPHAHASH - varying vec3 vPosition; -#endif -vec3 transformDirection( in vec3 dir, in mat4 matrix ) { - return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); -} -#define inverseTransformDirection transformDirectionByInverseViewMatrix -vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { - return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); -} -vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { - return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); -} -bool isPerspectiveMatrix( mat4 m ) { - return m[ 2 ][ 3 ] == - 1.0; -} -vec2 equirectUv( in vec3 dir ) { - float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; - float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; - return vec2( u, v ); -} -vec3 BRDF_Lambert( const in vec3 diffuseColor ) { - return RECIPROCAL_PI * diffuseColor; -} -vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { - float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); - return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} -float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { - float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); - return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} // validated`,ou=`#ifdef ENVMAP_TYPE_CUBE_UV - #define cubeUV_minMipLevel 4.0 - #define cubeUV_minTileSize 16.0 - float getFace( vec3 direction ) { - vec3 absDirection = abs( direction ); - float face = - 1.0; - if ( absDirection.x > absDirection.z ) { - if ( absDirection.x > absDirection.y ) - face = direction.x > 0.0 ? 0.0 : 3.0; - else - face = direction.y > 0.0 ? 1.0 : 4.0; - } else { - if ( absDirection.z > absDirection.y ) - face = direction.z > 0.0 ? 2.0 : 5.0; - else - face = direction.y > 0.0 ? 1.0 : 4.0; - } - return face; - } - vec2 getUV( vec3 direction, float face ) { - vec2 uv; - if ( face == 0.0 ) { - uv = vec2( direction.z, direction.y ) / abs( direction.x ); - } else if ( face == 1.0 ) { - uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); - } else if ( face == 2.0 ) { - uv = vec2( - direction.x, direction.y ) / abs( direction.z ); - } else if ( face == 3.0 ) { - uv = vec2( - direction.z, direction.y ) / abs( direction.x ); - } else if ( face == 4.0 ) { - uv = vec2( - direction.x, direction.z ) / abs( direction.y ); - } else { - uv = vec2( direction.x, direction.y ) / abs( direction.z ); - } - return 0.5 * ( uv + 1.0 ); - } - vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { - float face = getFace( direction ); - float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); - mipInt = max( mipInt, cubeUV_minMipLevel ); - float faceSize = exp2( mipInt ); - highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; - if ( face > 2.0 ) { - uv.y += faceSize; - face -= 3.0; - } - uv.x += face * faceSize; - uv.x += filterInt * 3.0 * cubeUV_minTileSize; - uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); - uv.x *= CUBEUV_TEXEL_WIDTH; - uv.y *= CUBEUV_TEXEL_HEIGHT; - #ifdef texture2DGradEXT - return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; - #else - return texture2D( envMap, uv ).rgb; - #endif - } - #define cubeUV_r0 1.0 - #define cubeUV_m0 - 2.0 - #define cubeUV_r1 0.8 - #define cubeUV_m1 - 1.0 - #define cubeUV_r4 0.4 - #define cubeUV_m4 2.0 - #define cubeUV_r5 0.305 - #define cubeUV_m5 3.0 - #define cubeUV_r6 0.21 - #define cubeUV_m6 4.0 - float roughnessToMip( float roughness ) { - float mip = 0.0; - if ( roughness >= cubeUV_r1 ) { - mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; - } else if ( roughness >= cubeUV_r4 ) { - mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; - } else if ( roughness >= cubeUV_r5 ) { - mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; - } else if ( roughness >= cubeUV_r6 ) { - mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; - } else { - mip = - 2.0 * log2( 1.16 * roughness ); } - return mip; - } - vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { - float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); - float mipF = fract( mip ); - float mipInt = floor( mip ); - vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); - if ( mipF == 0.0 ) { - return vec4( color0, 1.0 ); - } else { - vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); - return vec4( mix( color0, color1, mipF ), 1.0 ); - } - } -#endif`,lu=`vec3 transformedNormal = objectNormal; -#ifdef USE_TANGENT - vec3 transformedTangent = objectTangent; -#endif -#ifdef USE_BATCHING - mat3 bm = mat3( batchingMatrix ); - transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); - transformedNormal = bm * transformedNormal; - #ifdef USE_TANGENT - transformedTangent = bm * transformedTangent; - #endif -#endif -#ifdef USE_INSTANCING - mat3 im = mat3( instanceMatrix ); - transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); - transformedNormal = im * transformedNormal; - #ifdef USE_TANGENT - transformedTangent = im * transformedTangent; - #endif -#endif -transformedNormal = normalMatrix * transformedNormal; -#ifdef FLIP_SIDED - transformedNormal = - transformedNormal; -#endif -#ifdef USE_TANGENT - transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; -#endif`,cu=`#ifdef USE_DISPLACEMENTMAP - uniform sampler2D displacementMap; - uniform float displacementScale; - uniform float displacementBias; -#endif`,hu=`#ifdef USE_DISPLACEMENTMAP - transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,uu=`#ifdef USE_EMISSIVEMAP - vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); - #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE - emissiveColor = sRGBTransferEOTF( emissiveColor ); - #endif - totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,du=`#ifdef USE_EMISSIVEMAP - uniform sampler2D emissiveMap; -#endif`,fu="gl_FragColor = linearToOutputTexel( gl_FragColor );",pu=`vec4 LinearTransferOETF( in vec4 value ) { - return value; -} -vec4 sRGBTransferEOTF( in vec4 value ) { - return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); -} -vec4 sRGBTransferOETF( in vec4 value ) { - return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); -}`,mu=`#ifdef USE_ENVMAP - #ifdef ENV_WORLDPOS - vec3 cameraToFrag; - if ( isOrthographic ) { - cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); - } else { - cameraToFrag = normalize( vWorldPosition - cameraPosition ); - } - vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); - #ifdef ENVMAP_MODE_REFLECTION - vec3 reflectVec = reflect( cameraToFrag, worldNormal ); - #else - vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); - #endif - #else - vec3 reflectVec = vReflect; - #endif - #ifdef ENVMAP_TYPE_CUBE - vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); - #ifdef ENVMAP_BLENDING_MULTIPLY - outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); - #elif defined( ENVMAP_BLENDING_MIX ) - outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); - #elif defined( ENVMAP_BLENDING_ADD ) - outgoingLight += envColor.xyz * specularStrength * reflectivity; - #endif - #endif -#endif`,_u=`#ifdef USE_ENVMAP - uniform float envMapIntensity; - uniform mat3 envMapRotation; - #ifdef ENVMAP_TYPE_CUBE - uniform samplerCube envMap; - #else - uniform sampler2D envMap; - #endif -#endif`,gu=`#ifdef USE_ENVMAP - uniform float reflectivity; - #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) - #define ENV_WORLDPOS - #endif - #ifdef ENV_WORLDPOS - varying vec3 vWorldPosition; - uniform float refractionRatio; - #else - varying vec3 vReflect; - #endif -#endif`,xu=`#ifdef USE_ENVMAP - #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) - #define ENV_WORLDPOS - #endif - #ifdef ENV_WORLDPOS - - varying vec3 vWorldPosition; - #else - varying vec3 vReflect; - uniform float refractionRatio; - #endif -#endif`,vu=`#ifdef USE_ENVMAP - #ifdef ENV_WORLDPOS - vWorldPosition = worldPosition.xyz; - #else - vec3 cameraToVertex; - if ( isOrthographic ) { - cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); - } else { - cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); - } - vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); - #ifdef ENVMAP_MODE_REFLECTION - vReflect = reflect( cameraToVertex, worldNormal ); - #else - vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); - #endif - #endif -#endif`,Mu=`#ifdef USE_FOG - vFogDepth = - mvPosition.z; -#endif`,Su=`#ifdef USE_FOG - varying float vFogDepth; -#endif`,Eu=`#ifdef USE_FOG - #ifdef FOG_EXP2 - float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); - #else - float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); - #endif - gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); -#endif`,yu=`#ifdef USE_FOG - uniform vec3 fogColor; - varying float vFogDepth; - #ifdef FOG_EXP2 - uniform float fogDensity; - #else - uniform float fogNear; - uniform float fogFar; - #endif -#endif`,bu=`#ifdef USE_GRADIENTMAP - uniform sampler2D gradientMap; -#endif -vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { - float dotNL = dot( normal, lightDirection ); - vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); - #ifdef USE_GRADIENTMAP - return vec3( texture2D( gradientMap, coord ).r ); - #else - vec2 fw = fwidth( coord ) * 0.5; - return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); - #endif -}`,Tu=`#ifdef USE_LIGHTMAP - uniform sampler2D lightMap; - uniform float lightMapIntensity; -#endif`,Au=`LambertMaterial material; -material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,Ru=`varying vec3 vViewPosition; -struct LambertMaterial { - vec3 diffuseColor; - float specularStrength; -}; -void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { - float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); - vec3 irradiance = dotNL * directLight.color; - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -#define RE_Direct RE_Direct_Lambert -#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,wu=`uniform bool receiveShadow; -uniform vec3 ambientLightColor; -#if defined( USE_LIGHT_PROBES ) - uniform vec3 lightProbe[ 9 ]; -#endif -vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { - float x = normal.x, y = normal.y, z = normal.z; - vec3 result = shCoefficients[ 0 ] * 0.886227; - result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; - result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; - result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; - result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; - result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; - result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); - result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; - result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); - return result; -} -vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { - vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); - vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); - return irradiance; -} -vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { - vec3 irradiance = ambientLightColor; - return irradiance; -} -float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { - float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); - if ( cutoffDistance > 0.0 ) { - distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); - } - return distanceFalloff; -} -float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { - return smoothstep( coneCosine, penumbraCosine, angleCosine ); -} -#if NUM_DIR_LIGHTS > 0 - struct DirectionalLight { - vec3 direction; - vec3 color; - }; - uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; - void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { - light.color = directionalLight.color; - light.direction = directionalLight.direction; - light.visible = true; - } -#endif -#if NUM_POINT_LIGHTS > 0 - struct PointLight { - vec3 position; - vec3 color; - float distance; - float decay; - }; - uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; - void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { - vec3 lVector = pointLight.position - geometryPosition; - light.direction = normalize( lVector ); - float lightDistance = length( lVector ); - light.color = pointLight.color; - light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); - light.visible = ( light.color != vec3( 0.0 ) ); - } -#endif -#if NUM_SPOT_LIGHTS > 0 - struct SpotLight { - vec3 position; - vec3 direction; - vec3 color; - float distance; - float decay; - float coneCos; - float penumbraCos; - }; - uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; - void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { - vec3 lVector = spotLight.position - geometryPosition; - light.direction = normalize( lVector ); - float angleCos = dot( light.direction, spotLight.direction ); - float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); - if ( spotAttenuation > 0.0 ) { - float lightDistance = length( lVector ); - light.color = spotLight.color * spotAttenuation; - light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); - light.visible = ( light.color != vec3( 0.0 ) ); - } else { - light.color = vec3( 0.0 ); - light.visible = false; - } - } -#endif -#if NUM_RECT_AREA_LIGHTS > 0 - struct RectAreaLight { - vec3 color; - vec3 position; - vec3 halfWidth; - vec3 halfHeight; - }; - uniform sampler2D ltc_1; uniform sampler2D ltc_2; - uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; -#endif -#if NUM_HEMI_LIGHTS > 0 - struct HemisphereLight { - vec3 direction; - vec3 skyColor; - vec3 groundColor; - }; - uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; - vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { - float dotNL = dot( normal, hemiLight.direction ); - float hemiDiffuseWeight = 0.5 * dotNL + 0.5; - vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); - return irradiance; - } -#endif -#include `,Cu=`#ifdef USE_ENVMAP - vec3 getIBLIrradiance( const in vec3 normal ) { - #ifdef ENVMAP_TYPE_CUBE_UV - vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); - vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); - return PI * envMapColor.rgb * envMapIntensity; - #else - return vec3( 0.0 ); - #endif - } - vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { - #ifdef ENVMAP_TYPE_CUBE_UV - vec3 reflectVec = reflect( - viewDir, normal ); - reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); - reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); - vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); - return envMapColor.rgb * envMapIntensity; - #else - return vec3( 0.0 ); - #endif - } - #ifdef USE_ANISOTROPY - vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { - #ifdef ENVMAP_TYPE_CUBE_UV - vec3 bentNormal = cross( bitangent, viewDir ); - bentNormal = normalize( cross( bentNormal, bitangent ) ); - bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); - return getIBLRadiance( viewDir, bentNormal, roughness ); - #else - return vec3( 0.0 ); - #endif - } - #endif -#endif`,Pu=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,Du=`varying vec3 vViewPosition; -struct ToonMaterial { - vec3 diffuseColor; -}; -void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { - vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -#define RE_Direct RE_Direct_Toon -#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Lu=`BlinnPhongMaterial material; -material.diffuseColor = diffuseColor.rgb; -material.specularColor = specular; -material.specularShininess = shininess; -material.specularStrength = specularStrength;`,Iu=`varying vec3 vViewPosition; -struct BlinnPhongMaterial { - vec3 diffuseColor; - vec3 specularColor; - float specularShininess; - float specularStrength; -}; -void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { - float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); - vec3 irradiance = dotNL * directLight.color; - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); - reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; -} -void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -#define RE_Direct RE_Direct_BlinnPhong -#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Uu=`PhysicalMaterial material; -material.diffuseColor = diffuseColor.rgb; -material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); -material.metalness = metalnessFactor; -vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); -float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); -material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; -material.roughness = min( material.roughness, 1.0 ); -#ifdef IOR - material.ior = ior; - #ifdef USE_SPECULAR - float specularIntensityFactor = specularIntensity; - vec3 specularColorFactor = specularColor; - #ifdef USE_SPECULAR_COLORMAP - specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; - #endif - #ifdef USE_SPECULAR_INTENSITYMAP - specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; - #endif - material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); - #else - float specularIntensityFactor = 1.0; - vec3 specularColorFactor = vec3( 1.0 ); - material.specularF90 = 1.0; - #endif - material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; - material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); -#else - material.specularColor = vec3( 0.04 ); - material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); - material.specularF90 = 1.0; -#endif -#ifdef USE_CLEARCOAT - material.clearcoat = clearcoat; - material.clearcoatRoughness = clearcoatRoughness; - material.clearcoatF0 = vec3( 0.04 ); - material.clearcoatF90 = 1.0; - #ifdef USE_CLEARCOATMAP - material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; - #endif - #ifdef USE_CLEARCOAT_ROUGHNESSMAP - material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; - #endif - material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); - material.clearcoatRoughness += geometryRoughness; - material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); -#endif -#ifdef USE_DISPERSION - material.dispersion = dispersion; -#endif -#ifdef USE_IRIDESCENCE - material.iridescence = iridescence; - material.iridescenceIOR = iridescenceIOR; - #ifdef USE_IRIDESCENCEMAP - material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; - #endif - #ifdef USE_IRIDESCENCE_THICKNESSMAP - material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; - #else - material.iridescenceThickness = iridescenceThicknessMaximum; - #endif -#endif -#ifdef USE_SHEEN - material.sheenColor = sheenColor; - #ifdef USE_SHEEN_COLORMAP - material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; - #endif - material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); - #ifdef USE_SHEEN_ROUGHNESSMAP - material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; - #endif -#endif -#ifdef USE_ANISOTROPY - #ifdef USE_ANISOTROPYMAP - mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); - vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; - vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; - #else - vec2 anisotropyV = anisotropyVector; - #endif - material.anisotropy = length( anisotropyV ); - if( material.anisotropy == 0.0 ) { - anisotropyV = vec2( 1.0, 0.0 ); - } else { - anisotropyV /= material.anisotropy; - material.anisotropy = saturate( material.anisotropy ); - } - material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); - material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; - material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; -#endif`,Nu=`uniform sampler2D dfgLUT; -struct PhysicalMaterial { - vec3 diffuseColor; - vec3 diffuseContribution; - vec3 specularColor; - vec3 specularColorBlended; - float roughness; - float metalness; - float specularF90; - float dispersion; - #ifdef USE_CLEARCOAT - float clearcoat; - float clearcoatRoughness; - vec3 clearcoatF0; - float clearcoatF90; - #endif - #ifdef USE_IRIDESCENCE - float iridescence; - float iridescenceIOR; - float iridescenceThickness; - vec3 iridescenceFresnel; - vec3 iridescenceF0; - vec3 iridescenceFresnelDielectric; - vec3 iridescenceFresnelMetallic; - #endif - #ifdef USE_SHEEN - vec3 sheenColor; - float sheenRoughness; - #endif - #ifdef IOR - float ior; - #endif - #ifdef USE_TRANSMISSION - float transmission; - float transmissionAlpha; - float thickness; - float attenuationDistance; - vec3 attenuationColor; - #endif - #ifdef USE_ANISOTROPY - float anisotropy; - float alphaT; - vec3 anisotropyT; - vec3 anisotropyB; - #endif -}; -vec3 clearcoatSpecularDirect = vec3( 0.0 ); -vec3 clearcoatSpecularIndirect = vec3( 0.0 ); -vec3 sheenSpecularDirect = vec3( 0.0 ); -vec3 sheenSpecularIndirect = vec3(0.0 ); -vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { - float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); - float x2 = x * x; - float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); - return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); -} -float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { - float a2 = pow2( alpha ); - float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); - float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); - return 0.5 / max( gv + gl, EPSILON ); -} -float D_GGX( const in float alpha, const in float dotNH ) { - float a2 = pow2( alpha ); - float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; - return RECIPROCAL_PI * a2 / pow2( denom ); -} -#ifdef USE_ANISOTROPY - float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { - float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); - float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); - return 0.5 / max( gv + gl, EPSILON ); - } - float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { - float a2 = alphaT * alphaB; - highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); - highp float v2 = dot( v, v ); - float w2 = a2 / v2; - return RECIPROCAL_PI * a2 * pow2 ( w2 ); - } -#endif -#ifdef USE_CLEARCOAT - vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { - vec3 f0 = material.clearcoatF0; - float f90 = material.clearcoatF90; - float roughness = material.clearcoatRoughness; - float alpha = pow2( roughness ); - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float dotVH = saturate( dot( viewDir, halfDir ) ); - vec3 F = F_Schlick( f0, f90, dotVH ); - float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); - float D = D_GGX( alpha, dotNH ); - return F * ( V * D ); - } -#endif -vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { - vec3 f0 = material.specularColorBlended; - float f90 = material.specularF90; - float roughness = material.roughness; - float alpha = pow2( roughness ); - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float dotVH = saturate( dot( viewDir, halfDir ) ); - vec3 F = F_Schlick( f0, f90, dotVH ); - #ifdef USE_IRIDESCENCE - F = mix( F, material.iridescenceFresnel, material.iridescence ); - #endif - #ifdef USE_ANISOTROPY - float dotTL = dot( material.anisotropyT, lightDir ); - float dotTV = dot( material.anisotropyT, viewDir ); - float dotTH = dot( material.anisotropyT, halfDir ); - float dotBL = dot( material.anisotropyB, lightDir ); - float dotBV = dot( material.anisotropyB, viewDir ); - float dotBH = dot( material.anisotropyB, halfDir ); - float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); - float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); - #else - float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); - float D = D_GGX( alpha, dotNH ); - #endif - return F * ( V * D ); -} -vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { - const float LUT_SIZE = 64.0; - const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; - const float LUT_BIAS = 0.5 / LUT_SIZE; - float dotNV = saturate( dot( N, V ) ); - vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); - uv = uv * LUT_SCALE + LUT_BIAS; - return uv; -} -float LTC_ClippedSphereFormFactor( const in vec3 f ) { - float l = length( f ); - return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); -} -vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { - float x = dot( v1, v2 ); - float y = abs( x ); - float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; - float b = 3.4175940 + ( 4.1616724 + y ) * y; - float v = a / b; - float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; - return cross( v1, v2 ) * theta_sintheta; -} -vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { - vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; - vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; - vec3 lightNormal = cross( v1, v2 ); - if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); - vec3 T1, T2; - T1 = normalize( V - N * dot( V, N ) ); - T2 = - cross( N, T1 ); - mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); - vec3 coords[ 4 ]; - coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); - coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); - coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); - coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); - coords[ 0 ] = normalize( coords[ 0 ] ); - coords[ 1 ] = normalize( coords[ 1 ] ); - coords[ 2 ] = normalize( coords[ 2 ] ); - coords[ 3 ] = normalize( coords[ 3 ] ); - vec3 vectorFormFactor = vec3( 0.0 ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); - float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); - return vec3( result ); -} -#if defined( USE_SHEEN ) -float D_Charlie( float roughness, float dotNH ) { - float alpha = pow2( roughness ); - float invAlpha = 1.0 / alpha; - float cos2h = dotNH * dotNH; - float sin2h = max( 1.0 - cos2h, 0.0078125 ); - return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); -} -float V_Neubelt( float dotNV, float dotNL ) { - return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); -} -vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float D = D_Charlie( sheenRoughness, dotNH ); - float V = V_Neubelt( dotNV, dotNL ); - return sheenColor * ( D * V ); -} -#endif -float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { - float dotNV = saturate( dot( normal, viewDir ) ); - float r2 = roughness * roughness; - float rInv = 1.0 / ( roughness + 0.1 ); - float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; - float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; - float DG = exp( a * dotNV + b ); - return saturate( DG ); -} -vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { - float dotNV = saturate( dot( normal, viewDir ) ); - vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; - return specularColor * fab.x + specularF90 * fab.y; -} -#ifdef USE_IRIDESCENCE -void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { -#else -void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { -#endif - float dotNV = saturate( dot( normal, viewDir ) ); - vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; - #ifdef USE_IRIDESCENCE - vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); - #else - vec3 Fr = specularColor; - #endif - vec3 FssEss = Fr * fab.x + specularF90 * fab.y; - float Ess = fab.x + fab.y; - float Ems = 1.0 - Ess; - vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); - singleScatter += FssEss; - multiScatter += Fms * Ems; -} -vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { - vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; - vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; - vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; - vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; - float Ess_V = dfgV.x + dfgV.y; - float Ess_L = dfgL.x + dfgL.y; - float Ems_V = 1.0 - Ess_V; - float Ems_L = 1.0 - Ess_L; - vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; - vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); - float compensationFactor = Ems_V * Ems_L; - vec3 multiScatter = Fms * compensationFactor; - return singleScatter + multiScatter; -} -#if NUM_RECT_AREA_LIGHTS > 0 - void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - vec3 normal = geometryNormal; - vec3 viewDir = geometryViewDir; - vec3 position = geometryPosition; - vec3 lightPos = rectAreaLight.position; - vec3 halfWidth = rectAreaLight.halfWidth; - vec3 halfHeight = rectAreaLight.halfHeight; - vec3 lightColor = rectAreaLight.color; - float roughness = material.roughness; - vec3 rectCoords[ 4 ]; - rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; - rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; - rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; - vec2 uv = LTC_Uv( normal, viewDir, roughness ); - vec4 t1 = texture2D( ltc_1, uv ); - vec4 t2 = texture2D( ltc_2, uv ); - mat3 mInv = mat3( - vec3( t1.x, 0, t1.y ), - vec3( 0, 1, 0 ), - vec3( t1.z, 0, t1.w ) - ); - vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); - reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); - reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); - #ifdef USE_CLEARCOAT - vec3 Ncc = geometryClearcoatNormal; - vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); - vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); - vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); - mat3 mInvClearcoat = mat3( - vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), - vec3( 0, 1, 0 ), - vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) - ); - vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; - clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); - #endif - } -#endif -void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); - vec3 irradiance = dotNL * directLight.color; - #ifdef USE_CLEARCOAT - float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); - vec3 ccIrradiance = dotNLcc * directLight.color; - clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); - #endif - #ifdef USE_SHEEN - - sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); - - float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); - float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); - - float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); - - irradiance *= sheenEnergyComp; - - #endif - reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); -} -void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); - #ifdef USE_SHEEN - float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); - float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; - diffuse *= sheenEnergyComp; - #endif - reflectedLight.indirectDiffuse += diffuse; -} -void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { - #ifdef USE_CLEARCOAT - clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); - #endif - #ifdef USE_SHEEN - sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; - #endif - vec3 singleScatteringDielectric = vec3( 0.0 ); - vec3 multiScatteringDielectric = vec3( 0.0 ); - vec3 singleScatteringMetallic = vec3( 0.0 ); - vec3 multiScatteringMetallic = vec3( 0.0 ); - #ifdef USE_IRIDESCENCE - computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); - computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); - #else - computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); - computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); - #endif - vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); - vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); - vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; - vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); - vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; - vec3 indirectSpecular = radiance * singleScattering; - indirectSpecular += multiScattering * cosineWeightedIrradiance; - vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; - #ifdef USE_SHEEN - float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); - float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; - indirectSpecular *= sheenEnergyComp; - indirectDiffuse *= sheenEnergyComp; - #endif - reflectedLight.indirectSpecular += indirectSpecular; - reflectedLight.indirectDiffuse += indirectDiffuse; -} -#define RE_Direct RE_Direct_Physical -#define RE_Direct_RectArea RE_Direct_RectArea_Physical -#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical -#define RE_IndirectSpecular RE_IndirectSpecular_Physical -float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { - return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); -}`,Fu=` -vec3 geometryPosition = - vViewPosition; -vec3 geometryNormal = normal; -vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); -vec3 geometryClearcoatNormal = vec3( 0.0 ); -#ifdef USE_CLEARCOAT - geometryClearcoatNormal = clearcoatNormal; -#endif -#ifdef USE_IRIDESCENCE - float dotNVi = saturate( dot( normal, geometryViewDir ) ); - if ( material.iridescenceThickness == 0.0 ) { - material.iridescence = 0.0; - } else { - material.iridescence = saturate( material.iridescence ); - } - if ( material.iridescence > 0.0 ) { - material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); - material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); - material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); - material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); - } -#endif -IncidentLight directLight; -#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) - PointLight pointLight; - #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 - PointLightShadow pointLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { - pointLight = pointLights[ i ]; - getPointLightInfo( pointLight, geometryPosition, directLight ); - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) - pointLightShadow = pointLightShadows[ i ]; - directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; - #endif - RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) - SpotLight spotLight; - vec4 spotColor; - vec3 spotLightCoord; - bool inSpotLightMap; - #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 - SpotLightShadow spotLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { - spotLight = spotLights[ i ]; - getSpotLightInfo( spotLight, geometryPosition, directLight ); - #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) - #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX - #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) - #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS - #else - #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) - #endif - #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) - spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; - inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); - spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); - directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; - #endif - #undef SPOT_LIGHT_MAP_INDEX - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) - spotLightShadow = spotLightShadows[ i ]; - directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; - #endif - RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) - DirectionalLight directionalLight; - #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 - DirectionalLightShadow directionalLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { - directionalLight = directionalLights[ i ]; - getDirectionalLightInfo( directionalLight, directLight ); - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) - directionalLightShadow = directionalLightShadows[ i ]; - directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; - #endif - RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) - RectAreaLight rectAreaLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { - rectAreaLight = rectAreaLights[ i ]; - RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if defined( RE_IndirectDiffuse ) - vec3 iblIrradiance = vec3( 0.0 ); - vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); - #if defined( USE_LIGHT_PROBES ) - irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); - #endif - #if ( NUM_HEMI_LIGHTS > 0 ) - #pragma unroll_loop_start - for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { - irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); - } - #pragma unroll_loop_end - #endif - #ifdef USE_LIGHT_PROBES_GRID - vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; - vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); - irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); - #endif -#endif -#if defined( RE_IndirectSpecular ) - vec3 radiance = vec3( 0.0 ); - vec3 clearcoatRadiance = vec3( 0.0 ); -#endif`,Ou=`#if defined( RE_IndirectDiffuse ) - #ifdef USE_LIGHTMAP - vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); - vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; - irradiance += lightMapIrradiance; - #endif - #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) - #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) - iblIrradiance += getIBLIrradiance( geometryNormal ); - #endif - #endif -#endif -#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) - #ifdef USE_ANISOTROPY - radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); - #else - radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); - #endif - #ifdef USE_CLEARCOAT - clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); - #endif -#endif`,Bu=`#if defined( RE_IndirectDiffuse ) - #if defined( LAMBERT ) || defined( PHONG ) - irradiance += iblIrradiance; - #endif - RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif -#if defined( RE_IndirectSpecular ) - RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif`,zu=`#ifdef USE_LIGHT_PROBES_GRID -uniform highp sampler3D probesSH; -uniform vec3 probesMin; -uniform vec3 probesMax; -uniform vec3 probesResolution; -vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { - vec3 res = probesResolution; - vec3 gridRange = probesMax - probesMin; - vec3 resMinusOne = res - 1.0; - vec3 probeSpacing = gridRange / resMinusOne; - vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; - vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); - uvw = uvw * resMinusOne / res + 0.5 / res; - float nz = res.z; - float paddedSlices = nz + 2.0; - float atlasDepth = 7.0 * paddedSlices; - float uvZBase = uvw.z * nz + 1.0; - vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); - vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); - vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); - vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); - vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); - vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); - vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); - vec3 c0 = s0.xyz; - vec3 c1 = vec3( s0.w, s1.xy ); - vec3 c2 = vec3( s1.zw, s2.x ); - vec3 c3 = s2.yzw; - vec3 c4 = s3.xyz; - vec3 c5 = vec3( s3.w, s4.xy ); - vec3 c6 = vec3( s4.zw, s5.x ); - vec3 c7 = s5.yzw; - vec3 c8 = s6.xyz; - float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; - vec3 result = c0 * 0.886227; - result += c1 * 2.0 * 0.511664 * y; - result += c2 * 2.0 * 0.511664 * z; - result += c3 * 2.0 * 0.511664 * x; - result += c4 * 2.0 * 0.429043 * x * y; - result += c5 * 2.0 * 0.429043 * y * z; - result += c6 * ( 0.743125 * z * z - 0.247708 ); - result += c7 * 2.0 * 0.429043 * x * z; - result += c8 * 0.429043 * ( x * x - y * y ); - return max( result, vec3( 0.0 ) ); -} -#endif`,Gu=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) - gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`,Vu=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) - uniform float logDepthBufFC; - varying float vFragDepth; - varying float vIsPerspective; -#endif`,Hu=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER - varying float vFragDepth; - varying float vIsPerspective; -#endif`,ku=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER - vFragDepth = 1.0 + gl_Position.w; - vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); -#endif`,Wu=`#ifdef USE_MAP - vec4 sampledDiffuseColor = texture2D( map, vMapUv ); - #ifdef DECODE_VIDEO_TEXTURE - sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); - #endif - diffuseColor *= sampledDiffuseColor; -#endif`,Xu=`#ifdef USE_MAP - uniform sampler2D map; -#endif`,Yu=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) - #if defined( USE_POINTS_UV ) - vec2 uv = vUv; - #else - vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; - #endif -#endif -#ifdef USE_MAP - diffuseColor *= texture2D( map, uv ); -#endif -#ifdef USE_ALPHAMAP - diffuseColor.a *= texture2D( alphaMap, uv ).g; -#endif`,qu=`#if defined( USE_POINTS_UV ) - varying vec2 vUv; -#else - #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) - uniform mat3 uvTransform; - #endif -#endif -#ifdef USE_MAP - uniform sampler2D map; -#endif -#ifdef USE_ALPHAMAP - uniform sampler2D alphaMap; -#endif`,Ku=`float metalnessFactor = metalness; -#ifdef USE_METALNESSMAP - vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); - metalnessFactor *= texelMetalness.b; -#endif`,Zu=`#ifdef USE_METALNESSMAP - uniform sampler2D metalnessMap; -#endif`,$u=`#ifdef USE_INSTANCING_MORPH - float morphTargetInfluences[ MORPHTARGETS_COUNT ]; - float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; - } -#endif`,Ju=`#if defined( USE_MORPHCOLORS ) - vColor *= morphTargetBaseInfluence; - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - #if defined( USE_COLOR_ALPHA ) - if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; - #elif defined( USE_COLOR ) - if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; - #endif - } -#endif`,Qu=`#ifdef USE_MORPHNORMALS - objectNormal *= morphTargetBaseInfluence; - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; - } -#endif`,ju=`#ifdef USE_MORPHTARGETS - #ifndef USE_INSTANCING_MORPH - uniform float morphTargetBaseInfluence; - uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; - #endif - uniform sampler2DArray morphTargetsTexture; - uniform ivec2 morphTargetsTextureSize; - vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { - int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; - int y = texelIndex / morphTargetsTextureSize.x; - int x = texelIndex - y * morphTargetsTextureSize.x; - ivec3 morphUV = ivec3( x, y, morphTargetIndex ); - return texelFetch( morphTargetsTexture, morphUV, 0 ); - } -#endif`,ed=`#ifdef USE_MORPHTARGETS - transformed *= morphTargetBaseInfluence; - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; - } -#endif`,td=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; -#ifdef FLAT_SHADED - vec3 fdx = dFdx( vViewPosition ); - vec3 fdy = dFdy( vViewPosition ); - vec3 normal = normalize( cross( fdx, fdy ) ); -#else - vec3 normal = normalize( vNormal ); - #ifdef DOUBLE_SIDED - normal *= faceDirection; - #endif -#endif -#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) - #ifdef USE_TANGENT - mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); - #else - mat3 tbn = getTangentFrame( - vViewPosition, normal, - #if defined( USE_NORMALMAP ) - vNormalMapUv - #elif defined( USE_CLEARCOAT_NORMALMAP ) - vClearcoatNormalMapUv - #else - vUv - #endif - ); - #endif - #ifdef DOUBLE_SIDED - tbn[0] *= faceDirection; - tbn[1] *= faceDirection; - #endif -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - #ifdef USE_TANGENT - mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); - #else - mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); - #endif - #ifdef DOUBLE_SIDED - tbn2[0] *= faceDirection; - tbn2[1] *= faceDirection; - #endif -#endif -vec3 nonPerturbedNormal = normal;`,nd=`#ifdef USE_NORMALMAP_OBJECTSPACE - normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; - #ifdef FLIP_SIDED - normal = - normal; - #endif - #ifdef DOUBLE_SIDED - normal = normal * faceDirection; - #endif - normal = normalize( normalMatrix * normal ); -#elif defined( USE_NORMALMAP_TANGENTSPACE ) - vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; - #if defined( USE_PACKED_NORMALMAP ) - mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); - #endif - mapN.xy *= normalScale; - normal = normalize( tbn * mapN ); -#elif defined( USE_BUMPMAP ) - normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,id=`#ifndef FLAT_SHADED - varying vec3 vNormal; - #ifdef USE_TANGENT - varying vec3 vTangent; - varying vec3 vBitangent; - #endif -#endif`,sd=`#ifndef FLAT_SHADED - varying vec3 vNormal; - #ifdef USE_TANGENT - varying vec3 vTangent; - varying vec3 vBitangent; - #endif -#endif`,rd=`#ifndef FLAT_SHADED - vNormal = normalize( transformedNormal ); - #ifdef USE_TANGENT - vTangent = normalize( transformedTangent ); - vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); - #ifdef FLIP_SIDED - vBitangent = - vBitangent; - #endif - #endif -#endif`,ad=`#ifdef USE_NORMALMAP - uniform sampler2D normalMap; - uniform vec2 normalScale; -#endif -#ifdef USE_NORMALMAP_OBJECTSPACE - uniform mat3 normalMatrix; -#endif -#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) - mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { - vec3 q0 = dFdx( eye_pos.xyz ); - vec3 q1 = dFdy( eye_pos.xyz ); - vec2 st0 = dFdx( uv.st ); - vec2 st1 = dFdy( uv.st ); - vec3 N = surf_norm; - vec3 q1perp = cross( q1, N ); - vec3 q0perp = cross( N, q0 ); - vec3 T = q1perp * st0.x + q0perp * st1.x; - vec3 B = q1perp * st0.y + q0perp * st1.y; - float det = max( dot( T, T ), dot( B, B ) ); - float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); - return mat3( T * scale, B * scale, N ); - } -#endif`,od=`#ifdef USE_CLEARCOAT - vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,ld=`#ifdef USE_CLEARCOAT_NORMALMAP - vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; - clearcoatMapN.xy *= clearcoatNormalScale; - clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,cd=`#ifdef USE_CLEARCOATMAP - uniform sampler2D clearcoatMap; -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - uniform sampler2D clearcoatNormalMap; - uniform vec2 clearcoatNormalScale; -#endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - uniform sampler2D clearcoatRoughnessMap; -#endif`,hd=`#ifdef USE_IRIDESCENCEMAP - uniform sampler2D iridescenceMap; -#endif -#ifdef USE_IRIDESCENCE_THICKNESSMAP - uniform sampler2D iridescenceThicknessMap; -#endif`,ud=`#ifdef OPAQUE -diffuseColor.a = 1.0; -#endif -#ifdef USE_TRANSMISSION -diffuseColor.a *= material.transmissionAlpha; -#endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,dd=`vec3 packNormalToRGB( const in vec3 normal ) { - return normalize( normal ) * 0.5 + 0.5; -} -vec3 unpackRGBToNormal( const in vec3 rgb ) { - return 2.0 * rgb.xyz - 1.0; -} -const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; -const float Inv255 = 1. / 255.; -const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); -const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); -const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); -const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); -vec4 packDepthToRGBA( const in float v ) { - if( v <= 0.0 ) - return vec4( 0., 0., 0., 0. ); - if( v >= 1.0 ) - return vec4( 1., 1., 1., 1. ); - float vuf; - float af = modf( v * PackFactors.a, vuf ); - float bf = modf( vuf * ShiftRight8, vuf ); - float gf = modf( vuf * ShiftRight8, vuf ); - return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); -} -vec3 packDepthToRGB( const in float v ) { - if( v <= 0.0 ) - return vec3( 0., 0., 0. ); - if( v >= 1.0 ) - return vec3( 1., 1., 1. ); - float vuf; - float bf = modf( v * PackFactors.b, vuf ); - float gf = modf( vuf * ShiftRight8, vuf ); - return vec3( vuf * Inv255, gf * PackUpscale, bf ); -} -vec2 packDepthToRG( const in float v ) { - if( v <= 0.0 ) - return vec2( 0., 0. ); - if( v >= 1.0 ) - return vec2( 1., 1. ); - float vuf; - float gf = modf( v * 256., vuf ); - return vec2( vuf * Inv255, gf ); -} -float unpackRGBAToDepth( const in vec4 v ) { - return dot( v, UnpackFactors4 ); -} -float unpackRGBToDepth( const in vec3 v ) { - return dot( v, UnpackFactors3 ); -} -float unpackRGToDepth( const in vec2 v ) { - return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; -} -vec4 pack2HalfToRGBA( const in vec2 v ) { - vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); - return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); -} -vec2 unpackRGBATo2Half( const in vec4 v ) { - return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); -} -float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { - return ( viewZ + near ) / ( near - far ); -} -float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { - #ifdef USE_REVERSED_DEPTH_BUFFER - - return depth * ( far - near ) - far; - #else - return depth * ( near - far ) - near; - #endif -} -float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { - return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); -} -float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { - - #ifdef USE_REVERSED_DEPTH_BUFFER - return ( near * far ) / ( ( near - far ) * depth - near ); - #else - return ( near * far ) / ( ( far - near ) * depth - far ); - #endif -}`,fd=`#ifdef PREMULTIPLIED_ALPHA - gl_FragColor.rgb *= gl_FragColor.a; -#endif`,pd=`vec4 mvPosition = vec4( transformed, 1.0 ); -#ifdef USE_BATCHING - mvPosition = batchingMatrix * mvPosition; -#endif -#ifdef USE_INSTANCING - mvPosition = instanceMatrix * mvPosition; -#endif -mvPosition = modelViewMatrix * mvPosition; -gl_Position = projectionMatrix * mvPosition;`,md=`#ifdef DITHERING - gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,_d=`#ifdef DITHERING - vec3 dithering( vec3 color ) { - float grid_position = rand( gl_FragCoord.xy ); - vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); - dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); - return color + dither_shift_RGB; - } -#endif`,gd=`float roughnessFactor = roughness; -#ifdef USE_ROUGHNESSMAP - vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); - roughnessFactor *= texelRoughness.g; -#endif`,xd=`#ifdef USE_ROUGHNESSMAP - uniform sampler2D roughnessMap; -#endif`,vd=`#if NUM_SPOT_LIGHT_COORDS > 0 - varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; -#endif -#if NUM_SPOT_LIGHT_MAPS > 0 - uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; -#endif -#ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - #if defined( SHADOWMAP_TYPE_PCF ) - uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; - #else - uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; - #endif - varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; - struct DirectionalLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - #if defined( SHADOWMAP_TYPE_PCF ) - uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; - #else - uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; - #endif - struct SpotLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - #if defined( SHADOWMAP_TYPE_PCF ) - uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; - #elif defined( SHADOWMAP_TYPE_BASIC ) - uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; - #endif - varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; - struct PointLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - float shadowCameraNear; - float shadowCameraFar; - }; - uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; - #endif - #if defined( SHADOWMAP_TYPE_PCF ) - float interleavedGradientNoise( vec2 position ) { - return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); - } - vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { - const float goldenAngle = 2.399963229728653; - float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); - float theta = float( sampleIndex ) * goldenAngle + phi; - return vec2( cos( theta ), sin( theta ) ) * r; - } - #endif - #if defined( SHADOWMAP_TYPE_PCF ) - float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { - float shadow = 1.0; - shadowCoord.xyz /= shadowCoord.w; - shadowCoord.z += shadowBias; - bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; - bool frustumTest = inFrustum && shadowCoord.z <= 1.0; - if ( frustumTest ) { - vec2 texelSize = vec2( 1.0 ) / shadowMapSize; - float radius = shadowRadius * texelSize.x; - float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; - shadow = ( - texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + - texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + - texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + - texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + - texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) - ) * 0.2; - } - return mix( 1.0, shadow, shadowIntensity ); - } - #elif defined( SHADOWMAP_TYPE_VSM ) - float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { - float shadow = 1.0; - shadowCoord.xyz /= shadowCoord.w; - #ifdef USE_REVERSED_DEPTH_BUFFER - shadowCoord.z -= shadowBias; - #else - shadowCoord.z += shadowBias; - #endif - bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; - bool frustumTest = inFrustum && shadowCoord.z <= 1.0; - if ( frustumTest ) { - vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; - float mean = distribution.x; - float variance = distribution.y * distribution.y; - #ifdef USE_REVERSED_DEPTH_BUFFER - float hard_shadow = step( mean, shadowCoord.z ); - #else - float hard_shadow = step( shadowCoord.z, mean ); - #endif - - if ( hard_shadow == 1.0 ) { - shadow = 1.0; - } else { - variance = max( variance, 0.0000001 ); - float d = shadowCoord.z - mean; - float p_max = variance / ( variance + d * d ); - p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); - shadow = max( hard_shadow, p_max ); - } - } - return mix( 1.0, shadow, shadowIntensity ); - } - #else - float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { - float shadow = 1.0; - shadowCoord.xyz /= shadowCoord.w; - #ifdef USE_REVERSED_DEPTH_BUFFER - shadowCoord.z -= shadowBias; - #else - shadowCoord.z += shadowBias; - #endif - bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; - bool frustumTest = inFrustum && shadowCoord.z <= 1.0; - if ( frustumTest ) { - float depth = texture2D( shadowMap, shadowCoord.xy ).r; - #ifdef USE_REVERSED_DEPTH_BUFFER - shadow = step( depth, shadowCoord.z ); - #else - shadow = step( shadowCoord.z, depth ); - #endif - } - return mix( 1.0, shadow, shadowIntensity ); - } - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - #if defined( SHADOWMAP_TYPE_PCF ) - float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { - float shadow = 1.0; - vec3 lightToPosition = shadowCoord.xyz; - vec3 bd3D = normalize( lightToPosition ); - vec3 absVec = abs( lightToPosition ); - float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); - if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { - #ifdef USE_REVERSED_DEPTH_BUFFER - float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); - dp -= shadowBias; - #else - float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); - dp += shadowBias; - #endif - float texelSize = shadowRadius / shadowMapSize.x; - vec3 absDir = abs( bd3D ); - vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); - tangent = normalize( cross( bd3D, tangent ) ); - vec3 bitangent = cross( bd3D, tangent ); - float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; - vec2 sample0 = vogelDiskSample( 0, 5, phi ); - vec2 sample1 = vogelDiskSample( 1, 5, phi ); - vec2 sample2 = vogelDiskSample( 2, 5, phi ); - vec2 sample3 = vogelDiskSample( 3, 5, phi ); - vec2 sample4 = vogelDiskSample( 4, 5, phi ); - shadow = ( - texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + - texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + - texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + - texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + - texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) - ) * 0.2; - } - return mix( 1.0, shadow, shadowIntensity ); - } - #elif defined( SHADOWMAP_TYPE_BASIC ) - float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { - float shadow = 1.0; - vec3 lightToPosition = shadowCoord.xyz; - vec3 absVec = abs( lightToPosition ); - float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); - if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { - float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); - dp += shadowBias; - vec3 bd3D = normalize( lightToPosition ); - float depth = textureCube( shadowMap, bd3D ).r; - #ifdef USE_REVERSED_DEPTH_BUFFER - depth = 1.0 - depth; - #endif - shadow = step( dp, depth ); - } - return mix( 1.0, shadow, shadowIntensity ); - } - #endif - #endif -#endif`,Md=`#if NUM_SPOT_LIGHT_COORDS > 0 - uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; - varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; -#endif -#ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; - varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; - struct DirectionalLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - struct SpotLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; - varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; - struct PointLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - float shadowCameraNear; - float shadowCameraFar; - }; - uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; - #endif -#endif`,Sd=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) - #ifdef HAS_NORMAL - vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); - #else - vec3 shadowWorldNormal = vec3( 0.0 ); - #endif - vec4 shadowWorldPosition; -#endif -#if defined( USE_SHADOWMAP ) - #if NUM_DIR_LIGHT_SHADOWS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); - vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); - vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end - #endif -#endif -#if NUM_SPOT_LIGHT_COORDS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { - shadowWorldPosition = worldPosition; - #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) - shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; - #endif - vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end -#endif`,Ed=`float getShadowMask() { - float shadow = 1.0; - #ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - DirectionalLightShadow directionalLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { - directionalLight = directionalLightShadows[ i ]; - shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; - } - #pragma unroll_loop_end - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - SpotLightShadow spotLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { - spotLight = spotLightShadows[ i ]; - shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; - } - #pragma unroll_loop_end - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) - PointLightShadow pointLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { - pointLight = pointLightShadows[ i ]; - shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; - } - #pragma unroll_loop_end - #endif - #endif - return shadow; -}`,yd=`#ifdef USE_SKINNING - mat4 boneMatX = getBoneMatrix( skinIndex.x ); - mat4 boneMatY = getBoneMatrix( skinIndex.y ); - mat4 boneMatZ = getBoneMatrix( skinIndex.z ); - mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,bd=`#ifdef USE_SKINNING - uniform mat4 bindMatrix; - uniform mat4 bindMatrixInverse; - uniform highp sampler2D boneTexture; - mat4 getBoneMatrix( const in float i ) { - int size = textureSize( boneTexture, 0 ).x; - int j = int( i ) * 4; - int x = j % size; - int y = j / size; - vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); - vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); - vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); - vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); - return mat4( v1, v2, v3, v4 ); - } -#endif`,Td=`#ifdef USE_SKINNING - vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); - vec4 skinned = vec4( 0.0 ); - skinned += boneMatX * skinVertex * skinWeight.x; - skinned += boneMatY * skinVertex * skinWeight.y; - skinned += boneMatZ * skinVertex * skinWeight.z; - skinned += boneMatW * skinVertex * skinWeight.w; - transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,Ad=`#ifdef USE_SKINNING - mat4 skinMatrix = mat4( 0.0 ); - skinMatrix += skinWeight.x * boneMatX; - skinMatrix += skinWeight.y * boneMatY; - skinMatrix += skinWeight.z * boneMatZ; - skinMatrix += skinWeight.w * boneMatW; - skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; - objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; - #ifdef USE_TANGENT - objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; - #endif -#endif`,Rd=`float specularStrength; -#ifdef USE_SPECULARMAP - vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); - specularStrength = texelSpecular.r; -#else - specularStrength = 1.0; -#endif`,wd=`#ifdef USE_SPECULARMAP - uniform sampler2D specularMap; -#endif`,Cd=`#if defined( TONE_MAPPING ) - gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,Pd=`#ifndef saturate -#define saturate( a ) clamp( a, 0.0, 1.0 ) -#endif -uniform float toneMappingExposure; -vec3 LinearToneMapping( vec3 color ) { - return saturate( toneMappingExposure * color ); -} -vec3 ReinhardToneMapping( vec3 color ) { - color *= toneMappingExposure; - return saturate( color / ( vec3( 1.0 ) + color ) ); -} -vec3 CineonToneMapping( vec3 color ) { - color *= toneMappingExposure; - color = max( vec3( 0.0 ), color - 0.004 ); - return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); -} -vec3 RRTAndODTFit( vec3 v ) { - vec3 a = v * ( v + 0.0245786 ) - 0.000090537; - vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; - return a / b; -} -vec3 ACESFilmicToneMapping( vec3 color ) { - const mat3 ACESInputMat = mat3( - vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), - vec3( 0.04823, 0.01566, 0.83777 ) - ); - const mat3 ACESOutputMat = mat3( - vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), - vec3( -0.07367, -0.00605, 1.07602 ) - ); - color *= toneMappingExposure / 0.6; - color = ACESInputMat * color; - color = RRTAndODTFit( color ); - color = ACESOutputMat * color; - return saturate( color ); -} -const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( - vec3( 1.6605, - 0.1246, - 0.0182 ), - vec3( - 0.5876, 1.1329, - 0.1006 ), - vec3( - 0.0728, - 0.0083, 1.1187 ) -); -const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( - vec3( 0.6274, 0.0691, 0.0164 ), - vec3( 0.3293, 0.9195, 0.0880 ), - vec3( 0.0433, 0.0113, 0.8956 ) -); -vec3 agxDefaultContrastApprox( vec3 x ) { - vec3 x2 = x * x; - vec3 x4 = x2 * x2; - return + 15.5 * x4 * x2 - - 40.14 * x4 * x - + 31.96 * x4 - - 6.868 * x2 * x - + 0.4298 * x2 - + 0.1191 * x - - 0.00232; -} -vec3 AgXToneMapping( vec3 color ) { - const mat3 AgXInsetMatrix = mat3( - vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), - vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), - vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) - ); - const mat3 AgXOutsetMatrix = mat3( - vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), - vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), - vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) - ); - const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; - color *= toneMappingExposure; - color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; - color = AgXInsetMatrix * color; - color = max( color, 1e-10 ); color = log2( color ); - color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); - color = clamp( color, 0.0, 1.0 ); - color = agxDefaultContrastApprox( color ); - color = AgXOutsetMatrix * color; - color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); - color = LINEAR_REC2020_TO_LINEAR_SRGB * color; - color = clamp( color, 0.0, 1.0 ); - return color; -} -vec3 NeutralToneMapping( vec3 color ) { - const float StartCompression = 0.8 - 0.04; - const float Desaturation = 0.15; - color *= toneMappingExposure; - float x = min( color.r, min( color.g, color.b ) ); - float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; - color -= offset; - float peak = max( color.r, max( color.g, color.b ) ); - if ( peak < StartCompression ) return color; - float d = 1. - StartCompression; - float newPeak = 1. - d * d / ( peak + d - StartCompression ); - color *= newPeak / peak; - float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); - return mix( color, vec3( newPeak ), g ); -} -vec3 CustomToneMapping( vec3 color ) { return color; }`,Dd=`#ifdef USE_TRANSMISSION - material.transmission = transmission; - material.transmissionAlpha = 1.0; - material.thickness = thickness; - material.attenuationDistance = attenuationDistance; - material.attenuationColor = attenuationColor; - #ifdef USE_TRANSMISSIONMAP - material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; - #endif - #ifdef USE_THICKNESSMAP - material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; - #endif - vec3 pos = vWorldPosition; - vec3 v = normalize( cameraPosition - pos ); - vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); - vec4 transmitted = getIBLVolumeRefraction( - n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, - pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, - material.attenuationColor, material.attenuationDistance ); - material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); - totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,Ld=`#ifdef USE_TRANSMISSION - uniform float transmission; - uniform float thickness; - uniform float attenuationDistance; - uniform vec3 attenuationColor; - #ifdef USE_TRANSMISSIONMAP - uniform sampler2D transmissionMap; - #endif - #ifdef USE_THICKNESSMAP - uniform sampler2D thicknessMap; - #endif - uniform vec2 transmissionSamplerSize; - uniform sampler2D transmissionSamplerMap; - uniform mat4 modelMatrix; - uniform mat4 projectionMatrix; - varying vec3 vWorldPosition; - float w0( float a ) { - return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); - } - float w1( float a ) { - return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); - } - float w2( float a ){ - return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); - } - float w3( float a ) { - return ( 1.0 / 6.0 ) * ( a * a * a ); - } - float g0( float a ) { - return w0( a ) + w1( a ); - } - float g1( float a ) { - return w2( a ) + w3( a ); - } - float h0( float a ) { - return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); - } - float h1( float a ) { - return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); - } - vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { - uv = uv * texelSize.zw + 0.5; - vec2 iuv = floor( uv ); - vec2 fuv = fract( uv ); - float g0x = g0( fuv.x ); - float g1x = g1( fuv.x ); - float h0x = h0( fuv.x ); - float h1x = h1( fuv.x ); - float h0y = h0( fuv.y ); - float h1y = h1( fuv.y ); - vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; - vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; - vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; - vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; - return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + - g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); - } - vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { - vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); - vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); - vec2 fLodSizeInv = 1.0 / fLodSize; - vec2 cLodSizeInv = 1.0 / cLodSize; - vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); - vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); - return mix( fSample, cSample, fract( lod ) ); - } - vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { - vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); - vec3 modelScale; - modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); - modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); - modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); - return normalize( refractionVector ) * thickness * modelScale; - } - float applyIorToRoughness( const in float roughness, const in float ior ) { - return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); - } - vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { - float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); - return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); - } - vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { - if ( isinf( attenuationDistance ) ) { - return vec3( 1.0 ); - } else { - vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; - vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; - } - } - vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, - const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, - const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, - const in vec3 attenuationColor, const in float attenuationDistance ) { - vec4 transmittedLight; - vec3 transmittance; - #ifdef USE_DISPERSION - float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; - vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); - for ( int i = 0; i < 3; i ++ ) { - vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); - vec3 refractedRayExit = position + transmissionRay; - vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); - vec2 refractionCoords = ndcPos.xy / ndcPos.w; - refractionCoords += 1.0; - refractionCoords /= 2.0; - vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); - transmittedLight[ i ] = transmissionSample[ i ]; - transmittedLight.a += transmissionSample.a; - transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; - } - transmittedLight.a /= 3.0; - #else - vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); - vec3 refractedRayExit = position + transmissionRay; - vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); - vec2 refractionCoords = ndcPos.xy / ndcPos.w; - refractionCoords += 1.0; - refractionCoords /= 2.0; - transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); - transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); - #endif - vec3 attenuatedColor = transmittance * transmittedLight.rgb; - vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); - float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; - return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); - } -#endif`,Id=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) - varying vec2 vUv; -#endif -#ifdef USE_MAP - varying vec2 vMapUv; -#endif -#ifdef USE_ALPHAMAP - varying vec2 vAlphaMapUv; -#endif -#ifdef USE_LIGHTMAP - varying vec2 vLightMapUv; -#endif -#ifdef USE_AOMAP - varying vec2 vAoMapUv; -#endif -#ifdef USE_BUMPMAP - varying vec2 vBumpMapUv; -#endif -#ifdef USE_NORMALMAP - varying vec2 vNormalMapUv; -#endif -#ifdef USE_EMISSIVEMAP - varying vec2 vEmissiveMapUv; -#endif -#ifdef USE_METALNESSMAP - varying vec2 vMetalnessMapUv; -#endif -#ifdef USE_ROUGHNESSMAP - varying vec2 vRoughnessMapUv; -#endif -#ifdef USE_ANISOTROPYMAP - varying vec2 vAnisotropyMapUv; -#endif -#ifdef USE_CLEARCOATMAP - varying vec2 vClearcoatMapUv; -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - varying vec2 vClearcoatNormalMapUv; -#endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - varying vec2 vClearcoatRoughnessMapUv; -#endif -#ifdef USE_IRIDESCENCEMAP - varying vec2 vIridescenceMapUv; -#endif -#ifdef USE_IRIDESCENCE_THICKNESSMAP - varying vec2 vIridescenceThicknessMapUv; -#endif -#ifdef USE_SHEEN_COLORMAP - varying vec2 vSheenColorMapUv; -#endif -#ifdef USE_SHEEN_ROUGHNESSMAP - varying vec2 vSheenRoughnessMapUv; -#endif -#ifdef USE_SPECULARMAP - varying vec2 vSpecularMapUv; -#endif -#ifdef USE_SPECULAR_COLORMAP - varying vec2 vSpecularColorMapUv; -#endif -#ifdef USE_SPECULAR_INTENSITYMAP - varying vec2 vSpecularIntensityMapUv; -#endif -#ifdef USE_TRANSMISSIONMAP - uniform mat3 transmissionMapTransform; - varying vec2 vTransmissionMapUv; -#endif -#ifdef USE_THICKNESSMAP - uniform mat3 thicknessMapTransform; - varying vec2 vThicknessMapUv; -#endif`,Ud=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) - varying vec2 vUv; -#endif -#ifdef USE_MAP - uniform mat3 mapTransform; - varying vec2 vMapUv; -#endif -#ifdef USE_ALPHAMAP - uniform mat3 alphaMapTransform; - varying vec2 vAlphaMapUv; -#endif -#ifdef USE_LIGHTMAP - uniform mat3 lightMapTransform; - varying vec2 vLightMapUv; -#endif -#ifdef USE_AOMAP - uniform mat3 aoMapTransform; - varying vec2 vAoMapUv; -#endif -#ifdef USE_BUMPMAP - uniform mat3 bumpMapTransform; - varying vec2 vBumpMapUv; -#endif -#ifdef USE_NORMALMAP - uniform mat3 normalMapTransform; - varying vec2 vNormalMapUv; -#endif -#ifdef USE_DISPLACEMENTMAP - uniform mat3 displacementMapTransform; - varying vec2 vDisplacementMapUv; -#endif -#ifdef USE_EMISSIVEMAP - uniform mat3 emissiveMapTransform; - varying vec2 vEmissiveMapUv; -#endif -#ifdef USE_METALNESSMAP - uniform mat3 metalnessMapTransform; - varying vec2 vMetalnessMapUv; -#endif -#ifdef USE_ROUGHNESSMAP - uniform mat3 roughnessMapTransform; - varying vec2 vRoughnessMapUv; -#endif -#ifdef USE_ANISOTROPYMAP - uniform mat3 anisotropyMapTransform; - varying vec2 vAnisotropyMapUv; -#endif -#ifdef USE_CLEARCOATMAP - uniform mat3 clearcoatMapTransform; - varying vec2 vClearcoatMapUv; -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - uniform mat3 clearcoatNormalMapTransform; - varying vec2 vClearcoatNormalMapUv; -#endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - uniform mat3 clearcoatRoughnessMapTransform; - varying vec2 vClearcoatRoughnessMapUv; -#endif -#ifdef USE_SHEEN_COLORMAP - uniform mat3 sheenColorMapTransform; - varying vec2 vSheenColorMapUv; -#endif -#ifdef USE_SHEEN_ROUGHNESSMAP - uniform mat3 sheenRoughnessMapTransform; - varying vec2 vSheenRoughnessMapUv; -#endif -#ifdef USE_IRIDESCENCEMAP - uniform mat3 iridescenceMapTransform; - varying vec2 vIridescenceMapUv; -#endif -#ifdef USE_IRIDESCENCE_THICKNESSMAP - uniform mat3 iridescenceThicknessMapTransform; - varying vec2 vIridescenceThicknessMapUv; -#endif -#ifdef USE_SPECULARMAP - uniform mat3 specularMapTransform; - varying vec2 vSpecularMapUv; -#endif -#ifdef USE_SPECULAR_COLORMAP - uniform mat3 specularColorMapTransform; - varying vec2 vSpecularColorMapUv; -#endif -#ifdef USE_SPECULAR_INTENSITYMAP - uniform mat3 specularIntensityMapTransform; - varying vec2 vSpecularIntensityMapUv; -#endif -#ifdef USE_TRANSMISSIONMAP - uniform mat3 transmissionMapTransform; - varying vec2 vTransmissionMapUv; -#endif -#ifdef USE_THICKNESSMAP - uniform mat3 thicknessMapTransform; - varying vec2 vThicknessMapUv; -#endif`,Nd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) - vUv = vec3( uv, 1 ).xy; -#endif -#ifdef USE_MAP - vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; -#endif -#ifdef USE_ALPHAMAP - vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_LIGHTMAP - vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_AOMAP - vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_BUMPMAP - vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_NORMALMAP - vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_DISPLACEMENTMAP - vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_EMISSIVEMAP - vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_METALNESSMAP - vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_ROUGHNESSMAP - vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_ANISOTROPYMAP - vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_CLEARCOATMAP - vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_IRIDESCENCEMAP - vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_IRIDESCENCE_THICKNESSMAP - vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SHEEN_COLORMAP - vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SHEEN_ROUGHNESSMAP - vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SPECULARMAP - vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SPECULAR_COLORMAP - vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SPECULAR_INTENSITYMAP - vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_TRANSMISSIONMAP - vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_THICKNESSMAP - vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,Fd=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 - vec4 worldPosition = vec4( transformed, 1.0 ); - #ifdef USE_BATCHING - worldPosition = batchingMatrix * worldPosition; - #endif - #ifdef USE_INSTANCING - worldPosition = instanceMatrix * worldPosition; - #endif - worldPosition = modelMatrix * worldPosition; -#endif`;const Od=`varying vec2 vUv; -uniform mat3 uvTransform; -void main() { - vUv = ( uvTransform * vec3( uv, 1 ) ).xy; - gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,Bd=`uniform sampler2D t2D; -uniform float backgroundIntensity; -varying vec2 vUv; -void main() { - vec4 texColor = texture2D( t2D, vUv ); - #ifdef DECODE_VIDEO_TEXTURE - texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); - #endif - texColor.rgb *= backgroundIntensity; - gl_FragColor = texColor; - #include - #include -}`,zd=`varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include - gl_Position.z = gl_Position.w; -}`,Gd=`#ifdef ENVMAP_TYPE_CUBE - uniform samplerCube envMap; -#elif defined( ENVMAP_TYPE_CUBE_UV ) - uniform sampler2D envMap; -#endif -uniform float backgroundBlurriness; -uniform float backgroundIntensity; -uniform mat3 backgroundRotation; -varying vec3 vWorldDirection; -#include -void main() { - #ifdef ENVMAP_TYPE_CUBE - vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); - #elif defined( ENVMAP_TYPE_CUBE_UV ) - vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); - #else - vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - #endif - texColor.rgb *= backgroundIntensity; - gl_FragColor = texColor; - #include - #include -}`,Vd=`varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include - gl_Position.z = gl_Position.w; -}`,Hd=`uniform samplerCube tCube; -uniform float tFlip; -uniform float opacity; -varying vec3 vWorldDirection; -void main() { - vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); - gl_FragColor = texColor; - gl_FragColor.a *= opacity; - #include - #include -}`,kd=`#include -#include -#include -#include -#include -#include -#include -#include -varying vec2 vHighPrecisionZW; -void main() { - #include - #include - #include - #include - #ifdef USE_DISPLACEMENTMAP - #include - #include - #include - #endif - #include - #include - #include - #include - #include - #include - #include - vHighPrecisionZW = gl_Position.zw; -}`,Wd=`#if DEPTH_PACKING == 3200 - uniform float opacity; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -varying vec2 vHighPrecisionZW; -void main() { - vec4 diffuseColor = vec4( 1.0 ); - #include - #if DEPTH_PACKING == 3200 - diffuseColor.a = opacity; - #endif - #include - #include - #include - #include - #include - #ifdef USE_REVERSED_DEPTH_BUFFER - float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; - #else - float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; - #endif - #if DEPTH_PACKING == 3200 - gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); - #elif DEPTH_PACKING == 3201 - gl_FragColor = packDepthToRGBA( fragCoordZ ); - #elif DEPTH_PACKING == 3202 - gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); - #elif DEPTH_PACKING == 3203 - gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); - #endif -}`,Xd=`#define DISTANCE -varying vec3 vWorldPosition; -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #ifdef USE_DISPLACEMENTMAP - #include - #include - #include - #endif - #include - #include - #include - #include - #include - #include - #include - vWorldPosition = worldPosition.xyz; -}`,Yd=`#define DISTANCE -uniform vec3 referencePosition; -uniform float nearDistance; -uniform float farDistance; -varying vec3 vWorldPosition; -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( 1.0 ); - #include - #include - #include - #include - #include - float dist = length( vWorldPosition - referencePosition ); - dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); - dist = saturate( dist ); - gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); -}`,qd=`varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include -}`,Kd=`uniform sampler2D tEquirect; -varying vec3 vWorldDirection; -#include -void main() { - vec3 direction = normalize( vWorldDirection ); - vec2 sampleUV = equirectUv( direction ); - gl_FragColor = texture2D( tEquirect, sampleUV ); - #include - #include -}`,Zd=`uniform float scale; -attribute float lineDistance; -varying float vLineDistance; -#include -#include -#include -#include -#include -#include -#include -void main() { - vLineDistance = scale * lineDistance; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -}`,$d=`uniform vec3 diffuse; -uniform float opacity; -uniform float dashSize; -uniform float totalSize; -varying float vLineDistance; -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - if ( mod( vLineDistance, totalSize ) > dashSize ) { - discard; - } - vec3 outgoingLight = vec3( 0.0 ); - #include - #include - #include - outgoingLight = diffuseColor.rgb; - #include - #include - #include - #include - #include -}`,Jd=`#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) - #include - #include - #include - #include - #include - #endif - #include - #include - #include - #include - #include - #include - #include - #include - #include -}`,Qd=`uniform vec3 diffuse; -uniform float opacity; -#ifndef FLAT_SHADED - varying vec3 vNormal; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - #include - #include - #include - #include - #include - #include - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - #ifdef USE_LIGHTMAP - vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); - reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; - #else - reflectedLight.indirectDiffuse += vec3( 1.0 ); - #endif - #include - reflectedLight.indirectDiffuse *= diffuseColor.rgb; - vec3 outgoingLight = reflectedLight.indirectDiffuse; - #include - #include - #include - #include - #include - #include - #include -}`,jd=`#define LAMBERT -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include - #include -}`,ef=`#define LAMBERT -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include - #include -}`,tf=`#define MATCAP -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; -}`,nf=`#define MATCAP -uniform vec3 diffuse; -uniform float opacity; -uniform sampler2D matcap; -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 viewDir = normalize( vViewPosition ); - vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); - vec3 y = cross( viewDir, x ); - vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; - #ifdef USE_MATCAP - vec4 matcapColor = texture2D( matcap, uv ); - #else - vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); - #endif - vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; - #include - #include - #include - #include - #include - #include -}`,sf=`#define NORMAL -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) - varying vec3 vViewPosition; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) - vViewPosition = - mvPosition.xyz; -#endif -}`,rf=`#define NORMAL -uniform float opacity; -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) - varying vec3 vViewPosition; -#endif -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); - #include - #include - #include - #include - gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); - #ifdef OPAQUE - gl_FragColor.a = 1.0; - #endif -}`,af=`#define PHONG -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include - #include -}`,of=`#define PHONG -uniform vec3 diffuse; -uniform vec3 emissive; -uniform vec3 specular; -uniform float shininess; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include - #include -}`,lf=`#define STANDARD -varying vec3 vViewPosition; -#ifdef USE_TRANSMISSION - varying vec3 vWorldPosition; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include -#ifdef USE_TRANSMISSION - vWorldPosition = worldPosition.xyz; -#endif -}`,cf=`#define STANDARD -#ifdef PHYSICAL - #define IOR - #define USE_SPECULAR -#endif -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float roughness; -uniform float metalness; -uniform float opacity; -#ifdef IOR - uniform float ior; -#endif -#ifdef USE_SPECULAR - uniform float specularIntensity; - uniform vec3 specularColor; - #ifdef USE_SPECULAR_COLORMAP - uniform sampler2D specularColorMap; - #endif - #ifdef USE_SPECULAR_INTENSITYMAP - uniform sampler2D specularIntensityMap; - #endif -#endif -#ifdef USE_CLEARCOAT - uniform float clearcoat; - uniform float clearcoatRoughness; -#endif -#ifdef USE_DISPERSION - uniform float dispersion; -#endif -#ifdef USE_IRIDESCENCE - uniform float iridescence; - uniform float iridescenceIOR; - uniform float iridescenceThicknessMinimum; - uniform float iridescenceThicknessMaximum; -#endif -#ifdef USE_SHEEN - uniform vec3 sheenColor; - uniform float sheenRoughness; - #ifdef USE_SHEEN_COLORMAP - uniform sampler2D sheenColorMap; - #endif - #ifdef USE_SHEEN_ROUGHNESSMAP - uniform sampler2D sheenRoughnessMap; - #endif -#endif -#ifdef USE_ANISOTROPY - uniform vec2 anisotropyVector; - #ifdef USE_ANISOTROPYMAP - uniform sampler2D anisotropyMap; - #endif -#endif -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; - vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; - #include - vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; - #ifdef USE_SHEEN - - outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; - - #endif - #ifdef USE_CLEARCOAT - float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); - vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); - outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; - #endif - #include - #include - #include - #include - #include - #include -}`,hf=`#define TOON -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include -}`,uf=`#define TOON -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include -}`,df=`uniform float size; -uniform float scale; -#include -#include -#include -#include -#include -#include -#ifdef USE_POINTS_UV - varying vec2 vUv; - uniform mat3 uvTransform; -#endif -void main() { - #ifdef USE_POINTS_UV - vUv = ( uvTransform * vec3( uv, 1 ) ).xy; - #endif - #include - #include - #include - #include - #include - #include - gl_PointSize = size; - #ifdef USE_SIZEATTENUATION - bool isPerspective = isPerspectiveMatrix( projectionMatrix ); - if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); - #endif - #include - #include - #include - #include -}`,ff=`uniform vec3 diffuse; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - vec3 outgoingLight = vec3( 0.0 ); - #include - #include - #include - #include - #include - outgoingLight = diffuseColor.rgb; - #include - #include - #include - #include - #include -}`,pf=`#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -}`,mf=`uniform vec3 color; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); - #include - #include - #include - #include -}`,_f=`uniform float rotation; -uniform vec2 center; -#include -#include -#include -#include -#include -void main() { - #include - vec4 mvPosition = modelViewMatrix[ 3 ]; - vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); - #ifndef USE_SIZEATTENUATION - bool isPerspective = isPerspectiveMatrix( projectionMatrix ); - if ( isPerspective ) scale *= - mvPosition.z; - #endif - vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; - vec2 rotatedPosition; - rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; - rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; - mvPosition.xy += rotatedPosition; - gl_Position = projectionMatrix * mvPosition; - #include - #include - #include -}`,gf=`uniform vec3 diffuse; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - vec3 outgoingLight = vec3( 0.0 ); - #include - #include - #include - #include - #include - outgoingLight = diffuseColor.rgb; - #include - #include - #include - #include -}`,Be={alphahash_fragment:Oh,alphahash_pars_fragment:Bh,alphamap_fragment:zh,alphamap_pars_fragment:Gh,alphatest_fragment:Vh,alphatest_pars_fragment:Hh,aomap_fragment:kh,aomap_pars_fragment:Wh,batching_pars_vertex:Xh,batching_vertex:Yh,begin_vertex:qh,beginnormal_vertex:Kh,bsdfs:Zh,iridescence_fragment:$h,bumpmap_pars_fragment:Jh,clipping_planes_fragment:Qh,clipping_planes_pars_fragment:jh,clipping_planes_pars_vertex:eu,clipping_planes_vertex:tu,color_fragment:nu,color_pars_fragment:iu,color_pars_vertex:su,color_vertex:ru,common:au,cube_uv_reflection_fragment:ou,defaultnormal_vertex:lu,displacementmap_pars_vertex:cu,displacementmap_vertex:hu,emissivemap_fragment:uu,emissivemap_pars_fragment:du,colorspace_fragment:fu,colorspace_pars_fragment:pu,envmap_fragment:mu,envmap_common_pars_fragment:_u,envmap_pars_fragment:gu,envmap_pars_vertex:xu,envmap_physical_pars_fragment:Cu,envmap_vertex:vu,fog_vertex:Mu,fog_pars_vertex:Su,fog_fragment:Eu,fog_pars_fragment:yu,gradientmap_pars_fragment:bu,lightmap_pars_fragment:Tu,lights_lambert_fragment:Au,lights_lambert_pars_fragment:Ru,lights_pars_begin:wu,lights_toon_fragment:Pu,lights_toon_pars_fragment:Du,lights_phong_fragment:Lu,lights_phong_pars_fragment:Iu,lights_physical_fragment:Uu,lights_physical_pars_fragment:Nu,lights_fragment_begin:Fu,lights_fragment_maps:Ou,lights_fragment_end:Bu,lightprobes_pars_fragment:zu,logdepthbuf_fragment:Gu,logdepthbuf_pars_fragment:Vu,logdepthbuf_pars_vertex:Hu,logdepthbuf_vertex:ku,map_fragment:Wu,map_pars_fragment:Xu,map_particle_fragment:Yu,map_particle_pars_fragment:qu,metalnessmap_fragment:Ku,metalnessmap_pars_fragment:Zu,morphinstance_vertex:$u,morphcolor_vertex:Ju,morphnormal_vertex:Qu,morphtarget_pars_vertex:ju,morphtarget_vertex:ed,normal_fragment_begin:td,normal_fragment_maps:nd,normal_pars_fragment:id,normal_pars_vertex:sd,normal_vertex:rd,normalmap_pars_fragment:ad,clearcoat_normal_fragment_begin:od,clearcoat_normal_fragment_maps:ld,clearcoat_pars_fragment:cd,iridescence_pars_fragment:hd,opaque_fragment:ud,packing:dd,premultiplied_alpha_fragment:fd,project_vertex:pd,dithering_fragment:md,dithering_pars_fragment:_d,roughnessmap_fragment:gd,roughnessmap_pars_fragment:xd,shadowmap_pars_fragment:vd,shadowmap_pars_vertex:Md,shadowmap_vertex:Sd,shadowmask_pars_fragment:Ed,skinbase_vertex:yd,skinning_pars_vertex:bd,skinning_vertex:Td,skinnormal_vertex:Ad,specularmap_fragment:Rd,specularmap_pars_fragment:wd,tonemapping_fragment:Cd,tonemapping_pars_fragment:Pd,transmission_fragment:Dd,transmission_pars_fragment:Ld,uv_pars_fragment:Id,uv_pars_vertex:Ud,uv_vertex:Nd,worldpos_vertex:Fd,background_vert:Od,background_frag:Bd,backgroundCube_vert:zd,backgroundCube_frag:Gd,cube_vert:Vd,cube_frag:Hd,depth_vert:kd,depth_frag:Wd,distance_vert:Xd,distance_frag:Yd,equirect_vert:qd,equirect_frag:Kd,linedashed_vert:Zd,linedashed_frag:$d,meshbasic_vert:Jd,meshbasic_frag:Qd,meshlambert_vert:jd,meshlambert_frag:ef,meshmatcap_vert:tf,meshmatcap_frag:nf,meshnormal_vert:sf,meshnormal_frag:rf,meshphong_vert:af,meshphong_frag:of,meshphysical_vert:lf,meshphysical_frag:cf,meshtoon_vert:hf,meshtoon_frag:uf,points_vert:df,points_frag:ff,shadow_vert:pf,shadow_frag:mf,sprite_vert:_f,sprite_frag:gf},he={common:{diffuse:{value:new Oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ie},alphaMap:{value:null},alphaMapTransform:{value:new Ie},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ie}},envmap:{envMap:{value:null},envMapRotation:{value:new Ie},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ie}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ie}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ie},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ie},normalScale:{value:new Re(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ie},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ie}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ie}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ie}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Oe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new Oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ie},alphaTest:{value:0},uvTransform:{value:new Ie}},sprite:{diffuse:{value:new Oe(16777215)},opacity:{value:1},center:{value:new Re(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ie},alphaMap:{value:null},alphaMapTransform:{value:new Ie},alphaTest:{value:0}}},tn={basic:{uniforms:Dt([he.common,he.specularmap,he.envmap,he.aomap,he.lightmap,he.fog]),vertexShader:Be.meshbasic_vert,fragmentShader:Be.meshbasic_frag},lambert:{uniforms:Dt([he.common,he.specularmap,he.envmap,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.fog,he.lights,{emissive:{value:new Oe(0)},envMapIntensity:{value:1}}]),vertexShader:Be.meshlambert_vert,fragmentShader:Be.meshlambert_frag},phong:{uniforms:Dt([he.common,he.specularmap,he.envmap,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.fog,he.lights,{emissive:{value:new Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Be.meshphong_vert,fragmentShader:Be.meshphong_frag},standard:{uniforms:Dt([he.common,he.envmap,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.roughnessmap,he.metalnessmap,he.fog,he.lights,{emissive:{value:new Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Be.meshphysical_vert,fragmentShader:Be.meshphysical_frag},toon:{uniforms:Dt([he.common,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.gradientmap,he.fog,he.lights,{emissive:{value:new Oe(0)}}]),vertexShader:Be.meshtoon_vert,fragmentShader:Be.meshtoon_frag},matcap:{uniforms:Dt([he.common,he.bumpmap,he.normalmap,he.displacementmap,he.fog,{matcap:{value:null}}]),vertexShader:Be.meshmatcap_vert,fragmentShader:Be.meshmatcap_frag},points:{uniforms:Dt([he.points,he.fog]),vertexShader:Be.points_vert,fragmentShader:Be.points_frag},dashed:{uniforms:Dt([he.common,he.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Be.linedashed_vert,fragmentShader:Be.linedashed_frag},depth:{uniforms:Dt([he.common,he.displacementmap]),vertexShader:Be.depth_vert,fragmentShader:Be.depth_frag},normal:{uniforms:Dt([he.common,he.bumpmap,he.normalmap,he.displacementmap,{opacity:{value:1}}]),vertexShader:Be.meshnormal_vert,fragmentShader:Be.meshnormal_frag},sprite:{uniforms:Dt([he.sprite,he.fog]),vertexShader:Be.sprite_vert,fragmentShader:Be.sprite_frag},background:{uniforms:{uvTransform:{value:new Ie},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Be.background_vert,fragmentShader:Be.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ie}},vertexShader:Be.backgroundCube_vert,fragmentShader:Be.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Be.cube_vert,fragmentShader:Be.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Be.equirect_vert,fragmentShader:Be.equirect_frag},distance:{uniforms:Dt([he.common,he.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Be.distance_vert,fragmentShader:Be.distance_frag},shadow:{uniforms:Dt([he.lights,he.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:Be.shadow_vert,fragmentShader:Be.shadow_frag}};tn.physical={uniforms:Dt([tn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ie},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ie},clearcoatNormalScale:{value:new Re(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ie},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ie},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ie},sheen:{value:0},sheenColor:{value:new Oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ie},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ie},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ie},transmissionSamplerSize:{value:new Re},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ie},attenuationDistance:{value:0},attenuationColor:{value:new Oe(0)},specularColor:{value:new Oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ie},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ie},anisotropyVector:{value:new Re},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ie}}]),vertexShader:Be.meshphysical_vert,fragmentShader:Be.meshphysical_frag};const Ms={r:0,b:0,g:0},xf=new lt,Gl=new Ie;Gl.set(-1,0,0,0,1,0,0,0,1);function vf(i,e,t,n,s,r){const a=new Oe(0);let o=s===!0?0:1,c,l,f=null,m=0,h=null;function _(A){let R=A.isScene===!0?A.background:null;if(R&&R.isTexture){const M=A.backgroundBlurriness>0;R=e.get(R,M)}return R}function v(A){let R=!1;const M=_(A);M===null?p(a,o):M&&M.isColor&&(p(M,1),R=!0);const T=i.xr.getEnvironmentBlendMode();T==="additive"?t.buffers.color.setClear(0,0,0,1,r):T==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||R)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function S(A,R){const M=_(R);M&&(M.isCubeTexture||M.mapping===Gs)?(l===void 0&&(l=new Zt(new Yi(1,1,1),new hn({name:"BackgroundCubeMaterial",uniforms:Ri(tn.backgroundCube.uniforms),vertexShader:tn.backgroundCube.vertexShader,fragmentShader:tn.backgroundCube.fragmentShader,side:It,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(T,y,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(xf.makeRotationFromEuler(R.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Gl),l.material.toneMapped=Ye.getTransfer(M.colorSpace)!==je,(f!==M||m!==M.version||h!==i.toneMapping)&&(l.material.needsUpdate=!0,f=M,m=M.version,h=i.toneMapping),l.layers.enableAll(),A.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new Zt(new ks(2,2),new hn({name:"BackgroundMaterial",uniforms:Ri(tn.background.uniforms),vertexShader:tn.background.vertexShader,fragmentShader:tn.background.fragmentShader,side:Nn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.toneMapped=Ye.getTransfer(M.colorSpace)!==je,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(f!==M||m!==M.version||h!==i.toneMapping)&&(c.material.needsUpdate=!0,f=M,m=M.version,h=i.toneMapping),c.layers.enableAll(),A.unshift(c,c.geometry,c.material,0,0,null))}function p(A,R){A.getRGB(Ms,Fl(i)),t.buffers.color.setClear(Ms.r,Ms.g,Ms.b,R,r)}function u(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(A,R=1){a.set(A),o=R,p(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(A){o=A,p(a,o)},render:v,addToRenderList:S,dispose:u}}function Mf(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=h(null);let r=s,a=!1;function o(P,F,Y,K,z){let X=!1;const H=m(P,K,Y,F);r!==H&&(r=H,l(r.object)),X=_(P,K,Y,z),X&&v(P,K,Y,z),z!==null&&e.update(z,i.ELEMENT_ARRAY_BUFFER),(X||a)&&(a=!1,M(P,F,Y,K),z!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(z).buffer))}function c(){return i.createVertexArray()}function l(P){return i.bindVertexArray(P)}function f(P){return i.deleteVertexArray(P)}function m(P,F,Y,K){const z=K.wireframe===!0;let X=n[F.id];X===void 0&&(X={},n[F.id]=X);const H=P.isInstancedMesh===!0?P.id:0;let J=X[H];J===void 0&&(J={},X[H]=J);let j=J[Y.id];j===void 0&&(j={},J[Y.id]=j);let re=j[z];return re===void 0&&(re=h(c()),j[z]=re),re}function h(P){const F=[],Y=[],K=[];for(let z=0;z=0){const de=z[j];let _e=X[j];if(_e===void 0&&(j==="instanceMatrix"&&P.instanceMatrix&&(_e=P.instanceMatrix),j==="instanceColor"&&P.instanceColor&&(_e=P.instanceColor)),de===void 0||de.attribute!==_e||_e&&de.data!==_e.data)return!0;H++}return r.attributesNum!==H||r.index!==K}function v(P,F,Y,K){const z={},X=F.attributes;let H=0;const J=Y.getAttributes();for(const j in J)if(J[j].location>=0){let de=X[j];de===void 0&&(j==="instanceMatrix"&&P.instanceMatrix&&(de=P.instanceMatrix),j==="instanceColor"&&P.instanceColor&&(de=P.instanceColor));const _e={};_e.attribute=de,de&&de.data&&(_e.data=de.data),z[j]=_e,H++}r.attributes=z,r.attributesNum=H,r.index=K}function S(){const P=r.newAttributes;for(let F=0,Y=P.length;F=0){let re=z[J];if(re===void 0&&(J==="instanceMatrix"&&P.instanceMatrix&&(re=P.instanceMatrix),J==="instanceColor"&&P.instanceColor&&(re=P.instanceColor)),re!==void 0){const de=re.normalized,_e=re.itemSize,qe=e.get(re);if(qe===void 0)continue;const Je=qe.buffer,He=qe.type,q=qe.bytesPerElement,ne=He===i.INT||He===i.UNSIGNED_INT||re.gpuType===ba;if(re.isInterleavedBufferAttribute){const ee=re.data,De=ee.stride,Le=re.offset;if(ee.isInstancedInterleavedBuffer){for(let we=0;we0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const f=c(l);f!==l&&(Pe("WebGLRenderer:",l,"not supported, using",f,"instead."),l=f);const m=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Pe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const _=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),S=i.getParameter(i.MAX_TEXTURE_SIZE),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),u=i.getParameter(i.MAX_VERTEX_ATTRIBS),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),R=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),T=i.getParameter(i.MAX_SAMPLES),y=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:m,reversedDepthBuffer:h,maxTextures:_,maxVertexTextures:v,maxTextureSize:S,maxCubemapSize:p,maxAttributes:u,maxVertexUniforms:A,maxVaryings:R,maxFragmentUniforms:M,maxSamples:T,samples:y}}function yf(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new Dn,o=new Ie,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(m,h){const _=m.length!==0||h||n!==0||s;return s=h,n=m.length,_},this.beginShadows=function(){r=!0,f(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(m,h){t=f(m,h,0)},this.setState=function(m,h,_){const v=m.clippingPlanes,S=m.clipIntersection,p=m.clipShadows,u=i.get(m);if(!s||v===null||v.length===0||r&&!p)r?f(null):l();else{const A=r?0:n,R=A*4;let M=u.clippingState||null;c.value=M,M=f(v,h,R,_);for(let T=0;T!==R;++T)M[T]=t[T];u.clippingState=M,this.numIntersection=S?this.numPlanes:0,this.numPlanes+=A}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function f(m,h,_,v){const S=m!==null?m.length:0;let p=null;if(S!==0){if(p=c.value,v!==!0||p===null){const u=_+S*4,A=h.matrixWorldInverse;o.getNormalMatrix(A),(p===null||p.length0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ko(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ho(),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())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?T:0,T,T),m.setRenderTarget(s),u&&m.render(S,c),m.render(e,c)}m.toneMapping=_,m.autoClear=h,e.background=A}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===Zn||e.mapping===Ti;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ko()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ho());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;xi(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,Bi)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rv-In?n-v+In:0),u=4*(this._cubeSize-S);c.envMap.value=e.texture,c.roughness.value=_,c.mipInt.value=v-t,xi(r,p,u,3*S,2*S),s.setRenderTarget(r),s.render(o,Bi),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=v-n,xi(e,p,u,3*S,2*S),s.setRenderTarget(e),s.render(o,Bi)}_blur(e,t,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",r),this._halfBlur(a,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Xe("blur direction must be either latitudinal or longitudinal!");const f=3,m=this._lodMeshes[s];m.material=l;const h=l.uniforms,_=this._sizeLods[n]-1,v=isFinite(r)?Math.PI/(2*_):2*Math.PI/(2*Yn-1),S=r/v,p=isFinite(r)?1+Math.floor(f*S):Yn;p>Yn&&Pe(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Yn}`);const u=[];let A=0;for(let w=0;wR-In?s-R+In:0),y=4*(this._cubeSize-M);xi(t,T,y,3*M,2*M),c.setRenderTarget(t),c.render(m,Bi)}}function Af(i){const e=[],t=[],n=[];let s=i;const r=i-In+1+Bo.length;for(let a=0;ai-In?c=Bo[a-i+In-1]:a===0&&(c=0),t.push(c);const l=1/(o-2),f=-l,m=1+l,h=[f,f,m,f,m,m,f,f,m,m,f,m],_=6,v=6,S=3,p=2,u=1,A=new Float32Array(S*v*_),R=new Float32Array(p*v*_),M=new Float32Array(u*v*_);for(let y=0;y<_;y++){const w=y%3*2/3-1,g=y>2?0:-1,b=[w,g,0,w+2/3,g,0,w+2/3,g+1,0,w,g,0,w+2/3,g+1,0,w,g+1,0];A.set(b,S*v*y),R.set(h,p*v*y);const I=[y,y,y,y,y,y];M.set(I,u*v*y)}const T=new Ut;T.setAttribute("position",new Kt(A,S)),T.setAttribute("uv",new Kt(R,p)),T.setAttribute("faceIndex",new Kt(M,u)),n.push(new Zt(T,null)),s>In&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Vo(i,e,t){const n=new ln(i,e,t);return n.texture.mapping=Gs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function xi(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function Rf(i,e,t){return new hn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:bf,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Ws(),fragmentShader:` - - precision highp float; - precision highp int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - uniform float roughness; - uniform float mipInt; - - #define ENVMAP_TYPE_CUBE_UV - #include - - #define PI 3.14159265359 - - // Van der Corput radical inverse - float radicalInverse_VdC(uint bits) { - bits = (bits << 16u) | (bits >> 16u); - bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); - bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); - bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); - bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); - return float(bits) * 2.3283064365386963e-10; // / 0x100000000 - } - - // Hammersley sequence - vec2 hammersley(uint i, uint N) { - return vec2(float(i) / float(N), radicalInverse_VdC(i)); - } - - // GGX VNDF importance sampling (Eric Heitz 2018) - // "Sampling the GGX Distribution of Visible Normals" - // https://jcgt.org/published/0007/04/01/ - vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { - float alpha = roughness * roughness; - - // Section 4.1: Orthonormal basis - vec3 T1 = vec3(1.0, 0.0, 0.0); - vec3 T2 = cross(V, T1); - - // Section 4.2: Parameterization of projected area - float r = sqrt(Xi.x); - float phi = 2.0 * PI * Xi.y; - float t1 = r * cos(phi); - float t2 = r * sin(phi); - float s = 0.5 * (1.0 + V.z); - t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; - - // Section 4.3: Reprojection onto hemisphere - vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; - - // Section 3.4: Transform back to ellipsoid configuration - return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); - } - - void main() { - vec3 N = normalize(vOutputDirection); - vec3 V = N; // Assume view direction equals normal for pre-filtering - - vec3 prefilteredColor = vec3(0.0); - float totalWeight = 0.0; - - // For very low roughness, just sample the environment directly - if (roughness < 0.001) { - gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); - return; - } - - // Tangent space basis for VNDF sampling - vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); - vec3 tangent = normalize(cross(up, N)); - vec3 bitangent = cross(N, tangent); - - for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { - vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); - - // For PMREM, V = N, so in tangent space V is always (0, 0, 1) - vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); - - // Transform H back to world space - vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); - vec3 L = normalize(2.0 * dot(V, H) * H - V); - - float NdotL = max(dot(N, L), 0.0); - - if(NdotL > 0.0) { - // Sample environment at fixed mip level - // VNDF importance sampling handles the distribution filtering - vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); - - // Weight by NdotL for the split-sum approximation - // VNDF PDF naturally accounts for the visible microfacet distribution - prefilteredColor += sampleColor * NdotL; - totalWeight += NdotL; - } - } - - if (totalWeight > 0.0) { - prefilteredColor = prefilteredColor / totalWeight; - } - - gl_FragColor = vec4(prefilteredColor, 1.0); - } - `,blending:xn,depthTest:!1,depthWrite:!1})}function wf(i,e,t){const n=new Float32Array(Yn),s=new U(0,1,0);return new hn({name:"SphericalGaussianBlur",defines:{n:Yn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Ws(),fragmentShader:` - - precision mediump float; - precision mediump int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - uniform int samples; - uniform float weights[ n ]; - uniform bool latitudinal; - uniform float dTheta; - uniform float mipInt; - uniform vec3 poleAxis; - - #define ENVMAP_TYPE_CUBE_UV - #include - - vec3 getSample( float theta, vec3 axis ) { - - float cosTheta = cos( theta ); - // Rodrigues' axis-angle rotation - vec3 sampleDirection = vOutputDirection * cosTheta - + cross( axis, vOutputDirection ) * sin( theta ) - + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); - - return bilinearCubeUV( envMap, sampleDirection, mipInt ); - - } - - void main() { - - vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); - - if ( all( equal( axis, vec3( 0.0 ) ) ) ) { - - axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); - - } - - axis = normalize( axis ); - - gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); - - for ( int i = 1; i < n; i++ ) { - - if ( i >= samples ) { - - break; - - } - - float theta = dTheta * float( i ); - gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); - gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); - - } - - } - `,blending:xn,depthTest:!1,depthWrite:!1})}function Ho(){return new hn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ws(),fragmentShader:` - - precision mediump float; - precision mediump int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - - #include - - void main() { - - vec3 outputDirection = normalize( vOutputDirection ); - vec2 uv = equirectUv( outputDirection ); - - gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); - - } - `,blending:xn,depthTest:!1,depthWrite:!1})}function ko(){return new hn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ws(),fragmentShader:` - - precision mediump float; - precision mediump int; - - uniform float flipEnvMap; - - varying vec3 vOutputDirection; - - uniform samplerCube envMap; - - void main() { - - gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); - - } - `,blending:xn,depthTest:!1,depthWrite:!1})}function Ws(){return` - - precision mediump float; - precision mediump int; - - attribute float faceIndex; - - varying vec3 vOutputDirection; - - // RH coordinate system; PMREM face-indexing convention - vec3 getDirection( vec2 uv, float face ) { - - uv = 2.0 * uv - 1.0; - - vec3 direction = vec3( uv, 1.0 ); - - if ( face == 0.0 ) { - - direction = direction.zyx; // ( 1, v, u ) pos x - - } else if ( face == 1.0 ) { - - direction = direction.xzy; - direction.xz *= -1.0; // ( -u, 1, -v ) pos y - - } else if ( face == 2.0 ) { - - direction.x *= -1.0; // ( -u, v, 1 ) pos z - - } else if ( face == 3.0 ) { - - direction = direction.zyx; - direction.xz *= -1.0; // ( -1, v, -u ) neg x - - } else if ( face == 4.0 ) { - - direction = direction.xzy; - direction.xy *= -1.0; // ( -u, -1, v ) neg y - - } else if ( face == 5.0 ) { - - direction.z *= -1.0; // ( u, v, -1 ) neg z - - } - - return direction; - - } - - void main() { - - vOutputDirection = getDirection( uv, faceIndex ); - gl_Position = vec4( position, 1.0 ); - - } - `}class Vl extends ln{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new Ul(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` - - varying vec3 vWorldDirection; - - vec3 transformDirection( in vec3 dir, in mat4 matrix ) { - - return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); - - } - - void main() { - - vWorldDirection = transformDirection( position, modelMatrix ); - - #include - #include - - } - `,fragmentShader:` - - uniform sampler2D tEquirect; - - varying vec3 vWorldDirection; - - #include - - void main() { - - vec3 direction = normalize( vWorldDirection ); - - vec2 sampleUV = equirectUv( direction ); - - gl_FragColor = texture2D( tEquirect, sampleUV ); - - } - `},s=new Yi(5,5,5),r=new hn({name:"CubemapFromEquirect",uniforms:Ri(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:It,blending:xn});r.uniforms.tEquirect.value=t;const a=new Zt(s,r),o=t.minFilter;return t.minFilter===qn&&(t.minFilter=wt),new Dh(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(r)}}function Cf(i){let e=new WeakMap,t=new WeakMap,n=null;function s(h,_=!1){return h==null?null:_?a(h):r(h)}function r(h){if(h&&h.isTexture){const _=h.mapping;if(_===Ks||_===Zs)if(e.has(h)){const v=e.get(h).texture;return o(v,h.mapping)}else{const v=h.image;if(v&&v.height>0){const S=new Vl(v.height);return S.fromEquirectangularTexture(i,h),e.set(h,S),h.addEventListener("dispose",l),o(S.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const _=h.mapping,v=_===Ks||_===Zs,S=_===Zn||_===Ti;if(v||S){let p=t.get(h);const u=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==u)return n===null&&(n=new Go(i)),p=v?n.fromEquirectangular(h,p):n.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,t.set(h,p),p.texture;if(p!==void 0)return p.texture;{const A=h.image;return v&&A&&A.height>0||S&&A&&c(A)?(n===null&&(n=new Go(i)),p=v?n.fromEquirectangular(h):n.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,t.set(h,p),h.addEventListener("dispose",f),p.texture):null}}}return h}function o(h,_){return _===Ks?h.mapping=Zn:_===Zs&&(h.mapping=Ti),h}function c(h){let _=0;const v=6;for(let S=0;S=65535?Pl:Cl)(h,1);p.version=S;const u=r.get(m);u&&e.remove(u),r.set(m,p)}function f(m){const h=r.get(m);if(h){const _=m.index;_!==null&&h.version<_.version&&l(m)}else l(m);return r.get(m)}return{get:o,update:c,getWireframeAttribute:f}}function Lf(i,e,t){let n;function s(m){n=m}let r,a;function o(m){r=m.type,a=m.bytesPerElement}function c(m,h){i.drawElements(n,h,r,m*a),t.update(h,n,1)}function l(m,h,_){_!==0&&(i.drawElementsInstanced(n,h,r,m*a,_),t.update(h,n,_))}function f(m,h,_){if(_===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,h,0,r,m,0,_);let S=0;for(let p=0;p<_;p++)S+=h[p];t.update(S,n,1)}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=f}function If(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(r/3);break;case i.LINES:t.lines+=o*(r/2);break;case i.LINE_STRIP:t.lines+=o*(r-1);break;case i.LINE_LOOP:t.lines+=o*r;break;case i.POINTS:t.points+=o*r;break;default:Xe("WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function Uf(i,e,t){const n=new WeakMap,s=new ut;function r(a,o,c){const l=a.morphTargetInfluences,f=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,m=f!==void 0?f.length:0;let h=n.get(o);if(h===void 0||h.count!==m){let b=function(){w.dispose(),n.delete(o),o.removeEventListener("dispose",b)};h!==void 0&&h.texture.dispose();const _=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,S=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],u=o.morphAttributes.normal||[],A=o.morphAttributes.color||[];let R=0;_===!0&&(R=1),v===!0&&(R=2),S===!0&&(R=3);let M=o.attributes.position.count*R,T=1;M>e.maxTextureSize&&(T=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const y=new Float32Array(M*T*4*m),w=new Rl(y,M,T,m);w.type=rn,w.needsUpdate=!0;const g=R*4;for(let I=0;I - #include - - void main() { - gl_FragColor = texture2D( tDiffuse, vUv ); - - #ifdef LINEAR_TONE_MAPPING - gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); - #elif defined( REINHARD_TONE_MAPPING ) - gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); - #elif defined( CINEON_TONE_MAPPING ) - gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); - #elif defined( ACES_FILMIC_TONE_MAPPING ) - gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); - #elif defined( AGX_TONE_MAPPING ) - gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); - #elif defined( NEUTRAL_TONE_MAPPING ) - gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); - #elif defined( CUSTOM_TONE_MAPPING ) - gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); - #endif - - #ifdef SRGB_TRANSFER - gl_FragColor = sRGBTransferOETF( gl_FragColor ); - #endif - }`,depthTest:!1,depthWrite:!1}),f=new Zt(c,l),m=new Ba(-1,1,1,-1,0,1);let h=null,_=null,v=!1,S,p=null,u=[],A=!1;this.setSize=function(R,M){a.setSize(R,M),o.setSize(R,M);for(let T=0;T0&&u[0].isRenderPass===!0;const M=a.width,T=a.height;for(let y=0;y0)return i;const s=e*t;let r=Wo[s];if(r===void 0&&(r=new Float32Array(s),Wo[s]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(r,o)}return r}function vt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t0&&(this.seq=s.concat(r))}setValue(e,t,n,s){const r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){const s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,s)}}static seqWithValue(e,t){const n=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&n.push(a)}return n}}function $o(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const wp=37297;let Cp=0;function Pp(i,e){const t=i.split(` -`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return n.join(` -`)}const Jo=new Ie;function Dp(i){Ye._getMatrix(Jo,Ye.workingColorSpace,i);const e=`mat3( ${Jo.elements.map(t=>t.toFixed(4))} )`;switch(Ye.getTransfer(i)){case Is:return[e,"LinearTransferOETF"];case je:return[e,"sRGBTransferOETF"];default:return Pe("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Qo(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` - -`+r+` - -`+Pp(i.getShaderSource(e),o)}else return r}function Lp(i,e){const t=Dp(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` -`)}const Ip={[ul]:"Linear",[dl]:"Reinhard",[fl]:"Cineon",[pl]:"ACESFilmic",[_l]:"AgX",[gl]:"Neutral",[ml]:"Custom"};function Up(i,e){const t=Ip[e];return t===void 0?(Pe("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ss=new U;function Np(){Ye.getLuminanceCoefficients(Ss);const i=Ss.x.toFixed(4),e=Ss.y.toFixed(4),t=Ss.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` -`)}function Fp(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Hi).join(` -`)}function Op(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` -`)}function Bp(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function Ea(i){return i.replace(zp,Vp)}const Gp=new Map;function Vp(i,e){let t=Be[e];if(t===void 0){const n=Gp.get(e);if(n!==void 0)t=Be[n],Pe('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Ea(t)}const Hp=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function tl(i){return i.replace(Hp,kp)}function kp(i,e,t,n){let s="";for(let r=parseInt(e);r0&&(p+=` -`),u=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Hi).join(` -`),u.length>0&&(u+=` -`)):(p=[nl(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+f:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` -`].filter(Hi).join(` -`),u=[nl(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+f:"",t.envMap?"#define "+m:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==on?"#define TONE_MAPPING":"",t.toneMapping!==on?Be.tonemapping_pars_fragment:"",t.toneMapping!==on?Up("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Be.colorspace_pars_fragment,Lp("linearToOutputTexel",t.outputColorSpace),Np(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` -`].filter(Hi).join(` -`)),a=Ea(a),a=jo(a,t),a=el(a,t),o=Ea(o),o=jo(o,t),o=el(o,t),a=tl(a),o=tl(o),t.isRawShaderMaterial!==!0&&(A=`#version 300 es -`,p=[_,"#define attribute in","#define varying out","#define texture2D texture"].join(` -`)+` -`+p,u=["#define varying in",t.glslVersion===ro?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ro?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` -`)+` -`+u);const R=A+p+a,M=A+u+o,T=$o(s,s.VERTEX_SHADER,R),y=$o(s,s.FRAGMENT_SHADER,M);s.attachShader(S,T),s.attachShader(S,y),t.index0AttributeName!==void 0?s.bindAttribLocation(S,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(S,0,"position"),s.linkProgram(S);function w(P){if(i.debug.checkShaderErrors){const F=s.getProgramInfoLog(S)||"",Y=s.getShaderInfoLog(T)||"",K=s.getShaderInfoLog(y)||"",z=F.trim(),X=Y.trim(),H=K.trim();let J=!0,j=!0;if(s.getProgramParameter(S,s.LINK_STATUS)===!1)if(J=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,S,T,y);else{const re=Qo(s,T,"vertex"),de=Qo(s,y,"fragment");Xe("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(S,s.VALIDATE_STATUS)+` - -Material Name: `+P.name+` -Material Type: `+P.type+` - -Program Info Log: `+z+` -`+re+` -`+de)}else z!==""?Pe("WebGLProgram: Program Info Log:",z):(X===""||H==="")&&(j=!1);j&&(P.diagnostics={runnable:J,programLog:z,vertexShader:{log:X,prefix:p},fragmentShader:{log:H,prefix:u}})}s.deleteShader(T),s.deleteShader(y),g=new Cs(s,S),b=Bp(s,S)}let g;this.getUniforms=function(){return g===void 0&&w(this),g};let b;this.getAttributes=function(){return b===void 0&&w(this),b};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(S,wp)),I},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(S),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Cp++,this.cacheKey=e,this.usedTimes=1,this.program=S,this.vertexShader=T,this.fragmentShader=y,this}let em=0;class tm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new nm(e),t.set(e,n)),n}}class nm{constructor(e){this.id=em++,this.code=e,this.usedTimes=0}}function im(i){return i===$n||i===Ps||i===Ds}function sm(i,e,t,n,s,r){const a=new Ia,o=new tm,c=new Set,l=[],f=new Map,m=n.logarithmicDepthBuffer;let h=n.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(g){return c.add(g),g===0?"uv":`uv${g}`}function S(g,b,I,P,F,Y){const K=P.fog,z=F.geometry,X=g.isMeshStandardMaterial||g.isMeshLambertMaterial||g.isMeshPhongMaterial?P.environment:null,H=g.isMeshStandardMaterial||g.isMeshLambertMaterial&&!g.envMap||g.isMeshPhongMaterial&&!g.envMap,J=e.get(g.envMap||X,H),j=J&&J.mapping===Gs?J.image.height:null,re=_[g.type];g.precision!==null&&(h=n.getMaxPrecision(g.precision),h!==g.precision&&Pe("WebGLProgram.getParameters:",g.precision,"not supported, using",h,"instead."));const de=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,_e=de!==void 0?de.length:0;let qe=0;z.morphAttributes.position!==void 0&&(qe=1),z.morphAttributes.normal!==void 0&&(qe=2),z.morphAttributes.color!==void 0&&(qe=3);let Je,He,q,ne;if(re){const Me=tn[re];Je=Me.vertexShader,He=Me.fragmentShader}else{Je=g.vertexShader,He=g.fragmentShader;const Me=o.getVertexShaderStage(g),dt=o.getFragmentShaderStage(g);o.update(g,Me,dt),q=Me.id,ne=dt.id}const ee=i.getRenderTarget(),De=i.state.buffers.depth.getReversed(),Le=F.isInstancedMesh===!0,we=F.isBatchedMesh===!0,ct=!!g.map,ze=!!g.matcap,Qe=!!J,Ke=!!g.aoMap,ke=!!g.lightMap,xe=!!g.bumpMap&&g.wireframe===!1,ve=!!g.normalMap,Ue=!!g.displacementMap,We=!!g.emissiveMap,ot=!!g.metalnessMap,ht=!!g.roughnessMap,D=g.anisotropy>0,yt=g.clearcoat>0,Ze=g.dispersion>0,E=g.iridescence>0,d=g.sheen>0,N=g.transmission>0,G=D&&!!g.anisotropyMap,k=yt&&!!g.clearcoatMap,te=yt&&!!g.clearcoatNormalMap,se=yt&&!!g.clearcoatRoughnessMap,W=E&&!!g.iridescenceMap,$=E&&!!g.iridescenceThicknessMap,ae=d&&!!g.sheenColorMap,ye=d&&!!g.sheenRoughnessMap,ce=!!g.specularMap,oe=!!g.specularColorMap,Ae=!!g.specularIntensityMap,Ce=N&&!!g.transmissionMap,Ne=N&&!!g.thicknessMap,C=!!g.gradientMap,ie=!!g.alphaMap,Z=g.alphaTest>0,le=!!g.alphaHash,pe=!!g.extensions;let Q=on;g.toneMapped&&(ee===null||ee.isXRRenderTarget===!0)&&(Q=i.toneMapping);const Ee={shaderID:re,shaderType:g.type,shaderName:g.name,vertexShader:Je,fragmentShader:He,defines:g.defines,customVertexShaderID:q,customFragmentShaderID:ne,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:h,batching:we,batchingColor:we&&F._colorsTexture!==null,instancing:Le,instancingColor:Le&&F.instanceColor!==null,instancingMorph:Le&&F.morphTexture!==null,outputColorSpace:ee===null?i.outputColorSpace:ee.isXRRenderTarget===!0?ee.texture.colorSpace:Ye.workingColorSpace,alphaToCoverage:!!g.alphaToCoverage,map:ct,matcap:ze,envMap:Qe,envMapMode:Qe&&J.mapping,envMapCubeUVHeight:j,aoMap:Ke,lightMap:ke,bumpMap:xe,normalMap:ve,displacementMap:Ue,emissiveMap:We,normalMapObjectSpace:ve&&g.normalMapType===Dc,normalMapTangentSpace:ve&&g.normalMapType===ga,packedNormalMap:ve&&g.normalMapType===ga&&im(g.normalMap.format),metalnessMap:ot,roughnessMap:ht,anisotropy:D,anisotropyMap:G,clearcoat:yt,clearcoatMap:k,clearcoatNormalMap:te,clearcoatRoughnessMap:se,dispersion:Ze,iridescence:E,iridescenceMap:W,iridescenceThicknessMap:$,sheen:d,sheenColorMap:ae,sheenRoughnessMap:ye,specularMap:ce,specularColorMap:oe,specularIntensityMap:Ae,transmission:N,transmissionMap:Ce,thicknessMap:Ne,gradientMap:C,opaque:g.transparent===!1&&g.blending===Si&&g.alphaToCoverage===!1,alphaMap:ie,alphaTest:Z,alphaHash:le,combine:g.combine,mapUv:ct&&v(g.map.channel),aoMapUv:Ke&&v(g.aoMap.channel),lightMapUv:ke&&v(g.lightMap.channel),bumpMapUv:xe&&v(g.bumpMap.channel),normalMapUv:ve&&v(g.normalMap.channel),displacementMapUv:Ue&&v(g.displacementMap.channel),emissiveMapUv:We&&v(g.emissiveMap.channel),metalnessMapUv:ot&&v(g.metalnessMap.channel),roughnessMapUv:ht&&v(g.roughnessMap.channel),anisotropyMapUv:G&&v(g.anisotropyMap.channel),clearcoatMapUv:k&&v(g.clearcoatMap.channel),clearcoatNormalMapUv:te&&v(g.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:se&&v(g.clearcoatRoughnessMap.channel),iridescenceMapUv:W&&v(g.iridescenceMap.channel),iridescenceThicknessMapUv:$&&v(g.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&v(g.sheenColorMap.channel),sheenRoughnessMapUv:ye&&v(g.sheenRoughnessMap.channel),specularMapUv:ce&&v(g.specularMap.channel),specularColorMapUv:oe&&v(g.specularColorMap.channel),specularIntensityMapUv:Ae&&v(g.specularIntensityMap.channel),transmissionMapUv:Ce&&v(g.transmissionMap.channel),thicknessMapUv:Ne&&v(g.thicknessMap.channel),alphaMapUv:ie&&v(g.alphaMap.channel),vertexTangents:!!z.attributes.tangent&&(ve||D),vertexNormals:!!z.attributes.normal,vertexColors:g.vertexColors,vertexAlphas:g.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!z.attributes.uv&&(ct||ie),fog:!!K,useFog:g.fog===!0,fogExp2:!!K&&K.isFogExp2,flatShading:g.wireframe===!1&&(g.flatShading===!0||z.attributes.normal===void 0&&ve===!1&&(g.isMeshLambertMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isMeshPhysicalMaterial)),sizeAttenuation:g.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:De,skinning:F.isSkinnedMesh===!0,hasPositionAttribute:z.attributes.position!==void 0,morphTargets:z.morphAttributes.position!==void 0,morphNormals:z.morphAttributes.normal!==void 0,morphColors:z.morphAttributes.color!==void 0,morphTargetsCount:_e,morphTextureStride:qe,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numLightProbeGrids:Y.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:g.dithering,shadowMapEnabled:i.shadowMap.enabled&&I.length>0,shadowMapType:i.shadowMap.type,toneMapping:Q,decodeVideoTexture:ct&&g.map.isVideoTexture===!0&&Ye.getTransfer(g.map.colorSpace)===je,decodeVideoTextureEmissive:We&&g.emissiveMap.isVideoTexture===!0&&Ye.getTransfer(g.emissiveMap.colorSpace)===je,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===nn,flipSided:g.side===It,useDepthPacking:g.depthPacking>=0,depthPacking:g.depthPacking||0,index0AttributeName:g.index0AttributeName,extensionClipCullDistance:pe&&g.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(pe&&g.extensions.multiDraw===!0||we)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:g.customProgramCacheKey()};return Ee.vertexUv1s=c.has(1),Ee.vertexUv2s=c.has(2),Ee.vertexUv3s=c.has(3),c.clear(),Ee}function p(g){const b=[];if(g.shaderID?b.push(g.shaderID):(b.push(g.customVertexShaderID),b.push(g.customFragmentShaderID)),g.defines!==void 0)for(const I in g.defines)b.push(I),b.push(g.defines[I]);return g.isRawShaderMaterial===!1&&(u(b,g),A(b,g),b.push(i.outputColorSpace)),b.push(g.customProgramCacheKey),b.join()}function u(g,b){g.push(b.precision),g.push(b.outputColorSpace),g.push(b.envMapMode),g.push(b.envMapCubeUVHeight),g.push(b.mapUv),g.push(b.alphaMapUv),g.push(b.lightMapUv),g.push(b.aoMapUv),g.push(b.bumpMapUv),g.push(b.normalMapUv),g.push(b.displacementMapUv),g.push(b.emissiveMapUv),g.push(b.metalnessMapUv),g.push(b.roughnessMapUv),g.push(b.anisotropyMapUv),g.push(b.clearcoatMapUv),g.push(b.clearcoatNormalMapUv),g.push(b.clearcoatRoughnessMapUv),g.push(b.iridescenceMapUv),g.push(b.iridescenceThicknessMapUv),g.push(b.sheenColorMapUv),g.push(b.sheenRoughnessMapUv),g.push(b.specularMapUv),g.push(b.specularColorMapUv),g.push(b.specularIntensityMapUv),g.push(b.transmissionMapUv),g.push(b.thicknessMapUv),g.push(b.combine),g.push(b.fogExp2),g.push(b.sizeAttenuation),g.push(b.morphTargetsCount),g.push(b.morphAttributeCount),g.push(b.numDirLights),g.push(b.numPointLights),g.push(b.numSpotLights),g.push(b.numSpotLightMaps),g.push(b.numHemiLights),g.push(b.numRectAreaLights),g.push(b.numDirLightShadows),g.push(b.numPointLightShadows),g.push(b.numSpotLightShadows),g.push(b.numSpotLightShadowsWithMaps),g.push(b.numLightProbes),g.push(b.shadowMapType),g.push(b.toneMapping),g.push(b.numClippingPlanes),g.push(b.numClipIntersection),g.push(b.depthPacking)}function A(g,b){a.disableAll(),b.instancing&&a.enable(0),b.instancingColor&&a.enable(1),b.instancingMorph&&a.enable(2),b.matcap&&a.enable(3),b.envMap&&a.enable(4),b.normalMapObjectSpace&&a.enable(5),b.normalMapTangentSpace&&a.enable(6),b.clearcoat&&a.enable(7),b.iridescence&&a.enable(8),b.alphaTest&&a.enable(9),b.vertexColors&&a.enable(10),b.vertexAlphas&&a.enable(11),b.vertexUv1s&&a.enable(12),b.vertexUv2s&&a.enable(13),b.vertexUv3s&&a.enable(14),b.vertexTangents&&a.enable(15),b.anisotropy&&a.enable(16),b.alphaHash&&a.enable(17),b.batching&&a.enable(18),b.dispersion&&a.enable(19),b.batchingColor&&a.enable(20),b.gradientMap&&a.enable(21),b.packedNormalMap&&a.enable(22),b.vertexNormals&&a.enable(23),g.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.reversedDepthBuffer&&a.enable(4),b.skinning&&a.enable(5),b.morphTargets&&a.enable(6),b.morphNormals&&a.enable(7),b.morphColors&&a.enable(8),b.premultipliedAlpha&&a.enable(9),b.shadowMapEnabled&&a.enable(10),b.doubleSided&&a.enable(11),b.flipSided&&a.enable(12),b.useDepthPacking&&a.enable(13),b.dithering&&a.enable(14),b.transmission&&a.enable(15),b.sheen&&a.enable(16),b.opaque&&a.enable(17),b.pointsUvs&&a.enable(18),b.decodeVideoTexture&&a.enable(19),b.decodeVideoTextureEmissive&&a.enable(20),b.alphaToCoverage&&a.enable(21),b.numLightProbeGrids>0&&a.enable(22),b.hasPositionAttribute&&a.enable(23),g.push(a.mask)}function R(g){const b=_[g.type];let I;if(b){const P=tn[b];I=Mh.clone(P.uniforms)}else I=g.uniforms;return I}function M(g,b){let I=f.get(b);return I!==void 0?++I.usedTimes:(I=new jp(i,b,g,s),l.push(I),f.set(b,I)),I}function T(g){if(--g.usedTimes===0){const b=l.indexOf(g);l[b]=l[l.length-1],l.pop(),f.delete(g.cacheKey),g.destroy()}}function y(g){o.remove(g)}function w(){o.dispose()}return{getParameters:S,getProgramCacheKey:p,getUniforms:R,acquireProgram:M,releaseProgram:T,releaseShaderCache:y,programs:l,dispose:w}}function rm(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function am(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function il(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function sl(){const i=[];let e=0;const t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(h){let _=0;return h.isInstancedMesh&&(_+=2),h.isSkinnedMesh&&(_+=1),_}function o(h,_,v,S,p,u){let A=i[e];return A===void 0?(A={id:h.id,object:h,geometry:_,material:v,materialVariant:a(h),groupOrder:S,renderOrder:h.renderOrder,z:p,group:u},i[e]=A):(A.id=h.id,A.object=h,A.geometry=_,A.material=v,A.materialVariant=a(h),A.groupOrder=S,A.renderOrder=h.renderOrder,A.z=p,A.group=u),e++,A}function c(h,_,v,S,p,u){const A=o(h,_,v,S,p,u);v.transmission>0?n.push(A):v.transparent===!0?s.push(A):t.push(A)}function l(h,_,v,S,p,u){const A=o(h,_,v,S,p,u);v.transmission>0?n.unshift(A):v.transparent===!0?s.unshift(A):t.unshift(A)}function f(h,_,v){t.length>1&&t.sort(h||am),n.length>1&&n.sort(_||il),s.length>1&&s.sort(_||il),v&&(t.reverse(),n.reverse(),s.reverse())}function m(){for(let h=e,_=i.length;h<_;h++){const v=i[h];if(v.id===null)break;v.id=null,v.object=null,v.geometry=null,v.material=null,v.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:m,sort:f}}function om(){let i=new WeakMap;function e(n,s){const r=i.get(n);let a;return r===void 0?(a=new sl,i.set(n,[a])):s>=r.length?(a=new sl,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function lm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new U,color:new Oe};break;case"SpotLight":t={position:new U,direction:new U,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new U,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new U,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":t={color:new Oe,position:new U,halfWidth:new U,halfHeight:new U};break}return i[e.id]=t,t}}}function cm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Re};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Re};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Re,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let hm=0;function um(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function dm(i){const e=new lm,t=cm(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new U);const s=new U,r=new lt,a=new lt;function o(l){let f=0,m=0,h=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let _=0,v=0,S=0,p=0,u=0,A=0,R=0,M=0,T=0,y=0,w=0;l.sort(um);for(let b=0,I=l.length;b0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=he.LTC_FLOAT_1,n.rectAreaLTC2=he.LTC_FLOAT_2):(n.rectAreaLTC1=he.LTC_HALF_1,n.rectAreaLTC2=he.LTC_HALF_2)),n.ambient[0]=f,n.ambient[1]=m,n.ambient[2]=h;const g=n.hash;(g.directionalLength!==_||g.pointLength!==v||g.spotLength!==S||g.rectAreaLength!==p||g.hemiLength!==u||g.numDirectionalShadows!==A||g.numPointShadows!==R||g.numSpotShadows!==M||g.numSpotMaps!==T||g.numLightProbes!==w)&&(n.directional.length=_,n.spot.length=S,n.rectArea.length=p,n.point.length=v,n.hemi.length=u,n.directionalShadow.length=A,n.directionalShadowMap.length=A,n.pointShadow.length=R,n.pointShadowMap.length=R,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=R,n.spotLightMatrix.length=M+T-y,n.spotLightMap.length=T,n.numSpotLightShadowsWithMaps=y,n.numLightProbes=w,g.directionalLength=_,g.pointLength=v,g.spotLength=S,g.rectAreaLength=p,g.hemiLength=u,g.numDirectionalShadows=A,g.numPointShadows=R,g.numSpotShadows=M,g.numSpotMaps=T,g.numLightProbes=w,n.version=hm++)}function c(l,f){let m=0,h=0,_=0,v=0,S=0;const p=f.matrixWorldInverse;for(let u=0,A=l.length;u=a.length?(o=new rl(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const pm=`void main() { - gl_Position = vec4( position, 1.0 ); -}`,mm=`uniform sampler2D shadow_pass; -uniform vec2 resolution; -uniform float radius; -void main() { - const float samples = float( VSM_SAMPLES ); - float mean = 0.0; - float squared_mean = 0.0; - float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); - float uvStart = samples <= 1.0 ? 0.0 : - 1.0; - for ( float i = 0.0; i < samples; i ++ ) { - float uvOffset = uvStart + i * uvStride; - #ifdef HORIZONTAL_PASS - vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; - mean += distribution.x; - squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; - #else - float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; - mean += depth; - squared_mean += depth * depth; - #endif - } - mean = mean / samples; - squared_mean = squared_mean / samples; - float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); - gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); -}`,_m=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],gm=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],al=new lt,zi=new U,wr=new U;function xm(i,e,t){let n=new Na;const s=new Re,r=new Re,a=new ut,o=new Th,c=new Ah,l={},f=t.maxTextureSize,m={[Nn]:It,[It]:Nn,[nn]:nn},h=new hn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Re},radius:{value:4}},vertexShader:pm,fragmentShader:mm}),_=h.clone();_.defines.HORIZONTAL_PASS=1;const v=new Ut;v.setAttribute("position",new Kt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new Zt(v,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ys;let u=this.type;this.render=function(y,w,g){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||y.length===0)return;this.type===lc&&(Pe("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=ys);const b=i.getRenderTarget(),I=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),F=i.state;F.setBlending(xn),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const Y=u!==this.type;Y&&w.traverse(function(K){K.material&&(Array.isArray(K.material)?K.material.forEach(z=>z.needsUpdate=!0):K.material.needsUpdate=!0)});for(let K=0,z=y.length;Kf||s.y>f)&&(s.x>f&&(r.x=Math.floor(f/J.x),s.x=r.x*J.x,H.mapSize.x=r.x),s.y>f&&(r.y=Math.floor(f/J.y),s.y=r.y*J.y,H.mapSize.y=r.y));const j=i.state.buffers.depth.getReversed();if(H.camera._reversedDepth=j,H.map===null||Y===!0){if(H.map!==null&&(H.map.depthTexture!==null&&(H.map.depthTexture.dispose(),H.map.depthTexture=null),H.map.dispose()),this.type===Gi){if(X.isPointLight){Pe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}H.map=new ln(s.x,s.y,{format:$n,type:Mn,minFilter:wt,magFilter:wt,generateMipmaps:!1}),H.map.texture.name=X.name+".shadowMap",H.map.depthTexture=new Ai(s.x,s.y,rn),H.map.depthTexture.name=X.name+".shadowMapDepth",H.map.depthTexture.format=Sn,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=bt,H.map.depthTexture.magFilter=bt}else X.isPointLight?(H.map=new Vl(s.x),H.map.depthTexture=new xh(s.x,cn)):(H.map=new ln(s.x,s.y),H.map.depthTexture=new Ai(s.x,s.y,cn)),H.map.depthTexture.name=X.name+".shadowMap",H.map.depthTexture.format=Sn,this.type===ys?(H.map.depthTexture.compareFunction=j?Da:Pa,H.map.depthTexture.minFilter=wt,H.map.depthTexture.magFilter=wt):(H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=bt,H.map.depthTexture.magFilter=bt);H.camera.updateProjectionMatrix()}const re=H.map.isWebGLCubeRenderTarget?6:1;for(let de=0;de0||w.map&&w.alphaTest>0||w.alphaToCoverage===!0){const F=I.uuid,Y=w.uuid;let K=l[F];K===void 0&&(K={},l[F]=K);let z=K[Y];z===void 0&&(z=I.clone(),K[Y]=z,w.addEventListener("dispose",T)),I=z}if(I.visible=w.visible,I.wireframe=w.wireframe,b===Gi?I.side=w.shadowSide!==null?w.shadowSide:w.side:I.side=w.shadowSide!==null?w.shadowSide:m[w.side],I.alphaMap=w.alphaMap,I.alphaTest=w.alphaToCoverage===!0?.5:w.alphaTest,I.map=w.map,I.clipShadows=w.clipShadows,I.clippingPlanes=w.clippingPlanes,I.clipIntersection=w.clipIntersection,I.displacementMap=w.displacementMap,I.displacementScale=w.displacementScale,I.displacementBias=w.displacementBias,I.wireframeLinewidth=w.wireframeLinewidth,I.linewidth=w.linewidth,g.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const F=i.properties.get(I);F.light=g}return I}function M(y,w,g,b,I){if(y.visible===!1)return;if(y.layers.test(w.layers)&&(y.isMesh||y.isLine||y.isPoints)&&(y.castShadow||y.receiveShadow&&I===Gi)&&(!y.frustumCulled||n.intersectsObject(y))){y.modelViewMatrix.multiplyMatrices(g.matrixWorldInverse,y.matrixWorld);const Y=e.update(y),K=y.material;if(Array.isArray(K)){const z=Y.groups;for(let X=0,H=z.length;X=1):j.indexOf("OpenGL ES")!==-1&&(J=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),H=J>=2);let re=null,de={};const _e=i.getParameter(i.SCISSOR_BOX),qe=i.getParameter(i.VIEWPORT),Je=new ut().fromArray(_e),He=new ut().fromArray(qe);function q(C,ie,Z,le){const pe=new Uint8Array(4),Q=i.createTexture();i.bindTexture(C,Q),i.texParameteri(C,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(C,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ee=0;Ee"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Re,f=new WeakMap,m=new Set;let h;const _=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S(E,d){return v?new OffscreenCanvas(E,d):Us("canvas")}function p(E,d,N){let G=1;const k=Ze(E);if((k.width>N||k.height>N)&&(G=N/Math.max(k.width,k.height)),G<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){const te=Math.floor(G*k.width),se=Math.floor(G*k.height);h===void 0&&(h=S(te,se));const W=d?S(te,se):h;return W.width=te,W.height=se,W.getContext("2d").drawImage(E,0,0,te,se),Pe("WebGLRenderer: Texture has been resized from ("+k.width+"x"+k.height+") to ("+te+"x"+se+")."),W}else return"data"in E&&Pe("WebGLRenderer: Image in DataTexture is too big ("+k.width+"x"+k.height+")."),E;return E}function u(E){return E.generateMipmaps}function A(E){i.generateMipmap(E)}function R(E){return E.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:E.isWebGL3DRenderTarget?i.TEXTURE_3D:E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(E,d,N,G,k,te=!1){if(E!==null){if(i[E]!==void 0)return i[E];Pe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let se;G&&(se=e.get("EXT_texture_norm16"),se||Pe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let W=d;if(d===i.RED&&(N===i.FLOAT&&(W=i.R32F),N===i.HALF_FLOAT&&(W=i.R16F),N===i.UNSIGNED_BYTE&&(W=i.R8),N===i.UNSIGNED_SHORT&&se&&(W=se.R16_EXT),N===i.SHORT&&se&&(W=se.R16_SNORM_EXT)),d===i.RED_INTEGER&&(N===i.UNSIGNED_BYTE&&(W=i.R8UI),N===i.UNSIGNED_SHORT&&(W=i.R16UI),N===i.UNSIGNED_INT&&(W=i.R32UI),N===i.BYTE&&(W=i.R8I),N===i.SHORT&&(W=i.R16I),N===i.INT&&(W=i.R32I)),d===i.RG&&(N===i.FLOAT&&(W=i.RG32F),N===i.HALF_FLOAT&&(W=i.RG16F),N===i.UNSIGNED_BYTE&&(W=i.RG8),N===i.UNSIGNED_SHORT&&se&&(W=se.RG16_EXT),N===i.SHORT&&se&&(W=se.RG16_SNORM_EXT)),d===i.RG_INTEGER&&(N===i.UNSIGNED_BYTE&&(W=i.RG8UI),N===i.UNSIGNED_SHORT&&(W=i.RG16UI),N===i.UNSIGNED_INT&&(W=i.RG32UI),N===i.BYTE&&(W=i.RG8I),N===i.SHORT&&(W=i.RG16I),N===i.INT&&(W=i.RG32I)),d===i.RGB_INTEGER&&(N===i.UNSIGNED_BYTE&&(W=i.RGB8UI),N===i.UNSIGNED_SHORT&&(W=i.RGB16UI),N===i.UNSIGNED_INT&&(W=i.RGB32UI),N===i.BYTE&&(W=i.RGB8I),N===i.SHORT&&(W=i.RGB16I),N===i.INT&&(W=i.RGB32I)),d===i.RGBA_INTEGER&&(N===i.UNSIGNED_BYTE&&(W=i.RGBA8UI),N===i.UNSIGNED_SHORT&&(W=i.RGBA16UI),N===i.UNSIGNED_INT&&(W=i.RGBA32UI),N===i.BYTE&&(W=i.RGBA8I),N===i.SHORT&&(W=i.RGBA16I),N===i.INT&&(W=i.RGBA32I)),d===i.RGB&&(N===i.UNSIGNED_SHORT&&se&&(W=se.RGB16_EXT),N===i.SHORT&&se&&(W=se.RGB16_SNORM_EXT),N===i.UNSIGNED_INT_5_9_9_9_REV&&(W=i.RGB9_E5),N===i.UNSIGNED_INT_10F_11F_11F_REV&&(W=i.R11F_G11F_B10F)),d===i.RGBA){const $=te?Is:Ye.getTransfer(k);N===i.FLOAT&&(W=i.RGBA32F),N===i.HALF_FLOAT&&(W=i.RGBA16F),N===i.UNSIGNED_BYTE&&(W=$===je?i.SRGB8_ALPHA8:i.RGBA8),N===i.UNSIGNED_SHORT&&se&&(W=se.RGBA16_EXT),N===i.SHORT&&se&&(W=se.RGBA16_SNORM_EXT),N===i.UNSIGNED_SHORT_4_4_4_4&&(W=i.RGBA4),N===i.UNSIGNED_SHORT_5_5_5_1&&(W=i.RGB5_A1)}return(W===i.R16F||W===i.R32F||W===i.RG16F||W===i.RG32F||W===i.RGBA16F||W===i.RGBA32F)&&e.get("EXT_color_buffer_float"),W}function T(E,d){let N;return E?d===null||d===cn||d===Wi?N=i.DEPTH24_STENCIL8:d===rn?N=i.DEPTH32F_STENCIL8:d===ki&&(N=i.DEPTH24_STENCIL8,Pe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):d===null||d===cn||d===Wi?N=i.DEPTH_COMPONENT24:d===rn?N=i.DEPTH_COMPONENT32F:d===ki&&(N=i.DEPTH_COMPONENT16),N}function y(E,d){return u(E)===!0||E.isFramebufferTexture&&E.minFilter!==bt&&E.minFilter!==wt?Math.log2(Math.max(d.width,d.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?d.mipmaps.length:1}function w(E){const d=E.target;d.removeEventListener("dispose",w),b(d),d.isVideoTexture&&f.delete(d),d.isHTMLTexture&&m.delete(d)}function g(E){const d=E.target;d.removeEventListener("dispose",g),P(d)}function b(E){const d=n.get(E);if(d.__webglInit===void 0)return;const N=E.source,G=_.get(N);if(G){const k=G[d.__cacheKey];k.usedTimes--,k.usedTimes===0&&I(E),Object.keys(G).length===0&&_.delete(N)}n.remove(E)}function I(E){const d=n.get(E);i.deleteTexture(d.__webglTexture);const N=E.source,G=_.get(N);delete G[d.__cacheKey],a.memory.textures--}function P(E){const d=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let G=0;G<6;G++){if(Array.isArray(d.__webglFramebuffer[G]))for(let k=0;k=s.maxTextures&&Pe("WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+s.maxTextures),F+=1,E}function H(E){const d=[];return d.push(E.wrapS),d.push(E.wrapT),d.push(E.wrapR||0),d.push(E.magFilter),d.push(E.minFilter),d.push(E.anisotropy),d.push(E.internalFormat),d.push(E.format),d.push(E.type),d.push(E.generateMipmaps),d.push(E.premultiplyAlpha),d.push(E.flipY),d.push(E.unpackAlignment),d.push(E.colorSpace),d.join()}function J(E,d){const N=n.get(E);if(E.isVideoTexture&&D(E),E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&N.__version!==E.version){const G=E.image;if(G===null)Pe("WebGLRenderer: Texture marked for update but no image data found.");else if(G.complete===!1)Pe("WebGLRenderer: Texture marked for update but image is incomplete");else{De(N,E,d);return}}else E.isExternalTexture&&(N.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,N.__webglTexture,i.TEXTURE0+d)}function j(E,d){const N=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){De(N,E,d);return}else E.isExternalTexture&&(N.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,N.__webglTexture,i.TEXTURE0+d)}function re(E,d){const N=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){De(N,E,d);return}t.bindTexture(i.TEXTURE_3D,N.__webglTexture,i.TEXTURE0+d)}function de(E,d){const N=n.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&N.__version!==E.version){Le(N,E,d);return}t.bindTexture(i.TEXTURE_CUBE_MAP,N.__webglTexture,i.TEXTURE0+d)}const _e={[zr]:i.REPEAT,[gn]:i.CLAMP_TO_EDGE,[Gr]:i.MIRRORED_REPEAT},qe={[bt]:i.NEAREST,[Cc]:i.NEAREST_MIPMAP_NEAREST,[Zi]:i.NEAREST_MIPMAP_LINEAR,[wt]:i.LINEAR,[$s]:i.LINEAR_MIPMAP_NEAREST,[qn]:i.LINEAR_MIPMAP_LINEAR},Je={[Lc]:i.NEVER,[Oc]:i.ALWAYS,[Ic]:i.LESS,[Pa]:i.LEQUAL,[Uc]:i.EQUAL,[Da]:i.GEQUAL,[Nc]:i.GREATER,[Fc]:i.NOTEQUAL};function He(E,d){if(d.type===rn&&e.has("OES_texture_float_linear")===!1&&(d.magFilter===wt||d.magFilter===$s||d.magFilter===Zi||d.magFilter===qn||d.minFilter===wt||d.minFilter===$s||d.minFilter===Zi||d.minFilter===qn)&&Pe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(E,i.TEXTURE_WRAP_S,_e[d.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,_e[d.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,_e[d.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,qe[d.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,qe[d.minFilter]),d.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,Je[d.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(d.magFilter===bt||d.minFilter!==Zi&&d.minFilter!==qn||d.type===rn&&e.has("OES_texture_float_linear")===!1)return;if(d.anisotropy>1||n.get(d).__currentAnisotropy){const N=e.get("EXT_texture_filter_anisotropic");i.texParameterf(E,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(d.anisotropy,s.getMaxAnisotropy())),n.get(d).__currentAnisotropy=d.anisotropy}}}function q(E,d){let N=!1;E.__webglInit===void 0&&(E.__webglInit=!0,d.addEventListener("dispose",w));const G=d.source;let k=_.get(G);k===void 0&&(k={},_.set(G,k));const te=H(d);if(te!==E.__cacheKey){k[te]===void 0&&(k[te]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,N=!0),k[te].usedTimes++;const se=k[E.__cacheKey];se!==void 0&&(k[E.__cacheKey].usedTimes--,se.usedTimes===0&&I(d)),E.__cacheKey=te,E.__webglTexture=k[te].texture}return N}function ne(E,d,N){return Math.floor(Math.floor(E/N)/d)}function ee(E,d,N,G){const te=E.updateRanges;if(te.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,d.width,d.height,N,G,d.data);else{te.sort((ye,ce)=>ye.start-ce.start);let se=0;for(let ye=1;ye0){Ce&&Ne&&t.texStorage2D(i.TEXTURE_2D,ie,ce,Ae[0].width,Ae[0].height);for(let Z=0,le=Ae.length;Z0){const pe=Oo(oe.width,oe.height,d.format,d.type);for(const Q of d.layerUpdates){const Ee=oe.data.subarray(Q*pe/oe.data.BYTES_PER_ELEMENT,(Q+1)*pe/oe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,Q,oe.width,oe.height,1,ae,Ee)}d.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,0,oe.width,oe.height,$.depth,ae,oe.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Z,ce,oe.width,oe.height,$.depth,0,oe.data,0,0);else Pe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ce?C&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,0,oe.width,oe.height,$.depth,ae,ye,oe.data):t.texImage3D(i.TEXTURE_2D_ARRAY,Z,ce,oe.width,oe.height,$.depth,0,ae,ye,oe.data)}else{Ce&&Ne&&t.texStorage2D(i.TEXTURE_2D,ie,ce,Ae[0].width,Ae[0].height);for(let Z=0,le=Ae.length;Z0){const Z=Oo($.width,$.height,d.format,d.type);for(const le of d.layerUpdates){const pe=$.data.subarray(le*Z/$.data.BYTES_PER_ELEMENT,(le+1)*Z/$.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,le,$.width,$.height,1,ae,ye,pe)}d.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,$.width,$.height,$.depth,ae,ye,$.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ce,$.width,$.height,$.depth,0,ae,ye,$.data);else if(d.isData3DTexture)Ce?(Ne&&t.texStorage3D(i.TEXTURE_3D,ie,ce,$.width,$.height,$.depth),C&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,$.width,$.height,$.depth,ae,ye,$.data)):t.texImage3D(i.TEXTURE_3D,0,ce,$.width,$.height,$.depth,0,ae,ye,$.data);else if(d.isFramebufferTexture){if(Ne)if(Ce)t.texStorage2D(i.TEXTURE_2D,ie,ce,$.width,$.height);else{let Z=$.width,le=$.height;for(let pe=0;pe>=1,le>>=1}}else if(d.isHTMLTexture){if("texElementImage2D"in i){const Z=i.canvas;if(Z.hasAttribute("layoutsubtree")||Z.setAttribute("layoutsubtree","true"),$.parentNode!==Z){Z.appendChild($),m.add(d),Z.onpaint=le=>{const pe=le.changedElements;for(const Q of m)pe.includes(Q.image)&&(Q.needsUpdate=!0)},Z.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,$);else{const pe=i.RGBA,Q=i.RGBA,Ee=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,pe,Q,Ee,$)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Ae.length>0){if(Ce&&Ne){const Z=Ze(Ae[0]);t.texStorage2D(i.TEXTURE_2D,ie,ce,Z.width,Z.height)}for(let Z=0,le=Ae.length;Z0&&le++;const Q=Ze(ce[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,le,Ne,Q.width,Q.height)}for(let Q=0;Q<6;Q++)if(ye){C?Z&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,ce[Q].width,ce[Q].height,Ae,Ce,ce[Q].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,Ne,ce[Q].width,ce[Q].height,0,Ae,Ce,ce[Q].data);for(let Ee=0;Ee>te),oe=Math.max(1,d.height>>te);k===i.TEXTURE_3D||k===i.TEXTURE_2D_ARRAY?t.texImage3D(k,te,$,ce,oe,d.depth,0,se,W,null):t.texImage2D(k,te,$,ce,oe,0,se,W,null)}t.bindFramebuffer(i.FRAMEBUFFER,E),ht(d)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,k,ye.__webglTexture,0,ot(d)):(k===i.TEXTURE_2D||k>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&k<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,G,k,ye.__webglTexture,te),t.bindFramebuffer(i.FRAMEBUFFER,null)}function ct(E,d,N){if(i.bindRenderbuffer(i.RENDERBUFFER,E),d.depthBuffer){const G=d.depthTexture,k=G&&G.isDepthTexture?G.type:null,te=T(d.stencilBuffer,k),se=d.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ht(d)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ot(d),te,d.width,d.height):N?i.renderbufferStorageMultisample(i.RENDERBUFFER,ot(d),te,d.width,d.height):i.renderbufferStorage(i.RENDERBUFFER,te,d.width,d.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,se,i.RENDERBUFFER,E)}else{const G=d.textures;for(let k=0;k{delete d.__boundDepthTexture,delete d.__depthDisposeCallback,G.removeEventListener("dispose",k)};G.addEventListener("dispose",k),d.__depthDisposeCallback=k}d.__boundDepthTexture=G}if(E.depthTexture&&!d.__autoAllocateDepthBuffer)if(N)for(let G=0;G<6;G++)ze(d.__webglFramebuffer[G],E,G);else{const G=E.texture.mipmaps;G&&G.length>0?ze(d.__webglFramebuffer[0],E,0):ze(d.__webglFramebuffer,E,0)}else if(N){d.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(t.bindFramebuffer(i.FRAMEBUFFER,d.__webglFramebuffer[G]),d.__webglDepthbuffer[G]===void 0)d.__webglDepthbuffer[G]=i.createRenderbuffer(),ct(d.__webglDepthbuffer[G],E,!1);else{const k=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,te=d.__webglDepthbuffer[G];i.bindRenderbuffer(i.RENDERBUFFER,te),i.framebufferRenderbuffer(i.FRAMEBUFFER,k,i.RENDERBUFFER,te)}}else{const G=E.texture.mipmaps;if(G&&G.length>0?t.bindFramebuffer(i.FRAMEBUFFER,d.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,d.__webglFramebuffer),d.__webglDepthbuffer===void 0)d.__webglDepthbuffer=i.createRenderbuffer(),ct(d.__webglDepthbuffer,E,!1);else{const k=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,te=d.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,te),i.framebufferRenderbuffer(i.FRAMEBUFFER,k,i.RENDERBUFFER,te)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Ke(E,d,N){const G=n.get(E);d!==void 0&&we(G.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),N!==void 0&&Qe(E)}function ke(E){const d=E.texture,N=n.get(E),G=n.get(d);E.addEventListener("dispose",g);const k=E.textures,te=E.isWebGLCubeRenderTarget===!0,se=k.length>1;if(se||(G.__webglTexture===void 0&&(G.__webglTexture=i.createTexture()),G.__version=d.version,a.memory.textures++),te){N.__webglFramebuffer=[];for(let W=0;W<6;W++)if(d.mipmaps&&d.mipmaps.length>0){N.__webglFramebuffer[W]=[];for(let $=0;$0){N.__webglFramebuffer=[];for(let W=0;W0&&ht(E)===!1){N.__webglMultisampledFramebuffer=i.createFramebuffer(),N.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let W=0;W0)for(let $=0;$0)for(let $=0;$0){if(ht(E)===!1){const d=E.textures,N=E.width,G=E.height;let k=i.COLOR_BUFFER_BIT;const te=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=n.get(E),W=d.length>1;if(W)for(let ae=0;ae0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,se.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,se.__webglFramebuffer);for(let ae=0;ae0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&d.__useRenderToTexture!==!1}function D(E){const d=a.render.frame;f.get(E)!==d&&(f.set(E,d),E.update())}function yt(E,d){const N=E.colorSpace,G=E.format,k=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||N!==Ls&&N!==Ln&&(Ye.getTransfer(N)===je?(G!==qt||k!==Bt)&&Pe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Xe("WebGLTextures: Unsupported texture color space:",N)),d}function Ze(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(l.width=E.displayWidth,l.height=E.displayHeight):(l.width=E.width,l.height=E.height),l}this.allocateTextureUnit=X,this.resetTextureUnits=Y,this.getTextureUnits=K,this.setTextureUnits=z,this.setTexture2D=J,this.setTexture2DArray=j,this.setTexture3D=re,this.setTextureCube=de,this.rebindTextures=Ke,this.setupRenderTarget=ke,this.updateRenderTargetMipmap=xe,this.updateMultisampleRenderTarget=We,this.setupDepthRenderbuffer=Qe,this.setupFrameBufferTexture=we,this.useMultisampledRTT=ht,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Sm(i,e){function t(n,s=Ln){let r;const a=Ye.getTransfer(s);if(n===Bt)return i.UNSIGNED_BYTE;if(n===Ta)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Aa)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Sl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===El)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===vl)return i.BYTE;if(n===Ml)return i.SHORT;if(n===ki)return i.UNSIGNED_SHORT;if(n===ba)return i.INT;if(n===cn)return i.UNSIGNED_INT;if(n===rn)return i.FLOAT;if(n===Mn)return i.HALF_FLOAT;if(n===yl)return i.ALPHA;if(n===bl)return i.RGB;if(n===qt)return i.RGBA;if(n===Sn)return i.DEPTH_COMPONENT;if(n===Kn)return i.DEPTH_STENCIL;if(n===Tl)return i.RED;if(n===Ra)return i.RED_INTEGER;if(n===$n)return i.RG;if(n===wa)return i.RG_INTEGER;if(n===Ca)return i.RGBA_INTEGER;if(n===bs||n===Ts||n===As||n===Rs)if(a===je)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===bs)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ts)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===As)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Rs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===bs)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ts)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===As)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Rs)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Vr||n===Hr||n===kr||n===Wr)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Vr)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Hr)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===kr)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Wr)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Xr||n===Yr||n===qr||n===Kr||n===Zr||n===Ps||n===$r)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Xr||n===Yr)return a===je?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===qr)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Kr)return r.COMPRESSED_R11_EAC;if(n===Zr)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Ps)return r.COMPRESSED_RG11_EAC;if(n===$r)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Jr||n===Qr||n===jr||n===ea||n===ta||n===na||n===ia||n===sa||n===ra||n===aa||n===oa||n===la||n===ca||n===ha)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Jr)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Qr)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===jr)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ea)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ta)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===na)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===ia)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===sa)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ra)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===aa)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===oa)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===la)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ca)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ha)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ua||n===da||n===fa)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===ua)return a===je?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===da)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===fa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===pa||n===ma||n===Ds||n===_a)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===pa)return r.COMPRESSED_RED_RGTC1_EXT;if(n===ma)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ds)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===_a)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Wi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const Em=` -void main() { - - gl_Position = vec4( position, 1.0 ); - -}`,ym=` -uniform sampler2DArray depthColor; -uniform float depthWidth; -uniform float depthHeight; - -void main() { - - vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); - - if ( coord.x >= 1.0 ) { - - gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; - - } else { - - gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; - - } - -}`;class bm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Nl(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new hn({vertexShader:Em,fragmentShader:ym,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Zt(new ks(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Tm extends Bn{constructor(e,t){super();const n=this;let s=null,r=1,a=null,o="local-floor",c=1,l=null,f=null,m=null,h=null,_=null,v=null;const S=typeof XRWebGLBinding<"u",p=new bm,u={},A=t.getContextAttributes();let R=null,M=null;const T=[],y=[],w=new Re;let g=null;const b=new Ht;b.viewport=new ut;const I=new Ht;I.viewport=new ut;const P=[b,I],F=new Lh;let Y=null,K=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let ne=T[q];return ne===void 0&&(ne=new ir,T[q]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(q){let ne=T[q];return ne===void 0&&(ne=new ir,T[q]=ne),ne.getGripSpace()},this.getHand=function(q){let ne=T[q];return ne===void 0&&(ne=new ir,T[q]=ne),ne.getHandSpace()};function z(q){const ne=y.indexOf(q.inputSource);if(ne===-1)return;const ee=T[ne];ee!==void 0&&(ee.update(q.inputSource,q.frame,l||a),ee.dispatchEvent({type:q.type,data:q.inputSource}))}function X(){s.removeEventListener("select",z),s.removeEventListener("selectstart",z),s.removeEventListener("selectend",z),s.removeEventListener("squeeze",z),s.removeEventListener("squeezestart",z),s.removeEventListener("squeezeend",z),s.removeEventListener("end",X),s.removeEventListener("inputsourceschange",H);for(let q=0;q=0&&(y[De]=null,T[De].disconnect(ee))}for(let ne=0;ne=y.length){y.push(ee),De=we;break}else if(y[we]===null){y[we]=ee,De=we;break}if(De===-1)break}const Le=T[De];Le&&Le.connect(ee)}}const J=new U,j=new U;function re(q,ne,ee){J.setFromMatrixPosition(ne.matrixWorld),j.setFromMatrixPosition(ee.matrixWorld);const De=J.distanceTo(j),Le=ne.projectionMatrix.elements,we=ee.projectionMatrix.elements,ct=Le[14]/(Le[10]-1),ze=Le[14]/(Le[10]+1),Qe=(Le[9]+1)/Le[5],Ke=(Le[9]-1)/Le[5],ke=(Le[8]-1)/Le[0],xe=(we[8]+1)/we[0],ve=ct*ke,Ue=ct*xe,We=De/(-ke+xe),ot=We*-ke;if(ne.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(ot),q.translateZ(We),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),Le[10]===-1)q.projectionMatrix.copy(ne.projectionMatrix),q.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const ht=ct+We,D=ze+We,yt=ve-ot,Ze=Ue+(De-ot),E=Qe*ze/D*ht,d=Ke*ze/D*ht;q.projectionMatrix.makePerspective(yt,Ze,E,d,ht,D),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function de(q,ne){ne===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices(ne.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(s===null)return;let ne=q.near,ee=q.far;p.texture!==null&&(p.depthNear>0&&(ne=p.depthNear),p.depthFar>0&&(ee=p.depthFar)),F.near=I.near=b.near=ne,F.far=I.far=b.far=ee,(Y!==F.near||K!==F.far)&&(s.updateRenderState({depthNear:F.near,depthFar:F.far}),Y=F.near,K=F.far),F.layers.mask=q.layers.mask|6,b.layers.mask=F.layers.mask&-5,I.layers.mask=F.layers.mask&-3;const De=q.parent,Le=F.cameras;de(F,De);for(let we=0;we0&&(p.alphaTest.value=u.alphaTest);const A=e.get(u),R=A.envMap,M=A.envMapRotation;R&&(p.envMap.value=R,p.envMapRotation.value.setFromMatrix4(Am.makeRotationFromEuler(M)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1&&p.envMapRotation.value.premultiply(Yl),p.reflectivity.value=u.reflectivity,p.ior.value=u.ior,p.refractionRatio.value=u.refractionRatio),u.lightMap&&(p.lightMap.value=u.lightMap,p.lightMapIntensity.value=u.lightMapIntensity,t(u.lightMap,p.lightMapTransform)),u.aoMap&&(p.aoMap.value=u.aoMap,p.aoMapIntensity.value=u.aoMapIntensity,t(u.aoMap,p.aoMapTransform))}function a(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform))}function o(p,u){p.dashSize.value=u.dashSize,p.totalSize.value=u.dashSize+u.gapSize,p.scale.value=u.scale}function c(p,u,A,R){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.size.value=u.size*A,p.scale.value=R*.5,u.map&&(p.map.value=u.map,t(u.map,p.uvTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function l(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.rotation.value=u.rotation,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function f(p,u){p.specular.value.copy(u.specular),p.shininess.value=Math.max(u.shininess,1e-4)}function m(p,u){u.gradientMap&&(p.gradientMap.value=u.gradientMap)}function h(p,u){p.metalness.value=u.metalness,u.metalnessMap&&(p.metalnessMap.value=u.metalnessMap,t(u.metalnessMap,p.metalnessMapTransform)),p.roughness.value=u.roughness,u.roughnessMap&&(p.roughnessMap.value=u.roughnessMap,t(u.roughnessMap,p.roughnessMapTransform)),u.envMap&&(p.envMapIntensity.value=u.envMapIntensity)}function _(p,u,A){p.ior.value=u.ior,u.sheen>0&&(p.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),p.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(p.sheenColorMap.value=u.sheenColorMap,t(u.sheenColorMap,p.sheenColorMapTransform)),u.sheenRoughnessMap&&(p.sheenRoughnessMap.value=u.sheenRoughnessMap,t(u.sheenRoughnessMap,p.sheenRoughnessMapTransform))),u.clearcoat>0&&(p.clearcoat.value=u.clearcoat,p.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(p.clearcoatMap.value=u.clearcoatMap,t(u.clearcoatMap,p.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,t(u.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap&&(p.clearcoatNormalMap.value=u.clearcoatNormalMap,t(u.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===It&&p.clearcoatNormalScale.value.negate())),u.dispersion>0&&(p.dispersion.value=u.dispersion),u.iridescence>0&&(p.iridescence.value=u.iridescence,p.iridescenceIOR.value=u.iridescenceIOR,p.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(p.iridescenceMap.value=u.iridescenceMap,t(u.iridescenceMap,p.iridescenceMapTransform)),u.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=u.iridescenceThicknessMap,t(u.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),u.transmission>0&&(p.transmission.value=u.transmission,p.transmissionSamplerMap.value=A.texture,p.transmissionSamplerSize.value.set(A.width,A.height),u.transmissionMap&&(p.transmissionMap.value=u.transmissionMap,t(u.transmissionMap,p.transmissionMapTransform)),p.thickness.value=u.thickness,u.thicknessMap&&(p.thicknessMap.value=u.thicknessMap,t(u.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=u.attenuationDistance,p.attenuationColor.value.copy(u.attenuationColor)),u.anisotropy>0&&(p.anisotropyVector.value.set(u.anisotropy*Math.cos(u.anisotropyRotation),u.anisotropy*Math.sin(u.anisotropyRotation)),u.anisotropyMap&&(p.anisotropyMap.value=u.anisotropyMap,t(u.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=u.specularIntensity,p.specularColor.value.copy(u.specularColor),u.specularColorMap&&(p.specularColorMap.value=u.specularColorMap,t(u.specularColorMap,p.specularColorMapTransform)),u.specularIntensityMap&&(p.specularIntensityMap.value=u.specularIntensityMap,t(u.specularIntensityMap,p.specularIntensityMapTransform))}function v(p,u){u.matcap&&(p.matcap.value=u.matcap)}function S(p,u){const A=e.get(u).light;p.referencePosition.value.setFromMatrixPosition(A.matrixWorld),p.nearDistance.value=A.shadow.camera.near,p.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function wm(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,T){const y=T.program;n.uniformBlockBinding(M,y)}function l(M,T){let y=s[M.id];y===void 0&&(p(M),y=f(M),s[M.id]=y,M.addEventListener("dispose",A));const w=T.program;n.updateUBOMapping(M,w);const g=e.render.frame;r[M.id]!==g&&(h(M),r[M.id]=g)}function f(M){const T=m();M.__bindingPointIndex=T;const y=i.createBuffer(),w=M.__size,g=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,y),i.bufferData(i.UNIFORM_BUFFER,w,g),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,T,y),y}function m(){for(let M=0;M0&&(y+=w-g),M.__size=y,M.__cache={},this}function u(M){const T={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(T.boundary=4,T.storage=4):M.isVector2?(T.boundary=8,T.storage=8):M.isVector3||M.isColor?(T.boundary=16,T.storage=12):M.isVector4?(T.boundary=16,T.storage=16):M.isMatrix3?(T.boundary=48,T.storage=48):M.isMatrix4?(T.boundary=64,T.storage=64):M.isTexture?Pe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(T.boundary=16,T.storage=M.byteLength):Pe("WebGLRenderer: Unsupported uniform value type.",M),T}function A(M){const T=M.target;T.removeEventListener("dispose",A);const y=a.indexOf(T.__bindingPointIndex);a.splice(y,1),i.deleteBuffer(s[T.id]),delete s[T.id],delete r[T.id]}function R(){for(const M in s)i.deleteBuffer(s[M]);a=[],s={},r={}}return{bind:c,update:l,dispose:R}}const Cm=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let en=null;function Pm(){return en===null&&(en=new uh(Cm,16,16,$n,Mn),en.name="DFG_LUT",en.minFilter=wt,en.magFilter=wt,en.wrapS=gn,en.wrapT=gn,en.generateMipmaps=!1,en.needsUpdate=!0),en}class Dm{constructor(e={}){const{canvas:t=zc(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:f="default",failIfMajorPerformanceCaveat:m=!1,reversedDepthBuffer:h=!1,outputBufferType:_=Bt}=e;this.isWebGLRenderer=!0;let v;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");v=n.getContextAttributes().alpha}else v=a;const S=_,p=new Set([Ca,wa,Ra]),u=new Set([Bt,cn,ki,Wi,Ta,Aa]),A=new Uint32Array(4),R=new Int32Array(4),M=new U;let T=null,y=null;const w=[],g=[];let b=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=on,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let P=!1,F=null,Y=null,K=null,z=null;this._outputColorSpace=Vt;let X=0,H=0,J=null,j=-1,re=null;const de=new ut,_e=new ut;let qe=null;const Je=new Oe(0);let He=0,q=t.width,ne=t.height,ee=1,De=null,Le=null;const we=new ut(0,0,q,ne),ct=new ut(0,0,q,ne);let ze=!1;const Qe=new Na;let Ke=!1,ke=!1;const xe=new lt,ve=new U,Ue=new ut,We={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ot=!1;function ht(){return J===null?ee:1}let D=n;function yt(x,L){return t.getContext(x,L)}try{const x={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:f,failIfMajorPerformanceCaveat:m};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ya}`),t.addEventListener("webglcontextlost",dt,!1),t.addEventListener("webglcontextrestored",rt,!1),t.addEventListener("webglcontextcreationerror",$t,!1),D===null){const L="webgl2";if(D=yt(L,x),D===null)throw yt(L)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(x){throw Xe("WebGLRenderer: "+x.message),x}let Ze,E,d,N,G,k,te,se,W,$,ae,ye,ce,oe,Ae,Ce,Ne,C,ie,Z,le,pe,Q;function Ee(){Ze=new Pf(D),Ze.init(),le=new Sm(D,Ze),E=new Ef(D,Ze,e,le),d=new vm(D,Ze),E.reversedDepthBuffer&&h&&d.buffers.depth.setReversed(!0),Y=D.createFramebuffer(),K=D.createFramebuffer(),z=D.createFramebuffer(),N=new If(D),G=new rm,k=new Mm(D,Ze,d,G,E,le,N),te=new Cf(I),se=new Fh(D),pe=new Mf(D,se),W=new Df(D,se,N,pe),$=new Nf(D,W,se,pe,N),C=new Uf(D,E,k),Ae=new yf(G),ae=new sm(I,te,Ze,E,pe,Ae),ye=new Rm(I,G),ce=new om,oe=new fm(Ze),Ne=new vf(I,te,d,$,v,c),Ce=new xm(I,$,E),Q=new wm(D,N,E,d),ie=new Sf(D,Ze,N),Z=new Lf(D,Ze,N),N.programs=ae.programs,I.capabilities=E,I.extensions=Ze,I.properties=G,I.renderLists=ce,I.shadowMap=Ce,I.state=d,I.info=N}Ee(),S!==Bt&&(b=new Of(S,t.width,t.height,o,s,r));const Me=new Tm(I,D);this.xr=Me,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const x=Ze.get("WEBGL_lose_context");x&&x.loseContext()},this.forceContextRestore=function(){const x=Ze.get("WEBGL_lose_context");x&&x.restoreContext()},this.getPixelRatio=function(){return ee},this.setPixelRatio=function(x){x!==void 0&&(ee=x,this.setSize(q,ne,!1))},this.getSize=function(x){return x.set(q,ne)},this.setSize=function(x,L,V=!0){if(Me.isPresenting){Pe("WebGLRenderer: Can't change size while VR device is presenting.");return}q=x,ne=L,t.width=Math.floor(x*ee),t.height=Math.floor(L*ee),V===!0&&(t.style.width=x+"px",t.style.height=L+"px"),b!==null&&b.setSize(t.width,t.height),this.setViewport(0,0,x,L)},this.getDrawingBufferSize=function(x){return x.set(q*ee,ne*ee).floor()},this.setDrawingBufferSize=function(x,L,V){q=x,ne=L,ee=V,t.width=Math.floor(x*V),t.height=Math.floor(L*V),this.setViewport(0,0,x,L)},this.setEffects=function(x){if(S===Bt){Xe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(x){for(let L=0;L{function fe(){if(O.forEach(function(ge){G.get(ge).currentProgram.isReady()&&O.delete(ge)}),O.size===0){B(x);return}setTimeout(fe,10)}Ze.get("KHR_parallel_shader_compile")!==null?fe():setTimeout(fe,10)})};let Ys=null;function $l(x){Ys&&Ys(x)}function Ya(){zn.stop()}function qa(){zn.start()}const zn=new zl;zn.setAnimationLoop($l),typeof self<"u"&&zn.setContext(self),this.setAnimationLoop=function(x){Ys=x,Me.setAnimationLoop(x),x===null?zn.stop():zn.start()},Me.addEventListener("sessionstart",Ya),Me.addEventListener("sessionend",qa),this.render=function(x,L){if(L!==void 0&&L.isCamera!==!0){Xe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;F!==null&&F.renderStart(x,L);const V=Me.enabled===!0&&Me.isPresenting===!0,O=b!==null&&(J===null||V)&&b.begin(I,J);if(x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),Me.enabled===!0&&Me.isPresenting===!0&&(b===null||b.isCompositing()===!1)&&(Me.cameraAutoUpdate===!0&&Me.updateCamera(L),L=Me.getCamera()),x.isScene===!0&&x.onBeforeRender(I,x,L,J),y=oe.get(x,g.length),y.init(L),y.state.textureUnits=k.getTextureUnits(),g.push(y),xe.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),Qe.setFromProjectionMatrix(xe,an,L.reversedDepth),ke=this.localClippingEnabled,Ke=Ae.init(this.clippingPlanes,ke),T=ce.get(x,w.length),T.init(),w.push(T),Me.enabled===!0&&Me.isPresenting===!0){const ge=I.xr.getDepthSensingMesh();ge!==null&&qs(ge,L,-1/0,I.sortObjects)}qs(x,L,0,I.sortObjects),T.finish(),I.sortObjects===!0&&T.sort(De,Le,L.reversedDepth),ot=Me.enabled===!1||Me.isPresenting===!1||Me.hasDepthSensing()===!1,ot&&Ne.addToRenderList(T,x),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ke===!0&&Ae.beginShadows();const B=y.state.shadowsArray;if(Ce.render(B,x,L),Ke===!0&&Ae.endShadows(),(O&&b.hasRenderPass())===!1){const ge=T.opaque,ue=T.transmissive;if(y.setupLights(),L.isArrayCamera){const Se=L.cameras;if(ue.length>0)for(let be=0,Fe=Se.length;be0&&Za(ge,ue,x,L),ot&&Ne.render(x),Ka(T,x,L)}J!==null&&H===0&&(k.updateMultisampleRenderTarget(J),k.updateRenderTargetMipmap(J)),O&&b.end(I),x.isScene===!0&&x.onAfterRender(I,x,L),pe.resetDefaultState(),j=-1,re=null,g.pop(),g.length>0?(y=g[g.length-1],k.setTextureUnits(y.state.textureUnits),Ke===!0&&Ae.setGlobalState(I.clippingPlanes,y.state.camera)):y=null,w.pop(),w.length>0?T=w[w.length-1]:T=null,F!==null&&F.renderEnd()};function qs(x,L,V,O){if(x.visible===!1)return;if(x.layers.test(L.layers)){if(x.isGroup)V=x.renderOrder;else if(x.isLOD)x.autoUpdate===!0&&x.update(L);else if(x.isLightProbeGrid)y.pushLightProbeGrid(x);else if(x.isLight)y.pushLight(x),x.castShadow&&y.pushShadow(x);else if(x.isSprite){if(!x.frustumCulled||Qe.intersectsSprite(x)){O&&Ue.setFromMatrixPosition(x.matrixWorld).applyMatrix4(xe);const ge=$.update(x),ue=x.material;ue.visible&&T.push(x,ge,ue,V,Ue.z,null)}}else if((x.isMesh||x.isLine||x.isPoints)&&(!x.frustumCulled||Qe.intersectsObject(x))){const ge=$.update(x),ue=x.material;if(O&&(x.boundingSphere!==void 0?(x.boundingSphere===null&&x.computeBoundingSphere(),Ue.copy(x.boundingSphere.center)):(ge.boundingSphere===null&&ge.computeBoundingSphere(),Ue.copy(ge.boundingSphere.center)),Ue.applyMatrix4(x.matrixWorld).applyMatrix4(xe)),Array.isArray(ue)){const Se=ge.groups;for(let be=0,Fe=Se.length;be0&&qi(B,L,V),fe.length>0&&qi(fe,L,V),ge.length>0&&qi(ge,L,V),d.buffers.depth.setTest(!0),d.buffers.depth.setMask(!0),d.buffers.color.setMask(!0),d.setPolygonOffset(!1)}function Za(x,L,V,O){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;if(y.state.transmissionRenderTarget[O.id]===void 0){const Te=Ze.has("EXT_color_buffer_half_float")||Ze.has("EXT_color_buffer_float");y.state.transmissionRenderTarget[O.id]=new ln(1,1,{generateMipmaps:!0,type:Te?Mn:Bt,minFilter:qn,samples:Math.max(4,E.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ye.workingColorSpace})}const fe=y.state.transmissionRenderTarget[O.id],ge=O.viewport||de;fe.setSize(ge.z*I.transmissionResolutionScale,ge.w*I.transmissionResolutionScale);const ue=I.getRenderTarget(),Se=I.getActiveCubeFace(),be=I.getActiveMipmapLevel();I.setRenderTarget(fe),I.getClearColor(Je),He=I.getClearAlpha(),He<1&&I.setClearColor(16777215,.5),I.clear(),ot&&Ne.render(V);const Fe=I.toneMapping;I.toneMapping=on;const Ge=O.viewport;if(O.viewport!==void 0&&(O.viewport=void 0),y.setupLightsView(O),Ke===!0&&Ae.setGlobalState(I.clippingPlanes,O),qi(x,V,O),k.updateMultisampleRenderTarget(fe),k.updateRenderTargetMipmap(fe),Ze.has("WEBGL_multisampled_render_to_texture")===!1){let Te=!1;for(let et=0,pt=L.length;et0,O.currentProgram=Ge,O.uniformsList=null,Ge}function Ja(x){if(x.uniformsList===null){const L=x.currentProgram.getUniforms();x.uniformsList=Cs.seqWithValue(L.seq,x.uniforms)}return x.uniformsList}function Qa(x,L){const V=G.get(x);V.outputColorSpace=L.outputColorSpace,V.batching=L.batching,V.batchingColor=L.batchingColor,V.instancing=L.instancing,V.instancingColor=L.instancingColor,V.instancingMorph=L.instancingMorph,V.skinning=L.skinning,V.morphTargets=L.morphTargets,V.morphNormals=L.morphNormals,V.morphColors=L.morphColors,V.morphTargetsCount=L.morphTargetsCount,V.numClippingPlanes=L.numClippingPlanes,V.numIntersection=L.numClipIntersection,V.vertexAlphas=L.vertexAlphas,V.vertexTangents=L.vertexTangents,V.toneMapping=L.toneMapping}function Jl(x,L){if(x.length===0)return null;if(x.length===1)return x[0].texture!==null?x[0]:null;M.setFromMatrixPosition(L.matrixWorld);for(let V=0,O=x.length;V0),Te=!!V.morphAttributes.position,et=!!V.morphAttributes.normal,pt=!!V.morphAttributes.color;let ft=on;O.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(ft=I.toneMapping);const it=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,Tt=it!==void 0?it.length:0,me=G.get(O),Nt=y.state.lights;if(Ke===!0&&(ke===!0||x!==re)){const at=x===re&&O.id===j;Ae.setState(O,x,at)}let $e=!1;O.version===me.__version?(me.needsLights&&me.lightsStateVersion!==Nt.state.version||me.outputColorSpace!==ue||B.isBatchedMesh&&me.batching===!1||!B.isBatchedMesh&&me.batching===!0||B.isBatchedMesh&&me.batchingColor===!0&&B.colorTexture===null||B.isBatchedMesh&&me.batchingColor===!1&&B.colorTexture!==null||B.isInstancedMesh&&me.instancing===!1||!B.isInstancedMesh&&me.instancing===!0||B.isSkinnedMesh&&me.skinning===!1||!B.isSkinnedMesh&&me.skinning===!0||B.isInstancedMesh&&me.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&me.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&me.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&me.instancingMorph===!1&&B.morphTexture!==null||me.envMap!==be||O.fog===!0&&me.fog!==fe||me.numClippingPlanes!==void 0&&(me.numClippingPlanes!==Ae.numPlanes||me.numIntersection!==Ae.numIntersection)||me.vertexAlphas!==Fe||me.vertexTangents!==Ge||me.morphTargets!==Te||me.morphNormals!==et||me.morphColors!==pt||me.toneMapping!==ft||me.morphTargetsCount!==Tt||!!me.lightProbeGrid!=y.state.lightProbeGridArray.length>0)&&($e=!0):($e=!0,me.__version=O.version);let zt=me.currentProgram;$e===!0&&(zt=Ki(O,L,B),F&&O.isNodeMaterial&&F.onUpdateProgram(O,zt,me));let Qt=!1,En=!1,Qn=!1;const st=zt.getUniforms(),mt=me.uniforms;if(d.useProgram(zt.program)&&(Qt=!0,En=!0,Qn=!0),O.id!==j&&(j=O.id,En=!0),me.needsLights){const at=Jl(y.state.lightProbeGridArray,B);me.lightProbeGrid!==at&&(me.lightProbeGrid=at,En=!0)}if(Qt||re!==x){d.buffers.depth.getReversed()&&x.reversedDepth!==!0&&(x._reversedDepth=!0,x.updateProjectionMatrix()),st.setValue(D,"projectionMatrix",x.projectionMatrix),st.setValue(D,"viewMatrix",x.matrixWorldInverse);const bn=st.map.cameraPosition;bn!==void 0&&bn.setValue(D,ve.setFromMatrixPosition(x.matrixWorld)),E.logarithmicDepthBuffer&&st.setValue(D,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2)),(O.isMeshPhongMaterial||O.isMeshToonMaterial||O.isMeshLambertMaterial||O.isMeshBasicMaterial||O.isMeshStandardMaterial||O.isShaderMaterial)&&st.setValue(D,"isOrthographic",x.isOrthographicCamera===!0),re!==x&&(re=x,En=!0,Qn=!0)}if(me.needsLights&&(Nt.state.directionalShadowMap.length>0&&st.setValue(D,"directionalShadowMap",Nt.state.directionalShadowMap,k),Nt.state.spotShadowMap.length>0&&st.setValue(D,"spotShadowMap",Nt.state.spotShadowMap,k),Nt.state.pointShadowMap.length>0&&st.setValue(D,"pointShadowMap",Nt.state.pointShadowMap,k)),B.isSkinnedMesh){st.setOptional(D,B,"bindMatrix"),st.setOptional(D,B,"bindMatrixInverse");const at=B.skeleton;at&&(at.boneTexture===null&&at.computeBoneTexture(),st.setValue(D,"boneTexture",at.boneTexture,k))}B.isBatchedMesh&&(st.setOptional(D,B,"batchingTexture"),st.setValue(D,"batchingTexture",B._matricesTexture,k),st.setOptional(D,B,"batchingIdTexture"),st.setValue(D,"batchingIdTexture",B._indirectTexture,k),st.setOptional(D,B,"batchingColorTexture"),B._colorsTexture!==null&&st.setValue(D,"batchingColorTexture",B._colorsTexture,k));const yn=V.morphAttributes;if((yn.position!==void 0||yn.normal!==void 0||yn.color!==void 0)&&C.update(B,V,zt),(En||me.receiveShadow!==B.receiveShadow)&&(me.receiveShadow=B.receiveShadow,st.setValue(D,"receiveShadow",B.receiveShadow)),(O.isMeshStandardMaterial||O.isMeshLambertMaterial||O.isMeshPhongMaterial)&&O.envMap===null&&L.environment!==null&&(mt.envMapIntensity.value=L.environmentIntensity),mt.dfgLUT!==void 0&&(mt.dfgLUT.value=Pm()),En){if(st.setValue(D,"toneMappingExposure",I.toneMappingExposure),me.needsLights&&jl(mt,Qn),fe&&O.fog===!0&&ye.refreshFogUniforms(mt,fe),ye.refreshMaterialUniforms(mt,O,ee,ne,y.state.transmissionRenderTarget[x.id]),me.needsLights&&me.lightProbeGrid){const at=me.lightProbeGrid;mt.probesSH.value=at.texture,mt.probesMin.value.copy(at.boundingBox.min),mt.probesMax.value.copy(at.boundingBox.max),mt.probesResolution.value.copy(at.resolution)}Cs.upload(D,Ja(me),mt,k)}if(O.isShaderMaterial&&O.uniformsNeedUpdate===!0&&(Cs.upload(D,Ja(me),mt,k),O.uniformsNeedUpdate=!1),O.isSpriteMaterial&&st.setValue(D,"center",B.center),st.setValue(D,"modelViewMatrix",B.modelViewMatrix),st.setValue(D,"normalMatrix",B.normalMatrix),st.setValue(D,"modelMatrix",B.matrixWorld),O.uniformsGroups!==void 0){const at=O.uniformsGroups;for(let bn=0,jn=at.length;bn0&&k.useMultisampledRTT(x)===!1?O=G.get(x).__webglMultisampledFramebuffer:Array.isArray(be)?O=be[V]:O=be,de.copy(x.viewport),_e.copy(x.scissor),qe=x.scissorTest}else de.copy(we).multiplyScalar(ee).floor(),_e.copy(ct).multiplyScalar(ee).floor(),qe=ze;if(V!==0&&(O=Y),d.bindFramebuffer(D.FRAMEBUFFER,O)&&d.drawBuffers(x,O),d.viewport(de),d.scissor(_e),d.setScissorTest(qe),B){const ue=G.get(x.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+L,ue.__webglTexture,V)}else if(fe){const ue=L;for(let Se=0;Se1&&D.readBuffer(D.COLOR_ATTACHMENT0+ue),!E.textureFormatReadable(Fe)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!E.textureTypeReadable(Ge)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=x.width-O&&V>=0&&V<=x.height-B&&D.readPixels(L,V,O,B,le.convert(Fe),le.convert(Ge),fe)}finally{const be=J!==null?G.get(J).__webglFramebuffer:null;d.bindFramebuffer(D.FRAMEBUFFER,be)}}},this.readRenderTargetPixelsAsync=async function(x,L,V,O,B,fe,ge,ue=0){if(!(x&&x.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=G.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&ge!==void 0&&(Se=Se[ge]),Se)if(L>=0&&L<=x.width-O&&V>=0&&V<=x.height-B){d.bindFramebuffer(D.FRAMEBUFFER,Se);const be=x.textures[ue],Fe=be.format,Ge=be.type;if(x.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+ue),!E.textureFormatReadable(Fe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!E.textureTypeReadable(Ge))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Te=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,Te),D.bufferData(D.PIXEL_PACK_BUFFER,fe.byteLength,D.STREAM_READ),D.readPixels(L,V,O,B,le.convert(Fe),le.convert(Ge),0);const et=J!==null?G.get(J).__webglFramebuffer:null;d.bindFramebuffer(D.FRAMEBUFFER,et);const pt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await Gc(D,pt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,Te),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,fe),D.deleteBuffer(Te),D.deleteSync(pt),fe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(x,L=null,V=0){const O=Math.pow(2,-V),B=Math.floor(x.image.width*O),fe=Math.floor(x.image.height*O),ge=L!==null?L.x:0,ue=L!==null?L.y:0;k.setTexture2D(x,0),D.copyTexSubImage2D(D.TEXTURE_2D,V,0,0,ge,ue,B,fe),d.unbindTexture()},this.copyTextureToTexture=function(x,L,V=null,O=null,B=0,fe=0){let ge,ue,Se,be,Fe,Ge,Te,et,pt;const ft=x.isCompressedTexture?x.mipmaps[fe]:x.image;if(V!==null)ge=V.max.x-V.min.x,ue=V.max.y-V.min.y,Se=V.isBox3?V.max.z-V.min.z:1,be=V.min.x,Fe=V.min.y,Ge=V.isBox3?V.min.z:0;else{const mt=Math.pow(2,-B);ge=Math.floor(ft.width*mt),ue=Math.floor(ft.height*mt),x.isDataArrayTexture?Se=ft.depth:x.isData3DTexture?Se=Math.floor(ft.depth*mt):Se=1,be=0,Fe=0,Ge=0}O!==null?(Te=O.x,et=O.y,pt=O.z):(Te=0,et=0,pt=0);const it=le.convert(L.format),Tt=le.convert(L.type);let me;L.isData3DTexture?(k.setTexture3D(L,0),me=D.TEXTURE_3D):L.isDataArrayTexture||L.isCompressedArrayTexture?(k.setTexture2DArray(L,0),me=D.TEXTURE_2D_ARRAY):(k.setTexture2D(L,0),me=D.TEXTURE_2D),d.activeTexture(D.TEXTURE0),d.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,L.flipY),d.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),d.pixelStorei(D.UNPACK_ALIGNMENT,L.unpackAlignment);const Nt=d.getParameter(D.UNPACK_ROW_LENGTH),$e=d.getParameter(D.UNPACK_IMAGE_HEIGHT),zt=d.getParameter(D.UNPACK_SKIP_PIXELS),Qt=d.getParameter(D.UNPACK_SKIP_ROWS),En=d.getParameter(D.UNPACK_SKIP_IMAGES);d.pixelStorei(D.UNPACK_ROW_LENGTH,ft.width),d.pixelStorei(D.UNPACK_IMAGE_HEIGHT,ft.height),d.pixelStorei(D.UNPACK_SKIP_PIXELS,be),d.pixelStorei(D.UNPACK_SKIP_ROWS,Fe),d.pixelStorei(D.UNPACK_SKIP_IMAGES,Ge);const Qn=x.isDataArrayTexture||x.isData3DTexture,st=L.isDataArrayTexture||L.isData3DTexture;if(x.isDepthTexture){const mt=G.get(x),yn=G.get(L),at=G.get(mt.__renderTarget),bn=G.get(yn.__renderTarget);d.bindFramebuffer(D.READ_FRAMEBUFFER,at.__webglFramebuffer),d.bindFramebuffer(D.DRAW_FRAMEBUFFER,bn.__webglFramebuffer);for(let jn=0;jnMath.PI&&(n-=Lt),s<-Math.PI?s+=Lt:s>Math.PI&&(s-=Lt),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(gt.setFromSpherical(this._spherical),gt.applyQuaternion(this._quatInverse),t.copy(this.target).add(gt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=gt.length();a=this._clampDistance(o*this._scale);const c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){const o=new U(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=c!==this.object.zoom;const l=new U(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=gt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Es.origin.copy(this.object.position),Es.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Es.direction))Cr||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Cr||this._lastTargetPosition.distanceToSquared(this.target)>Cr?(this.dispatchEvent(ol),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Lt/60*this.autoRotateSpeed*e:Lt/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){gt.setFromMatrixColumn(t,0),gt.multiplyScalar(-e),this._panOffset.add(gt)}_panUp(e,t){this.screenSpacePanning===!0?gt.setFromMatrixColumn(t,1):(gt.setFromMatrixColumn(t,0),gt.crossVectors(this.object.up,gt)),gt.multiplyScalar(e),this._panOffset.add(gt)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;gt.copy(s).sub(this.target);let r=gt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Lt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Lt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Lt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Lt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Lt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Lt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Lt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Lt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t"u"?e:getComputedStyle(document.documentElement).getPropertyValue(i).trim()||e}function cl(i){return Math.max(40,26*Math.sqrt(Math.max(i,1)))}function Ym(i,e){const t=document.createElement("canvas");t.width=512,t.height=64;const n=t.getContext("2d");n&&(n.clearRect(0,0,512,64),n.fillStyle=e,n.font="600 28px sans-serif",n.textAlign="center",n.textBaseline="middle",n.fillText(i,256,32));const s=new gh(t),r=new ch(new Dl({map:s,transparent:!0,depthTest:!1}));return r.scale.set(110,14,1),r}function Km({nodes:i,edges:e,selectedId:t,neighborIds:n,onSelect:s}){const r=un.useRef(null),a=un.useRef(null),[o,c]=un.useState(null),[l,f]=un.useState(null),m=un.useRef(s);m.current=s;const h=un.useRef({selectedId:t,neighborIds:n});h.current={selectedId:t,neighborIds:n};const _=un.useRef(null),v=`${i.map(S=>S.id).join("\0")}|${e.map(S=>S.id).join("\0")}`;return un.useEffect(()=>{const S=a.current;if(!S)return;const p=window.matchMedia("(prefers-reduced-motion: reduce)").matches,u=Wn("--graph-bg","#0b0f14"),A=new Oe(Wn("--accent","#4cc9f0")),R=new ih;R.background=new Oe(u);const M=new Ht(50,1,1,8e3);let T;try{T=new Dm({antialias:!0,alpha:!1,failIfMajorPerformanceCaveat:!1,powerPreference:"low-power"})}catch{f("WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map.");return}if(!T.getContext()){T.dispose(),f("WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map.");return}f(null),T.setClearColor(u,1),T.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),T.domElement.dataset.testid="graph-3d-canvas",S.appendChild(T.domElement);const y=new Im(M,T.domElement);y.enableDamping=!p,y.dampingFactor=.08,y.minDistance=80,y.maxDistance=2400,R.add(new Ph(16777215,.7));const w=new Ch(16777215,.85);w.position.set(200,320,180),R.add(w);const g=tc(i),b=new Map(i.map(xe=>[xe.id,xe])),I=new Map,P=new Vi;R.add(P);const F=new Oa(11,18,14);for(const xe of i){const ve=g.get(xe.id)??{x:0,y:0,z:0},Ue=new bh({color:nc(xe.type),roughness:.45,metalness:.05,transparent:!0,opacity:1}),We=new Zt(F,Ue);We.position.set(ve.x,ve.y,ve.z),We.userData.id=xe.id,P.add(We),I.set(xe.id,We)}const Y=new Ut,K=[],z=[],X=new Oe(Wn("--edge-cheap","#4a5568")),H=new Oe(Wn("--edge-expensive","#f4a261")),J=new Oe(Wn("--edge-critical","#e85d04"));for(const xe of e){const ve=g.get(xe.src),Ue=g.get(xe.dst);if(!ve||!Ue)continue;K.push(ve.x,ve.y,ve.z,Ue.x,Ue.y,Ue.z);const We=xe.weight==="critical"?J:xe.weight==="expensive"?H:X;z.push(We.r,We.g,We.b,We.r,We.g,We.b)}Y.setAttribute("position",new xt(K,3)),Y.setAttribute("color",new xt(z,3));const j=new _h(Y,new Il({vertexColors:!0,transparent:!0,opacity:.55}));P.add(j);const re=new Ua({color:new Oe(Wn("--muted","#8b9bb0")),transparent:!0,opacity:.07,side:nn,depthWrite:!1}),de=Wn("--muted","#8b9bb0"),_e=[],qe=[];for(const xe of ic(i)){const ve=new Fa(cl(xe.count),48);qe.push(ve);const Ue=new Zt(ve,re);Ue.rotation.y=Math.PI/2,Ue.position.x=xe.x,P.add(Ue);const We=Ym(sc[xe.layer]??`layer ${xe.layer}`,de);We.position.set(xe.x,cl(xe.count)+18,0),P.add(We),_e.push(We)}const Je=_.current;if(Je&&Je.topology===v)M.position.set(Je.position.x,Je.position.y,Je.position.z),y.target.set(Je.target.x,Je.target.y,Je.target.z),M.lookAt(y.target);else{const xe=new wi().setFromObject(P),ve=xe.getCenter(new U),Ue=xe.getSize(new U);y.target.copy(ve),M.position.set(ve.x+Ue.x*.15,ve.y+Math.max(140,Ue.y*.45),ve.z+Math.max(280,Ue.z*.9+180)),M.lookAt(ve)}const He=new Ih;He.params.Mesh={...He.params.Mesh,threshold:2};const q=new Re,ne=[...I.values()],ee=(xe,ve)=>{const Ue=!!(xe&&ve.size),We=new Oe(0);for(const[ot,ht]of I){const D=ht.material,yt=!Ue||ve.has(ot),Ze=ot===xe;D.opacity=Ze?1:yt?.95:.12,ht.scale.setScalar(Ze?1.25:yt?1:.7),D.emissive.copy(Ze?A:We),D.emissiveIntensity=Ze?.35:0}j.material.opacity=Ue?.85:.5},De=xe=>{const ve=T.domElement.getBoundingClientRect();q.x=(xe.clientX-ve.left)/ve.width*2-1,q.y=-((xe.clientY-ve.top)/ve.height)*2+1},Le=()=>{He.setFromCamera(q,M);const xe=He.intersectObjects(ne,!1)[0],ve=xe==null?void 0:xe.object.userData.id;return ve?b.get(ve)??null:null},we=xe=>{De(xe);const ve=Le();if(!ve){c(null),T.domElement.style.cursor="grab";return}T.domElement.style.cursor="pointer";const Ue=(r.current??S).getBoundingClientRect();c({node:ve,x:xe.clientX-Ue.left,y:xe.clientY-Ue.top})},ct=xe=>{De(xe);const ve=Le();m.current(ve?ve.id:null)},ze=()=>{const xe=S.clientWidth||1,ve=S.clientHeight||1;M.aspect=xe/ve,M.updateProjectionMatrix(),T.setSize(xe,ve,!1)};ze();const Qe=new ResizeObserver(ze);Qe.observe(S);let Ke=0;const ke=()=>{Ke=requestAnimationFrame(ke),y.update(),T.render(R,M)};return ke(),T.domElement.addEventListener("pointermove",we),T.domElement.addEventListener("click",ct),S.__paint=ee,ee(h.current.selectedId,h.current.neighborIds),()=>{var xe;_.current={topology:v,position:{x:M.position.x,y:M.position.y,z:M.position.z},target:{x:y.target.x,y:y.target.y,z:y.target.z}},cancelAnimationFrame(Ke),Qe.disconnect(),T.domElement.removeEventListener("pointermove",we),T.domElement.removeEventListener("click",ct),delete S.__paint,y.dispose(),F.dispose(),Y.dispose(),re.dispose();for(const ve of qe)ve.dispose();j.material.dispose();for(const ve of _e){const Ue=ve.material;(xe=Ue.map)==null||xe.dispose(),Ue.dispose()}for(const ve of I.values())ve.material.dispose();T.dispose(),T.domElement.remove(),c(null)}},[v]),un.useEffect(()=>{var S,p;(p=(S=a.current)==null?void 0:S.__paint)==null||p.call(S,t,n)},[t,n]),ei.jsxs("div",{className:"graph-3d-host",ref:r,children:[ei.jsx("div",{className:"graph-3d-canvas-host",ref:a}),l?ei.jsx("p",{className:"muted graph-3d-hint","data-testid":"graph-3d-fallback",children:l}):null,o?ei.jsxs("div",{className:"graph-3d-tip",style:{left:o.x+12,top:o.y+12},children:[ei.jsx("div",{className:"t",children:rc(o.node.type)}),ei.jsx("div",{className:"n",children:o.node.name})]}):null]})}export{Km as LayeredGraph3D}; diff --git a/src/loadpath/static/assets/LayeredGraph3D-DIGrA9CU.js b/src/loadpath/static/assets/LayeredGraph3D-DIGrA9CU.js new file mode 100644 index 0000000..e337116 --- /dev/null +++ b/src/loadpath/static/assets/LayeredGraph3D-DIGrA9CU.js @@ -0,0 +1,4116 @@ +import{r as Ot,l as oc,n as nr,c as lc,i as cc,a as hc,j as Zn,t as uc}from"./index-CcW4ogPp.js";/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const La="185",wi={ROTATE:0,DOLLY:1,PAN:2},Ai={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},dc=0,lo=1,fc=2,Ds=1,pc=2,qi=3,Hn=0,zt=1,cn=2,yn=0,Ri=1,co=2,ho=3,uo=4,mc=5,jn=100,_c=101,gc=102,xc=103,vc=104,Mc=200,Sc=201,Ec=202,yc=203,zr=204,Gr=205,bc=206,Tc=207,Ac=208,wc=209,Rc=210,Cc=211,Pc=212,Dc=213,Lc=214,Vr=0,Hr=1,kr=2,Di=3,Wr=4,Xr=5,Yr=6,qr=7,vl=0,Ic=1,Uc=2,fn=0,Ml=1,Sl=2,El=3,yl=4,bl=5,Tl=6,Al=7,wl=300,ii=301,Li=302,ir=303,sr=304,$s=306,Zr=1e3,En=1001,Kr=1002,At=1003,Nc=1004,is=1005,Lt=1006,rr=1007,ti=1008,Wt=1009,Rl=1010,Cl=1011,$i=1012,Ia=1013,mn=1014,un=1015,Tn=1016,Ua=1017,Na=1018,Ji=1020,Pl=35902,Dl=35899,Ll=1021,Il=1022,nn=1023,An=1026,ni=1027,Ul=1028,Fa=1029,si=1030,Oa=1031,Ba=1033,Ls=33776,Is=33777,Us=33778,Ns=33779,$r=35840,Jr=35841,Qr=35842,jr=35843,ea=36196,ta=37492,na=37496,ia=37488,sa=37489,Bs=37490,ra=37491,aa=37808,oa=37809,la=37810,ca=37811,ha=37812,ua=37813,da=37814,fa=37815,pa=37816,ma=37817,_a=37818,ga=37819,xa=37820,va=37821,Ma=36492,Sa=36494,Ea=36495,ya=36283,ba=36284,zs=36285,Ta=36286,Fc=3200,Aa=0,Oc=1,zn="",kt="srgb",Gs="srgb-linear",Vs="linear",Je="srgb",li=7680,fo=519,Bc=512,zc=513,Gc=514,za=515,Vc=516,Hc=517,Ga=518,kc=519,wa=35044,po="300 es",dn=2e3,Qi=2001;function Wc(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Hs(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Xc(){const i=Hs("canvas");return i.style.display="block",i}const mo={};function ks(...i){const e="THREE."+i.shift();console.log(e,...i)}function Nl(i){const e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function De(...i){i=Nl(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function We(...i){i=Nl(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Ci(...i){const e=i.join(" ");e in mo||(mo[e]=!0,De(...i))}function Yc(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const qc={[Vr]:Hr,[kr]:Yr,[Wr]:qr,[Di]:Xr,[Hr]:Vr,[Yr]:kr,[qr]:Wr,[Xr]:Di};class Xn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const s=n[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let r=0,a=s.length;r>8&255]+Pt[i>>16&255]+Pt[i>>24&255]+"-"+Pt[e&255]+Pt[e>>8&255]+"-"+Pt[e>>16&15|64]+Pt[e>>24&255]+"-"+Pt[t&63|128]+Pt[t>>8&255]+"-"+Pt[t>>16&255]+Pt[t>>24&255]+Pt[n&255]+Pt[n>>8&255]+Pt[n>>16&255]+Pt[n>>24&255]).toLowerCase()}function He(i,e,t){return Math.max(e,Math.min(t,i))}function Zc(i,e){return(i%e+e)%e}function ar(i,e,t){return(1-t)*i+t*e}function hn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function je(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const Kc={DEG2RAD:Fs},Ja=class Ja{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,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,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: 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("THREE.Vector2: 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,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,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,t){return this.x=e.x-t.x,this.y=e.y-t.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 t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+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,t){return this.x=He(this.x,e.x,t.x),this.y=He(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=He(this.x,e,t),this.y=He(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(He(n,e,t))}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 t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(He(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Ja.prototype.isVector2=!0;let we=Ja;class kn{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let c=n[s+0],l=n[s+1],d=n[s+2],m=n[s+3],h=r[a+0],_=r[a+1],v=r[a+2],E=r[a+3];if(m!==E||c!==h||l!==_||d!==v){let p=c*h+l*_+d*v+m*E;p<0&&(h=-h,_=-_,v=-v,E=-E,p=-p);let u=1-o;if(p<.9995){const A=Math.acos(p),R=Math.sin(A);u=Math.sin(u*A)/R,o=Math.sin(o*A)/R,c=c*u+h*o,l=l*u+_*o,d=d*u+v*o,m=m*u+E*o}else{c=c*u+h*o,l=l*u+_*o,d=d*u+v*o,m=m*u+E*o;const A=1/Math.sqrt(c*c+l*l+d*d+m*m);c*=A,l*=A,d*=A,m*=A}}e[t]=c,e[t+1]=l,e[t+2]=d,e[t+3]=m}static multiplyQuaternionsFlat(e,t,n,s,r,a){const o=n[s],c=n[s+1],l=n[s+2],d=n[s+3],m=r[a],h=r[a+1],_=r[a+2],v=r[a+3];return e[t]=o*v+d*m+c*_-l*h,e[t+1]=c*v+d*h+l*m-o*_,e[t+2]=l*v+d*_+o*h-c*m,e[t+3]=d*v-o*m-c*h-l*_,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,t,n,s){return this._x=e,this._y=t,this._z=n,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,t=!0){const n=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),d=o(s/2),m=o(r/2),h=c(n/2),_=c(s/2),v=c(r/2);switch(a){case"XYZ":this._x=h*d*m+l*_*v,this._y=l*_*m-h*d*v,this._z=l*d*v+h*_*m,this._w=l*d*m-h*_*v;break;case"YXZ":this._x=h*d*m+l*_*v,this._y=l*_*m-h*d*v,this._z=l*d*v-h*_*m,this._w=l*d*m+h*_*v;break;case"ZXY":this._x=h*d*m-l*_*v,this._y=l*_*m+h*d*v,this._z=l*d*v+h*_*m,this._w=l*d*m-h*_*v;break;case"ZYX":this._x=h*d*m-l*_*v,this._y=l*_*m+h*d*v,this._z=l*d*v-h*_*m,this._w=l*d*m+h*_*v;break;case"YZX":this._x=h*d*m+l*_*v,this._y=l*_*m+h*d*v,this._z=l*d*v-h*_*m,this._w=l*d*m-h*_*v;break;case"XZY":this._x=h*d*m-l*_*v,this._y=l*_*m-h*d*v,this._z=l*d*v+h*_*m,this._w=l*d*m+h*_*v;break;default:De("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],d=t[6],m=t[10],h=n+o+m;if(h>0){const _=.5/Math.sqrt(h+1);this._w=.25/_,this._x=(d-c)*_,this._y=(r-l)*_,this._z=(a-s)*_}else if(n>o&&n>m){const _=2*Math.sqrt(1+n-o-m);this._w=(d-c)/_,this._x=.25*_,this._y=(s+a)/_,this._z=(r+l)/_}else if(o>m){const _=2*Math.sqrt(1+o-n-m);this._w=(r-l)/_,this._x=(s+a)/_,this._y=.25*_,this._z=(c+d)/_}else{const _=2*Math.sqrt(1+m-n-o);this._w=(a-s)/_,this._x=(r+l)/_,this._y=(c+d)/_,this._z=.25*_}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(He(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);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,t){const n=e._x,s=e._y,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,d=t._w;return this._x=n*d+a*o+s*l-r*c,this._y=s*d+a*c+r*o-n*l,this._z=r*d+a*l+n*c-s*o,this._w=a*d-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),d=Math.sin(l);c=Math.sin(c*l)/d,t=Math.sin(t*l)/d,this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),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}}const Qa=class Qa{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,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,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: 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("THREE.Vector3: 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,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,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,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.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,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(_o.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(_o.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*s-o*n),d=2*(o*t-r*s),m=2*(r*n-a*t);return this.x=t+c*l+a*m-o*d,this.y=n+c*d+o*l-r*m,this.z=s+c*m+r*d-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[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,t){return this.x=He(this.x,e.x,t.x),this.y=He(this.y,e.y,t.y),this.z=He(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=He(this.x,e,t),this.y=He(this.y,e,t),this.z=He(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(He(n,e,t))}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,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,s=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return or.copy(this).projectOnVector(e),this.sub(or)}reflect(e){return this.sub(or.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(He(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+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,t,n){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*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,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Qa.prototype.isVector3=!0;let I=Qa;const or=new I,_o=new kn,ja=class ja{constructor(e,t,n,s,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l)}set(e,t,n,s,r,a,o,c,l){const d=this.elements;return d[0]=e,d[1]=s,d[2]=o,d[3]=t,d[4]=r,d[5]=c,d[6]=n,d[7]=a,d[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],d=n[4],m=n[7],h=n[2],_=n[5],v=n[8],E=s[0],p=s[3],u=s[6],A=s[1],R=s[4],M=s[7],T=s[2],S=s[5],w=s[8];return r[0]=a*E+o*A+c*T,r[3]=a*p+o*R+c*S,r[6]=a*u+o*M+c*w,r[1]=l*E+d*A+m*T,r[4]=l*p+d*R+m*S,r[7]=l*u+d*M+m*w,r[2]=h*E+_*A+v*T,r[5]=h*p+_*R+v*S,r[8]=h*u+_*M+v*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],d=e[8];return t*a*d-t*o*l-n*r*d+n*o*c+s*r*l-s*a*c}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],d=e[8],m=d*a-o*l,h=o*c-d*r,_=l*r-a*c,v=t*m+n*h+s*_;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const E=1/v;return e[0]=m*E,e[1]=(s*l-d*n)*E,e[2]=(o*n-s*a)*E,e[3]=h*E,e[4]=(d*t-s*c)*E,e[5]=(s*r-o*t)*E,e[6]=_*E,e[7]=(n*c-l*t)*E,e[8]=(a*t-n*r)*E,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-s*l,s*c,-s*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return Ci("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(lr.makeScale(e,t)),this}rotate(e){return Ci("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(lr.makeRotation(-e)),this}translate(e,t){return Ci("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(lr.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};ja.prototype.isMatrix3=!0;let Fe=ja;const lr=new Fe,go=new Fe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),xo=new Fe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function $c(){const i={enabled:!0,workingColorSpace:Gs,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Je&&(s.r=bn(s.r),s.g=bn(s.g),s.b=bn(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Je&&(s.r=Pi(s.r),s.g=Pi(s.g),s.b=Pi(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===zn?Vs:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].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,r){return Ci("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ci("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Gs]:{primaries:e,whitePoint:n,transfer:Vs,toXYZ:go,fromXYZ:xo,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:kt},outputColorSpaceConfig:{drawingBufferColorSpace:kt}},[kt]:{primaries:e,whitePoint:n,transfer:Je,toXYZ:go,fromXYZ:xo,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:kt}}}),i}const Xe=$c();function bn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Pi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ci;class Jc{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ci===void 0&&(ci=Hs("canvas")),ci.width=e.width,ci.height=e.height;const s=ci.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=ci}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Hs("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(hr).x}get height(){return this.source.getSize(hr).y}get depth(){return this.source.getSize(hr).z}get image(){return this.source.data}set image(e){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,t){this.updateRanges.push({start:e,count:t})}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.normalized=e.normalized,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 t in e){const n=e[t];if(n===void 0){De(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){De(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={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,normalized:this.normalized,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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==wl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Zr:e.x=e.x-Math.floor(e.x);break;case En:e.x=e.x<0?0:1;break;case Kr: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 Zr:e.y=e.y-Math.floor(e.y);break;case En:e.y=e.y<0?0:1;break;case Kr: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++}}It.DEFAULT_IMAGE=null;It.DEFAULT_MAPPING=wl;It.DEFAULT_ANISOTROPY=1;const eo=class eo{constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,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,t,n,s){return this.x=e,this.y=t,this.z=n,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,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: 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("THREE.Vector4: 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,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,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,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.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 t=this.x,n=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*r,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 t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r;const c=e.elements,l=c[0],d=c[4],m=c[8],h=c[1],_=c[5],v=c[9],E=c[2],p=c[6],u=c[10];if(Math.abs(d-h)<.01&&Math.abs(m-E)<.01&&Math.abs(v-p)<.01){if(Math.abs(d+h)<.1&&Math.abs(m+E)<.1&&Math.abs(v+p)<.1&&Math.abs(l+_+u-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const R=(l+1)/2,M=(_+1)/2,T=(u+1)/2,S=(d+h)/4,w=(m+E)/4,g=(v+p)/4;return R>M&&R>T?R<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(R),s=S/n,r=w/n):M>T?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=S/s,r=g/s):T<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(T),n=w/r,s=g/r),this.set(n,s,r,t),this}let A=Math.sqrt((p-v)*(p-v)+(m-E)*(m-E)+(h-d)*(h-d));return Math.abs(A)<.001&&(A=1),this.x=(p-v)/A,this.y=(m-E)/A,this.z=(h-d)/A,this.w=Math.acos((l+_+u-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[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,t){return this.x=He(this.x,e.x,t.x),this.y=He(this.y,e.y,t.y),this.z=He(this.z,e.z,t.z),this.w=He(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=He(this.x,e,t),this.y=He(this.y,e,t),this.z=He(this.z,e,t),this.w=He(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(He(n,e,t))}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,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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}};eo.prototype.isVector4=!0;let ht=eo;class eh extends Xn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Lt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ht(0,0,e,t),this.scissorTest=!1,this.viewport=new ht(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new It(s),a=n.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}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 t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),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 r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.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=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,d=c.length;l0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),d.length>0&&(n.images=d),m.length>0&&(n.shapes=m),h.length>0&&(n.skeletons=h),_.length>0&&(n.animations=_),v.length>0&&(n.nodes=v)}return n.object=s,n;function a(o){const c=[];for(const l in o){const d=o[l];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!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.pivot=e.pivot!==null?e.pivot.clone():null,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.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n_+v?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=_-v&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(lh)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Zi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Ol={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},In={h:0,s:0,l:0},as={h:0,s:0,l:0};function fr(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class Ie{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===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,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=kt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Xe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Xe.workingColorSpace){return this.r=e,this.g=t,this.b=n,Xe.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Xe.workingColorSpace){if(e=Zc(e,1),t=He(t,0,1),n=He(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=fr(a,r,e+1/3),this.g=fr(a,r,e),this.b=fr(a,r,e-1/3)}return Xe.colorSpaceToWorking(this,s),this}setStyle(e,t=kt){function n(r){r!==void 0&&parseFloat(r)<1&&De("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:De("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);De("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=kt){const n=Ol[e.toLowerCase()];return n!==void 0?this.setHex(n,t):De("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=bn(e.r),this.g=bn(e.g),this.b=bn(e.b),this}copyLinearToSRGB(e){return this.r=Pi(e.r),this.g=Pi(e.g),this.b=Pi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=kt){return Xe.workingToColorSpace(Dt.copy(this),e),Math.round(He(Dt.r*255,0,255))*65536+Math.round(He(Dt.g*255,0,255))*256+Math.round(He(Dt.b*255,0,255))}getHexString(e=kt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Xe.workingColorSpace){Xe.workingToColorSpace(Dt.copy(this),t);const n=Dt.r,s=Dt.g,r=Dt.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let c,l;const d=(o+a)/2;if(o===a)c=0,l=0;else{const m=a-o;switch(l=d<=.5?m/(a+o):m/(2-a-o),a){case n:c=(s-r)/m+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const jt=new I,xn=new I,pr=new I,vn=new I,fi=new I,pi=new I,Ao=new I,mr=new I,_r=new I,gr=new I,xr=new ht,vr=new ht,Mr=new ht;class Zt{constructor(e=new I,t=new I,n=new I){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),jt.subVectors(e,t),s.cross(jt);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){jt.subVectors(s,t),xn.subVectors(n,t),pr.subVectors(e,t);const a=jt.dot(jt),o=jt.dot(xn),c=jt.dot(pr),l=xn.dot(xn),d=xn.dot(pr),m=a*l-o*o;if(m===0)return r.set(0,0,0),null;const h=1/m,_=(l*c-o*d)*h,v=(a*d-o*c)*h;return r.set(1-_-v,v,_)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,vn)===null?!1:vn.x>=0&&vn.y>=0&&vn.x+vn.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,vn)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,vn.x),c.addScaledVector(a,vn.y),c.addScaledVector(o,vn.z),c)}static getInterpolatedAttribute(e,t,n,s,r,a){return xr.setScalar(0),vr.setScalar(0),Mr.setScalar(0),xr.fromBufferAttribute(e,t),vr.fromBufferAttribute(e,n),Mr.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(xr,r.x),a.addScaledVector(vr,r.y),a.addScaledVector(Mr,r.z),a}static isFrontFacing(e,t,n,s){return jt.subVectors(n,t),xn.subVectors(e,t),jt.cross(xn).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),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 jt.subVectors(this.c,this.b),xn.subVectors(this.a,this.b),jt.cross(xn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Zt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Zt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return Zt.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return Zt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Zt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,s=this.b,r=this.c;let a,o;fi.subVectors(s,n),pi.subVectors(r,n),mr.subVectors(e,n);const c=fi.dot(mr),l=pi.dot(mr);if(c<=0&&l<=0)return t.copy(n);_r.subVectors(e,s);const d=fi.dot(_r),m=pi.dot(_r);if(d>=0&&m<=d)return t.copy(s);const h=c*m-d*l;if(h<=0&&c>=0&&d<=0)return a=c/(c-d),t.copy(n).addScaledVector(fi,a);gr.subVectors(e,r);const _=fi.dot(gr),v=pi.dot(gr);if(v>=0&&_<=v)return t.copy(r);const E=_*l-c*v;if(E<=0&&l>=0&&v<=0)return o=l/(l-v),t.copy(n).addScaledVector(pi,o);const p=d*v-_*m;if(p<=0&&m-d>=0&&_-v>=0)return Ao.subVectors(r,s),o=(m-d)/(m-d+(_-v)),t.copy(s).addScaledVector(Ao,o);const u=1/(p+E+h);return a=E*u,o=h*u,t.copy(n).addScaledVector(fi,a).addScaledVector(pi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ni{constructor(e=new I(1/0,1/0,1/0),t=new I(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=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,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(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,en),en.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Bi),ls.subVectors(this.max,Bi),mi.subVectors(e.a,Bi),_i.subVectors(e.b,Bi),gi.subVectors(e.c,Bi),Un.subVectors(_i,mi),Nn.subVectors(gi,_i),Kn.subVectors(mi,gi);let t=[0,-Un.z,Un.y,0,-Nn.z,Nn.y,0,-Kn.z,Kn.y,Un.z,0,-Un.x,Nn.z,0,-Nn.x,Kn.z,0,-Kn.x,-Un.y,Un.x,0,-Nn.y,Nn.x,0,-Kn.y,Kn.x,0];return!Sr(t,mi,_i,gi,ls)||(t=[1,0,0,0,1,0,0,0,1],!Sr(t,mi,_i,gi,ls))?!1:(cs.crossVectors(Un,Nn),t=[cs.x,cs.y,cs.z],Sr(t,mi,_i,gi,ls))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,en).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(en).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:(Mn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Mn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Mn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Mn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Mn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Mn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Mn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Mn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Mn),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 Mn=[new I,new I,new I,new I,new I,new I,new I,new I],en=new I,os=new Ni,mi=new I,_i=new I,gi=new I,Un=new I,Nn=new I,Kn=new I,Bi=new I,ls=new I,cs=new I,$n=new I;function Sr(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){$n.fromArray(i,r);const o=s.x*Math.abs($n.x)+s.y*Math.abs($n.y)+s.z*Math.abs($n.z),c=e.dot($n),l=t.dot($n),d=n.dot($n);if(Math.max(-Math.max(c,l,d),Math.min(c,l,d))>o)return!1}return!0}const vt=new I,hs=new we;let hh=0;class sn extends Xn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:hh++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=wa,this.updateRanges=[],this.gpuType=un,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.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,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}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;zi.subVectors(e,this.center);const t=zi.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(zi,s/n),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):(Er.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(zi.copy(e.center).add(Er)),this.expandByPoint(zi.copy(e.center).sub(Er))),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}}let dh=0;const Yt=new at,yr=new Et,xi=new I,Ht=new Ni,Gi=new Ni,Tt=new I;class wt extends Xn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:dh++}),this.uuid=Vn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Wc(e)?zl:Bl)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Fe().getNormalMatrix(e);n.applyNormalMatrix(r),n.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._transformed=!0,this}applyQuaternion(e){return Yt.makeRotationFromQuaternion(e),this.applyMatrix4(Yt),this}rotateX(e){return Yt.makeRotationX(e),this.applyMatrix4(Yt),this}rotateY(e){return Yt.makeRotationY(e),this.applyMatrix4(Yt),this}rotateZ(e){return Yt.makeRotationZ(e),this.applyMatrix4(Yt),this}translate(e,t,n){return Yt.makeTranslation(e,t,n),this.applyMatrix4(Yt),this}scale(e,t,n){return Yt.makeScale(e,t,n),this.applyMatrix4(Yt),this}lookAt(e){return yr.lookAt(e),yr.updateMatrix(),this.applyMatrix4(yr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(xi).negate(),this.translate(xi.x,xi.y,xi.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let s=0,r=e.length;st.count&&De("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ni);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){We("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new I(-1/0,-1/0,-1/0),new I(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const s={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],d=[];for(let m=0,h=l.length;m0&&(s[c]=d,r=!0)}r&&(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 t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const s=e.attributes;for(const l in s){const d=s[l];this.setAttribute(l,d.clone(t))}const r=e.morphAttributes;for(const l in r){const d=[],m=r[l];for(let h=0,_=m.length;h<_;h++)d.push(m[h].clone(t));this.morphAttributes[l]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,d=a.length;l0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){De(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){De(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ri&&(n.blending=this.blending),this.side!==Hn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==zr&&(n.blendSrc=this.blendSrc),this.blendDst!==Gr&&(n.blendDst=this.blendDst),this.blendEquation!==jn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Di&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==fo&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==li&&(n.stencilFail=this.stencilFail),this.stencilZFail!==li&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==li&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ie().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new we().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new we().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}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 t=e.clippingPlanes;let n=null;if(t!==null){const s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,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.allowOverride=e.allowOverride,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 Gl extends ri{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ie(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let vi;const Vi=new I,Mi=new I,Si=new I,Ei=new we,Hi=new we,Vl=new at,us=new I,ki=new I,ds=new I,wo=new we,br=new we,Ro=new we;class mh extends Et{constructor(e=new Gl){if(super(),this.isSprite=!0,this.type="Sprite",vi===void 0){vi=new wt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new fh(t,5);vi.setIndex([0,1,2,0,2,3]),vi.setAttribute("position",new Ws(n,3,0,!1)),vi.setAttribute("uv",new Ws(n,2,3,!1))}this.geometry=vi,this.material=e,this.center=new we(.5,.5),this.count=1}raycast(e,t){e.camera===null&&We('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Mi.setFromMatrixScale(this.matrixWorld),Vl.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Si.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Mi.multiplyScalar(-Si.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;fs(us.set(-.5,-.5,0),Si,a,Mi,s,r),fs(ki.set(.5,-.5,0),Si,a,Mi,s,r),fs(ds.set(.5,.5,0),Si,a,Mi,s,r),wo.set(0,0),br.set(1,0),Ro.set(1,1);let o=e.ray.intersectTriangle(us,ki,ds,!1,Vi);if(o===null&&(fs(ki.set(-.5,.5,0),Si,a,Mi,s,r),br.set(0,1),o=e.ray.intersectTriangle(us,ds,ki,!1,Vi),o===null))return;const c=e.ray.origin.distanceTo(Vi);ce.far||t.push({distance:c,point:Vi.clone(),uv:Zt.getInterpolation(Vi,us,ki,ds,wo,br,Ro,new we),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function fs(i,e,t,n,s,r){Ei.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(Hi.x=r*Ei.x-s*Ei.y,Hi.y=s*Ei.x+r*Ei.y):Hi.copy(Ei),i.copy(e),i.x+=Hi.x,i.y+=Hi.y,i.applyMatrix4(Vl)}const Sn=new I,Tr=new I,ps=new I,Fn=new I,Ar=new I,ms=new I,wr=new I;class Qs{constructor(e=new I,t=new I(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.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,Sn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Sn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Sn.copy(this.origin).addScaledVector(this.direction,t),Sn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Tr.copy(e).add(t).multiplyScalar(.5),ps.copy(t).sub(e).normalize(),Fn.copy(this.origin).sub(Tr);const r=e.distanceTo(t)*.5,a=-this.direction.dot(ps),o=Fn.dot(this.direction),c=-Fn.dot(ps),l=Fn.lengthSq(),d=Math.abs(1-a*a);let m,h,_,v;if(d>0)if(m=a*c-o,h=a*o-c,v=r*d,m>=0)if(h>=-v)if(h<=v){const E=1/d;m*=E,h*=E,_=m*(m+a*h+2*o)+h*(a*m+h+2*c)+l}else h=r,m=Math.max(0,-(a*h+o)),_=-m*m+h*(h+2*c)+l;else h=-r,m=Math.max(0,-(a*h+o)),_=-m*m+h*(h+2*c)+l;else h<=-v?(m=Math.max(0,-(-a*r+o)),h=m>0?-r:Math.min(Math.max(-r,-c),r),_=-m*m+h*(h+2*c)+l):h<=v?(m=0,h=Math.min(Math.max(-r,-c),r),_=h*(h+2*c)+l):(m=Math.max(0,-(a*r+o)),h=m>0?r:Math.min(Math.max(-r,-c),r),_=-m*m+h*(h+2*c)+l);else h=a>0?-r:r,m=Math.max(0,-(a*h+o)),_=-m*m+h*(h+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,m),s&&s.copy(Tr).addScaledVector(ps,h),_}intersectSphere(e,t){Sn.subVectors(e.center,this.origin);const n=Sn.dot(this.direction),s=Sn.dot(Sn)-n*n,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,a,o,c;const l=1/this.direction.x,d=1/this.direction.y,m=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,s=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,s=(e.min.x-h.x)*l),d>=0?(r=(e.min.y-h.y)*d,a=(e.max.y-h.y)*d):(r=(e.max.y-h.y)*d,a=(e.min.y-h.y)*d),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a=0?(o=(e.min.z-h.z)*m,c=(e.max.z-h.z)*m):(o=(e.max.z-h.z)*m,c=(e.min.z-h.z)*m),n>c||o>s)||((o>n||n!==n)&&(n=o),(c=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Sn)!==null}intersectTriangle(e,t,n,s,r){Ar.subVectors(t,e),ms.subVectors(n,e),wr.crossVectors(Ar,ms);let a=this.direction.dot(wr),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Fn.subVectors(this.origin,e);const c=o*this.direction.dot(ms.crossVectors(Fn,ms));if(c<0)return null;const l=o*this.direction.dot(Ar.cross(Fn));if(l<0||c+l>a)return null;const d=-o*Fn.dot(wr);return d<0?null:this.at(d/a,r)}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 Xs extends ri{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ie(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 Wn,this.combine=vl,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 Co=new at,Jn=new Qs,_s=new Js,Po=new I,gs=new I,xs=new I,vs=new I,Rr=new I,Ms=new I,Do=new I,Ss=new I;class Kt extends Et{constructor(e=new wt,t=new Xs){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),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 t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(Co.copy(r).invert(),Jn.copy(e.ray).applyMatrix4(Co),!(n.boundingBox!==null&&Jn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Jn)))}_computeIntersections(e,t,n){let s;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,d=r.attributes.uv1,m=r.attributes.normal,h=r.groups,_=r.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,E=h.length;vt.far?null:{distance:l,point:Ss.clone(),object:i}}function Es(i,e,t,n,s,r,a,o,c,l){i.getVertexPosition(o,gs),i.getVertexPosition(c,xs),i.getVertexPosition(l,vs);const d=_h(i,e,t,n,gs,xs,vs,Do);if(d){const m=new I;Zt.getBarycoord(Do,gs,xs,vs,m),s&&(d.uv=Zt.getInterpolatedAttribute(s,o,c,l,m,new we)),r&&(d.uv1=Zt.getInterpolatedAttribute(r,o,c,l,m,new we)),a&&(d.normal=Zt.getInterpolatedAttribute(a,o,c,l,m,new I),d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1));const h={a:o,b:c,c:l,normal:new I,materialIndex:0};Zt.getNormal(gs,xs,vs,h.normal),d.face=h,d.barycoord=m}return d}class gh extends It{constructor(e=null,t=1,n=1,s,r,a,o,c,l=At,d=At,m,h){super(null,a,o,c,l,d,s,r,m,h),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Cr=new I,xh=new I,vh=new Fe;class Bn{constructor(e=new I(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const s=Cr.subVectors(n,t).cross(xh.subVectors(e,t)).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,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const s=e.delta(Cr),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||vh.getNormalMatrix(e),s=this.coplanarPoint(Cr).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Qn=new Js,Mh=new we(.5,.5),ys=new I;class Wa{constructor(e=new Bn,t=new Bn,n=new Bn,s=new Bn,r=new Bn,a=new Bn){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=dn,n=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],d=r[4],m=r[5],h=r[6],_=r[7],v=r[8],E=r[9],p=r[10],u=r[11],A=r[12],R=r[13],M=r[14],T=r[15];if(s[0].setComponents(l-a,_-d,u-v,T-A).normalize(),s[1].setComponents(l+a,_+d,u+v,T+A).normalize(),s[2].setComponents(l+o,_+m,u+E,T+R).normalize(),s[3].setComponents(l-o,_-m,u-E,T-R).normalize(),n)s[4].setComponents(c,h,p,M).normalize(),s[5].setComponents(l-c,_-h,u-p,T-M).normalize();else if(s[4].setComponents(l-c,_-h,u-p,T-M).normalize(),t===dn)s[5].setComponents(l+c,_+h,u+p,T+M).normalize();else if(t===Qi)s[5].setComponents(c,h,p,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Qn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Qn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Qn)}intersectsSprite(e){Qn.center.set(0,0,0);const t=Mh.distanceTo(e.center);return Qn.radius=.7071067811865476+t,Qn.applyMatrix4(e.matrixWorld),this.intersectsSphere(Qn)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)0?e.max.x:e.min.x,ys.y=s.normal.y>0?e.max.y:e.min.y,ys.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(ys)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Ys extends ri{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ie(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const qs=new I,Zs=new I,Lo=new at,Wi=new Qs,bs=new Js,Pr=new I,Io=new I;class Hl extends Et{constructor(e=new wt,t=new Ys){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let s=1,r=t.count;s0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;rn)return;Pr.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Pr);if(!(le.far))return{distance:l,point:Io.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const Uo=new I,No=new I;class Fo extends Hl{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let s=0,r=t.count;s0?1:-1,d.push(te.x,te.y,te.z),m.push(de/w),m.push(1-he/g),Y+=1}}for(let he=0;he0&&R(!0),t>0&&R(!1)),this.setIndex(d),this.setAttribute("position",new gt(m,3)),this.setAttribute("normal",new gt(h,3)),this.setAttribute("uv",new gt(_,2));function A(){const M=new I,T=new I;let S=0;const w=(t-e)/n;for(let g=0;g<=r;g++){const b=[],L=g/r,D=L*(t-e)+e;for(let B=0;B<=s;B++){const Z=B/s,W=Z*c+o,O=Math.sin(W),H=Math.cos(W);T.x=D*O,T.y=-L*n+p,T.z=D*H,m.push(T.x,T.y,T.z),M.set(O,w,H).normalize(),h.push(M.x,M.y,M.z),_.push(Z,1-L),b.push(v++)}E.push(b)}for(let g=0;g0||b!==0)&&(d.push(L,D,Z),S+=3),(t>0||b!==r-1)&&(d.push(D,B,Z),S+=3)}l.addGroup(u,S,0),u+=S}function R(M){const T=v,S=new we,w=new I;let g=0;const b=M===!0?e:t,L=M===!0?1:-1;for(let B=1;B<=s;B++)m.push(0,p*L,0),h.push(0,L,0),_.push(.5,.5),v++;const D=v;for(let B=0;B<=s;B++){const W=B/s*c+o,O=Math.cos(W),H=Math.sin(W);w.x=b*H,w.y=p*L,w.z=b*O,m.push(w.x,w.y,w.z),h.push(0,L,0),S.x=O*.5+.5,S.y=H*.5*L+.5,_.push(S.x,S.y),v++}for(let B=0;B0)&&_.push(R,M,S),(u!==n-1||c0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new Ie().setHex(s.value);break;case"v2":this.uniforms[n].value=new we().fromArray(s.value);break;case"v3":this.uniforms[n].value=new I().fromArray(s.value);break;case"v4":this.uniforms[n].value=new ht().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Fe().fromArray(s.value);break;case"m4":this.uniforms[n].value=new at().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class wh extends _n{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Rh extends ri{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ie(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Aa,this.normalScale=new we(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Wn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Ch extends ri{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Fc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ph extends ri{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Dh extends Ys{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}class Za extends Et{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ie(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Lh extends Za{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ie(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const Dr=new at,zo=new I,Go=new I;class Ih{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new we(512,512),this.mapType=Wt,this.map=null,this.mapPass=null,this.matrix=new at,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Wa,this._frameExtents=new we(1,1),this._viewportCount=1,this._viewports=[new ht(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;zo.setFromMatrixPosition(e.matrixWorld),t.position.copy(zo),Go.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Go),t.updateMatrixWorld(),Dr.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Dr,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Qi||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Dr)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const As=new I,ws=new kn,an=new I;class Yl extends Et{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new at,this.projectionMatrix=new at,this.projectionMatrixInverse=new at,this.coordinateSystem=dn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),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.matrixWorld.decompose(As,ws,an),an.x===1&&an.y===1&&an.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(As,ws,an.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(As,ws,an),an.x===1&&an.y===1&&an.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(As,ws,an.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const On=new I,Vo=new we,Ho=new we;class qt extends Yl{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),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 t=.5*this.getFilmHeight()/e;this.fov=Ra*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Fs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ra*2*Math.atan(Math.tan(Fs*.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,t,n){On.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(On.x,On.y).multiplyScalar(-e/On.z),On.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(On.x,On.y).multiplyScalar(-e/On.z)}getViewSize(e,t){return this.getViewBounds(e,Vo,Ho),t.subVectors(Ho,Vo)}setViewOffset(e,t,n,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Fs*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,t-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Ka extends Yl{constructor(e=-1,t=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=s+t,c=s-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=d*this.view.offsetY,c=o-d*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Uh extends Ih{constructor(){super(new Ka(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Nh extends Za{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.shadow=new Uh}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class Fh extends Za{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}const yi=-90,bi=1;class Oh extends Et{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new qt(yi,bi,e,t);s.layers=this.layers,this.add(s);const r=new qt(yi,bi,e,t);r.layers=this.layers,this.add(r);const a=new qt(yi,bi,e,t);a.layers=this.layers,this.add(a);const o=new qt(yi,bi,e,t);o.layers=this.layers,this.add(o);const c=new qt(yi,bi,e,t);c.layers=this.layers,this.add(c);const l=new qt(yi,bi,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===dn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Qi)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,d]=this.children,m=e.getRenderTarget(),h=e.getActiveCubeFace(),_=e.getActiveMipmapLevel(),v=e.xr.enabled;e.xr.enabled=!1;const E=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let p=!1;e.isWebGLRenderer===!0?p=e.state.buffers.depth.getReversed():p=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=E,e.setRenderTarget(n,5,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,d),e.setRenderTarget(m,h,_),e.xr.enabled=v,n.texture.needsPMREMUpdate=!0}}class Bh extends qt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const ko=new at;class zh{constructor(e,t,n=0,s=1/0){this.ray=new Qs(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new Ha,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):We("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return ko.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(ko),this}intersectObject(e,t=!0,n=[]){return Ca(e,this,n,t),n.sort(Wo),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s_.start-v.start);let h=0;for(let _=1;_ 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,ru=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,au=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,ou=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,lu=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,cu=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,hu=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,uu=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec4( 1.0 ); +#endif +#ifdef USE_COLOR_ALPHA + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,du=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,fu=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,pu=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,mu=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,_u=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,gu=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,xu=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,vu="gl_FragColor = linearToOutputTexel( gl_FragColor );",Mu=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +}`,Su=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,Eu=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,yu=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,bu=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Tu=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Au=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,wu=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Ru=`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,Cu=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Pu=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,Du=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Lu=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,Iu=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Uu=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,Nu=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Fu=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Ou=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Bu=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,zu=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Gu=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,Vu=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,Hu=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,ku=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,Wu=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,Xu=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,Yu=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,qu=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,Zu=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,Ku=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,$u=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,Ju=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,Qu=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,ju=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,ed=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,td=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,nd=`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,id=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,sd=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,rd=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,ad=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,od=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,ld=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,cd=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,hd=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,ud=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,dd=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,fd=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,pd=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,md=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,_d=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,gd=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,xd=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,vd=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,Md=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,Sd=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,Ed=`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,yd=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,bd=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,Td=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,Ad=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,wd=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,Rd=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,Cd=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,Pd=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,Dd=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,Ld=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,Id=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,Ud=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,Nd=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Fd=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,Od=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,Bd=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,zd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,Gd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,Vd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,Hd=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const kd=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,Wd=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,Xd=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,Yd=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,qd=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,Zd=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,Kd=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,$d=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,Jd=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,Qd=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,jd=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,ef=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,tf=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,nf=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,sf=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,rf=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,af=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,of=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,lf=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,cf=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,hf=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,uf=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,df=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,ff=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,pf=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,mf=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,_f=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,gf=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,xf=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,vf=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Mf=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Sf=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,Ef=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,yf=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,ze={alphahash_fragment:kh,alphahash_pars_fragment:Wh,alphamap_fragment:Xh,alphamap_pars_fragment:Yh,alphatest_fragment:qh,alphatest_pars_fragment:Zh,aomap_fragment:Kh,aomap_pars_fragment:$h,batching_pars_vertex:Jh,batching_vertex:Qh,begin_vertex:jh,beginnormal_vertex:eu,bsdfs:tu,iridescence_fragment:nu,bumpmap_pars_fragment:iu,clipping_planes_fragment:su,clipping_planes_pars_fragment:ru,clipping_planes_pars_vertex:au,clipping_planes_vertex:ou,color_fragment:lu,color_pars_fragment:cu,color_pars_vertex:hu,color_vertex:uu,common:du,cube_uv_reflection_fragment:fu,defaultnormal_vertex:pu,displacementmap_pars_vertex:mu,displacementmap_vertex:_u,emissivemap_fragment:gu,emissivemap_pars_fragment:xu,colorspace_fragment:vu,colorspace_pars_fragment:Mu,envmap_fragment:Su,envmap_common_pars_fragment:Eu,envmap_pars_fragment:yu,envmap_pars_vertex:bu,envmap_physical_pars_fragment:Nu,envmap_vertex:Tu,fog_vertex:Au,fog_pars_vertex:wu,fog_fragment:Ru,fog_pars_fragment:Cu,gradientmap_pars_fragment:Pu,lightmap_pars_fragment:Du,lights_lambert_fragment:Lu,lights_lambert_pars_fragment:Iu,lights_pars_begin:Uu,lights_toon_fragment:Fu,lights_toon_pars_fragment:Ou,lights_phong_fragment:Bu,lights_phong_pars_fragment:zu,lights_physical_fragment:Gu,lights_physical_pars_fragment:Vu,lights_fragment_begin:Hu,lights_fragment_maps:ku,lights_fragment_end:Wu,lightprobes_pars_fragment:Xu,logdepthbuf_fragment:Yu,logdepthbuf_pars_fragment:qu,logdepthbuf_pars_vertex:Zu,logdepthbuf_vertex:Ku,map_fragment:$u,map_pars_fragment:Ju,map_particle_fragment:Qu,map_particle_pars_fragment:ju,metalnessmap_fragment:ed,metalnessmap_pars_fragment:td,morphinstance_vertex:nd,morphcolor_vertex:id,morphnormal_vertex:sd,morphtarget_pars_vertex:rd,morphtarget_vertex:ad,normal_fragment_begin:od,normal_fragment_maps:ld,normal_pars_fragment:cd,normal_pars_vertex:hd,normal_vertex:ud,normalmap_pars_fragment:dd,clearcoat_normal_fragment_begin:fd,clearcoat_normal_fragment_maps:pd,clearcoat_pars_fragment:md,iridescence_pars_fragment:_d,opaque_fragment:gd,packing:xd,premultiplied_alpha_fragment:vd,project_vertex:Md,dithering_fragment:Sd,dithering_pars_fragment:Ed,roughnessmap_fragment:yd,roughnessmap_pars_fragment:bd,shadowmap_pars_fragment:Td,shadowmap_pars_vertex:Ad,shadowmap_vertex:wd,shadowmask_pars_fragment:Rd,skinbase_vertex:Cd,skinning_pars_vertex:Pd,skinning_vertex:Dd,skinnormal_vertex:Ld,specularmap_fragment:Id,specularmap_pars_fragment:Ud,tonemapping_fragment:Nd,tonemapping_pars_fragment:Fd,transmission_fragment:Od,transmission_pars_fragment:Bd,uv_pars_fragment:zd,uv_pars_vertex:Gd,uv_vertex:Vd,worldpos_vertex:Hd,background_vert:kd,background_frag:Wd,backgroundCube_vert:Xd,backgroundCube_frag:Yd,cube_vert:qd,cube_frag:Zd,depth_vert:Kd,depth_frag:$d,distance_vert:Jd,distance_frag:Qd,equirect_vert:jd,equirect_frag:ef,linedashed_vert:tf,linedashed_frag:nf,meshbasic_vert:sf,meshbasic_frag:rf,meshlambert_vert:af,meshlambert_frag:of,meshmatcap_vert:lf,meshmatcap_frag:cf,meshnormal_vert:hf,meshnormal_frag:uf,meshphong_vert:df,meshphong_frag:ff,meshphysical_vert:pf,meshphysical_frag:mf,meshtoon_vert:_f,meshtoon_frag:gf,points_vert:xf,points_frag:vf,shadow_vert:Mf,shadow_frag:Sf,sprite_vert:Ef,sprite_frag:yf},pe={common:{diffuse:{value:new Ie(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Fe},alphaMap:{value:null},alphaMapTransform:{value:new Fe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Fe}},envmap:{envMap:{value:null},envMapRotation:{value:new Fe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Fe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Fe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Fe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Fe},normalScale:{value:new we(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Fe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Fe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Fe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Fe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ie(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new I},probesMax:{value:new I},probesResolution:{value:new I}},points:{diffuse:{value:new Ie(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Fe},alphaTest:{value:0},uvTransform:{value:new Fe}},sprite:{diffuse:{value:new Ie(16777215)},opacity:{value:1},center:{value:new we(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Fe},alphaMap:{value:null},alphaMapTransform:{value:new Fe},alphaTest:{value:0}}},ln={basic:{uniforms:Nt([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:ze.meshbasic_vert,fragmentShader:ze.meshbasic_frag},lambert:{uniforms:Nt([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new Ie(0)},envMapIntensity:{value:1}}]),vertexShader:ze.meshlambert_vert,fragmentShader:ze.meshlambert_frag},phong:{uniforms:Nt([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new Ie(0)},specular:{value:new Ie(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ze.meshphong_vert,fragmentShader:ze.meshphong_frag},standard:{uniforms:Nt([pe.common,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.roughnessmap,pe.metalnessmap,pe.fog,pe.lights,{emissive:{value:new Ie(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag},toon:{uniforms:Nt([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new Ie(0)}}]),vertexShader:ze.meshtoon_vert,fragmentShader:ze.meshtoon_frag},matcap:{uniforms:Nt([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:ze.meshmatcap_vert,fragmentShader:ze.meshmatcap_frag},points:{uniforms:Nt([pe.points,pe.fog]),vertexShader:ze.points_vert,fragmentShader:ze.points_frag},dashed:{uniforms:Nt([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ze.linedashed_vert,fragmentShader:ze.linedashed_frag},depth:{uniforms:Nt([pe.common,pe.displacementmap]),vertexShader:ze.depth_vert,fragmentShader:ze.depth_frag},normal:{uniforms:Nt([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:ze.meshnormal_vert,fragmentShader:ze.meshnormal_frag},sprite:{uniforms:Nt([pe.sprite,pe.fog]),vertexShader:ze.sprite_vert,fragmentShader:ze.sprite_frag},background:{uniforms:{uvTransform:{value:new Fe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ze.background_vert,fragmentShader:ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Fe}},vertexShader:ze.backgroundCube_vert,fragmentShader:ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ze.cube_vert,fragmentShader:ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ze.equirect_vert,fragmentShader:ze.equirect_frag},distance:{uniforms:Nt([pe.common,pe.displacementmap,{referencePosition:{value:new I},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ze.distance_vert,fragmentShader:ze.distance_frag},shadow:{uniforms:Nt([pe.lights,pe.fog,{color:{value:new Ie(0)},opacity:{value:1}}]),vertexShader:ze.shadow_vert,fragmentShader:ze.shadow_frag}};ln.physical={uniforms:Nt([ln.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Fe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Fe},clearcoatNormalScale:{value:new we(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Fe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Fe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Fe},sheen:{value:0},sheenColor:{value:new Ie(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Fe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Fe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Fe},transmissionSamplerSize:{value:new we},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Fe},attenuationDistance:{value:0},attenuationColor:{value:new Ie(0)},specularColor:{value:new Ie(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Fe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Fe},anisotropyVector:{value:new we},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Fe}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag};const Rs={r:0,b:0,g:0},bf=new at,Zl=new Fe;Zl.set(-1,0,0,0,1,0,0,0,1);function Tf(i,e,t,n,s,r){const a=new Ie(0);let o=s===!0?0:1,c,l,d=null,m=0,h=null;function _(A){let R=A.isScene===!0?A.background:null;if(R&&R.isTexture){const M=A.backgroundBlurriness>0;R=e.get(R,M)}return R}function v(A){let R=!1;const M=_(A);M===null?p(a,o):M&&M.isColor&&(p(M,1),R=!0);const T=i.xr.getEnvironmentBlendMode();T==="additive"?t.buffers.color.setClear(0,0,0,1,r):T==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||R)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function E(A,R){const M=_(R);M&&(M.isCubeTexture||M.mapping===$s)?(l===void 0&&(l=new Kt(new ji(1,1,1),new _n({name:"BackgroundCubeMaterial",uniforms:Ui(ln.backgroundCube.uniforms),vertexShader:ln.backgroundCube.vertexShader,fragmentShader:ln.backgroundCube.fragmentShader,side:zt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(T,S,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(bf.makeRotationFromEuler(R.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Zl),l.material.toneMapped=Xe.getTransfer(M.colorSpace)!==Je,(d!==M||m!==M.version||h!==i.toneMapping)&&(l.material.needsUpdate=!0,d=M,m=M.version,h=i.toneMapping),l.layers.enableAll(),A.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new Kt(new es(2,2),new _n({name:"BackgroundMaterial",uniforms:Ui(ln.background.uniforms),vertexShader:ln.background.vertexShader,fragmentShader:ln.background.fragmentShader,side:Hn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.toneMapped=Xe.getTransfer(M.colorSpace)!==Je,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(d!==M||m!==M.version||h!==i.toneMapping)&&(c.material.needsUpdate=!0,d=M,m=M.version,h=i.toneMapping),c.layers.enableAll(),A.unshift(c,c.geometry,c.material,0,0,null))}function p(A,R){A.getRGB(Rs,Xl(i)),t.buffers.color.setClear(Rs.r,Rs.g,Rs.b,R,r)}function u(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(A,R=1){a.set(A),o=R,p(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(A){o=A,p(a,o)},render:v,addToRenderList:E,dispose:u}}function Af(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=h(null);let r=s,a=!1;function o(D,B,Z,W,O){let H=!1;const Y=m(D,W,Z,B);r!==Y&&(r=Y,l(r.object)),H=_(D,W,Z,O),H&&v(D,W,Z,O),O!==null&&e.update(O,i.ELEMENT_ARRAY_BUFFER),(H||a)&&(a=!1,M(D,B,Z,W),O!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function c(){return i.createVertexArray()}function l(D){return i.bindVertexArray(D)}function d(D){return i.deleteVertexArray(D)}function m(D,B,Z,W){const O=W.wireframe===!0;let H=n[B.id];H===void 0&&(H={},n[B.id]=H);const Y=D.isInstancedMesh===!0?D.id:0;let ee=H[Y];ee===void 0&&(ee={},H[Y]=ee);let te=ee[Z.id];te===void 0&&(te={},ee[Z.id]=te);let he=te[O];return he===void 0&&(he=h(c()),te[O]=he),he}function h(D){const B=[],Z=[],W=[];for(let O=0;O=0){const me=O[te];let de=H[te];if(de===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(de=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(de=D.instanceColor)),me===void 0||me.attribute!==de||de&&me.data!==de.data)return!0;Y++}return r.attributesNum!==Y||r.index!==W}function v(D,B,Z,W){const O={},H=B.attributes;let Y=0;const ee=Z.getAttributes();for(const te in ee)if(ee[te].location>=0){let me=H[te];me===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(me=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(me=D.instanceColor));const de={};de.attribute=me,me&&me.data&&(de.data=me.data),O[te]=de,Y++}r.attributes=O,r.attributesNum=Y,r.index=W}function E(){const D=r.newAttributes;for(let B=0,Z=D.length;B=0){let he=O[ee];if(he===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(he=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(he=D.instanceColor)),he!==void 0){const me=he.normalized,de=he.itemSize,Ye=e.get(he);if(Ye===void 0)continue;const st=Ye.buffer,qe=Ye.type,j=Ye.bytesPerElement,ae=qe===i.INT||qe===i.UNSIGNED_INT||he.gpuType===Ia;if(he.isInterleavedBufferAttribute){const ne=he.data,Ae=ne.stride,Ue=he.offset;if(ne.isInstancedInterleavedBuffer){for(let Re=0;Re0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const d=c(l);d!==l&&(De("WebGLRenderer:",l,"not supported, using",d,"instead."),l=d);const m=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&De("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const _=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),E=i.getParameter(i.MAX_TEXTURE_SIZE),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),u=i.getParameter(i.MAX_VERTEX_ATTRIBS),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),R=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),T=i.getParameter(i.MAX_SAMPLES),S=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:m,reversedDepthBuffer:h,maxTextures:_,maxVertexTextures:v,maxTextureSize:E,maxCubemapSize:p,maxAttributes:u,maxVertexUniforms:A,maxVaryings:R,maxFragmentUniforms:M,maxSamples:T,samples:S}}function Cf(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new Bn,o=new Fe,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(m,h){const _=m.length!==0||h||n!==0||s;return s=h,n=m.length,_},this.beginShadows=function(){r=!0,d(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(m,h){t=d(m,h,0)},this.setState=function(m,h,_){const v=m.clippingPlanes,E=m.clipIntersection,p=m.clipShadows,u=i.get(m);if(!s||v===null||v.length===0||r&&!p)r?d(null):l();else{const A=r?0:n,R=A*4;let M=u.clippingState||null;c.value=M,M=d(v,h,R,_);for(let T=0;T!==R;++T)M[T]=t[T];u.clippingState=M,this.numIntersection=E?this.numPlanes:0,this.numPlanes+=A}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function d(m,h,_,v){const E=m!==null?m.length:0;let p=null;if(E!==0){if(p=c.value,v!==!0||p===null){const u=_+E*4,A=h.matrixWorldInverse;o.getNormalMatrix(A),(p===null||p.length0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=jo(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Qo(),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())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?T:0,T,T),m.setRenderTarget(s),u&&m.render(E,c),m.render(e,c)}m.toneMapping=_,m.autoClear=h,e.background=A}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===ii||e.mapping===Li;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=jo()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Qo());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;Ti(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,Xi)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rv-Gn?n-v+Gn:0),u=4*(this._cubeSize-E);c.envMap.value=e.texture,c.roughness.value=_,c.mipInt.value=v-t,Ti(r,p,u,3*E,2*E),s.setRenderTarget(r),s.render(o,Xi),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=v-n,Ti(e,p,u,3*E,2*E),s.setRenderTarget(e),s.render(o,Xi)}_blur(e,t,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",r),this._halfBlur(a,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&We("blur direction must be either latitudinal or longitudinal!");const d=3,m=this._lodMeshes[s];m.material=l;const h=l.uniforms,_=this._sizeLods[n]-1,v=isFinite(r)?Math.PI/(2*_):2*Math.PI/(2*ei-1),E=r/v,p=isFinite(r)?1+Math.floor(d*E):ei;p>ei&&De(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${ei}`);const u=[];let A=0;for(let w=0;wR-Gn?s-R+Gn:0),S=4*(this._cubeSize-M);Ti(t,T,S,3*M,2*M),c.setRenderTarget(t),c.render(m,Xi)}}function Lf(i){const e=[],t=[],n=[];let s=i;const r=i-Gn+1+Zo.length;for(let a=0;ai-Gn?c=Zo[a-i+Gn-1]:a===0&&(c=0),t.push(c);const l=1/(o-2),d=-l,m=1+l,h=[d,d,m,d,m,m,d,d,m,m,d,m],_=6,v=6,E=3,p=2,u=1,A=new Float32Array(E*v*_),R=new Float32Array(p*v*_),M=new Float32Array(u*v*_);for(let S=0;S<_;S++){const w=S%3*2/3-1,g=S>2?0:-1,b=[w,g,0,w+2/3,g,0,w+2/3,g+1,0,w,g,0,w+2/3,g+1,0,w,g+1,0];A.set(b,E*v*S),R.set(h,p*v*S);const L=[S,S,S,S,S,S];M.set(L,u*v*S)}const T=new wt;T.setAttribute("position",new sn(A,E)),T.setAttribute("uv",new sn(R,p)),T.setAttribute("faceIndex",new sn(M,u)),n.push(new Kt(T,null)),s>Gn&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Jo(i,e,t){const n=new pn(i,e,t);return n.texture.mapping=$s,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ti(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function If(i,e,t){return new _n({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Pf,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:js(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:yn,depthTest:!1,depthWrite:!1})}function Uf(i,e,t){const n=new Float32Array(ei),s=new I(0,1,0);return new _n({name:"SphericalGaussianBlur",defines:{n:ei,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:js(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:yn,depthTest:!1,depthWrite:!1})}function Qo(){return new _n({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:js(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:yn,depthTest:!1,depthWrite:!1})}function jo(){return new _n({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:js(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:yn,depthTest:!1,depthWrite:!1})}function js(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class Kl extends pn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new kl(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new ji(5,5,5),r=new _n({name:"CubemapFromEquirect",uniforms:Ui(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:zt,blending:yn});r.uniforms.tEquirect.value=t;const a=new Kt(s,r),o=t.minFilter;return t.minFilter===ti&&(t.minFilter=Lt),new Oh(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(r)}}function Nf(i){let e=new WeakMap,t=new WeakMap,n=null;function s(h,_=!1){return h==null?null:_?a(h):r(h)}function r(h){if(h&&h.isTexture){const _=h.mapping;if(_===ir||_===sr)if(e.has(h)){const v=e.get(h).texture;return o(v,h.mapping)}else{const v=h.image;if(v&&v.height>0){const E=new Kl(v.height);return E.fromEquirectangularTexture(i,h),e.set(h,E),h.addEventListener("dispose",l),o(E.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const _=h.mapping,v=_===ir||_===sr,E=_===ii||_===Li;if(v||E){let p=t.get(h);const u=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==u)return n===null&&(n=new $o(i)),p=v?n.fromEquirectangular(h,p):n.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,t.set(h,p),p.texture;if(p!==void 0)return p.texture;{const A=h.image;return v&&A&&A.height>0||E&&A&&c(A)?(n===null&&(n=new $o(i)),p=v?n.fromEquirectangular(h):n.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,t.set(h,p),h.addEventListener("dispose",d),p.texture):null}}}return h}function o(h,_){return _===ir?h.mapping=ii:_===sr&&(h.mapping=Li),h}function c(h){let _=0;const v=6;for(let E=0;E=65535?zl:Bl)(h,1);p.version=E;const u=r.get(m);u&&e.remove(u),r.set(m,p)}function d(m){const h=r.get(m);if(h){const _=m.index;_!==null&&h.version<_.version&&l(m)}else l(m);return r.get(m)}return{get:o,update:c,getWireframeAttribute:d}}function Bf(i,e,t){let n;function s(m){n=m}let r,a;function o(m){r=m.type,a=m.bytesPerElement}function c(m,h){i.drawElements(n,h,r,m*a),t.update(h,n,1)}function l(m,h,_){_!==0&&(i.drawElementsInstanced(n,h,r,m*a,_),t.update(h,n,_))}function d(m,h,_){if(_===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,h,0,r,m,0,_);let E=0;for(let p=0;p<_;p++)E+=h[p];t.update(E,n,1)}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=d}function zf(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(r/3);break;case i.LINES:t.lines+=o*(r/2);break;case i.LINE_STRIP:t.lines+=o*(r-1);break;case i.LINE_LOOP:t.lines+=o*r;break;case i.POINTS:t.points+=o*r;break;default:We("WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function Gf(i,e,t){const n=new WeakMap,s=new ht;function r(a,o,c){const l=a.morphTargetInfluences,d=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,m=d!==void 0?d.length:0;let h=n.get(o);if(h===void 0||h.count!==m){let b=function(){w.dispose(),n.delete(o),o.removeEventListener("dispose",b)};h!==void 0&&h.texture.dispose();const _=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,E=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],u=o.morphAttributes.normal||[],A=o.morphAttributes.color||[];let R=0;_===!0&&(R=1),v===!0&&(R=2),E===!0&&(R=3);let M=o.attributes.position.count*R,T=1;M>e.maxTextureSize&&(T=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const S=new Float32Array(M*T*4*m),w=new Fl(S,M,T,m);w.type=un,w.needsUpdate=!0;const g=R*4;for(let L=0;L + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),d=new Kt(c,l),m=new Ka(-1,1,1,-1,0,1);let h=null,_=null,v=!1,E,p=null,u=[],A=!1;this.setSize=function(R,M){a.setSize(R,M),o.setSize(R,M);for(let T=0;T0&&u[0].isRenderPass===!0;const M=a.width,T=a.height;for(let S=0;S0)return i;const s=e*t;let r=el[s];if(r===void 0&&(r=new Float32Array(s),el[s]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(r,o)}return r}function yt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t0&&(this.seq=s.concat(r))}setValue(e,t,n,s){const r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){const s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,s)}}static seqWithValue(e,t){const n=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&n.push(a)}return n}}function al(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Up=37297;let Np=0;function Fp(i,e){const t=i.split(` +`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return n.join(` +`)}const ol=new Fe;function Op(i){Xe._getMatrix(ol,Xe.workingColorSpace,i);const e=`mat3( ${ol.elements.map(t=>t.toFixed(4))} )`;switch(Xe.getTransfer(i)){case Vs:return[e,"LinearTransferOETF"];case Je:return[e,"sRGBTransferOETF"];default:return De("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function ll(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+Fp(i.getShaderSource(e),o)}else return r}function Bp(i,e){const t=Op(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const zp={[Ml]:"Linear",[Sl]:"Reinhard",[El]:"Cineon",[yl]:"ACESFilmic",[Tl]:"AgX",[Al]:"Neutral",[bl]:"Custom"};function Gp(i,e){const t=zp[e];return t===void 0?(De("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Cs=new I;function Vp(){Xe.getLuminanceCoefficients(Cs);const i=Cs.x.toFixed(4),e=Cs.y.toFixed(4),t=Cs.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function Hp(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ki).join(` +`)}function kp(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` +`)}function Wp(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function Da(i){return i.replace(Xp,qp)}const Yp=new Map;function qp(i,e){let t=ze[e];if(t===void 0){const n=Yp.get(e);if(n!==void 0)t=ze[n],De('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Da(t)}const Zp=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function ul(i){return i.replace(Zp,Kp)}function Kp(i,e,t,n){let s="";for(let r=parseInt(e);r0&&(p+=` +`),u=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Ki).join(` +`),u.length>0&&(u+=` +`)):(p=[dl(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+d:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(Ki).join(` +`),u=[dl(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+d:"",t.envMap?"#define "+m:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==fn?"#define TONE_MAPPING":"",t.toneMapping!==fn?ze.tonemapping_pars_fragment:"",t.toneMapping!==fn?Gp("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ze.colorspace_pars_fragment,Bp("linearToOutputTexel",t.outputColorSpace),Vp(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(Ki).join(` +`)),a=Da(a),a=cl(a,t),a=hl(a,t),o=Da(o),o=cl(o,t),o=hl(o,t),a=ul(a),o=ul(o),t.isRawShaderMaterial!==!0&&(A=`#version 300 es +`,p=[_,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+p,u=["#define varying in",t.glslVersion===po?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===po?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+u);const R=A+p+a,M=A+u+o,T=al(s,s.VERTEX_SHADER,R),S=al(s,s.FRAGMENT_SHADER,M);s.attachShader(E,T),s.attachShader(E,S),t.index0AttributeName!==void 0?s.bindAttribLocation(E,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(E,0,"position"),s.linkProgram(E);function w(D){if(i.debug.checkShaderErrors){const B=s.getProgramInfoLog(E)||"",Z=s.getShaderInfoLog(T)||"",W=s.getShaderInfoLog(S)||"",O=B.trim(),H=Z.trim(),Y=W.trim();let ee=!0,te=!0;if(s.getProgramParameter(E,s.LINK_STATUS)===!1)if(ee=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,E,T,S);else{const he=ll(s,T,"vertex"),me=ll(s,S,"fragment");We("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(E,s.VALIDATE_STATUS)+` + +Material Name: `+D.name+` +Material Type: `+D.type+` + +Program Info Log: `+O+` +`+he+` +`+me)}else O!==""?De("WebGLProgram: Program Info Log:",O):(H===""||Y==="")&&(te=!1);te&&(D.diagnostics={runnable:ee,programLog:O,vertexShader:{log:H,prefix:p},fragmentShader:{log:Y,prefix:u}})}s.deleteShader(T),s.deleteShader(S),g=new Os(s,E),b=Wp(s,E)}let g;this.getUniforms=function(){return g===void 0&&w(this),g};let b;this.getAttributes=function(){return b===void 0&&w(this),b};let L=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return L===!1&&(L=s.getProgramParameter(E,Up)),L},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(E),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Np++,this.cacheKey=e,this.usedTimes=1,this.program=E,this.vertexShader=T,this.fragmentShader=S,this}let am=0;class om{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new lm(e),t.set(e,n)),n}}class lm{constructor(e){this.id=am++,this.code=e,this.usedTimes=0}}function cm(i){return i===si||i===Bs||i===zs}function hm(i,e,t,n,s,r){const a=new Ha,o=new om,c=new Set,l=[],d=new Map,m=n.logarithmicDepthBuffer;let h=n.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(g){return c.add(g),g===0?"uv":`uv${g}`}function E(g,b,L,D,B,Z){const W=D.fog,O=B.geometry,H=g.isMeshStandardMaterial||g.isMeshLambertMaterial||g.isMeshPhongMaterial?D.environment:null,Y=g.isMeshStandardMaterial||g.isMeshLambertMaterial&&!g.envMap||g.isMeshPhongMaterial&&!g.envMap,ee=e.get(g.envMap||H,Y),te=ee&&ee.mapping===$s?ee.image.height:null,he=_[g.type];g.precision!==null&&(h=n.getMaxPrecision(g.precision),h!==g.precision&&De("WebGLProgram.getParameters:",g.precision,"not supported, using",h,"instead."));const me=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,de=me!==void 0?me.length:0;let Ye=0;O.morphAttributes.position!==void 0&&(Ye=1),O.morphAttributes.normal!==void 0&&(Ye=2),O.morphAttributes.color!==void 0&&(Ye=3);let st,qe,j,ae;if(he){const J=ln[he];st=J.vertexShader,qe=J.fragmentShader}else{st=g.vertexShader,qe=g.fragmentShader;const J=o.getVertexShaderStage(g),Te=o.getFragmentShaderStage(g);o.update(g,J,Te),j=J.id,ae=Te.id}const ne=i.getRenderTarget(),Ae=i.state.buffers.depth.getReversed(),Ue=B.isInstancedMesh===!0,Re=B.isBatchedMesh===!0,rt=!!g.map,Ge=!!g.matcap,Ze=!!ee,ke=!!g.aoMap,Be=!!g.lightMap,ot=!!g.bumpMap&&g.wireframe===!1,ut=!!g.normalMap,ft=!!g.displacementMap,pt=!!g.emissiveMap,lt=!!g.metalnessMap,ct=!!g.roughnessMap,U=g.anisotropy>0,Rt=g.clearcoat>0,$e=g.dispersion>0,y=g.iridescence>0,f=g.sheen>0,F=g.transmission>0,z=U&&!!g.anisotropyMap,K=Rt&&!!g.clearcoatMap,se=Rt&&!!g.clearcoatNormalMap,ie=Rt&&!!g.clearcoatRoughnessMap,q=y&&!!g.iridescenceMap,Q=y&&!!g.iridescenceThicknessMap,oe=f&&!!g.sheenColorMap,Se=f&&!!g.sheenRoughnessMap,ue=!!g.specularMap,le=!!g.specularColorMap,Ee=!!g.specularIntensityMap,Ce=F&&!!g.transmissionMap,Ne=F&&!!g.thicknessMap,P=!!g.gradientMap,re=!!g.alphaMap,$=g.alphaTest>0,ce=!!g.alphaHash,fe=!!g.extensions;let C=fn;g.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(C=i.toneMapping);const X={shaderID:he,shaderType:g.type,shaderName:g.name,vertexShader:st,fragmentShader:qe,defines:g.defines,customVertexShaderID:j,customFragmentShaderID:ae,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:h,batching:Re,batchingColor:Re&&B._colorsTexture!==null,instancing:Ue,instancingColor:Ue&&B.instanceColor!==null,instancingMorph:Ue&&B.morphTexture!==null,outputColorSpace:ne===null?i.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:Xe.workingColorSpace,alphaToCoverage:!!g.alphaToCoverage,map:rt,matcap:Ge,envMap:Ze,envMapMode:Ze&&ee.mapping,envMapCubeUVHeight:te,aoMap:ke,lightMap:Be,bumpMap:ot,normalMap:ut,displacementMap:ft,emissiveMap:pt,normalMapObjectSpace:ut&&g.normalMapType===Oc,normalMapTangentSpace:ut&&g.normalMapType===Aa,packedNormalMap:ut&&g.normalMapType===Aa&&cm(g.normalMap.format),metalnessMap:lt,roughnessMap:ct,anisotropy:U,anisotropyMap:z,clearcoat:Rt,clearcoatMap:K,clearcoatNormalMap:se,clearcoatRoughnessMap:ie,dispersion:$e,iridescence:y,iridescenceMap:q,iridescenceThicknessMap:Q,sheen:f,sheenColorMap:oe,sheenRoughnessMap:Se,specularMap:ue,specularColorMap:le,specularIntensityMap:Ee,transmission:F,transmissionMap:Ce,thicknessMap:Ne,gradientMap:P,opaque:g.transparent===!1&&g.blending===Ri&&g.alphaToCoverage===!1,alphaMap:re,alphaTest:$,alphaHash:ce,combine:g.combine,mapUv:rt&&v(g.map.channel),aoMapUv:ke&&v(g.aoMap.channel),lightMapUv:Be&&v(g.lightMap.channel),bumpMapUv:ot&&v(g.bumpMap.channel),normalMapUv:ut&&v(g.normalMap.channel),displacementMapUv:ft&&v(g.displacementMap.channel),emissiveMapUv:pt&&v(g.emissiveMap.channel),metalnessMapUv:lt&&v(g.metalnessMap.channel),roughnessMapUv:ct&&v(g.roughnessMap.channel),anisotropyMapUv:z&&v(g.anisotropyMap.channel),clearcoatMapUv:K&&v(g.clearcoatMap.channel),clearcoatNormalMapUv:se&&v(g.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ie&&v(g.clearcoatRoughnessMap.channel),iridescenceMapUv:q&&v(g.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&v(g.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&v(g.sheenColorMap.channel),sheenRoughnessMapUv:Se&&v(g.sheenRoughnessMap.channel),specularMapUv:ue&&v(g.specularMap.channel),specularColorMapUv:le&&v(g.specularColorMap.channel),specularIntensityMapUv:Ee&&v(g.specularIntensityMap.channel),transmissionMapUv:Ce&&v(g.transmissionMap.channel),thicknessMapUv:Ne&&v(g.thicknessMap.channel),alphaMapUv:re&&v(g.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(ut||U),vertexNormals:!!O.attributes.normal,vertexColors:g.vertexColors,vertexAlphas:g.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:B.isPoints===!0&&!!O.attributes.uv&&(rt||re),fog:!!W,useFog:g.fog===!0,fogExp2:!!W&&W.isFogExp2,flatShading:g.wireframe===!1&&(g.flatShading===!0||O.attributes.normal===void 0&&ut===!1&&(g.isMeshLambertMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isMeshPhysicalMaterial)),sizeAttenuation:g.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:Ae,skinning:B.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:de,morphTextureStride:Ye,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numLightProbeGrids:Z.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:g.dithering,shadowMapEnabled:i.shadowMap.enabled&&L.length>0,shadowMapType:i.shadowMap.type,toneMapping:C,decodeVideoTexture:rt&&g.map.isVideoTexture===!0&&Xe.getTransfer(g.map.colorSpace)===Je,decodeVideoTextureEmissive:pt&&g.emissiveMap.isVideoTexture===!0&&Xe.getTransfer(g.emissiveMap.colorSpace)===Je,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===cn,flipSided:g.side===zt,useDepthPacking:g.depthPacking>=0,depthPacking:g.depthPacking||0,index0AttributeName:g.index0AttributeName,extensionClipCullDistance:fe&&g.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(fe&&g.extensions.multiDraw===!0||Re)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:g.customProgramCacheKey()};return X.vertexUv1s=c.has(1),X.vertexUv2s=c.has(2),X.vertexUv3s=c.has(3),c.clear(),X}function p(g){const b=[];if(g.shaderID?b.push(g.shaderID):(b.push(g.customVertexShaderID),b.push(g.customFragmentShaderID)),g.defines!==void 0)for(const L in g.defines)b.push(L),b.push(g.defines[L]);return g.isRawShaderMaterial===!1&&(u(b,g),A(b,g),b.push(i.outputColorSpace)),b.push(g.customProgramCacheKey),b.join()}function u(g,b){g.push(b.precision),g.push(b.outputColorSpace),g.push(b.envMapMode),g.push(b.envMapCubeUVHeight),g.push(b.mapUv),g.push(b.alphaMapUv),g.push(b.lightMapUv),g.push(b.aoMapUv),g.push(b.bumpMapUv),g.push(b.normalMapUv),g.push(b.displacementMapUv),g.push(b.emissiveMapUv),g.push(b.metalnessMapUv),g.push(b.roughnessMapUv),g.push(b.anisotropyMapUv),g.push(b.clearcoatMapUv),g.push(b.clearcoatNormalMapUv),g.push(b.clearcoatRoughnessMapUv),g.push(b.iridescenceMapUv),g.push(b.iridescenceThicknessMapUv),g.push(b.sheenColorMapUv),g.push(b.sheenRoughnessMapUv),g.push(b.specularMapUv),g.push(b.specularColorMapUv),g.push(b.specularIntensityMapUv),g.push(b.transmissionMapUv),g.push(b.thicknessMapUv),g.push(b.combine),g.push(b.fogExp2),g.push(b.sizeAttenuation),g.push(b.morphTargetsCount),g.push(b.morphAttributeCount),g.push(b.numDirLights),g.push(b.numPointLights),g.push(b.numSpotLights),g.push(b.numSpotLightMaps),g.push(b.numHemiLights),g.push(b.numRectAreaLights),g.push(b.numDirLightShadows),g.push(b.numPointLightShadows),g.push(b.numSpotLightShadows),g.push(b.numSpotLightShadowsWithMaps),g.push(b.numLightProbes),g.push(b.shadowMapType),g.push(b.toneMapping),g.push(b.numClippingPlanes),g.push(b.numClipIntersection),g.push(b.depthPacking)}function A(g,b){a.disableAll(),b.instancing&&a.enable(0),b.instancingColor&&a.enable(1),b.instancingMorph&&a.enable(2),b.matcap&&a.enable(3),b.envMap&&a.enable(4),b.normalMapObjectSpace&&a.enable(5),b.normalMapTangentSpace&&a.enable(6),b.clearcoat&&a.enable(7),b.iridescence&&a.enable(8),b.alphaTest&&a.enable(9),b.vertexColors&&a.enable(10),b.vertexAlphas&&a.enable(11),b.vertexUv1s&&a.enable(12),b.vertexUv2s&&a.enable(13),b.vertexUv3s&&a.enable(14),b.vertexTangents&&a.enable(15),b.anisotropy&&a.enable(16),b.alphaHash&&a.enable(17),b.batching&&a.enable(18),b.dispersion&&a.enable(19),b.batchingColor&&a.enable(20),b.gradientMap&&a.enable(21),b.packedNormalMap&&a.enable(22),b.vertexNormals&&a.enable(23),g.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.reversedDepthBuffer&&a.enable(4),b.skinning&&a.enable(5),b.morphTargets&&a.enable(6),b.morphNormals&&a.enable(7),b.morphColors&&a.enable(8),b.premultipliedAlpha&&a.enable(9),b.shadowMapEnabled&&a.enable(10),b.doubleSided&&a.enable(11),b.flipSided&&a.enable(12),b.useDepthPacking&&a.enable(13),b.dithering&&a.enable(14),b.transmission&&a.enable(15),b.sheen&&a.enable(16),b.opaque&&a.enable(17),b.pointsUvs&&a.enable(18),b.decodeVideoTexture&&a.enable(19),b.decodeVideoTextureEmissive&&a.enable(20),b.alphaToCoverage&&a.enable(21),b.numLightProbeGrids>0&&a.enable(22),b.hasPositionAttribute&&a.enable(23),g.push(a.mask)}function R(g){const b=_[g.type];let L;if(b){const D=ln[b];L=bh.clone(D.uniforms)}else L=g.uniforms;return L}function M(g,b){let L=d.get(b);return L!==void 0?++L.usedTimes:(L=new rm(i,b,g,s),l.push(L),d.set(b,L)),L}function T(g){if(--g.usedTimes===0){const b=l.indexOf(g);l[b]=l[l.length-1],l.pop(),d.delete(g.cacheKey),g.destroy()}}function S(g){o.remove(g)}function w(){o.dispose()}return{getParameters:E,getProgramCacheKey:p,getUniforms:R,acquireProgram:M,releaseProgram:T,releaseShaderCache:S,programs:l,dispose:w}}function um(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function dm(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function fl(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function pl(){const i=[];let e=0;const t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(h){let _=0;return h.isInstancedMesh&&(_+=2),h.isSkinnedMesh&&(_+=1),_}function o(h,_,v,E,p,u){let A=i[e];return A===void 0?(A={id:h.id,object:h,geometry:_,material:v,materialVariant:a(h),groupOrder:E,renderOrder:h.renderOrder,z:p,group:u},i[e]=A):(A.id=h.id,A.object=h,A.geometry=_,A.material=v,A.materialVariant=a(h),A.groupOrder=E,A.renderOrder=h.renderOrder,A.z=p,A.group=u),e++,A}function c(h,_,v,E,p,u){const A=o(h,_,v,E,p,u);v.transmission>0?n.push(A):v.transparent===!0?s.push(A):t.push(A)}function l(h,_,v,E,p,u){const A=o(h,_,v,E,p,u);v.transmission>0?n.unshift(A):v.transparent===!0?s.unshift(A):t.unshift(A)}function d(h,_,v){t.length>1&&t.sort(h||dm),n.length>1&&n.sort(_||fl),s.length>1&&s.sort(_||fl),v&&(t.reverse(),n.reverse(),s.reverse())}function m(){for(let h=e,_=i.length;h<_;h++){const v=i[h];if(v.id===null)break;v.id=null,v.object=null,v.geometry=null,v.material=null,v.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:m,sort:d}}function fm(){let i=new WeakMap;function e(n,s){const r=i.get(n);let a;return r===void 0?(a=new pl,i.set(n,[a])):s>=r.length?(a=new pl,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function pm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new I,color:new Ie};break;case"SpotLight":t={position:new I,direction:new I,color:new Ie,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new I,color:new Ie,distance:0,decay:0};break;case"HemisphereLight":t={direction:new I,skyColor:new Ie,groundColor:new Ie};break;case"RectAreaLight":t={color:new Ie,position:new I,halfWidth:new I,halfHeight:new I};break}return i[e.id]=t,t}}}function mm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new we};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new we};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new we,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let _m=0;function gm(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function xm(i){const e=new pm,t=mm(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new I);const s=new I,r=new at,a=new at;function o(l){let d=0,m=0,h=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let _=0,v=0,E=0,p=0,u=0,A=0,R=0,M=0,T=0,S=0,w=0;l.sort(gm);for(let b=0,L=l.length;b0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=pe.LTC_FLOAT_1,n.rectAreaLTC2=pe.LTC_FLOAT_2):(n.rectAreaLTC1=pe.LTC_HALF_1,n.rectAreaLTC2=pe.LTC_HALF_2)),n.ambient[0]=d,n.ambient[1]=m,n.ambient[2]=h;const g=n.hash;(g.directionalLength!==_||g.pointLength!==v||g.spotLength!==E||g.rectAreaLength!==p||g.hemiLength!==u||g.numDirectionalShadows!==A||g.numPointShadows!==R||g.numSpotShadows!==M||g.numSpotMaps!==T||g.numLightProbes!==w)&&(n.directional.length=_,n.spot.length=E,n.rectArea.length=p,n.point.length=v,n.hemi.length=u,n.directionalShadow.length=A,n.directionalShadowMap.length=A,n.pointShadow.length=R,n.pointShadowMap.length=R,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=R,n.spotLightMatrix.length=M+T-S,n.spotLightMap.length=T,n.numSpotLightShadowsWithMaps=S,n.numLightProbes=w,g.directionalLength=_,g.pointLength=v,g.spotLength=E,g.rectAreaLength=p,g.hemiLength=u,g.numDirectionalShadows=A,g.numPointShadows=R,g.numSpotShadows=M,g.numSpotMaps=T,g.numLightProbes=w,n.version=_m++)}function c(l,d){let m=0,h=0,_=0,v=0,E=0;const p=d.matrixWorldInverse;for(let u=0,A=l.length;u=a.length?(o=new ml(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const Mm=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,Sm=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); + gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); +}`,Em=[new I(1,0,0),new I(-1,0,0),new I(0,1,0),new I(0,-1,0),new I(0,0,1),new I(0,0,-1)],ym=[new I(0,-1,0),new I(0,-1,0),new I(0,0,1),new I(0,0,-1),new I(0,-1,0),new I(0,-1,0)],_l=new at,Yi=new I,Or=new I;function bm(i,e,t){let n=new Wa;const s=new we,r=new we,a=new ht,o=new Ch,c=new Ph,l={},d=t.maxTextureSize,m={[Hn]:zt,[zt]:Hn,[cn]:cn},h=new _n({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new we},radius:{value:4}},vertexShader:Mm,fragmentShader:Sm}),_=h.clone();_.defines.HORIZONTAL_PASS=1;const v=new wt;v.setAttribute("position",new sn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const E=new Kt(v,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ds;let u=this.type;this.render=function(S,w,g){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||S.length===0)return;this.type===pc&&(De("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Ds);const b=i.getRenderTarget(),L=i.getActiveCubeFace(),D=i.getActiveMipmapLevel(),B=i.state;B.setBlending(yn),B.buffers.depth.getReversed()===!0?B.buffers.color.setClear(0,0,0,0):B.buffers.color.setClear(1,1,1,1),B.buffers.depth.setTest(!0),B.setScissorTest(!1);const Z=u!==this.type;Z&&w.traverse(function(W){W.material&&(Array.isArray(W.material)?W.material.forEach(O=>O.needsUpdate=!0):W.material.needsUpdate=!0)});for(let W=0,O=S.length;Wd||s.y>d)&&(s.x>d&&(r.x=Math.floor(d/ee.x),s.x=r.x*ee.x,Y.mapSize.x=r.x),s.y>d&&(r.y=Math.floor(d/ee.y),s.y=r.y*ee.y,Y.mapSize.y=r.y));const te=i.state.buffers.depth.getReversed();if(Y.camera._reversedDepth=te,Y.map===null||Z===!0){if(Y.map!==null&&(Y.map.depthTexture!==null&&(Y.map.depthTexture.dispose(),Y.map.depthTexture=null),Y.map.dispose()),this.type===qi){if(H.isPointLight){De("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}Y.map=new pn(s.x,s.y,{format:si,type:Tn,minFilter:Lt,magFilter:Lt,generateMipmaps:!1}),Y.map.texture.name=H.name+".shadowMap",Y.map.depthTexture=new Ii(s.x,s.y,un),Y.map.depthTexture.name=H.name+".shadowMapDepth",Y.map.depthTexture.format=An,Y.map.depthTexture.compareFunction=null,Y.map.depthTexture.minFilter=At,Y.map.depthTexture.magFilter=At}else H.isPointLight?(Y.map=new Kl(s.x),Y.map.depthTexture=new Eh(s.x,mn)):(Y.map=new pn(s.x,s.y),Y.map.depthTexture=new Ii(s.x,s.y,mn)),Y.map.depthTexture.name=H.name+".shadowMap",Y.map.depthTexture.format=An,this.type===Ds?(Y.map.depthTexture.compareFunction=te?Ga:za,Y.map.depthTexture.minFilter=Lt,Y.map.depthTexture.magFilter=Lt):(Y.map.depthTexture.compareFunction=null,Y.map.depthTexture.minFilter=At,Y.map.depthTexture.magFilter=At);Y.camera.updateProjectionMatrix()}const he=Y.map.isWebGLCubeRenderTarget?6:1;for(let me=0;me0||w.map&&w.alphaTest>0||w.alphaToCoverage===!0){const B=L.uuid,Z=w.uuid;let W=l[B];W===void 0&&(W={},l[B]=W);let O=W[Z];O===void 0&&(O=L.clone(),W[Z]=O,w.addEventListener("dispose",T)),L=O}if(L.visible=w.visible,L.wireframe=w.wireframe,b===qi?L.side=w.shadowSide!==null?w.shadowSide:w.side:L.side=w.shadowSide!==null?w.shadowSide:m[w.side],L.alphaMap=w.alphaMap,L.alphaTest=w.alphaToCoverage===!0?.5:w.alphaTest,L.map=w.map,L.clipShadows=w.clipShadows,L.clippingPlanes=w.clippingPlanes,L.clipIntersection=w.clipIntersection,L.displacementMap=w.displacementMap,L.displacementScale=w.displacementScale,L.displacementBias=w.displacementBias,L.wireframeLinewidth=w.wireframeLinewidth,L.linewidth=w.linewidth,g.isPointLight===!0&&L.isMeshDistanceMaterial===!0){const B=i.properties.get(L);B.light=g}return L}function M(S,w,g,b,L){if(S.visible===!1)return;if(S.layers.test(w.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&L===qi)&&(!S.frustumCulled||n.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(g.matrixWorldInverse,S.matrixWorld);const Z=e.update(S),W=S.material;if(Array.isArray(W)){const O=Z.groups;for(let H=0,Y=O.length;H=1):te.indexOf("OpenGL ES")!==-1&&(ee=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),Y=ee>=2);let he=null,me={};const de=i.getParameter(i.SCISSOR_BOX),Ye=i.getParameter(i.VIEWPORT),st=new ht().fromArray(de),qe=new ht().fromArray(Ye);function j(P,re,$,ce){const fe=new Uint8Array(4),C=i.createTexture();i.bindTexture(P,C),i.texParameteri(P,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(P,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let X=0;X<$;X++)P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY?i.texImage3D(re,0,i.RGBA,1,1,ce,0,i.RGBA,i.UNSIGNED_BYTE,fe):i.texImage2D(re+X,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,fe);return C}const ae={};ae[i.TEXTURE_2D]=j(i.TEXTURE_2D,i.TEXTURE_2D,1),ae[i.TEXTURE_CUBE_MAP]=j(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),ae[i.TEXTURE_2D_ARRAY]=j(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),ae[i.TEXTURE_3D]=j(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ne(i.DEPTH_TEST),a.setFunc(Di),ot(!1),ut(lo),ne(i.CULL_FACE),ke(yn);function ne(P){d[P]!==!0&&(i.enable(P),d[P]=!0)}function Ae(P){d[P]!==!1&&(i.disable(P),d[P]=!1)}function Ue(P,re){return h[P]!==re?(i.bindFramebuffer(P,re),h[P]=re,P===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=re),P===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=re),!0):!1}function Re(P,re){let $=v,ce=!1;if(P){$=_.get(re),$===void 0&&($=[],_.set(re,$));const fe=P.textures;if($.length!==fe.length||$[0]!==i.COLOR_ATTACHMENT0){for(let C=0,X=fe.length;C"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new we,d=new WeakMap,m=new Set;let h;const _=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function E(y,f){return v?new OffscreenCanvas(y,f):Hs("canvas")}function p(y,f,F){let z=1;const K=$e(y);if((K.width>F||K.height>F)&&(z=F/Math.max(K.width,K.height)),z<1)if(typeof HTMLImageElement<"u"&&y instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&y instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&y instanceof ImageBitmap||typeof VideoFrame<"u"&&y instanceof VideoFrame){const se=Math.floor(z*K.width),ie=Math.floor(z*K.height);h===void 0&&(h=E(se,ie));const q=f?E(se,ie):h;return q.width=se,q.height=ie,q.getContext("2d").drawImage(y,0,0,se,ie),De("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+se+"x"+ie+")."),q}else return"data"in y&&De("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),y;return y}function u(y){return y.generateMipmaps}function A(y){i.generateMipmap(y)}function R(y){return y.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:y.isWebGL3DRenderTarget?i.TEXTURE_3D:y.isWebGLArrayRenderTarget||y.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(y,f,F,z,K,se=!1){if(y!==null){if(i[y]!==void 0)return i[y];De("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+y+"'")}let ie;z&&(ie=e.get("EXT_texture_norm16"),ie||De("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let q=f;if(f===i.RED&&(F===i.FLOAT&&(q=i.R32F),F===i.HALF_FLOAT&&(q=i.R16F),F===i.UNSIGNED_BYTE&&(q=i.R8),F===i.UNSIGNED_SHORT&&ie&&(q=ie.R16_EXT),F===i.SHORT&&ie&&(q=ie.R16_SNORM_EXT)),f===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&(q=i.R8UI),F===i.UNSIGNED_SHORT&&(q=i.R16UI),F===i.UNSIGNED_INT&&(q=i.R32UI),F===i.BYTE&&(q=i.R8I),F===i.SHORT&&(q=i.R16I),F===i.INT&&(q=i.R32I)),f===i.RG&&(F===i.FLOAT&&(q=i.RG32F),F===i.HALF_FLOAT&&(q=i.RG16F),F===i.UNSIGNED_BYTE&&(q=i.RG8),F===i.UNSIGNED_SHORT&&ie&&(q=ie.RG16_EXT),F===i.SHORT&&ie&&(q=ie.RG16_SNORM_EXT)),f===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&(q=i.RG8UI),F===i.UNSIGNED_SHORT&&(q=i.RG16UI),F===i.UNSIGNED_INT&&(q=i.RG32UI),F===i.BYTE&&(q=i.RG8I),F===i.SHORT&&(q=i.RG16I),F===i.INT&&(q=i.RG32I)),f===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&(q=i.RGB8UI),F===i.UNSIGNED_SHORT&&(q=i.RGB16UI),F===i.UNSIGNED_INT&&(q=i.RGB32UI),F===i.BYTE&&(q=i.RGB8I),F===i.SHORT&&(q=i.RGB16I),F===i.INT&&(q=i.RGB32I)),f===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&(q=i.RGBA8UI),F===i.UNSIGNED_SHORT&&(q=i.RGBA16UI),F===i.UNSIGNED_INT&&(q=i.RGBA32UI),F===i.BYTE&&(q=i.RGBA8I),F===i.SHORT&&(q=i.RGBA16I),F===i.INT&&(q=i.RGBA32I)),f===i.RGB&&(F===i.UNSIGNED_SHORT&&ie&&(q=ie.RGB16_EXT),F===i.SHORT&&ie&&(q=ie.RGB16_SNORM_EXT),F===i.UNSIGNED_INT_5_9_9_9_REV&&(q=i.RGB9_E5),F===i.UNSIGNED_INT_10F_11F_11F_REV&&(q=i.R11F_G11F_B10F)),f===i.RGBA){const Q=se?Vs:Xe.getTransfer(K);F===i.FLOAT&&(q=i.RGBA32F),F===i.HALF_FLOAT&&(q=i.RGBA16F),F===i.UNSIGNED_BYTE&&(q=Q===Je?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT&&ie&&(q=ie.RGBA16_EXT),F===i.SHORT&&ie&&(q=ie.RGBA16_SNORM_EXT),F===i.UNSIGNED_SHORT_4_4_4_4&&(q=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&(q=i.RGB5_A1)}return(q===i.R16F||q===i.R32F||q===i.RG16F||q===i.RG32F||q===i.RGBA16F||q===i.RGBA32F)&&e.get("EXT_color_buffer_float"),q}function T(y,f){let F;return y?f===null||f===mn||f===Ji?F=i.DEPTH24_STENCIL8:f===un?F=i.DEPTH32F_STENCIL8:f===$i&&(F=i.DEPTH24_STENCIL8,De("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):f===null||f===mn||f===Ji?F=i.DEPTH_COMPONENT24:f===un?F=i.DEPTH_COMPONENT32F:f===$i&&(F=i.DEPTH_COMPONENT16),F}function S(y,f){return u(y)===!0||y.isFramebufferTexture&&y.minFilter!==At&&y.minFilter!==Lt?Math.log2(Math.max(f.width,f.height))+1:y.mipmaps!==void 0&&y.mipmaps.length>0?y.mipmaps.length:y.isCompressedTexture&&Array.isArray(y.image)?f.mipmaps.length:1}function w(y){const f=y.target;f.removeEventListener("dispose",w),b(f),f.isVideoTexture&&d.delete(f),f.isHTMLTexture&&m.delete(f)}function g(y){const f=y.target;f.removeEventListener("dispose",g),D(f)}function b(y){const f=n.get(y);if(f.__webglInit===void 0)return;const F=y.source,z=_.get(F);if(z){const K=z[f.__cacheKey];K.usedTimes--,K.usedTimes===0&&L(y),Object.keys(z).length===0&&_.delete(F)}n.remove(y)}function L(y){const f=n.get(y);i.deleteTexture(f.__webglTexture);const F=y.source,z=_.get(F);delete z[f.__cacheKey],a.memory.textures--}function D(y){const f=n.get(y);if(y.depthTexture&&(y.depthTexture.dispose(),n.remove(y.depthTexture)),y.isWebGLCubeRenderTarget)for(let z=0;z<6;z++){if(Array.isArray(f.__webglFramebuffer[z]))for(let K=0;K=s.maxTextures&&De("WebGLTextures: Trying to use "+y+" texture units while this GPU supports only "+s.maxTextures),B+=1,y}function Y(y){const f=[];return f.push(y.wrapS),f.push(y.wrapT),f.push(y.wrapR||0),f.push(y.magFilter),f.push(y.minFilter),f.push(y.anisotropy),f.push(y.internalFormat),f.push(y.format),f.push(y.type),f.push(y.generateMipmaps),f.push(y.premultiplyAlpha),f.push(y.flipY),f.push(y.unpackAlignment),f.push(y.colorSpace),f.join()}function ee(y,f){const F=n.get(y);if(y.isVideoTexture&&U(y),y.isRenderTargetTexture===!1&&y.isExternalTexture!==!0&&y.version>0&&F.__version!==y.version){const z=y.image;if(z===null)De("WebGLRenderer: Texture marked for update but no image data found.");else if(z.complete===!1)De("WebGLRenderer: Texture marked for update but image is incomplete");else{Ae(F,y,f);return}}else y.isExternalTexture&&(F.__webglTexture=y.sourceTexture?y.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+f)}function te(y,f){const F=n.get(y);if(y.isRenderTargetTexture===!1&&y.version>0&&F.__version!==y.version){Ae(F,y,f);return}else y.isExternalTexture&&(F.__webglTexture=y.sourceTexture?y.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+f)}function he(y,f){const F=n.get(y);if(y.isRenderTargetTexture===!1&&y.version>0&&F.__version!==y.version){Ae(F,y,f);return}t.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+f)}function me(y,f){const F=n.get(y);if(y.isCubeDepthTexture!==!0&&y.version>0&&F.__version!==y.version){Ue(F,y,f);return}t.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+f)}const de={[Zr]:i.REPEAT,[En]:i.CLAMP_TO_EDGE,[Kr]:i.MIRRORED_REPEAT},Ye={[At]:i.NEAREST,[Nc]:i.NEAREST_MIPMAP_NEAREST,[is]:i.NEAREST_MIPMAP_LINEAR,[Lt]:i.LINEAR,[rr]:i.LINEAR_MIPMAP_NEAREST,[ti]:i.LINEAR_MIPMAP_LINEAR},st={[Bc]:i.NEVER,[kc]:i.ALWAYS,[zc]:i.LESS,[za]:i.LEQUAL,[Gc]:i.EQUAL,[Ga]:i.GEQUAL,[Vc]:i.GREATER,[Hc]:i.NOTEQUAL};function qe(y,f){if(f.type===un&&e.has("OES_texture_float_linear")===!1&&(f.magFilter===Lt||f.magFilter===rr||f.magFilter===is||f.magFilter===ti||f.minFilter===Lt||f.minFilter===rr||f.minFilter===is||f.minFilter===ti)&&De("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(y,i.TEXTURE_WRAP_S,de[f.wrapS]),i.texParameteri(y,i.TEXTURE_WRAP_T,de[f.wrapT]),(y===i.TEXTURE_3D||y===i.TEXTURE_2D_ARRAY)&&i.texParameteri(y,i.TEXTURE_WRAP_R,de[f.wrapR]),i.texParameteri(y,i.TEXTURE_MAG_FILTER,Ye[f.magFilter]),i.texParameteri(y,i.TEXTURE_MIN_FILTER,Ye[f.minFilter]),f.compareFunction&&(i.texParameteri(y,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(y,i.TEXTURE_COMPARE_FUNC,st[f.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(f.magFilter===At||f.minFilter!==is&&f.minFilter!==ti||f.type===un&&e.has("OES_texture_float_linear")===!1)return;if(f.anisotropy>1||n.get(f).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");i.texParameterf(y,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(f.anisotropy,s.getMaxAnisotropy())),n.get(f).__currentAnisotropy=f.anisotropy}}}function j(y,f){let F=!1;y.__webglInit===void 0&&(y.__webglInit=!0,f.addEventListener("dispose",w));const z=f.source;let K=_.get(z);K===void 0&&(K={},_.set(z,K));const se=Y(f);if(se!==y.__cacheKey){K[se]===void 0&&(K[se]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,F=!0),K[se].usedTimes++;const ie=K[y.__cacheKey];ie!==void 0&&(K[y.__cacheKey].usedTimes--,ie.usedTimes===0&&L(f)),y.__cacheKey=se,y.__webglTexture=K[se].texture}return F}function ae(y,f,F){return Math.floor(Math.floor(y/F)/f)}function ne(y,f,F,z){const se=y.updateRanges;if(se.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,f.width,f.height,F,z,f.data);else{se.sort((Se,ue)=>Se.start-ue.start);let ie=0;for(let Se=1;Se0){Ce&&Ne&&t.texStorage2D(i.TEXTURE_2D,re,ue,Ee[0].width,Ee[0].height);for(let $=0,ce=Ee.length;$0){const fe=qo(le.width,le.height,f.format,f.type);for(const C of f.layerUpdates){const X=le.data.subarray(C*fe/le.data.BYTES_PER_ELEMENT,(C+1)*fe/le.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,C,le.width,le.height,1,oe,X)}f.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,le.width,le.height,Q.depth,oe,le.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,$,ue,le.width,le.height,Q.depth,0,le.data,0,0);else De("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ce?P&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,le.width,le.height,Q.depth,oe,Se,le.data):t.texImage3D(i.TEXTURE_2D_ARRAY,$,ue,le.width,le.height,Q.depth,0,oe,Se,le.data)}else{Ce&&Ne&&t.texStorage2D(i.TEXTURE_2D,re,ue,Ee[0].width,Ee[0].height);for(let $=0,ce=Ee.length;$0){const $=qo(Q.width,Q.height,f.format,f.type);for(const ce of f.layerUpdates){const fe=Q.data.subarray(ce*$/Q.data.BYTES_PER_ELEMENT,(ce+1)*$/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ce,Q.width,Q.height,1,oe,Se,fe)}f.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,oe,Se,Q.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ue,Q.width,Q.height,Q.depth,0,oe,Se,Q.data);else if(f.isData3DTexture)Ce?(Ne&&t.texStorage3D(i.TEXTURE_3D,re,ue,Q.width,Q.height,Q.depth),P&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,oe,Se,Q.data)):t.texImage3D(i.TEXTURE_3D,0,ue,Q.width,Q.height,Q.depth,0,oe,Se,Q.data);else if(f.isFramebufferTexture){if(Ne)if(Ce)t.texStorage2D(i.TEXTURE_2D,re,ue,Q.width,Q.height);else{let $=Q.width,ce=Q.height;for(let fe=0;fe>=1,ce>>=1}}else if(f.isHTMLTexture){if("texElementImage2D"in i){const $=i.canvas;if($.hasAttribute("layoutsubtree")||$.setAttribute("layoutsubtree","true"),Q.parentNode!==$){$.appendChild(Q),m.add(f),$.onpaint=ce=>{const fe=ce.changedElements;for(const C of m)fe.includes(C.image)&&(C.needsUpdate=!0)},$.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,Q);else{const fe=i.RGBA,C=i.RGBA,X=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,fe,C,X,Q)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Ee.length>0){if(Ce&&Ne){const $=$e(Ee[0]);t.texStorage2D(i.TEXTURE_2D,re,ue,$.width,$.height)}for(let $=0,ce=Ee.length;$0&&ce++;const C=$e(ue[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ce,Ne,C.width,C.height)}for(let C=0;C<6;C++)if(Se){P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+C,0,0,0,ue[C].width,ue[C].height,Ee,Ce,ue[C].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+C,0,Ne,ue[C].width,ue[C].height,0,Ee,Ce,ue[C].data);for(let X=0;X>se),le=Math.max(1,f.height>>se);K===i.TEXTURE_3D||K===i.TEXTURE_2D_ARRAY?t.texImage3D(K,se,Q,ue,le,f.depth,0,ie,q,null):t.texImage2D(K,se,Q,ue,le,0,ie,q,null)}t.bindFramebuffer(i.FRAMEBUFFER,y),ct(f)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,z,K,Se.__webglTexture,0,lt(f)):(K===i.TEXTURE_2D||K>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,z,K,Se.__webglTexture,se),t.bindFramebuffer(i.FRAMEBUFFER,null)}function rt(y,f,F){if(i.bindRenderbuffer(i.RENDERBUFFER,y),f.depthBuffer){const z=f.depthTexture,K=z&&z.isDepthTexture?z.type:null,se=T(f.stencilBuffer,K),ie=f.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ct(f)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,lt(f),se,f.width,f.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,lt(f),se,f.width,f.height):i.renderbufferStorage(i.RENDERBUFFER,se,f.width,f.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ie,i.RENDERBUFFER,y)}else{const z=f.textures;for(let K=0;K{delete f.__boundDepthTexture,delete f.__depthDisposeCallback,z.removeEventListener("dispose",K)};z.addEventListener("dispose",K),f.__depthDisposeCallback=K}f.__boundDepthTexture=z}if(y.depthTexture&&!f.__autoAllocateDepthBuffer)if(F)for(let z=0;z<6;z++)Ge(f.__webglFramebuffer[z],y,z);else{const z=y.texture.mipmaps;z&&z.length>0?Ge(f.__webglFramebuffer[0],y,0):Ge(f.__webglFramebuffer,y,0)}else if(F){f.__webglDepthbuffer=[];for(let z=0;z<6;z++)if(t.bindFramebuffer(i.FRAMEBUFFER,f.__webglFramebuffer[z]),f.__webglDepthbuffer[z]===void 0)f.__webglDepthbuffer[z]=i.createRenderbuffer(),rt(f.__webglDepthbuffer[z],y,!1);else{const K=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=f.__webglDepthbuffer[z];i.bindRenderbuffer(i.RENDERBUFFER,se),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,se)}}else{const z=y.texture.mipmaps;if(z&&z.length>0?t.bindFramebuffer(i.FRAMEBUFFER,f.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,f.__webglFramebuffer),f.__webglDepthbuffer===void 0)f.__webglDepthbuffer=i.createRenderbuffer(),rt(f.__webglDepthbuffer,y,!1);else{const K=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=f.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,se),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,se)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function ke(y,f,F){const z=n.get(y);f!==void 0&&Re(z.__webglFramebuffer,y,y.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&Ze(y)}function Be(y){const f=y.texture,F=n.get(y),z=n.get(f);y.addEventListener("dispose",g);const K=y.textures,se=y.isWebGLCubeRenderTarget===!0,ie=K.length>1;if(ie||(z.__webglTexture===void 0&&(z.__webglTexture=i.createTexture()),z.__version=f.version,a.memory.textures++),se){F.__webglFramebuffer=[];for(let q=0;q<6;q++)if(f.mipmaps&&f.mipmaps.length>0){F.__webglFramebuffer[q]=[];for(let Q=0;Q0){F.__webglFramebuffer=[];for(let q=0;q0&&ct(y)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let q=0;q0)for(let Q=0;Q0)for(let Q=0;Q0){if(ct(y)===!1){const f=y.textures,F=y.width,z=y.height;let K=i.COLOR_BUFFER_BIT;const se=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=n.get(y),q=f.length>1;if(q)for(let oe=0;oe0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ie.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ie.__webglFramebuffer);for(let oe=0;oe0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&f.__useRenderToTexture!==!1}function U(y){const f=a.render.frame;d.get(y)!==f&&(d.set(y,f),y.update())}function Rt(y,f){const F=y.colorSpace,z=y.format,K=y.type;return y.isCompressedTexture===!0||y.isVideoTexture===!0||F!==Gs&&F!==zn&&(Xe.getTransfer(F)===Je?(z!==nn||K!==Wt)&&De("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):We("WebGLTextures: Unsupported texture color space:",F)),f}function $e(y){return typeof HTMLImageElement<"u"&&y instanceof HTMLImageElement?(l.width=y.naturalWidth||y.width,l.height=y.naturalHeight||y.height):typeof VideoFrame<"u"&&y instanceof VideoFrame?(l.width=y.displayWidth,l.height=y.displayHeight):(l.width=y.width,l.height=y.height),l}this.allocateTextureUnit=H,this.resetTextureUnits=Z,this.getTextureUnits=W,this.setTextureUnits=O,this.setTexture2D=ee,this.setTexture2DArray=te,this.setTexture3D=he,this.setTextureCube=me,this.rebindTextures=ke,this.setupRenderTarget=Be,this.updateRenderTargetMipmap=ot,this.updateMultisampleRenderTarget=pt,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=Re,this.useMultisampledRTT=ct,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function wm(i,e){function t(n,s=zn){let r;const a=Xe.getTransfer(s);if(n===Wt)return i.UNSIGNED_BYTE;if(n===Ua)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Na)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Pl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Dl)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Rl)return i.BYTE;if(n===Cl)return i.SHORT;if(n===$i)return i.UNSIGNED_SHORT;if(n===Ia)return i.INT;if(n===mn)return i.UNSIGNED_INT;if(n===un)return i.FLOAT;if(n===Tn)return i.HALF_FLOAT;if(n===Ll)return i.ALPHA;if(n===Il)return i.RGB;if(n===nn)return i.RGBA;if(n===An)return i.DEPTH_COMPONENT;if(n===ni)return i.DEPTH_STENCIL;if(n===Ul)return i.RED;if(n===Fa)return i.RED_INTEGER;if(n===si)return i.RG;if(n===Oa)return i.RG_INTEGER;if(n===Ba)return i.RGBA_INTEGER;if(n===Ls||n===Is||n===Us||n===Ns)if(a===Je)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Ls)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Is)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Us)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ns)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Ls)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Is)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Us)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ns)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===$r||n===Jr||n===Qr||n===jr)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===$r)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Jr)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Qr)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===jr)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ea||n===ta||n===na||n===ia||n===sa||n===Bs||n===ra)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===ea||n===ta)return a===Je?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===na)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===ia)return r.COMPRESSED_R11_EAC;if(n===sa)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Bs)return r.COMPRESSED_RG11_EAC;if(n===ra)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===aa||n===oa||n===la||n===ca||n===ha||n===ua||n===da||n===fa||n===pa||n===ma||n===_a||n===ga||n===xa||n===va)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===aa)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===oa)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===la)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ca)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ha)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ua)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===da)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===fa)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===pa)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ma)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===_a)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ga)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===xa)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===va)return a===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ma||n===Sa||n===Ea)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Ma)return a===Je?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Sa)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ea)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===ya||n===ba||n===zs||n===Ta)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===ya)return r.COMPRESSED_RED_RGTC1_EXT;if(n===ba)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===zs)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ta)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ji?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const Rm=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Cm=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class Pm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Wl(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new _n({vertexShader:Rm,fragmentShader:Cm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Kt(new es(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Dm extends Xn{constructor(e,t){super();const n=this;let s=null,r=1,a=null,o="local-floor",c=1,l=null,d=null,m=null,h=null,_=null,v=null;const E=typeof XRWebGLBinding<"u",p=new Pm,u={},A=t.getContextAttributes();let R=null,M=null;const T=[],S=[],w=new we;let g=null;const b=new qt;b.viewport=new ht;const L=new qt;L.viewport=new ht;const D=[b,L],B=new Bh;let Z=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let ae=T[j];return ae===void 0&&(ae=new dr,T[j]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(j){let ae=T[j];return ae===void 0&&(ae=new dr,T[j]=ae),ae.getGripSpace()},this.getHand=function(j){let ae=T[j];return ae===void 0&&(ae=new dr,T[j]=ae),ae.getHandSpace()};function O(j){const ae=S.indexOf(j.inputSource);if(ae===-1)return;const ne=T[ae];ne!==void 0&&(ne.update(j.inputSource,j.frame,l||a),ne.dispatchEvent({type:j.type,data:j.inputSource}))}function H(){s.removeEventListener("select",O),s.removeEventListener("selectstart",O),s.removeEventListener("selectend",O),s.removeEventListener("squeeze",O),s.removeEventListener("squeezestart",O),s.removeEventListener("squeezeend",O),s.removeEventListener("end",H),s.removeEventListener("inputsourceschange",Y);for(let j=0;j=0&&(S[Ae]=null,T[Ae].disconnect(ne))}for(let ae=0;ae=S.length){S.push(ne),Ae=Re;break}else if(S[Re]===null){S[Re]=ne,Ae=Re;break}if(Ae===-1)break}const Ue=T[Ae];Ue&&Ue.connect(ne)}}const ee=new I,te=new I;function he(j,ae,ne){ee.setFromMatrixPosition(ae.matrixWorld),te.setFromMatrixPosition(ne.matrixWorld);const Ae=ee.distanceTo(te),Ue=ae.projectionMatrix.elements,Re=ne.projectionMatrix.elements,rt=Ue[14]/(Ue[10]-1),Ge=Ue[14]/(Ue[10]+1),Ze=(Ue[9]+1)/Ue[5],ke=(Ue[9]-1)/Ue[5],Be=(Ue[8]-1)/Ue[0],ot=(Re[8]+1)/Re[0],ut=rt*Be,ft=rt*ot,pt=Ae/(-Be+ot),lt=pt*-Be;if(ae.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(lt),j.translateZ(pt),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert(),Ue[10]===-1)j.projectionMatrix.copy(ae.projectionMatrix),j.projectionMatrixInverse.copy(ae.projectionMatrixInverse);else{const ct=rt+pt,U=Ge+pt,Rt=ut-lt,$e=ft+(Ae-lt),y=Ze*Ge/U*ct,f=ke*Ge/U*ct;j.projectionMatrix.makePerspective(Rt,$e,y,f,ct,U),j.projectionMatrixInverse.copy(j.projectionMatrix).invert()}}function me(j,ae){ae===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(ae.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(s===null)return;let ae=j.near,ne=j.far;p.texture!==null&&(p.depthNear>0&&(ae=p.depthNear),p.depthFar>0&&(ne=p.depthFar)),B.near=L.near=b.near=ae,B.far=L.far=b.far=ne,(Z!==B.near||W!==B.far)&&(s.updateRenderState({depthNear:B.near,depthFar:B.far}),Z=B.near,W=B.far),B.layers.mask=j.layers.mask|6,b.layers.mask=B.layers.mask&-5,L.layers.mask=B.layers.mask&-3;const Ae=j.parent,Ue=B.cameras;me(B,Ae);for(let Re=0;Re0&&(p.alphaTest.value=u.alphaTest);const A=e.get(u),R=A.envMap,M=A.envMapRotation;R&&(p.envMap.value=R,p.envMapRotation.value.setFromMatrix4(Lm.makeRotationFromEuler(M)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1&&p.envMapRotation.value.premultiply(ec),p.reflectivity.value=u.reflectivity,p.ior.value=u.ior,p.refractionRatio.value=u.refractionRatio),u.lightMap&&(p.lightMap.value=u.lightMap,p.lightMapIntensity.value=u.lightMapIntensity,t(u.lightMap,p.lightMapTransform)),u.aoMap&&(p.aoMap.value=u.aoMap,p.aoMapIntensity.value=u.aoMapIntensity,t(u.aoMap,p.aoMapTransform))}function a(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform))}function o(p,u){p.dashSize.value=u.dashSize,p.totalSize.value=u.dashSize+u.gapSize,p.scale.value=u.scale}function c(p,u,A,R){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.size.value=u.size*A,p.scale.value=R*.5,u.map&&(p.map.value=u.map,t(u.map,p.uvTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function l(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.rotation.value=u.rotation,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function d(p,u){p.specular.value.copy(u.specular),p.shininess.value=Math.max(u.shininess,1e-4)}function m(p,u){u.gradientMap&&(p.gradientMap.value=u.gradientMap)}function h(p,u){p.metalness.value=u.metalness,u.metalnessMap&&(p.metalnessMap.value=u.metalnessMap,t(u.metalnessMap,p.metalnessMapTransform)),p.roughness.value=u.roughness,u.roughnessMap&&(p.roughnessMap.value=u.roughnessMap,t(u.roughnessMap,p.roughnessMapTransform)),u.envMap&&(p.envMapIntensity.value=u.envMapIntensity)}function _(p,u,A){p.ior.value=u.ior,u.sheen>0&&(p.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),p.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(p.sheenColorMap.value=u.sheenColorMap,t(u.sheenColorMap,p.sheenColorMapTransform)),u.sheenRoughnessMap&&(p.sheenRoughnessMap.value=u.sheenRoughnessMap,t(u.sheenRoughnessMap,p.sheenRoughnessMapTransform))),u.clearcoat>0&&(p.clearcoat.value=u.clearcoat,p.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(p.clearcoatMap.value=u.clearcoatMap,t(u.clearcoatMap,p.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,t(u.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap&&(p.clearcoatNormalMap.value=u.clearcoatNormalMap,t(u.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===zt&&p.clearcoatNormalScale.value.negate())),u.dispersion>0&&(p.dispersion.value=u.dispersion),u.iridescence>0&&(p.iridescence.value=u.iridescence,p.iridescenceIOR.value=u.iridescenceIOR,p.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(p.iridescenceMap.value=u.iridescenceMap,t(u.iridescenceMap,p.iridescenceMapTransform)),u.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=u.iridescenceThicknessMap,t(u.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),u.transmission>0&&(p.transmission.value=u.transmission,p.transmissionSamplerMap.value=A.texture,p.transmissionSamplerSize.value.set(A.width,A.height),u.transmissionMap&&(p.transmissionMap.value=u.transmissionMap,t(u.transmissionMap,p.transmissionMapTransform)),p.thickness.value=u.thickness,u.thicknessMap&&(p.thicknessMap.value=u.thicknessMap,t(u.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=u.attenuationDistance,p.attenuationColor.value.copy(u.attenuationColor)),u.anisotropy>0&&(p.anisotropyVector.value.set(u.anisotropy*Math.cos(u.anisotropyRotation),u.anisotropy*Math.sin(u.anisotropyRotation)),u.anisotropyMap&&(p.anisotropyMap.value=u.anisotropyMap,t(u.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=u.specularIntensity,p.specularColor.value.copy(u.specularColor),u.specularColorMap&&(p.specularColorMap.value=u.specularColorMap,t(u.specularColorMap,p.specularColorMapTransform)),u.specularIntensityMap&&(p.specularIntensityMap.value=u.specularIntensityMap,t(u.specularIntensityMap,p.specularIntensityMapTransform))}function v(p,u){u.matcap&&(p.matcap.value=u.matcap)}function E(p,u){const A=e.get(u).light;p.referencePosition.value.setFromMatrixPosition(A.matrixWorld),p.nearDistance.value=A.shadow.camera.near,p.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Um(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,T){const S=T.program;n.uniformBlockBinding(M,S)}function l(M,T){let S=s[M.id];S===void 0&&(p(M),S=d(M),s[M.id]=S,M.addEventListener("dispose",A));const w=T.program;n.updateUBOMapping(M,w);const g=e.render.frame;r[M.id]!==g&&(h(M),r[M.id]=g)}function d(M){const T=m();M.__bindingPointIndex=T;const S=i.createBuffer(),w=M.__size,g=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,w,g),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,T,S),S}function m(){for(let M=0;M0&&(S+=w-g),M.__size=S,M.__cache={},this}function u(M){const T={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(T.boundary=4,T.storage=4):M.isVector2?(T.boundary=8,T.storage=8):M.isVector3||M.isColor?(T.boundary=16,T.storage=12):M.isVector4?(T.boundary=16,T.storage=16):M.isMatrix3?(T.boundary=48,T.storage=48):M.isMatrix4?(T.boundary=64,T.storage=64):M.isTexture?De("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(T.boundary=16,T.storage=M.byteLength):De("WebGLRenderer: Unsupported uniform value type.",M),T}function A(M){const T=M.target;T.removeEventListener("dispose",A);const S=a.indexOf(T.__bindingPointIndex);a.splice(S,1),i.deleteBuffer(s[T.id]),delete s[T.id],delete r[T.id]}function R(){for(const M in s)i.deleteBuffer(s[M]);a=[],s={},r={}}return{bind:c,update:l,dispose:R}}const Nm=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let on=null;function Fm(){return on===null&&(on=new gh(Nm,16,16,si,Tn),on.name="DFG_LUT",on.minFilter=Lt,on.magFilter=Lt,on.wrapS=En,on.wrapT=En,on.generateMipmaps=!1,on.needsUpdate=!0),on}class Om{constructor(e={}){const{canvas:t=Xc(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:m=!1,reversedDepthBuffer:h=!1,outputBufferType:_=Wt}=e;this.isWebGLRenderer=!0;let v;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");v=n.getContextAttributes().alpha}else v=a;const E=_,p=new Set([Ba,Oa,Fa]),u=new Set([Wt,mn,$i,Ji,Ua,Na]),A=new Uint32Array(4),R=new Int32Array(4),M=new I;let T=null,S=null;const w=[],g=[];let b=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=fn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const L=this;let D=!1,B=null,Z=null,W=null,O=null;this._outputColorSpace=kt;let H=0,Y=0,ee=null,te=-1,he=null;const me=new ht,de=new ht;let Ye=null;const st=new Ie(0);let qe=0,j=t.width,ae=t.height,ne=1,Ae=null,Ue=null;const Re=new ht(0,0,j,ae),rt=new ht(0,0,j,ae);let Ge=!1;const Ze=new Wa;let ke=!1,Be=!1;const ot=new at,ut=new I,ft=new ht,pt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let lt=!1;function ct(){return ee===null?ne:1}let U=n;function Rt(x,N){return t.getContext(x,N)}try{const x={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:d,failIfMajorPerformanceCaveat:m};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${La}`),t.addEventListener("webglcontextlost",Te,!1),t.addEventListener("webglcontextrestored",Pe,!1),t.addEventListener("webglcontextcreationerror",Le,!1),U===null){const N="webgl2";if(U=Rt(N,x),U===null)throw Rt(N)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(x){throw We("WebGLRenderer: "+x.message),x}let $e,y,f,F,z,K,se,ie,q,Q,oe,Se,ue,le,Ee,Ce,Ne,P,re,$,ce,fe,C;function X(){$e=new Ff(U),$e.init(),ce=new wm(U,$e),y=new Rf(U,$e,e,ce),f=new Tm(U,$e),y.reversedDepthBuffer&&h&&f.buffers.depth.setReversed(!0),Z=U.createFramebuffer(),W=U.createFramebuffer(),O=U.createFramebuffer(),F=new zf(U),z=new um,K=new Am(U,$e,f,z,y,ce,F),se=new Nf(L),ie=new Hh(U),fe=new Af(U,ie),q=new Of(U,ie,F,fe),Q=new Vf(U,q,ie,fe,F),P=new Gf(U,y,K),Ee=new Cf(z),oe=new hm(L,se,$e,y,fe,Ee),Se=new Im(L,z),ue=new fm,le=new vm($e),Ne=new Tf(L,se,f,Q,v,c),Ce=new bm(L,Q,y),C=new Um(U,F,y,f),re=new wf(U,$e,F),$=new Bf(U,$e,F),F.programs=oe.programs,L.capabilities=y,L.extensions=$e,L.properties=z,L.renderLists=ue,L.shadowMap=Ce,L.state=f,L.info=F}X(),E!==Wt&&(b=new kf(E,t.width,t.height,o,s,r));const J=new Dm(L,U);this.xr=J,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){const x=$e.get("WEBGL_lose_context");x&&x.loseContext()},this.forceContextRestore=function(){const x=$e.get("WEBGL_lose_context");x&&x.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(x){x!==void 0&&(ne=x,this.setSize(j,ae,!1))},this.getSize=function(x){return x.set(j,ae)},this.setSize=function(x,N,k=!0){if(J.isPresenting){De("WebGLRenderer: Can't change size while VR device is presenting.");return}j=x,ae=N,t.width=Math.floor(x*ne),t.height=Math.floor(N*ne),k===!0&&(t.style.width=x+"px",t.style.height=N+"px"),b!==null&&b.setSize(t.width,t.height),this.setViewport(0,0,x,N)},this.getDrawingBufferSize=function(x){return x.set(j*ne,ae*ne).floor()},this.setDrawingBufferSize=function(x,N,k){j=x,ae=N,ne=k,t.width=Math.floor(x*k),t.height=Math.floor(N*k),this.setViewport(0,0,x,N)},this.setEffects=function(x){if(E===Wt){We("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(x){for(let N=0;N{function ge(){if(G.forEach(function(ve){z.get(ve).currentProgram.isReady()&&G.delete(ve)}),G.size===0){V(x);return}setTimeout(ge,10)}$e.get("KHR_parallel_shader_compile")!==null?ge():setTimeout(ge,10)})};let wn=null;function Yn(x){wn&&wn(x)}function tr(){Jt.stop()}function Rn(){Jt.start()}const Jt=new ql;Jt.setAnimationLoop(Yn),typeof self<"u"&&Jt.setContext(self),this.setAnimationLoop=function(x){wn=x,J.setAnimationLoop(x),x===null?Jt.stop():Jt.start()},J.addEventListener("sessionstart",tr),J.addEventListener("sessionend",Rn),this.render=function(x,N){if(N!==void 0&&N.isCamera!==!0){We("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;B!==null&&B.renderStart(x,N);const k=J.enabled===!0&&J.isPresenting===!0,G=b!==null&&(ee===null||k)&&b.begin(L,ee);if(x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),J.enabled===!0&&J.isPresenting===!0&&(b===null||b.isCompositing()===!1)&&(J.cameraAutoUpdate===!0&&J.updateCamera(N),N=J.getCamera()),x.isScene===!0&&x.onBeforeRender(L,x,N,ee),S=le.get(x,g.length),S.init(N),S.state.textureUnits=K.getTextureUnits(),g.push(S),ot.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),Ze.setFromProjectionMatrix(ot,dn,N.reversedDepth),Be=this.localClippingEnabled,ke=Ee.init(this.clippingPlanes,Be),T=ue.get(x,w.length),T.init(),w.push(T),J.enabled===!0&&J.isPresenting===!0){const ve=L.xr.getDepthSensingMesh();ve!==null&&qn(ve,N,-1/0,L.sortObjects)}qn(x,N,0,L.sortObjects),T.finish(),L.sortObjects===!0&&T.sort(Ae,Ue,N.reversedDepth),lt=J.enabled===!1||J.isPresenting===!1||J.hasDepthSensing()===!1,lt&&Ne.addToRenderList(T,x),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),ke===!0&&Ee.beginShadows();const V=S.state.shadowsArray;if(Ce.render(V,x,N),ke===!0&&Ee.endShadows(),(G&&b.hasRenderPass())===!1){const ve=T.opaque,_e=T.transmissive;if(S.setupLights(),N.isArrayCamera){const Me=N.cameras;if(_e.length>0)for(let ye=0,Oe=Me.length;ye0&&io(ve,_e,x,N),lt&&Ne.render(x),no(T,x,N)}ee!==null&&Y===0&&(K.updateMultisampleRenderTarget(ee),K.updateRenderTargetMipmap(ee)),G&&b.end(L),x.isScene===!0&&x.onAfterRender(L,x,N),fe.resetDefaultState(),te=-1,he=null,g.pop(),g.length>0?(S=g[g.length-1],K.setTextureUnits(S.state.textureUnits),ke===!0&&Ee.setGlobalState(L.clippingPlanes,S.state.camera)):S=null,w.pop(),w.length>0?T=w[w.length-1]:T=null,B!==null&&B.renderEnd()};function qn(x,N,k,G){if(x.visible===!1)return;if(x.layers.test(N.layers)){if(x.isGroup)k=x.renderOrder;else if(x.isLOD)x.autoUpdate===!0&&x.update(N);else if(x.isLightProbeGrid)S.pushLightProbeGrid(x);else if(x.isLight)S.pushLight(x),x.castShadow&&S.pushShadow(x);else if(x.isSprite){if(!x.frustumCulled||Ze.intersectsSprite(x)){G&&ft.setFromMatrixPosition(x.matrixWorld).applyMatrix4(ot);const ve=Q.update(x),_e=x.material;_e.visible&&T.push(x,ve,_e,k,ft.z,null)}}else if((x.isMesh||x.isLine||x.isPoints)&&(!x.frustumCulled||Ze.intersectsObject(x))){const ve=Q.update(x),_e=x.material;if(G&&(x.boundingSphere!==void 0?(x.boundingSphere===null&&x.computeBoundingSphere(),ft.copy(x.boundingSphere.center)):(ve.boundingSphere===null&&ve.computeBoundingSphere(),ft.copy(ve.boundingSphere.center)),ft.applyMatrix4(x.matrixWorld).applyMatrix4(ot)),Array.isArray(_e)){const Me=ve.groups;for(let ye=0,Oe=Me.length;ye0&&ts(V,N,k),ge.length>0&&ts(ge,N,k),ve.length>0&&ts(ve,N,k),f.buffers.depth.setTest(!0),f.buffers.depth.setMask(!0),f.buffers.color.setMask(!0),f.setPolygonOffset(!1)}function io(x,N,k,G){if((k.isScene===!0?k.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[G.id]===void 0){const be=$e.has("EXT_color_buffer_half_float")||$e.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[G.id]=new pn(1,1,{generateMipmaps:!0,type:be?Tn:Wt,minFilter:ti,samples:Math.max(4,y.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Xe.workingColorSpace})}const ge=S.state.transmissionRenderTarget[G.id],ve=G.viewport||me;ge.setSize(ve.z*L.transmissionResolutionScale,ve.w*L.transmissionResolutionScale);const _e=L.getRenderTarget(),Me=L.getActiveCubeFace(),ye=L.getActiveMipmapLevel();L.setRenderTarget(ge),L.getClearColor(st),qe=L.getClearAlpha(),qe<1&&L.setClearColor(16777215,.5),L.clear(),lt&&Ne.render(k);const Oe=L.toneMapping;L.toneMapping=fn;const Ve=G.viewport;if(G.viewport!==void 0&&(G.viewport=void 0),S.setupLightsView(G),ke===!0&&Ee.setGlobalState(L.clippingPlanes,G),ts(x,k,G),K.updateMultisampleRenderTarget(ge),K.updateRenderTargetMipmap(ge),$e.has("WEBGL_multisampled_render_to_texture")===!1){let be=!1;for(let Qe=0,mt=N.length;Qe0,G.currentProgram=Ve,G.uniformsList=null,Ve}function ro(x){if(x.uniformsList===null){const N=x.currentProgram.getUniforms();x.uniformsList=Os.seqWithValue(N.seq,x.uniforms)}return x.uniformsList}function ao(x,N){const k=z.get(x);k.outputColorSpace=N.outputColorSpace,k.batching=N.batching,k.batchingColor=N.batchingColor,k.instancing=N.instancing,k.instancingColor=N.instancingColor,k.instancingMorph=N.instancingMorph,k.skinning=N.skinning,k.morphTargets=N.morphTargets,k.morphNormals=N.morphNormals,k.morphColors=N.morphColors,k.morphTargetsCount=N.morphTargetsCount,k.numClippingPlanes=N.numClippingPlanes,k.numIntersection=N.numClipIntersection,k.vertexAlphas=N.vertexAlphas,k.vertexTangents=N.vertexTangents,k.toneMapping=N.toneMapping}function ic(x,N){if(x.length===0)return null;if(x.length===1)return x[0].texture!==null?x[0]:null;M.setFromMatrixPosition(N.matrixWorld);for(let k=0,G=x.length;k0),be=!!k.morphAttributes.position,Qe=!!k.morphAttributes.normal,mt=!!k.morphAttributes.color;let dt=fn;G.toneMapped&&(ee===null||ee.isXRRenderTarget===!0)&&(dt=L.toneMapping);const tt=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,Ct=tt!==void 0?tt.length:0,xe=z.get(G),Gt=S.state.lights;if(ke===!0&&(Be===!0||x!==he)){const it=x===he&&G.id===te;Ee.setState(G,x,it)}let Ke=!1;G.version===xe.__version?(xe.needsLights&&xe.lightsStateVersion!==Gt.state.version||xe.outputColorSpace!==_e||V.isBatchedMesh&&xe.batching===!1||!V.isBatchedMesh&&xe.batching===!0||V.isBatchedMesh&&xe.batchingColor===!0&&V.colorTexture===null||V.isBatchedMesh&&xe.batchingColor===!1&&V.colorTexture!==null||V.isInstancedMesh&&xe.instancing===!1||!V.isInstancedMesh&&xe.instancing===!0||V.isSkinnedMesh&&xe.skinning===!1||!V.isSkinnedMesh&&xe.skinning===!0||V.isInstancedMesh&&xe.instancingColor===!0&&V.instanceColor===null||V.isInstancedMesh&&xe.instancingColor===!1&&V.instanceColor!==null||V.isInstancedMesh&&xe.instancingMorph===!0&&V.morphTexture===null||V.isInstancedMesh&&xe.instancingMorph===!1&&V.morphTexture!==null||xe.envMap!==ye||G.fog===!0&&xe.fog!==ge||xe.numClippingPlanes!==void 0&&(xe.numClippingPlanes!==Ee.numPlanes||xe.numIntersection!==Ee.numIntersection)||xe.vertexAlphas!==Oe||xe.vertexTangents!==Ve||xe.morphTargets!==be||xe.morphNormals!==Qe||xe.morphColors!==mt||xe.toneMapping!==dt||xe.morphTargetsCount!==Ct||!!xe.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(Ke=!0):(Ke=!0,xe.__version=G.version);let Xt=xe.currentProgram;Ke===!0&&(Xt=ns(G,N,V),B&&G.isNodeMaterial&&B.onUpdateProgram(G,Xt,xe));let rn=!1,Cn=!1,ai=!1;const nt=Xt.getUniforms(),_t=xe.uniforms;if(f.useProgram(Xt.program)&&(rn=!0,Cn=!0,ai=!0),G.id!==te&&(te=G.id,Cn=!0),xe.needsLights){const it=ic(S.state.lightProbeGridArray,V);xe.lightProbeGrid!==it&&(xe.lightProbeGrid=it,Cn=!0)}if(rn||he!==x){f.buffers.depth.getReversed()&&x.reversedDepth!==!0&&(x._reversedDepth=!0,x.updateProjectionMatrix()),nt.setValue(U,"projectionMatrix",x.projectionMatrix),nt.setValue(U,"viewMatrix",x.matrixWorldInverse);const Dn=nt.map.cameraPosition;Dn!==void 0&&Dn.setValue(U,ut.setFromMatrixPosition(x.matrixWorld)),y.logarithmicDepthBuffer&&nt.setValue(U,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2)),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&nt.setValue(U,"isOrthographic",x.isOrthographicCamera===!0),he!==x&&(he=x,Cn=!0,ai=!0)}if(xe.needsLights&&(Gt.state.directionalShadowMap.length>0&&nt.setValue(U,"directionalShadowMap",Gt.state.directionalShadowMap,K),Gt.state.spotShadowMap.length>0&&nt.setValue(U,"spotShadowMap",Gt.state.spotShadowMap,K),Gt.state.pointShadowMap.length>0&&nt.setValue(U,"pointShadowMap",Gt.state.pointShadowMap,K)),V.isSkinnedMesh){nt.setOptional(U,V,"bindMatrix"),nt.setOptional(U,V,"bindMatrixInverse");const it=V.skeleton;it&&(it.boneTexture===null&&it.computeBoneTexture(),nt.setValue(U,"boneTexture",it.boneTexture,K))}V.isBatchedMesh&&(nt.setOptional(U,V,"batchingTexture"),nt.setValue(U,"batchingTexture",V._matricesTexture,K),nt.setOptional(U,V,"batchingIdTexture"),nt.setValue(U,"batchingIdTexture",V._indirectTexture,K),nt.setOptional(U,V,"batchingColorTexture"),V._colorsTexture!==null&&nt.setValue(U,"batchingColorTexture",V._colorsTexture,K));const Pn=k.morphAttributes;if((Pn.position!==void 0||Pn.normal!==void 0||Pn.color!==void 0)&&P.update(V,k,Xt),(Cn||xe.receiveShadow!==V.receiveShadow)&&(xe.receiveShadow=V.receiveShadow,nt.setValue(U,"receiveShadow",V.receiveShadow)),(G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial)&&G.envMap===null&&N.environment!==null&&(_t.envMapIntensity.value=N.environmentIntensity),_t.dfgLUT!==void 0&&(_t.dfgLUT.value=Fm()),Cn){if(nt.setValue(U,"toneMappingExposure",L.toneMappingExposure),xe.needsLights&&rc(_t,ai),ge&&G.fog===!0&&Se.refreshFogUniforms(_t,ge),Se.refreshMaterialUniforms(_t,G,ne,ae,S.state.transmissionRenderTarget[x.id]),xe.needsLights&&xe.lightProbeGrid){const it=xe.lightProbeGrid;_t.probesSH.value=it.texture,_t.probesMin.value.copy(it.boundingBox.min),_t.probesMax.value.copy(it.boundingBox.max),_t.probesResolution.value.copy(it.resolution)}Os.upload(U,ro(xe),_t,K)}if(G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&(Os.upload(U,ro(xe),_t,K),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&nt.setValue(U,"center",V.center),nt.setValue(U,"modelViewMatrix",V.modelViewMatrix),nt.setValue(U,"normalMatrix",V.normalMatrix),nt.setValue(U,"modelMatrix",V.matrixWorld),G.uniformsGroups!==void 0){const it=G.uniformsGroups;for(let Dn=0,oi=it.length;Dn0&&K.useMultisampledRTT(x)===!1?G=z.get(x).__webglMultisampledFramebuffer:Array.isArray(ye)?G=ye[k]:G=ye,me.copy(x.viewport),de.copy(x.scissor),Ye=x.scissorTest}else me.copy(Re).multiplyScalar(ne).floor(),de.copy(rt).multiplyScalar(ne).floor(),Ye=Ge;if(k!==0&&(G=Z),f.bindFramebuffer(U.FRAMEBUFFER,G)&&f.drawBuffers(x,G),f.viewport(me),f.scissor(de),f.setScissorTest(Ye),V){const _e=z.get(x.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_CUBE_MAP_POSITIVE_X+N,_e.__webglTexture,k)}else if(ge){const _e=N;for(let Me=0;Me1&&U.readBuffer(U.COLOR_ATTACHMENT0+_e),!y.textureFormatReadable(Oe)){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!y.textureTypeReadable(Ve)){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=x.width-G&&k>=0&&k<=x.height-V&&U.readPixels(N,k,G,V,ce.convert(Oe),ce.convert(Ve),ge)}finally{const ye=ee!==null?z.get(ee).__webglFramebuffer:null;f.bindFramebuffer(U.FRAMEBUFFER,ye)}}},this.readRenderTargetPixelsAsync=async function(x,N,k,G,V,ge,ve,_e=0){if(!(x&&x.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Me=z.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&ve!==void 0&&(Me=Me[ve]),Me)if(N>=0&&N<=x.width-G&&k>=0&&k<=x.height-V){f.bindFramebuffer(U.FRAMEBUFFER,Me);const ye=x.textures[_e],Oe=ye.format,Ve=ye.type;if(x.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+_e),!y.textureFormatReadable(Oe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!y.textureTypeReadable(Ve))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const be=U.createBuffer();U.bindBuffer(U.PIXEL_PACK_BUFFER,be),U.bufferData(U.PIXEL_PACK_BUFFER,ge.byteLength,U.STREAM_READ),U.readPixels(N,k,G,V,ce.convert(Oe),ce.convert(Ve),0);const Qe=ee!==null?z.get(ee).__webglFramebuffer:null;f.bindFramebuffer(U.FRAMEBUFFER,Qe);const mt=U.fenceSync(U.SYNC_GPU_COMMANDS_COMPLETE,0);return U.flush(),await Yc(U,mt,4),U.bindBuffer(U.PIXEL_PACK_BUFFER,be),U.getBufferSubData(U.PIXEL_PACK_BUFFER,0,ge),U.deleteBuffer(be),U.deleteSync(mt),ge}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(x,N=null,k=0){const G=Math.pow(2,-k),V=Math.floor(x.image.width*G),ge=Math.floor(x.image.height*G),ve=N!==null?N.x:0,_e=N!==null?N.y:0;K.setTexture2D(x,0),U.copyTexSubImage2D(U.TEXTURE_2D,k,0,0,ve,_e,V,ge),f.unbindTexture()},this.copyTextureToTexture=function(x,N,k=null,G=null,V=0,ge=0){let ve,_e,Me,ye,Oe,Ve,be,Qe,mt;const dt=x.isCompressedTexture?x.mipmaps[ge]:x.image;if(k!==null)ve=k.max.x-k.min.x,_e=k.max.y-k.min.y,Me=k.isBox3?k.max.z-k.min.z:1,ye=k.min.x,Oe=k.min.y,Ve=k.isBox3?k.min.z:0;else{const _t=Math.pow(2,-V);ve=Math.floor(dt.width*_t),_e=Math.floor(dt.height*_t),x.isDataArrayTexture?Me=dt.depth:x.isData3DTexture?Me=Math.floor(dt.depth*_t):Me=1,ye=0,Oe=0,Ve=0}G!==null?(be=G.x,Qe=G.y,mt=G.z):(be=0,Qe=0,mt=0);const tt=ce.convert(N.format),Ct=ce.convert(N.type);let xe;N.isData3DTexture?(K.setTexture3D(N,0),xe=U.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(K.setTexture2DArray(N,0),xe=U.TEXTURE_2D_ARRAY):(K.setTexture2D(N,0),xe=U.TEXTURE_2D),f.activeTexture(U.TEXTURE0),f.pixelStorei(U.UNPACK_FLIP_Y_WEBGL,N.flipY),f.pixelStorei(U.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),f.pixelStorei(U.UNPACK_ALIGNMENT,N.unpackAlignment);const Gt=f.getParameter(U.UNPACK_ROW_LENGTH),Ke=f.getParameter(U.UNPACK_IMAGE_HEIGHT),Xt=f.getParameter(U.UNPACK_SKIP_PIXELS),rn=f.getParameter(U.UNPACK_SKIP_ROWS),Cn=f.getParameter(U.UNPACK_SKIP_IMAGES);f.pixelStorei(U.UNPACK_ROW_LENGTH,dt.width),f.pixelStorei(U.UNPACK_IMAGE_HEIGHT,dt.height),f.pixelStorei(U.UNPACK_SKIP_PIXELS,ye),f.pixelStorei(U.UNPACK_SKIP_ROWS,Oe),f.pixelStorei(U.UNPACK_SKIP_IMAGES,Ve);const ai=x.isDataArrayTexture||x.isData3DTexture,nt=N.isDataArrayTexture||N.isData3DTexture;if(x.isDepthTexture){const _t=z.get(x),Pn=z.get(N),it=z.get(_t.__renderTarget),Dn=z.get(Pn.__renderTarget);f.bindFramebuffer(U.READ_FRAMEBUFFER,it.__webglFramebuffer),f.bindFramebuffer(U.DRAW_FRAMEBUFFER,Dn.__webglFramebuffer);for(let oi=0;oiMath.PI&&(n-=Bt),s<-Math.PI?s+=Bt:s>Math.PI&&(s-=Bt),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(St.setFromSpherical(this._spherical),St.applyQuaternion(this._quatInverse),t.copy(this.target).add(St),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=St.length();a=this._clampDistance(o*this._scale);const c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){const o=new I(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=c!==this.object.zoom;const l=new I(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=St.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Ps.origin.copy(this.object.position),Ps.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ps.direction))Br||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Br||this._lastTargetPosition.distanceToSquared(this.target)>Br?(this.dispatchEvent(gl),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Bt/60*this.autoRotateSpeed*e:Bt/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){St.setFromMatrixColumn(t,0),St.multiplyScalar(-e),this._panOffset.add(St)}_panUp(e,t){this.screenSpacePanning===!0?St.setFromMatrixColumn(t,1):(St.setFromMatrixColumn(t,0),St.crossVectors(this.object.up,St)),St.multiplyScalar(e),this._panOffset.add(St)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;St.copy(s).sub(this.target);let r=St.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Bt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Bt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Bt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Bt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Bt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Bt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Bt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Bt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t"u"?e:getComputedStyle(document.documentElement).getPropertyValue(i).trim()||e}function e_(i,e=26){return i.length<=e?i:`${i.slice(0,e-1)}…`}function nc(i,e,t){const n=document.createElement("canvas");n.width=t.width,n.height=t.height;const s=n.getContext("2d");s&&(s.clearRect(0,0,t.width,t.height),s.fillStyle=e,s.font=t.font,s.textAlign="center",s.textBaseline="middle",s.fillText(i,t.width/2,t.height/2));const r=new Sh(n);r.colorSpace=kt;const a=new mh(new Gl({map:r,transparent:!0,depthTest:!1}));return a.scale.set(t.width*.22,t.height*.22,1),a}function t_(i,e){const t=nc(i,e,{width:512,height:64,font:"600 28px sans-serif"});return t.scale.set(110,14,1),t}function n_(i,e){const t=nc(e_(i),e,{width:384,height:48,font:"600 22px sans-serif"});return t.scale.set(52,6.5,1),t}function i_(i,e,t,n){return i.weight==="critical"?n:i.weight==="expensive"?t:e}function r_({nodes:i,edges:e,selectedId:t,neighborIds:n,onSelect:s,layout:r="layers",nodeRoles:a,testOverlay:o=!1}){const c=Ot.useRef(null),l=Ot.useRef(null),[d,m]=Ot.useState(null),[h,_]=Ot.useState(null),[v,E]=Ot.useState(()=>typeof document>"u"?"obsidian":document.documentElement.dataset.theme||"obsidian"),p=Ot.useRef(s);p.current=s;const u=Ot.useRef({selectedId:t,neighborIds:n});u.current={selectedId:t,neighborIds:n};const A=Ot.useRef({nodeRoles:a,testOverlay:o});A.current={nodeRoles:a,testOverlay:o};const R=Ot.useRef(null),M=Ot.useRef(!1),T=`${r}|${i.map(S=>S.id).join("\0")}|${e.map(S=>S.id).join("\0")}`;return Ot.useEffect(()=>{const S=document.documentElement,w=()=>E(S.dataset.theme||"obsidian"),g=new MutationObserver(w);return g.observe(S,{attributes:!0,attributeFilter:["data-theme"]}),()=>g.disconnect()},[]),Ot.useEffect(()=>{var fe;const S=l.current;if(!S)return;const w=window.matchMedia("(prefers-reduced-motion: reduce)").matches,g=tn("--graph-bg","#0b0f14"),b=tn("--ink","#e8eef7"),L=new Ie(tn("--accent","#4cc9f0")),D=new Ie(tn("--low","#e76f51")),B=new Ie(tn("--high","#2a9d8f")),Z=new ch;Z.background=new Ie(g),Z.fog=new ka(new Ie(g),520,2800);const W=new qt(50,1,1,8e3);let O;try{O=new Om({antialias:!0,alpha:!1,failIfMajorPerformanceCaveat:!1,powerPreference:"low-power"})}catch{_("WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map.");return}if(!O.getContext()){O.dispose(),_("WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map.");return}_(null),O.setClearColor(g,1),O.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),O.domElement.dataset.testid="graph-3d-canvas",S.appendChild(O.domElement);const H=new zm(W,O.domElement);H.enableDamping=!w,H.dampingFactor=.08,H.minDistance=80,H.maxDistance=2400,Z.add(new Lh(16777215,1713203,.55)),Z.add(new Fh(16777215,.42));const Y=new Nh(16777215,.8);Y.position.set(200,320,180),Z.add(Y);const ee=oc(i,e,r),te=new Map(i.map(C=>[C.id,C])),he=new Map,me=new Map,de=new Zi;Z.add(de);const Ye=new qa(1,18,14),st=i.length<=Qm,qe=[];for(const C of i){const X=ee.get(C.id)??{x:0,y:0,z:0},J=nr(C.type),Te=new Rh({color:lc(C.type),roughness:.42,metalness:.08,transparent:!0,opacity:1}),Pe=new Kt(Ye,Te);if(Pe.position.set(X.x,X.y,X.z),Pe.scale.setScalar(J),Pe.userData.id=C.id,de.add(Pe),he.set(C.id,Pe),st){const Le=n_(C.name,b);Le.position.set(X.x,X.y+J+8,X.z),de.add(Le),me.set(C.id,Le),qe.push(Le)}}const j=new Ie(tn("--edge-cheap","#4a5568")),ae=new Ie(tn("--edge-expensive","#f4a261")),ne=new Ie(tn("--edge-critical","#e85d04")),Ae=[],Ue=[],Re=[],rt=[],Ge=[];for(const C of e){const X=ee.get(C.src),J=ee.get(C.dst);if(!X||!J)continue;const Te=i_(C,j,ae,ne),Pe=cc(C),Le=Te.clone().multiplyScalar(.55);Pe?(Ae.push({edge:C,a:X,b:J,color:Te,inferred:Pe,solidIndex:-1,dashedIndex:rt.length/3}),rt.push(X.x,X.y,X.z,J.x,J.y,J.z),Ge.push(Le.r,Le.g,Le.b,Te.r,Te.g,Te.b)):(Ae.push({edge:C,a:X,b:J,color:Te,inferred:Pe,solidIndex:Ue.length/3,dashedIndex:-1}),Ue.push(X.x,X.y,X.z,J.x,J.y,J.z),Re.push(Le.r,Le.g,Le.b,Te.r,Te.g,Te.b))}const Ze=new wt;Ze.setAttribute("position",new gt(Ue,3)),Ze.setAttribute("color",new gt(Re,3));const ke=new Fo(Ze,new Ys({vertexColors:!0,transparent:!0,opacity:.58}));de.add(ke);const Be=new wt;Be.setAttribute("position",new gt(rt,3)),Be.setAttribute("color",new gt(Ge,3));const ot=new Dh({vertexColors:!0,transparent:!0,opacity:.5,dashSize:7,gapSize:5}),ut=new Fo(Be,ot);ut.computeLineDistances(),de.add(ut);const ft=new Ya(2.2,7,8),pt=[];if(Ae.length<=jm){const C=new I(0,1,0),X=new I;for(const J of Ae){const Te=new Xs({color:J.color,transparent:!0,opacity:.85}),Pe=new Kt(ft,Te);X.set(J.b.x-J.a.x,J.b.y-J.a.y,J.b.z-J.a.z);const Le=X.length();if(Le<8)Pe.visible=!1;else{X.multiplyScalar(1/Le);const xt=nr(((fe=te.get(J.edge.dst))==null?void 0:fe.type)||""),Ft=Math.min(Le-4,xt+5);Pe.position.set(J.b.x-X.x*Ft,J.b.y-X.y*Ft,J.b.z-X.z*Ft),Pe.quaternion.setFromUnitVectors(C,X)}Pe.userData.src=J.edge.src,Pe.userData.dst=J.edge.dst,de.add(Pe),pt.push(Pe)}}const ct=new Xs({color:new Ie(tn("--node-line","#2a3d52")),transparent:!0,opacity:.16,side:cn,depthWrite:!1}),U=new Ys({color:new Ie(tn("--muted","#8b9bb0")),transparent:!0,opacity:.28}),Rt=tn("--muted","#8b9bb0"),$e=[],y=[],f=new es(1,1);y.push(f);for(const C of hc(i,ee,r))if(C.shape==="slab"){const X=new Kt(f,ct);X.scale.set(C.extentZ*2,C.extentY*2,1),X.rotation.y=Math.PI/2,X.position.set(C.x,C.y,C.z),de.add(X);const J=new wt().setFromPoints([new I(C.x,C.y-C.extentY,C.z-C.extentZ),new I(C.x,C.y+C.extentY,C.z-C.extentZ),new I(C.x,C.y+C.extentY,C.z+C.extentZ),new I(C.x,C.y-C.extentY,C.z+C.extentZ)]);if(y.push(J),de.add(new Oo(J,U)),C.label){const Te=t_(C.label,Rt);Te.position.set(C.x,C.y+C.extentY+12,C.z),de.add(Te),$e.push(Te)}}else if(C.radius>=12){const X=[];for(let Te=0;Te<64;Te+=1){const Pe=Te/64*Math.PI*2;X.push(new I(Math.cos(Pe)*C.radius,Math.sin(Pe)*C.radius,C.z))}const J=new wt().setFromPoints(X);y.push(J),de.add(new Oo(J,U))}const F=R.current;if(F&&F.topology===T)W.position.set(F.position.x,F.position.y,F.position.z),H.target.set(F.target.x,F.target.y,F.target.z),W.lookAt(H.target);else{const C=new Ni().setFromObject(de),X=C.getCenter(new I),J=C.getSize(new I);H.target.copy(X),W.position.set(X.x+J.x*.15,X.y+Math.max(140,J.y*.45),X.z+Math.max(280,J.z*.9+180)),W.lookAt(X)}const z=new zh;z.params.Mesh={...z.params.Mesh,threshold:2};const K=new we,se=[...he.values()];let ie=null,q=null;const Q=(C,X)=>{const J=C.color.clone().multiplyScalar(.55*X),Te=C.color.clone().multiplyScalar(X),Pe=C.inferred?Be.getAttribute("color"):Ze.getAttribute("color"),Le=C.inferred?C.dashedIndex:C.solidIndex;Le<0||(Pe.setXYZ(Le,J.r,J.g,J.b),Pe.setXYZ(Le+1,Te.r,Te.g,Te.b))},oe=(C,X)=>{const J=!!(C&&X.size),Te=A.current.nodeRoles||{},Pe=A.current.testOverlay;for(const[Le,xt]of he){const Ft=te.get(Le),Mt=xt.material,$t=!J||X.has(Le),wn=Le===C,Yn=Te[Le]||[];let Rn=nr((Ft==null?void 0:Ft.type)||"");wn?Rn*=1.28:$t?Yn.includes("seed")&&(Rn*=1.12):Rn*=.7,xt.scale.setScalar(Rn),Mt.opacity=wn?1:$t?.96:.12,wn?(Mt.emissive.copy(L),Mt.emissiveIntensity=.4):Yn.includes("untested")?(Mt.emissive.copy(D),Mt.emissiveIntensity=$t?.32:.05):Pe&&Yn.includes("tested")?(Mt.emissive.copy(B),Mt.emissiveIntensity=$t?.22:.04):Yn.includes("seed")?(Mt.emissive.copy(L),Mt.emissiveIntensity=$t?.2:.04):Yn.includes("contract")?(Mt.emissive.copy(L),Mt.emissiveIntensity=$t?.16:.03):(Mt.emissive.set(0),Mt.emissiveIntensity=0);const Jt=ee.get(Le)??{x:0,y:0,z:0},qn=me.get(Le);qn&&(qn.visible=wn||J&&X.has(Le)||!C&&st,qn.position.set(Jt.x,Jt.y+Rn+8,Jt.z))}ke.material.opacity=J?.9:.55,ot.opacity=J?.78:.48;for(const Le of Ae){const xt=!!(C&&(Le.edge.src===C||Le.edge.dst===C)),Ft=!J||X.has(Le.edge.src)&&X.has(Le.edge.dst);Q(Le,xt?1:Ft?.85:.12)}Ae.length&&(Ze.getAttribute("color").needsUpdate=!0,Be.getAttribute("color").needsUpdate=!0);for(const Le of pt){const xt=Le.userData.src,Ft=Le.userData.dst,Mt=!!(C&&(xt===C||Ft===C)),$t=!J||X.has(xt)&&X.has(Ft);Le.visible=$t&&(Ae.length<=80||Mt),Le.material.opacity=Mt?1:.75}},Se=C=>{if(!C){ie=null,q=null;return}const X=ee.get(C);if(!X)return;const J=new I(X.x,X.y,X.z),Te=W.position.clone().sub(H.target);if(Te.length()<40&&Te.set(90,110,180),w){H.target.copy(J),W.position.copy(J).add(Te),ie=null,q=null;return}ie=J,q=J.clone().add(Te)},ue=C=>{const X=O.domElement.getBoundingClientRect();K.x=(C.clientX-X.left)/X.width*2-1,K.y=-((C.clientY-X.top)/X.height)*2+1},le=()=>{z.setFromCamera(K,W);const C=z.intersectObjects(se,!1)[0],X=C==null?void 0:C.object.userData.id;return X?te.get(X)??null:null},Ee=C=>{ue(C);const X=le();if(!X){m(null),O.domElement.style.cursor="grab";return}O.domElement.style.cursor="pointer";const J=(c.current??S).getBoundingClientRect();m({node:X,x:C.clientX-J.left,y:C.clientY-J.top})},Ce=C=>{ue(C);const X=le();p.current(X?X.id:null)},Ne=()=>{ie=null,q=null},P=()=>{const C=S.clientWidth||1,X=S.clientHeight||1;W.aspect=C/X,W.updateProjectionMatrix(),O.setSize(C,X,!1)};P();const re=new ResizeObserver(P);re.observe(S);let $=0;const ce=()=>{$=requestAnimationFrame(ce);try{ie&&q&&(H.target.lerp(ie,.14),W.position.lerp(q,.14),H.target.distanceTo(ie)<1.5&&(H.target.copy(ie),W.position.copy(q),ie=null,q=null)),H.update(),O.render(Z,W)}catch{cancelAnimationFrame($),_("WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map.")}};return ce(),O.domElement.addEventListener("pointermove",Ee),O.domElement.addEventListener("click",Ce),H.addEventListener("start",Ne),S.__paint=oe,S.__focus=Se,oe(u.current.selectedId,u.current.neighborIds),()=>{var C;R.current={topology:T,position:{x:W.position.x,y:W.position.y,z:W.position.z},target:{x:H.target.x,y:H.target.y,z:H.target.z}},cancelAnimationFrame($),re.disconnect(),O.domElement.removeEventListener("pointermove",Ee),O.domElement.removeEventListener("click",Ce),H.removeEventListener("start",Ne),delete S.__paint,delete S.__focus,H.dispose(),Ye.dispose(),ft.dispose(),Ze.dispose(),Be.dispose(),ct.dispose(),U.dispose();for(const X of y)X.dispose();ke.material.dispose(),ot.dispose();for(const X of[...$e,...qe]){const J=X.material;(C=J.map)==null||C.dispose(),J.dispose()}for(const X of he.values())X.material.dispose();for(const X of pt)X.material.dispose();O.dispose(),O.domElement.remove(),m(null)}},[T,v]),Ot.useEffect(()=>{var S,w;(w=(S=l.current)==null?void 0:S.__paint)==null||w.call(S,t,n)},[t,n,a,o]),Ot.useEffect(()=>{var S,w;if(!M.current){M.current=!0;return}(w=(S=l.current)==null?void 0:S.__focus)==null||w.call(S,t)},[t]),Zn.jsxs("div",{className:"graph-3d-host",ref:c,children:[Zn.jsx("div",{className:"graph-3d-canvas-host",ref:l}),h?Zn.jsx("p",{className:"muted graph-3d-hint","data-testid":"graph-3d-fallback",children:h}):null,d?Zn.jsxs("div",{className:"graph-3d-tip",style:{left:d.x+12,top:d.y+12},children:[Zn.jsxs("div",{className:"t",children:[uc(d.node.type),d.node.context?` · ${d.node.context}`:""]}),Zn.jsx("div",{className:"n",children:d.node.name}),d.node.file_path?Zn.jsx("div",{className:"f",children:d.node.file_path}):null]}):null]})}export{r_ as LayeredGraph3D}; diff --git a/src/loadpath/static/assets/index-CcW4ogPp.js b/src/loadpath/static/assets/index-CcW4ogPp.js new file mode 100644 index 0000000..899dc41 --- /dev/null +++ b/src/loadpath/static/assets/index-CcW4ogPp.js @@ -0,0 +1,62 @@ +var N0=Object.defineProperty;var b0=(e,r,o)=>r in e?N0(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o;var ih=(e,r,o)=>b0(e,typeof r!="symbol"?r+"":r,o);(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function Op(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Hu={exports:{}},Ki={},Bu={exports:{}},Ae={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var sh;function j0(){if(sh)return Ae;sh=1;var e=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),v=Symbol.iterator;function g(R){return R===null||typeof R!="object"?null:(R=v&&R[v]||R["@@iterator"],typeof R=="function"?R:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,k={};function b(R,z,re){this.props=R,this.context=z,this.refs=k,this.updater=re||x}b.prototype.isReactComponent={},b.prototype.setState=function(R,z){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,z,"setState")},b.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function E(){}E.prototype=b.prototype;function I(R,z,re){this.props=R,this.context=z,this.refs=k,this.updater=re||x}var _=I.prototype=new E;_.constructor=I,S(_,b.prototype),_.isPureReactComponent=!0;var j=Array.isArray,L=Object.prototype.hasOwnProperty,$={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function U(R,z,re){var oe,fe={},le=null,he=null;if(z!=null)for(oe in z.ref!==void 0&&(he=z.ref),z.key!==void 0&&(le=""+z.key),z)L.call(z,oe)&&!F.hasOwnProperty(oe)&&(fe[oe]=z[oe]);var Z=arguments.length-2;if(Z===1)fe.children=re;else if(1>>1,z=M[R];if(0>>1;Ra(fe,H))lea(he,fe)?(M[R]=he,M[le]=H,R=le):(M[R]=fe,M[oe]=H,R=oe);else if(lea(he,H))M[R]=he,M[le]=H,R=le;else break e}}return D}function a(M,D){var H=M.sortIndex-D.sortIndex;return H!==0?H:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();e.unstable_now=function(){return c.now()-h}}var p=[],y=[],w=1,v=null,g=3,x=!1,S=!1,k=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function _(M){for(var D=o(y);D!==null;){if(D.callback===null)s(y);else if(D.startTime<=M)s(y),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(y)}}function j(M){if(k=!1,_(M),!S)if(o(p)!==null)S=!0,W(L);else{var D=o(y);D!==null&&Y(j,D.startTime-M)}}function L(M,D){S=!1,k&&(k=!1,E(U),U=-1),x=!0;var H=g;try{for(_(D),v=o(p);v!==null&&(!(v.expirationTime>D)||M&&!J());){var R=v.callback;if(typeof R=="function"){v.callback=null,g=v.priorityLevel;var z=R(v.expirationTime<=D);D=e.unstable_now(),typeof z=="function"?v.callback=z:v===o(p)&&s(p),_(D)}else s(p);v=o(p)}if(v!==null)var re=!0;else{var oe=o(y);oe!==null&&Y(j,oe.startTime-D),re=!1}return re}finally{v=null,g=H,x=!1}}var $=!1,F=null,U=-1,q=5,te=-1;function J(){return!(e.unstable_now()-teM||125R?(M.sortIndex=H,r(y,M),o(p)===null&&M===o(y)&&(k?(E(U),U=-1):k=!0,Y(j,H-R))):(M.sortIndex=z,r(p,M),S||x||(S=!0,W(L))),M},e.unstable_shouldYield=J,e.unstable_wrapCallback=function(M){var D=g;return function(){var H=g;g=D;try{return M.apply(this,arguments)}finally{g=H}}}})(Uu)),Uu}var dh;function I0(){return dh||(dh=1,Wu.exports=P0()),Wu.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var fh;function R0(){if(fh)return Ot;fh=1;var e=ps(),r=I0();function o(t){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+t,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,w={},v={};function g(t){return p.call(v,t)?!0:p.call(w,t)?!1:y.test(t)?v[t]=!0:(w[t]=!0,!1)}function x(t,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function S(t,n,i,l){if(n===null||typeof n>"u"||x(t,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function k(t,n,i,l,f,m,N){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=t,this.type=n,this.sanitizeURL=m,this.removeEmptyString=N}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){b[t]=new k(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var n=t[0];b[n]=new k(n,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){b[t]=new k(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){b[t]=new k(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){b[t]=new k(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){b[t]=new k(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){b[t]=new k(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){b[t]=new k(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){b[t]=new k(t,5,!1,t.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function I(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var n=t.replace(E,I);b[n]=new k(n,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var n=t.replace(E,I);b[n]=new k(n,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var n=t.replace(E,I);b[n]=new k(n,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){b[t]=new k(t,1,!1,t.toLowerCase(),null,!1,!1)}),b.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){b[t]=new k(t,1,!1,t.toLowerCase(),null,!0,!0)});function _(t,n,i,l){var f=b.hasOwnProperty(n)?b[n]:null;(f!==null?f.type!==0:l||!(2T||f[N]!==m[T]){var O=` +`+f[N].replace(" at new "," at ");return t.displayName&&O.includes("")&&(O=O.replace("",t.displayName)),O}while(1<=N&&0<=T);break}}}finally{re=!1,Error.prepareStackTrace=i}return(t=t?t.displayName||t.name:"")?z(t):""}function fe(t){switch(t.tag){case 5:return z(t.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return t=oe(t.type,!1),t;case 11:return t=oe(t.type.render,!1),t;case 1:return t=oe(t.type,!0),t;default:return""}}function le(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case F:return"Fragment";case $:return"Portal";case q:return"Profiler";case U:return"StrictMode";case Q:return"Suspense";case C:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case J:return(t.displayName||"Context")+".Consumer";case te:return(t._context.displayName||"Context")+".Provider";case ne:var n=t.render;return t=t.displayName,t||(t=n.displayName||n.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case V:return n=t.displayName||null,n!==null?n:le(t.type)||"Memo";case W:n=t._payload,t=t._init;try{return le(t(n))}catch{}}return null}function he(t){var n=t.type;switch(t.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=n.render,t=t.displayName||t.name||"",n.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return le(n);case 8:return n===U?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function se(t){var n=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(t){var n=se(t)?"checked":"value",i=Object.getOwnPropertyDescriptor(t.constructor.prototype,n),l=""+t[n];if(!t.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,m=i.set;return Object.defineProperty(t,n,{configurable:!0,get:function(){return f.call(this)},set:function(N){l=""+N,m.call(this,N)}}),Object.defineProperty(t,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(N){l=""+N},stopTracking:function(){t._valueTracker=null,delete t[n]}}}}function Ne(t){t._valueTracker||(t._valueTracker=me(t))}function we(t){if(!t)return!1;var n=t._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return t&&(l=se(t)?t.checked?"true":"false":t.value),t=l,t!==i?(n.setValue(t),!0):!1}function ye(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Me(t,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??t._wrapperState.initialChecked})}function Te(t,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),t._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Le(t,n){n=n.checked,n!=null&&_(t,"checked",n,!1)}function De(t,n){Le(t,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&t.value===""||t.value!=i)&&(t.value=""+i):t.value!==""+i&&(t.value=""+i);else if(l==="submit"||l==="reset"){t.removeAttribute("value");return}n.hasOwnProperty("value")?$e(t,n.type,i):n.hasOwnProperty("defaultValue")&&$e(t,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(t.defaultChecked=!!n.defaultChecked)}function pe(t,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+t._wrapperState.initialValue,i||n===t.value||(t.value=n),t.defaultValue=n}i=t.name,i!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,i!==""&&(t.name=i)}function $e(t,n,i){(n!=="number"||ye(t.ownerDocument)!==t)&&(i==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+i&&(t.defaultValue=""+i))}var Ve=Array.isArray;function Ue(t,n,i,l){if(t=t.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=rt.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;n.firstChild;)t.appendChild(n.firstChild)}});function Pt(t,n){if(n){var i=t.firstChild;if(i&&i===t.lastChild&&i.nodeType===3){i.nodeValue=n;return}}t.textContent=n}var bn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},di=["Webkit","ms","Moz","O"];Object.keys(bn).forEach(function(t){di.forEach(function(n){n=n+t.charAt(0).toUpperCase()+t.substring(1),bn[n]=bn[t]})});function Vn(t,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||bn.hasOwnProperty(t)&&bn[t]?(""+n).trim():n+"px"}function So(t,n){t=t.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=Vn(i,n[i],l);i==="float"&&(i="cssFloat"),l?t.setProperty(i,f):t[i]=f}}var dr=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Br(t,n){if(n){if(dr[t]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,t));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function Wn(t,n){if(t.indexOf("-")===-1)return typeof n.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Vr=null;function fr(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var hr=null,Ht=null,dt=null;function Un(t){if(t=Ai(t)){if(typeof hr!="function")throw Error(o(280));var n=t.stateNode;n&&(n=zs(n),hr(t.stateNode,t.type,n))}}function Gn(t){Ht?dt?dt.push(t):dt=[t]:Ht=t}function jn(){if(Ht){var t=Ht,n=dt;if(dt=Ht=null,Un(t),n)for(t=0;t>>=0,t===0?32:31-(gi(t)/mi|0)|0}var In=64,Zn=4194304;function Rn(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Kt(t,n){var i=t.pendingLanes;if(i===0)return 0;var l=0,f=t.suspendedLanes,m=t.pingedLanes,N=i&268435455;if(N!==0){var T=N&~f;T!==0?l=Rn(T):(m&=N,m!==0&&(l=Rn(m)))}else N=i&~f,N!==0?l=Rn(N):m!==0&&(l=Rn(m));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,m=n&-n,f>=m||f===16&&(m&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=t.entangledLanes,n!==0)for(t=t.entanglements,n&=l;0i;i++)n.push(t);return n}function Jn(t,n,i){t.pendingLanes|=n,n!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,n=31-yt(n),t[n]=i}function Co(t,n){var i=t.pendingLanes&~n;t.pendingLanes=n,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=n,t.mutableReadLanes&=n,t.entangledLanes&=n,n=t.entanglements;var l=t.eventTimes;for(t=t.expirationTimes;0=ji),Qc=" ",Zc=!1;function Jc(t,n){switch(t){case"keyup":return xy.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ed(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var To=!1;function _y(t,n){switch(t){case"compositionend":return ed(n);case"keypress":return n.which!==32?null:(Zc=!0,Qc);case"textInput":return t=n.data,t===Qc&&Zc?null:t;default:return null}}function Sy(t,n){if(To)return t==="compositionend"||!_l&&Jc(t,n)?(t=Uc(),js=gl=wr=null,To=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-t};t=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=ad(i)}}function ud(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?ud(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function cd(){for(var t=window,n=ye();n instanceof t.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)t=n.contentWindow;else break;n=ye(t.document)}return n}function Nl(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n&&(n==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||n==="textarea"||t.contentEditable==="true")}function Iy(t){var n=cd(),i=t.focusedElem,l=t.selectionRange;if(n!==i&&i&&i.ownerDocument&&ud(i.ownerDocument.documentElement,i)){if(l!==null&&Nl(i)){if(n=l.start,t=l.end,t===void 0&&(t=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(t,i.value.length);else if(t=(n=i.ownerDocument||document)&&n.defaultView||window,t.getSelection){t=t.getSelection();var f=i.textContent.length,m=Math.min(l.start,f);l=l.end===void 0?m:Math.min(l.end,f),!t.extend&&m>l&&(f=l,l=m,m=f),f=ld(i,m);var N=ld(i,l);f&&N&&(t.rangeCount!==1||t.anchorNode!==f.node||t.anchorOffset!==f.offset||t.focusNode!==N.node||t.focusOffset!==N.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),t.removeAllRanges(),m>l?(t.addRange(n),t.extend(N.node,N.offset)):(n.setEnd(N.node,N.offset),t.addRange(n)))}}for(n=[],t=i;t=t.parentNode;)t.nodeType===1&&n.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Lo=null,bl=null,Pi=null,jl=!1;function dd(t,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;jl||Lo==null||Lo!==ye(l)||(l=Lo,"selectionStart"in l&&Nl(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),Pi&&Mi(Pi,l)||(Pi=l,l=Ls(bl,"onSelect"),0Oo||(t.current=Dl[Oo],Dl[Oo]=null,Oo--)}function Ge(t,n){Oo++,Dl[Oo]=t.current,t.current=n}var Nr={},St=kr(Nr),Lt=kr(!1),Jr=Nr;function Fo(t,n){var i=t.type.contextTypes;if(!i)return Nr;var l=t.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},m;for(m in i)f[m]=n[m];return l&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=n,t.__reactInternalMemoizedMaskedChildContext=f),f}function At(t){return t=t.childContextTypes,t!=null}function Ds(){qe(Lt),qe(St)}function jd(t,n,i){if(St.current!==Nr)throw Error(o(168));Ge(St,n),Ge(Lt,i)}function Ed(t,n,i){var l=t.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,he(t)||"Unknown",f));return H({},i,l)}function Os(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Nr,Jr=St.current,Ge(St,t),Ge(Lt,Lt.current),!0}function Cd(t,n,i){var l=t.stateNode;if(!l)throw Error(o(169));i?(t=Ed(t,n,Jr),l.__reactInternalMemoizedMergedChildContext=t,qe(Lt),qe(St),Ge(St,t)):qe(Lt),Ge(Lt,i)}var tr=null,Fs=!1,Ol=!1;function Md(t){tr===null?tr=[t]:tr.push(t)}function Vy(t){Fs=!0,Md(t)}function br(){if(!Ol&&tr!==null){Ol=!0;var t=0,n=Be;try{var i=tr;for(Be=1;t>=N,f-=N,nr=1<<32-yt(n)+f|i<Ce?(pt=je,je=null):pt=je.sibling;var He=ie(X,je,K[Ce],de);if(He===null){je===null&&(je=pt);break}t&&je&&He.alternate===null&&n(X,je),B=m(He,B,Ce),be===null?Se=He:be.sibling=He,be=He,je=pt}if(Ce===K.length)return i(X,je),Qe&&to(X,Ce),Se;if(je===null){for(;CeCe?(pt=je,je=null):pt=je.sibling;var Lr=ie(X,je,He.value,de);if(Lr===null){je===null&&(je=pt);break}t&&je&&Lr.alternate===null&&n(X,je),B=m(Lr,B,Ce),be===null?Se=Lr:be.sibling=Lr,be=Lr,je=pt}if(He.done)return i(X,je),Qe&&to(X,Ce),Se;if(je===null){for(;!He.done;Ce++,He=K.next())He=ue(X,He.value,de),He!==null&&(B=m(He,B,Ce),be===null?Se=He:be.sibling=He,be=He);return Qe&&to(X,Ce),Se}for(je=l(X,je);!He.done;Ce++,He=K.next())He=ge(je,X,Ce,He.value,de),He!==null&&(t&&He.alternate!==null&&je.delete(He.key===null?Ce:He.key),B=m(He,B,Ce),be===null?Se=He:be.sibling=He,be=He);return t&&je.forEach(function(k0){return n(X,k0)}),Qe&&to(X,Ce),Se}function ot(X,B,K,de){if(typeof K=="object"&&K!==null&&K.type===F&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case L:e:{for(var Se=K.key,be=B;be!==null;){if(be.key===Se){if(Se=K.type,Se===F){if(be.tag===7){i(X,be.sibling),B=f(be,K.props.children),B.return=X,X=B;break e}}else if(be.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===W&&Ad(Se)===be.type){i(X,be.sibling),B=f(be,K.props),B.ref=$i(X,be,K),B.return=X,X=B;break e}i(X,be);break}else n(X,be);be=be.sibling}K.type===F?(B=uo(K.props.children,X.mode,de,K.key),B.return=X,X=B):(de=pa(K.type,K.key,K.props,null,X.mode,de),de.ref=$i(X,B,K),de.return=X,X=de)}return N(X);case $:e:{for(be=K.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===K.containerInfo&&B.stateNode.implementation===K.implementation){i(X,B.sibling),B=f(B,K.children||[]),B.return=X,X=B;break e}else{i(X,B);break}else n(X,B);B=B.sibling}B=$u(K,X.mode,de),B.return=X,X=B}return N(X);case W:return be=K._init,ot(X,B,be(K._payload),de)}if(Ve(K))return xe(X,B,K,de);if(D(K))return _e(X,B,K,de);Ws(X,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,B!==null&&B.tag===6?(i(X,B.sibling),B=f(B,K),B.return=X,X=B):(i(X,B),B=Au(K,X.mode,de),B.return=X,X=B),N(X)):i(X,B)}return ot}var Wo=$d(!0),zd=$d(!1),Us=kr(null),Gs=null,Uo=null,Ul=null;function Gl(){Ul=Uo=Gs=null}function Yl(t){var n=Us.current;qe(Us),t._currentValue=n}function Xl(t,n,i){for(;t!==null;){var l=t.alternate;if((t.childLanes&n)!==n?(t.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),t===i)break;t=t.return}}function Go(t,n){Gs=t,Ul=Uo=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&n)!==0&&($t=!0),t.firstContext=null)}function Jt(t){var n=t._currentValue;if(Ul!==t)if(t={context:t,memoizedValue:n,next:null},Uo===null){if(Gs===null)throw Error(o(308));Uo=t,Gs.dependencies={lanes:0,firstContext:t}}else Uo=Uo.next=t;return n}var no=null;function ql(t){no===null?no=[t]:no.push(t)}function Dd(t,n,i,l){var f=n.interleaved;return f===null?(i.next=i,ql(n)):(i.next=f.next,f.next=i),n.interleaved=i,or(t,l)}function or(t,n){t.lanes|=n;var i=t.alternate;for(i!==null&&(i.lanes|=n),i=t,t=t.return;t!==null;)t.childLanes|=n,i=t.alternate,i!==null&&(i.childLanes|=n),i=t,t=t.return;return i.tag===3?i.stateNode:null}var jr=!1;function Kl(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Od(t,n){t=t.updateQueue,n.updateQueue===t&&(n.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function ir(t,n){return{eventTime:t,lane:n,tag:0,payload:null,callback:null,next:null}}function Er(t,n,i){var l=t.updateQueue;if(l===null)return null;if(l=l.shared,(Oe&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,or(t,i)}return f=l.interleaved,f===null?(n.next=n,ql(l)):(n.next=f.next,f.next=n),l.interleaved=n,or(t,i)}function Ys(t,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=t.pendingLanes,i|=l,n.lanes=i,vr(t,i)}}function Fd(t,n){var i=t.updateQueue,l=t.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,m=null;if(i=i.firstBaseUpdate,i!==null){do{var N={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};m===null?f=m=N:m=m.next=N,i=i.next}while(i!==null);m===null?f=m=n:m=m.next=n}else f=m=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:m,shared:l.shared,effects:l.effects},t.updateQueue=i;return}t=i.lastBaseUpdate,t===null?i.firstBaseUpdate=n:t.next=n,i.lastBaseUpdate=n}function Xs(t,n,i,l){var f=t.updateQueue;jr=!1;var m=f.firstBaseUpdate,N=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,ee=O.next;O.next=null,N===null?m=ee:N.next=ee,N=O;var ae=t.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==N&&(T===null?ae.firstBaseUpdate=ee:T.next=ee,ae.lastBaseUpdate=O))}if(m!==null){var ue=f.baseState;N=0,ae=ee=O=null,T=m;do{var ie=T.lane,ge=T.eventTime;if((l&ie)===ie){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=t,_e=T;switch(ie=n,ge=i,_e.tag){case 1:if(xe=_e.payload,typeof xe=="function"){ue=xe.call(ge,ue,ie);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=_e.payload,ie=typeof xe=="function"?xe.call(ge,ue,ie):xe,ie==null)break e;ue=H({},ue,ie);break e;case 2:jr=!0}}T.callback!==null&&T.lane!==0&&(t.flags|=64,ie=f.effects,ie===null?f.effects=[T]:ie.push(T))}else ge={eventTime:ge,lane:ie,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(ee=ae=ge,O=ue):ae=ae.next=ge,N|=ie;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;ie=T,T=ie.next,ie.next=null,f.lastBaseUpdate=ie,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=ee,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do N|=f.lane,f=f.next;while(f!==n)}else m===null&&(f.shared.lanes=0);io|=N,t.lanes=N,t.memoizedState=ue}}function Hd(t,n,i){if(t=n.effects,n.effects=null,t!==null)for(n=0;ni?i:4,t(!0);var l=tu.transition;tu.transition={};try{t(!1),n()}finally{Be=i,tu.transition=l}}function af(){return en().memoizedState}function Yy(t,n,i){var l=Ir(t);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},lf(t))uf(n,i);else if(i=Dd(t,n,i,l),i!==null){var f=Ct();yn(i,t,l,f),cf(i,n,l)}}function Xy(t,n,i){var l=Ir(t),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(lf(t))uf(n,f);else{var m=t.alternate;if(t.lanes===0&&(m===null||m.lanes===0)&&(m=n.lastRenderedReducer,m!==null))try{var N=n.lastRenderedState,T=m(N,i);if(f.hasEagerState=!0,f.eagerState=T,fn(T,N)){var O=n.interleaved;O===null?(f.next=f,ql(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Dd(t,n,f,l),i!==null&&(f=Ct(),yn(i,t,l,f),cf(i,n,l))}}function lf(t){var n=t.alternate;return t===Je||n!==null&&n===Je}function uf(t,n){Fi=Qs=!0;var i=t.pending;i===null?n.next=n:(n.next=i.next,i.next=n),t.pending=n}function cf(t,n,i){if((i&4194240)!==0){var l=n.lanes;l&=t.pendingLanes,i|=l,n.lanes=i,vr(t,i)}}var ea={readContext:Jt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},qy={readContext:Jt,useCallback:function(t,n){return An().memoizedState=[t,n===void 0?null:n],t},useContext:Jt,useEffect:Zd,useImperativeHandle:function(t,n,i){return i=i!=null?i.concat([t]):null,Zs(4194308,4,tf.bind(null,n,t),i)},useLayoutEffect:function(t,n){return Zs(4194308,4,t,n)},useInsertionEffect:function(t,n){return Zs(4,2,t,n)},useMemo:function(t,n){var i=An();return n=n===void 0?null:n,t=t(),i.memoizedState=[t,n],t},useReducer:function(t,n,i){var l=An();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:n},l.queue=t,t=t.dispatch=Yy.bind(null,Je,t),[l.memoizedState,t]},useRef:function(t){var n=An();return t={current:t},n.memoizedState=t},useState:Kd,useDebugValue:lu,useDeferredValue:function(t){return An().memoizedState=t},useTransition:function(){var t=Kd(!1),n=t[0];return t=Gy.bind(null,t[1]),An().memoizedState=t,[n,t]},useMutableSource:function(){},useSyncExternalStore:function(t,n,i){var l=Je,f=An();if(Qe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(oo&30)!==0||Ud(l,n,i)}f.memoizedState=i;var m={value:i,getSnapshot:n};return f.queue=m,Zd(Yd.bind(null,l,m,t),[t]),l.flags|=2048,Vi(9,Gd.bind(null,l,m,i,n),void 0,null),i},useId:function(){var t=An(),n=ht.identifierPrefix;if(Qe){var i=rr,l=nr;i=(l&~(1<<32-yt(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Hi++,0<\/script>",t=t.removeChild(t.firstChild)):typeof l.is=="string"?t=N.createElement(i,{is:l.is}):(t=N.createElement(i),i==="select"&&(N=t,l.multiple?N.multiple=!0:l.size&&(N.size=l.size))):t=N.createElementNS(t,i),t[Tn]=n,t[Li]=l,Pf(t,n,!1,!1),n.stateNode=t;e:{switch(N=Wn(i,l),i){case"dialog":Xe("cancel",t),Xe("close",t),f=l;break;case"iframe":case"object":case"embed":Xe("load",t),f=l;break;case"video":case"audio":for(f=0;fQo&&(n.flags|=128,l=!0,Wi(m,!1),n.lanes=4194304)}else{if(!l)if(t=qs(N),t!==null){if(n.flags|=128,l=!0,i=t.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Wi(m,!0),m.tail===null&&m.tailMode==="hidden"&&!N.alternate&&!Qe)return Nt(n),null}else 2*Ye()-m.renderingStartTime>Qo&&i!==1073741824&&(n.flags|=128,l=!0,Wi(m,!1),n.lanes=4194304);m.isBackwards?(N.sibling=n.child,n.child=N):(i=m.last,i!==null?i.sibling=N:n.child=N,m.last=N)}return m.tail!==null?(n=m.tail,m.rendering=n,m.tail=n.sibling,m.renderingStartTime=Ye(),n.sibling=null,i=Ze.current,Ge(Ze,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return Ru(),l=n.memoizedState!==null,t!==null&&t.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Ut&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function r0(t,n){switch(Hl(n),n.tag){case 1:return At(n.type)&&Ds(),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return Yo(),qe(Lt),qe(St),eu(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 5:return Zl(n),null;case 13:if(qe(Ze),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(o(340));Vo()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return qe(Ze),null;case 4:return Yo(),null;case 10:return Yl(n.type._context),null;case 22:case 23:return Ru(),null;case 24:return null;default:return null}}var oa=!1,bt=!1,o0=typeof WeakSet=="function"?WeakSet:Set,ve=null;function qo(t,n){var i=t.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){nt(t,n,l)}else i.current=null}function wu(t,n,i){try{i()}catch(l){nt(t,n,l)}}var Tf=!1;function i0(t,n){if(Rl=Ns,t=cd(),Nl(t)){if("selectionStart"in t)var i={start:t.selectionStart,end:t.selectionEnd};else e:{i=(i=t.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,m=l.focusNode;l=l.focusOffset;try{i.nodeType,m.nodeType}catch{i=null;break e}var N=0,T=-1,O=-1,ee=0,ae=0,ue=t,ie=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=N+f),ue!==m||l!==0&&ue.nodeType!==3||(O=N+l),ue.nodeType===3&&(N+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)ie=ue,ue=ge;for(;;){if(ue===t)break t;if(ie===i&&++ee===f&&(T=N),ie===m&&++ae===l&&(O=N),(ge=ue.nextSibling)!==null)break;ue=ie,ie=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(Tl={focusedElem:t,selectionRange:i},Ns=!1,ve=n;ve!==null;)if(n=ve,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,ve=t;else for(;ve!==null;){n=ve;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var _e=xe.memoizedProps,ot=xe.memoizedState,X=n.stateNode,B=X.getSnapshotBeforeUpdate(n.elementType===n.type?_e:pn(n.type,_e),ot);X.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var K=n.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){nt(n,n.return,de)}if(t=n.sibling,t!==null){t.return=n.return,ve=t;break}ve=n.return}return xe=Tf,Tf=!1,xe}function Ui(t,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&t)===t){var m=f.destroy;f.destroy=void 0,m!==void 0&&wu(n,i,m)}f=f.next}while(f!==l)}}function ia(t,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&t)===t){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function _u(t){var n=t.ref;if(n!==null){var i=t.stateNode;switch(t.tag){case 5:t=i;break;default:t=i}typeof n=="function"?n(t):n.current=t}}function Lf(t){var n=t.alternate;n!==null&&(t.alternate=null,Lf(n)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(n=t.stateNode,n!==null&&(delete n[Tn],delete n[Li],delete n[zl],delete n[Hy],delete n[By])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function Af(t){return t.tag===5||t.tag===3||t.tag===4}function $f(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Af(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Su(t,n,i){var l=t.tag;if(l===5||l===6)t=t.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(t,n):i.insertBefore(t,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(t,i)):(n=i,n.appendChild(t)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=$s));else if(l!==4&&(t=t.child,t!==null))for(Su(t,n,i),t=t.sibling;t!==null;)Su(t,n,i),t=t.sibling}function ku(t,n,i){var l=t.tag;if(l===5||l===6)t=t.stateNode,n?i.insertBefore(t,n):i.appendChild(t);else if(l!==4&&(t=t.child,t!==null))for(ku(t,n,i),t=t.sibling;t!==null;)ku(t,n,i),t=t.sibling}var vt=null,gn=!1;function Cr(t,n,i){for(i=i.child;i!==null;)zf(t,n,i),i=i.sibling}function zf(t,n,i){if(_t&&typeof _t.onCommitFiberUnmount=="function")try{_t.onCommitFiberUnmount(Pn,i)}catch{}switch(i.tag){case 5:bt||qo(i,n);case 6:var l=vt,f=gn;vt=null,Cr(t,n,i),vt=l,gn=f,vt!==null&&(gn?(t=vt,i=i.stateNode,t.nodeType===8?t.parentNode.removeChild(i):t.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(gn?(t=vt,i=i.stateNode,t.nodeType===8?$l(t.parentNode,i):t.nodeType===1&&$l(t,i),ki(t)):$l(vt,i.stateNode));break;case 4:l=vt,f=gn,vt=i.stateNode.containerInfo,gn=!0,Cr(t,n,i),vt=l,gn=f;break;case 0:case 11:case 14:case 15:if(!bt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var m=f,N=m.destroy;m=m.tag,N!==void 0&&((m&2)!==0||(m&4)!==0)&&wu(i,n,N),f=f.next}while(f!==l)}Cr(t,n,i);break;case 1:if(!bt&&(qo(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){nt(i,n,T)}Cr(t,n,i);break;case 21:Cr(t,n,i);break;case 22:i.mode&1?(bt=(l=bt)||i.memoizedState!==null,Cr(t,n,i),bt=l):Cr(t,n,i);break;default:Cr(t,n,i)}}function Df(t){var n=t.updateQueue;if(n!==null){t.updateQueue=null;var i=t.stateNode;i===null&&(i=t.stateNode=new o0),n.forEach(function(l){var f=p0.bind(null,t,l);i.has(l)||(i.add(l),l.then(f,f))})}}function mn(t,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=N),l&=~m}if(l=f,l=Ye()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*a0(l/1960))-l,10t?16:t,Pr===null)var l=!1;else{if(t=Pr,Pr=null,ca=0,(Oe&6)!==0)throw Error(o(331));var f=Oe;for(Oe|=4,ve=t.current;ve!==null;){var m=ve,N=m.child;if((ve.flags&16)!==0){var T=m.deletions;if(T!==null){for(var O=0;OYe()-ju?ao(t,0):bu|=i),Dt(t,n)}function Qf(t,n){n===0&&((t.mode&1)===0?n=1:(n=Zn,Zn<<=1,(Zn&130023424)===0&&(Zn=4194304)));var i=Ct();t=or(t,n),t!==null&&(Jn(t,n,i),Dt(t,i))}function h0(t){var n=t.memoizedState,i=0;n!==null&&(i=n.retryLane),Qf(t,i)}function p0(t,n){var i=0;switch(t.tag){case 13:var l=t.stateNode,f=t.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=t.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Qf(t,i)}var Zf;Zf=function(t,n,i){if(t!==null)if(t.memoizedProps!==n.pendingProps||Lt.current)$t=!0;else{if((t.lanes&i)===0&&(n.flags&128)===0)return $t=!1,t0(t,n,i);$t=(t.flags&131072)!==0}else $t=!1,Qe&&(n.flags&1048576)!==0&&Pd(n,Bs,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;ra(t,n),t=n.pendingProps;var f=Fo(n,St.current);Go(n,i),f=ru(null,n,l,t,f,i);var m=ou();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,At(l)?(m=!0,Os(n)):m=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Kl(n),f.updater=ta,n.stateNode=f,f._reactInternals=n,cu(n,l,t,i),n=pu(null,n,l,!0,m,i)):(n.tag=0,Qe&&m&&Fl(n),Et(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(ra(t,n),t=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=m0(l),t=pn(l,t),f){case 0:n=hu(null,n,l,t,i);break e;case 1:n=Nf(null,n,l,t,i);break e;case 11:n=xf(null,n,l,t,i);break e;case 14:n=wf(null,n,l,pn(l.type,t),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:pn(l,f),hu(t,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:pn(l,f),Nf(t,n,l,f,i);case 3:e:{if(bf(n),t===null)throw Error(o(387));l=n.pendingProps,m=n.memoizedState,f=m.element,Od(t,n),Xs(n,l,null,i);var N=n.memoizedState;if(l=N.element,m.isDehydrated)if(m={element:l,isDehydrated:!1,cache:N.cache,pendingSuspenseBoundaries:N.pendingSuspenseBoundaries,transitions:N.transitions},n.updateQueue.baseState=m,n.memoizedState=m,n.flags&256){f=Xo(Error(o(423)),n),n=jf(t,n,l,i,f);break e}else if(l!==f){f=Xo(Error(o(424)),n),n=jf(t,n,l,i,f);break e}else for(Wt=Sr(n.stateNode.containerInfo.firstChild),Vt=n,Qe=!0,hn=null,i=zd(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Vo(),l===f){n=sr(t,n,i);break e}Et(t,n,l,i)}n=n.child}return n;case 5:return Bd(n),t===null&&Vl(n),l=n.type,f=n.pendingProps,m=t!==null?t.memoizedProps:null,N=f.children,Ll(l,f)?N=null:m!==null&&Ll(l,m)&&(n.flags|=32),kf(t,n),Et(t,n,N,i),n.child;case 6:return t===null&&Vl(n),null;case 13:return Ef(t,n,i);case 4:return Ql(n,n.stateNode.containerInfo),l=n.pendingProps,t===null?n.child=Wo(n,null,l,i):Et(t,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:pn(l,f),xf(t,n,l,f,i);case 7:return Et(t,n,n.pendingProps,i),n.child;case 8:return Et(t,n,n.pendingProps.children,i),n.child;case 12:return Et(t,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,m=n.memoizedProps,N=f.value,Ge(Us,l._currentValue),l._currentValue=N,m!==null)if(fn(m.value,N)){if(m.children===f.children&&!Lt.current){n=sr(t,n,i);break e}}else for(m=n.child,m!==null&&(m.return=n);m!==null;){var T=m.dependencies;if(T!==null){N=m.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(m.tag===1){O=ir(-1,i&-i),O.tag=2;var ee=m.updateQueue;if(ee!==null){ee=ee.shared;var ae=ee.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),ee.pending=O}}m.lanes|=i,O=m.alternate,O!==null&&(O.lanes|=i),Xl(m.return,i,n),T.lanes|=i;break}O=O.next}}else if(m.tag===10)N=m.type===n.type?null:m.child;else if(m.tag===18){if(N=m.return,N===null)throw Error(o(341));N.lanes|=i,T=N.alternate,T!==null&&(T.lanes|=i),Xl(N,i,n),N=m.sibling}else N=m.child;if(N!==null)N.return=m;else for(N=m;N!==null;){if(N===n){N=null;break}if(m=N.sibling,m!==null){m.return=N.return,N=m;break}N=N.return}m=N}Et(t,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Go(n,i),f=Jt(f),l=l(f),n.flags|=1,Et(t,n,l,i),n.child;case 14:return l=n.type,f=pn(l,n.pendingProps),f=pn(l.type,f),wf(t,n,l,f,i);case 15:return _f(t,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:pn(l,f),ra(t,n),n.tag=1,At(l)?(t=!0,Os(n)):t=!1,Go(n,i),ff(n,l,f),cu(n,l,f,i),pu(null,n,l,!0,t,i);case 19:return Mf(t,n,i);case 22:return Sf(t,n,i)}throw Error(o(156,n.tag))};function Jf(t,n){return Kn(t,n)}function g0(t,n,i,l){this.tag=t,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function nn(t,n,i,l){return new g0(t,n,i,l)}function Lu(t){return t=t.prototype,!(!t||!t.isReactComponent)}function m0(t){if(typeof t=="function")return Lu(t)?1:0;if(t!=null){if(t=t.$$typeof,t===ne)return 11;if(t===V)return 14}return 2}function Tr(t,n){var i=t.alternate;return i===null?(i=nn(t.tag,n,t.key,t.mode),i.elementType=t.elementType,i.type=t.type,i.stateNode=t.stateNode,i.alternate=t,t.alternate=i):(i.pendingProps=n,i.type=t.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=t.flags&14680064,i.childLanes=t.childLanes,i.lanes=t.lanes,i.child=t.child,i.memoizedProps=t.memoizedProps,i.memoizedState=t.memoizedState,i.updateQueue=t.updateQueue,n=t.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=t.sibling,i.index=t.index,i.ref=t.ref,i}function pa(t,n,i,l,f,m){var N=2;if(l=t,typeof t=="function")Lu(t)&&(N=1);else if(typeof t=="string")N=5;else e:switch(t){case F:return uo(i.children,f,m,n);case U:N=8,f|=8;break;case q:return t=nn(12,i,n,f|2),t.elementType=q,t.lanes=m,t;case Q:return t=nn(13,i,n,f),t.elementType=Q,t.lanes=m,t;case C:return t=nn(19,i,n,f),t.elementType=C,t.lanes=m,t;case Y:return ga(i,f,m,n);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case te:N=10;break e;case J:N=9;break e;case ne:N=11;break e;case V:N=14;break e;case W:N=16,l=null;break e}throw Error(o(130,t==null?t:typeof t,""))}return n=nn(N,i,n,f),n.elementType=t,n.type=l,n.lanes=m,n}function uo(t,n,i,l){return t=nn(7,t,l,n),t.lanes=i,t}function ga(t,n,i,l){return t=nn(22,t,l,n),t.elementType=Y,t.lanes=i,t.stateNode={isHidden:!1},t}function Au(t,n,i){return t=nn(6,t,null,n),t.lanes=i,t}function $u(t,n,i){return n=nn(4,t.children!==null?t.children:[],t.key,n),n.lanes=i,n.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},n}function y0(t,n,i,l,f){this.tag=n,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ln(0),this.expirationTimes=ln(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ln(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function zu(t,n,i,l,f,m,N,T,O){return t=new y0(t,n,i,T,O),n===1?(n=1,m===!0&&(n|=8)):n=0,m=nn(3,null,null,n),t.current=m,m.stateNode=t,m.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Kl(m),t}function v0(t,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),Vu.exports=R0(),Vu.exports}var ph;function T0(){if(ph)return Sa;ph=1;var e=Fp();return Sa.createRoot=e.createRoot,Sa.hydrateRoot=e.hydrateRoot,Sa}var L0=T0();function Hp(e,r="Request failed"){const o=(e||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function ze(e,r){const o=await fetch(e,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Hp(s,o.statusText||"Request failed"))}return o.json()}const A0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Re={health:()=>ze("/api/health"),settings:()=>ze("/api/settings"),saveSettings:e=>{const r={...e};for(const o of A0)r[o]===""&&delete r[o];return ze("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>ze("/api/repos"),browse:e=>ze(`/api/fs${e?`?path=${encodeURIComponent(e)}`:""}`),gitRefs:(e,r=50)=>ze(`/api/git/refs?repo_path=${encodeURIComponent(e)}&limit=${r}`),index:(e,r=!0)=>ze("/api/index",{method:"POST",body:JSON.stringify({repo_path:e,incremental:r})}),indexStatus:e=>ze(`/api/index?repo_path=${encodeURIComponent(e)}`),indexProgress:e=>ze(`/api/index/progress?repo_path=${encodeURIComponent(e)}`),architecture:(e,r=!0)=>ze(`/api/architecture?repo_path=${encodeURIComponent(e)}&graph=${r?"1":"0"}`),architectureGraph:e=>ze(`/api/architecture/graph?repo_path=${encodeURIComponent(e)}`),review:(e,r,o,s=!0,a=!1)=>ze("/api/review",{method:"POST",body:JSON.stringify({repo_path:e,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(e,r)=>ze("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:e,node_id:r})}),reviewPr:(e,r,o,s)=>ze("/api/prs/review",{method:"POST",body:JSON.stringify({provider:e,repo:r,number:o,repo_path:s||null})}),init:(e,r=!1)=>ze("/api/init",{method:"POST",body:JSON.stringify({repo_path:e,overwrite:r})}),postComment:(e,r,o,s)=>ze("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:e,repo:r,number:o,markdown:s})}),graph:(e,r="full")=>ze(`/api/graph?repo_path=${encodeURIComponent(e)}&scope=${r}`),prs:(e,r,o="open",s)=>ze("/api/prs",{method:"POST",body:JSON.stringify({provider:e,repo:r,state:o,repo_path:s||null})}),scmRepos:e=>ze(`/api/scm/repos?provider=${encodeURIComponent(e)}`),oauthStatus:()=>ze("/api/oauth/status"),githubOAuthStart:()=>ze("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:e=>ze("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:e})}),bitbucketOAuthStart:()=>ze("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>ze("/api/oauth/gitlab/start"),oauthDisconnect:e=>ze("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:e})}),residual:e=>ze("/api/ai/residual",{method:"POST",body:JSON.stringify({review:e})}),reviews:e=>ze(`/api/reviews?repo_path=${encodeURIComponent(e)}`),getReview:(e,r)=>ze(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(e)}`),reviewDiff:(e,r,o)=>ze(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(e)}&other=${encodeURIComponent(o)}`),config:e=>ze(`/api/config?repo_path=${encodeURIComponent(e)}`),saveConfig:(e,r)=>ze("/api/config",{method:"PUT",body:JSON.stringify({repo_path:e,...r})}),addWaiver:(e,r,o,s)=>ze("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:e,rule:r,node:o||null,reason:s||""})}),marks:(e,r)=>ze(`/api/marks?repo_path=${encodeURIComponent(e)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:e=>ze(`/api/architecture/health?repo_path=${encodeURIComponent(e)}`),workspaceStatus:e=>ze(`/api/workspace/status?repo_path=${encodeURIComponent(e)}`),openEditor:(e,r,o,s)=>ze("/api/open",{method:"POST",body:JSON.stringify({repo_path:e,path:r,line:o||null,editor:s||null})}),exportHtml:e=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:e})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Hp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(e,r,o,s)=>ze("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:e,edges:r,source_id:o,target_id:s||null})})};function $0(e,r){const o=r.trim().toLowerCase();return o?e.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):e}function z0({open:e,actions:r,onClose:o}){const[s,a]=A.useState(""),[u,c]=A.useState(0),h=A.useRef(null),p=A.useMemo(()=>$0(r,s),[r,s]);if(A.useEffect(()=>{if(!e)return;a(""),c(0);const g=window.setTimeout(()=>{var x;return(x=h.current)==null?void 0:x.focus()},0);return()=>window.clearTimeout(g)},[e]),A.useEffect(()=>{c(0)},[s]),!e)return null;const y=p.slice(0,40),w=y[Math.min(u,Math.max(y.length-1,0))],v=g=>{g&&(o(),g.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:g=>{g.target===g.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:g=>a(g.target.value),onKeyDown:g=>{g.key==="Escape"?(g.preventDefault(),o()):g.key==="ArrowDown"?(g.preventDefault(),c(x=>Math.min(Math.max(y.length-1,0),x+1))):g.key==="ArrowUp"?(g.preventDefault(),c(x=>Math.max(0,x-1))):g.key==="Enter"&&(g.preventDefault(),v(w))}}),d.jsxs("ul",{children:[y.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,y.map((g,x)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:x===u?"active":"",onMouseEnter:()=>c(x),onClick:()=>v(g),children:[d.jsx("span",{children:g.label}),g.hint?d.jsx("span",{className:"muted",children:g.hint}):null]})},g.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function D0({config:e,busy:r,onSave:o,onWaiver:s}){const[a,u]=A.useState(e),[c,h]=A.useState(e.available_rules[0]||""),[p,y]=A.useState(""),[w,v]=A.useState("");A.useEffect(()=>{u(e)},[e]);const g=Object.entries(a.contexts||{}),x=(I,_,j)=>{const L=a.contexts[I];if(!L)return;const $=F=>F.split(",").map(U=>U.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[I]:{...L,[_]:_==="name"?j:$(j)}}})},S=(I,_)=>{const j=_.trim();if(!j||j===I)return;const{[I]:L,...$}=a.contexts;L&&u({...a,contexts:{...$,[j]:{...L,name:j}}})},k=()=>{let I=1;for(;a.contexts[`context-${I}`];)I+=1;const _=`context-${I}`;u({...a,contexts:{...a.contexts,[_]:{name:_,django_apps:[],react:[],public_api:[],owners:[]}}})},b=I=>{const{[I]:_,...j}=a.contexts;u({...a,contexts:j})},E=I=>{const _=a.rules.includes(I);u({...a,rules:_?a.rules.filter(j=>j!==I):[...a.rules,I]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),g.map(([I,_])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:I})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:I,"data-testid":`config-context-name-${I}`,onBlur:j=>S(I,j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(_.django_apps||[]).join(", "),onChange:j=>x(I,"django_apps",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(_.react||[]).join(", "),onChange:j=>x(I,"react",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(_.public_api||[]).join(", "),onChange:j=>x(I,"public_api",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(_.owners||[]).join(", "),onChange:j=>x(I,"owners",j.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>b(I),children:"Remove context"})]},I)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:k,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(I=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(I),onChange:()=>E(I)}),I]},I))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((I,_)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:I.rule}),I.node?` · ${I.node}`:"",I.reason?` — ${I.reason}`:""]},`${I.rule}:${I.node}:${_}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:I=>h(I.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(I=>d.jsx("option",{value:I,children:I},I))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:I=>y(I.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:w,onChange:I=>v(I.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,w),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function rs(e){return e.replaceAll("_"," ")}function O0(e){return e.replaceAll("_"," ")}function ci(e){return e.split(".").pop()||e}function lc(e){if(!e)return"";const r=new Date(e);return Number.isNaN(r.getTime())?e:r.toLocaleString()}function F0(e){return e.split(/[\\/]/).filter(Boolean).pop()||e}function Dr(e){return e.replace(/([/\\._:@-])/g,"$1​")}function _o({className:e,children:r}){return d.jsx("svg",{className:e,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function H0({className:e}){return d.jsxs(_o,{className:e,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function B0({className:e}){return d.jsxs(_o,{className:e,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function V0({className:e}){return d.jsxs(_o,{className:e,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function W0({className:e}){return d.jsxs(_o,{className:e,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function U0({className:e}){return d.jsxs(_o,{className:e,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function Bp({className:e}){return d.jsx(_o,{className:e,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function G0({className:e}){return d.jsx(_o,{className:e,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const Y0="modulepreload",X0=function(e,r){return new URL(e,r).href},gh={},q0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(w){return Promise.all(w.map(v=>Promise.resolve(v).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),y=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(w=>{if(w=X0(w,s),w in gh)return;gh[w]=!0;const v=w.endsWith(".css"),g=v?'[rel="stylesheet"]':"";if(!!s)for(let k=h.length-1;k>=0;k--){const b=h[k];if(b.href===w&&(!v||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${w}"]${g}`))return;const S=document.createElement("link");if(S.rel=v?"stylesheet":Y0,v||(S.as="script"),S.crossOrigin="",S.href=w,y&&S.setAttribute("nonce",y),document.head.appendChild(S),v)return new Promise((k,b)=>{S.addEventListener("load",k),S.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${w}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function st(e){if(typeof e=="string"||typeof e=="number")return""+e;let r="";if(Array.isArray(e))for(let o=0,s;o{}};function el(){for(var e=0,r=arguments.length,o={},s;e=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}La.prototype=el.prototype={constructor:La,on:function(e,r){var o=this._,s=Q0(e+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),yh.hasOwnProperty(r)?{space:yh[r],local:e}:e}function J0(e){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===uc&&r.documentElement.namespaceURI===uc?r.createElement(e):r.createElementNS(o,e)}}function ev(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Vp(e){var r=tl(e);return(r.local?ev:J0)(r)}function tv(){}function kc(e){return e==null?tv:function(){return this.querySelector(e)}}function nv(e){typeof e!="function"&&(e=kc(e));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=_&&(_=I+1);!(L=b[_])&&++_=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function Ev(e){e||(e=Cv);function r(v,g){return v&&g?e(v.__data__,g.__data__):!v-!g}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:e>=r?0:NaN}function Mv(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Pv(){return Array.from(this)}function Iv(){for(var e=this._groups,r=0,o=e.length;r1?this.each((r==null?Bv:typeof r=="function"?Wv:Vv)(e,r,o??"")):ri(this.node(),e)}function ri(e,r){return e.style.getPropertyValue(r)||Xp(e).getComputedStyle(e,null).getPropertyValue(r)}function Gv(e){return function(){delete this[e]}}function Yv(e,r){return function(){this[e]=r}}function Xv(e,r){return function(){var o=r.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function qv(e,r){return arguments.length>1?this.each((r==null?Gv:typeof r=="function"?Xv:Yv)(e,r)):this.node()[e]}function qp(e){return e.trim().split(/^|\s+/)}function Nc(e){return e.classList||new Kp(e)}function Kp(e){this._node=e,this._names=qp(e.getAttribute("class")||"")}Kp.prototype={add:function(e){var r=this._names.indexOf(e);r<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var r=this._names.indexOf(e);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Qp(e,r){for(var o=Nc(e),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function kx(e){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>e;function cc(e,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:y,dispatch:w}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:w}})}cc.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Tx(e){return!e.ctrlKey&&!e.button}function Lx(){return this.parentNode}function Ax(e,r){return r??{x:e.x,y:e.y}}function $x(){return navigator.maxTouchPoints||"ontouchstart"in this}function rg(){var e=Tx,r=Lx,o=Ax,s=$x,a={},u=el("start","drag","end"),c=0,h,p,y,w,v=0;function g(j){j.on("mousedown.drag",x).filter(s).on("touchstart.drag",b).on("touchmove.drag",E,Rx).on("touchend.drag touchcancel.drag",I).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(j,L){if(!(w||!e.call(this,j,L))){var $=_(this,r.call(this,j,L),j,L,"mouse");$&&(Gt(j.view).on("mousemove.drag",S,os).on("mouseup.drag",k,os),tg(j.view),Gu(j),y=!1,h=j.clientX,p=j.clientY,$("start",j))}}function S(j){if(ti(j),!y){var L=j.clientX-h,$=j.clientY-p;y=L*L+$*$>v}a.mouse("drag",j)}function k(j){Gt(j.view).on("mousemove.drag mouseup.drag",null),ng(j.view,y),ti(j),a.mouse("end",j)}function b(j,L){if(e.call(this,j,L)){var $=j.changedTouches,F=r.call(this,j,L),U=$.length,q,te;for(q=0;q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?Na(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?Na(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=Dx.exec(e))?new Ft(r[1],r[2],r[3],1):(r=Ox.exec(e))?new Ft(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=Fx.exec(e))?Na(r[1],r[2],r[3],r[4]):(r=Hx.exec(e))?Na(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=Bx.exec(e))?Nh(r[1],r[2]/100,r[3]/100,1):(r=Vx.exec(e))?Nh(r[1],r[2]/100,r[3]/100,r[4]):vh.hasOwnProperty(e)?_h(vh[e]):e==="transparent"?new Ft(NaN,NaN,NaN,0):null}function _h(e){return new Ft(e>>16&255,e>>8&255,e&255,1)}function Na(e,r,o,s){return s<=0&&(e=r=o=NaN),new Ft(e,r,o,s)}function Gx(e){return e instanceof ms||(e=mo(e)),e?(e=e.rgb(),new Ft(e.r,e.g,e.b,e.opacity)):new Ft}function dc(e,r,o,s){return arguments.length===1?Gx(e):new Ft(e,r,o,s??1)}function Ft(e,r,o,s){this.r=+e,this.g=+r,this.b=+o,this.opacity=+s}bc(Ft,dc,og(ms,{brighter(e){return e=e==null?Fa:Math.pow(Fa,e),new Ft(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?is:Math.pow(is,e),new Ft(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ft(ho(this.r),ho(this.g),ho(this.b),Ha(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Sh,formatHex:Sh,formatHex8:Yx,formatRgb:kh,toString:kh}));function Sh(){return`#${fo(this.r)}${fo(this.g)}${fo(this.b)}`}function Yx(){return`#${fo(this.r)}${fo(this.g)}${fo(this.b)}${fo((isNaN(this.opacity)?1:this.opacity)*255)}`}function kh(){const e=Ha(this.opacity);return`${e===1?"rgb(":"rgba("}${ho(this.r)}, ${ho(this.g)}, ${ho(this.b)}${e===1?")":`, ${e})`}`}function Ha(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ho(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function fo(e){return e=ho(e),(e<16?"0":"")+e.toString(16)}function Nh(e,r,o,s){return s<=0?e=r=o=NaN:o<=0||o>=1?e=r=NaN:r<=0&&(e=NaN),new xn(e,r,o,s)}function ig(e){if(e instanceof xn)return new xn(e.h,e.s,e.l,e.opacity);if(e instanceof ms||(e=mo(e)),!e)return new xn;if(e instanceof xn)return e;e=e.rgb();var r=e.r/255,o=e.g/255,s=e.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new xn(c,h,p,e.opacity)}function Xx(e,r,o,s){return arguments.length===1?ig(e):new xn(e,r,o,s??1)}function xn(e,r,o,s){this.h=+e,this.s=+r,this.l=+o,this.opacity=+s}bc(xn,Xx,og(ms,{brighter(e){return e=e==null?Fa:Math.pow(Fa,e),new xn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?is:Math.pow(is,e),new xn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,r=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Ft(Yu(e>=240?e-240:e+120,a,s),Yu(e,a,s),Yu(e<120?e+240:e-120,a,s),this.opacity)},clamp(){return new xn(bh(this.h),ba(this.s),ba(this.l),Ha(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Ha(this.opacity);return`${e===1?"hsl(":"hsla("}${bh(this.h)}, ${ba(this.s)*100}%, ${ba(this.l)*100}%${e===1?")":`, ${e})`}`}}));function bh(e){return e=(e||0)%360,e<0?e+360:e}function ba(e){return Math.max(0,Math.min(1,e||0))}function Yu(e,r,o){return(e<60?r+(o-r)*e/60:e<180?o:e<240?r+(o-r)*(240-e)/60:r)*255}const jc=e=>()=>e;function qx(e,r){return function(o){return e+o*r}}function Kx(e,r,o){return e=Math.pow(e,o),r=Math.pow(r,o)-e,o=1/o,function(s){return Math.pow(e+s*r,o)}}function Qx(e){return(e=+e)==1?sg:function(r,o){return o-r?Kx(r,o,e):jc(isNaN(r)?o:r)}}function sg(e,r){var o=r-e;return o?qx(e,o):jc(isNaN(e)?r:e)}const Ba=(function e(r){var o=Qx(r);function s(a,u){var c=o((a=dc(a)).r,(u=dc(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),y=sg(a.opacity,u.opacity);return function(w){return a.r=c(w),a.g=h(w),a.b=p(w),a.opacity=y(w),a+""}}return s.gamma=e,s})(1);function Zx(e,r){r||(r=[]);var o=e?Math.min(r.length,e.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:zn(s,a)})),o=Xu.lastIndex;return o180?w+=360:w-y>180&&(y+=360),g.push({i:v.push(a(v)+"rotate(",null,s)-2,x:zn(y,w)})):w&&v.push(a(v)+"rotate("+w+s)}function h(y,w,v,g){y!==w?g.push({i:v.push(a(v)+"skewX(",null,s)-2,x:zn(y,w)}):w&&v.push(a(v)+"skewX("+w+s)}function p(y,w,v,g,x,S){if(y!==v||w!==g){var k=x.push(a(x)+"scale(",null,",",null,")");S.push({i:k-4,x:zn(y,v)},{i:k-2,x:zn(w,g)})}else(v!==1||g!==1)&&x.push(a(x)+"scale("+v+","+g+")")}return function(y,w){var v=[],g=[];return y=e(y),w=e(w),u(y.translateX,y.translateY,w.translateX,w.translateY,v,g),c(y.rotate,w.rotate,v,g),h(y.skewX,w.skewX,v,g),p(y.scaleX,y.scaleY,w.scaleX,w.scaleY,v,g),y=w=null,function(x){for(var S=-1,k=g.length,b;++S=0&&e._call.call(void 0,r),e=e._next;--oi}function Ch(){yo=(Wa=as.now())+nl,oi=Ji=0;try{hw()}finally{oi=0,gw(),yo=0}}function pw(){var e=as.now(),r=e-Wa;r>cg&&(nl-=r,Wa=e)}function gw(){for(var e,r=Va,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),e=r,r=r._next):(o=r._next,r._next=null,r=e?e._next=o:Va=o);es=e,pc(s)}function pc(e){if(!oi){Ji&&(Ji=clearTimeout(Ji));var r=e-yo;r>24?(e<1/0&&(Ji=setTimeout(Ch,e-as.now()-nl)),Qi&&(Qi=clearInterval(Qi))):(Qi||(Wa=as.now(),Qi=setInterval(pw,cg)),oi=1,dg(Ch))}}function Mh(e,r,o){var s=new Ua;return r=r==null?0:+r,s.restart(a=>{s.stop(),e(a+r)},r,o),s}var mw=el("start","end","cancel","interrupt"),yw=[],hg=0,Ph=1,gc=2,$a=3,Ih=4,mc=5,za=6;function rl(e,r,o,s,a,u){var c=e.__transition;if(!c)e.__transition={};else if(o in c)return;vw(e,o,{name:r,index:s,group:a,on:mw,tween:yw,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:hg})}function Cc(e,r){var o=kn(e,r);if(o.state>hg)throw new Error("too late; already scheduled");return o}function Hn(e,r){var o=kn(e,r);if(o.state>$a)throw new Error("too late; already running");return o}function kn(e,r){var o=e.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function vw(e,r,o){var s=e.__transition,a;s[r]=o,o.timer=fg(u,0,o.time);function u(y){o.state=Ph,o.timer.restart(c,o.delay,o.time),o.delay<=y&&c(y-o.delay)}function c(y){var w,v,g,x;if(o.state!==Ph)return p();for(w in s)if(x=s[w],x.name===o.name){if(x.state===$a)return Mh(c);x.state===Ih?(x.state=za,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete s[w]):+wgc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function Xw(e,r,o){var s,a,u=Yw(r)?Cc:Hn;return function(){var c=u(this,e),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function qw(e,r){var o=this._id;return arguments.length<2?kn(this.node(),o).on.on(e):this.each(Xw(o,e,r))}function Kw(e){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==e)return;r&&r.removeChild(this)}}function Qw(){return this.on("end.remove",Kw(this._id))}function Zw(e){var r=this._name,o=this._id;typeof e!="function"&&(e=kc(e));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>e;function k1(e,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function ur(e,r,o){this.k=e,this.x=r,this.y=o}ur.prototype={constructor:ur,scale:function(e){return e===1?this:new ur(this.k*e,this.x,this.y)},translate:function(e,r){return e===0&r===0?this:new ur(this.k,this.x+this.k*e,this.y+this.k*r)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ol=new ur(1,0,0);yg.prototype=ur.prototype;function yg(e){for(;!e.__zoom;)if(!(e=e.parentNode))return ol;return e.__zoom}function qu(e){e.stopImmediatePropagation()}function Zi(e){e.preventDefault(),e.stopImmediatePropagation()}function N1(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function b1(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Rh(){return this.__zoom||ol}function j1(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function E1(){return navigator.maxTouchPoints||"ontouchstart"in this}function C1(e,r,o){var s=e.invertX(r[0][0])-o[0][0],a=e.invertX(r[1][0])-o[1][0],u=e.invertY(r[0][1])-o[0][1],c=e.invertY(r[1][1])-o[1][1];return e.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function vg(){var e=N1,r=b1,o=C1,s=j1,a=E1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Aa,y=el("start","zoom","end"),w,v,g,x=500,S=150,k=0,b=10;function E(C){C.property("__zoom",Rh).on("wheel.zoom",U,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",J).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",Q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,V,W,Y){var M=C.selection?C.selection():C;M.property("__zoom",Rh),C!==M?L(C,V,W,Y):M.interrupt().each(function(){$(this,arguments).event(Y).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(C,V,W,Y){E.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,Y)},E.scaleTo=function(C,V,W,Y){E.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,H=W==null?j(M):typeof W=="function"?W.apply(this,arguments):W,R=D.invert(H),z=typeof V=="function"?V.apply(this,arguments):V;return o(_(I(D,z),H,R),M,c)},W,Y)},E.translateBy=function(C,V,W,Y){E.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,Y)},E.translateTo=function(C,V,W,Y,M){E.transform(C,function(){var D=r.apply(this,arguments),H=this.__zoom,R=Y==null?j(D):typeof Y=="function"?Y.apply(this,arguments):Y;return o(ol.translate(R[0],R[1]).scale(H.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},Y,M)};function I(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new ur(V,C.x,C.y)}function _(C,V,W){var Y=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return Y===C.x&&M===C.y?C:new ur(C.k,Y,M)}function j(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function L(C,V,W,Y){C.on("start.zoom",function(){$(this,arguments).event(Y).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(Y).end()}).tween("zoom",function(){var M=this,D=arguments,H=$(M,D).event(Y),R=r.apply(M,D),z=W==null?j(R):typeof W=="function"?W.apply(M,D):W,re=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,le=p(oe.invert(z).concat(re/oe.k),fe.invert(z).concat(re/fe.k));return function(he){if(he===1)he=fe;else{var Z=le(he),se=re/Z[2];he=new ur(se,z[0]-Z[0]*se,z[1]-Z[1]*se)}H.zoom(null,he)}})}function $(C,V,W){return!W&&C.__zooming||new F(C,V)}function F(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Gt(this.that).datum();y.call(C,this.that,new k1(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:y}),V)}};function U(C,...V){if(!e.apply(this,arguments))return;var W=$(this,V).event(C),Y=this.__zoom,M=Math.max(u[0],Math.min(u[1],Y.k*Math.pow(2,s.apply(this,arguments)))),D=vn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=Y.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(Y.k===M)return;W.mouse=[D,Y.invert(D)],Da(this),W.start()}Zi(C),W.wheel=setTimeout(H,S),W.zoom("mouse",o(_(I(Y,M),W.mouse[0],W.mouse[1]),W.extent,c));function H(){W.wheel=null,W.end()}}function q(C,...V){if(g||!e.apply(this,arguments))return;var W=C.currentTarget,Y=$(this,V,!0).event(C),M=Gt(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",re,!0),D=vn(C,W),H=C.clientX,R=C.clientY;tg(C.view),qu(C),Y.mouse=[D,this.__zoom.invert(D)],Da(this),Y.start();function z(oe){if(Zi(oe),!Y.moved){var fe=oe.clientX-H,le=oe.clientY-R;Y.moved=fe*fe+le*le>k}Y.event(oe).zoom("mouse",o(_(Y.that.__zoom,Y.mouse[0]=vn(oe,W),Y.mouse[1]),Y.extent,c))}function re(oe){M.on("mousemove.zoom mouseup.zoom",null),ng(oe.view,Y.moved),Zi(oe),Y.event(oe).end()}}function te(C,...V){if(e.apply(this,arguments)){var W=this.__zoom,Y=vn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(Y),D=W.k*(C.shiftKey?.5:2),H=o(_(I(W,D),Y,M),r.apply(this,V),c);Zi(C),h>0?Gt(this).transition().duration(h).call(L,H,Y,C):Gt(this).call(E.transform,H,Y,C)}}function J(C,...V){if(e.apply(this,arguments)){var W=C.touches,Y=W.length,M=$(this,V,C.changedTouches.length===Y).event(C),D,H,R,z;for(qu(C),H=0;H`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ls=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],xg=["Enter"," ","Escape"],wg={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:r,y:o})=>`Moved selected node ${e}. New position, x: ${r}, y: ${o}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var ii;(function(e){e.Strict="strict",e.Loose="loose"})(ii||(ii={}));var po;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(po||(po={}));var us;(function(e){e.Partial="partial",e.Full="full"})(us||(us={}));const _g={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Or;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Or||(Or={}));var cs;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(cs||(cs={}));var ke;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ke||(ke={}));const Th={[ke.Left]:ke.Right,[ke.Right]:ke.Left,[ke.Top]:ke.Bottom,[ke.Bottom]:ke.Top};function Sg(e){return e===null?null:e?"valid":"invalid"}const kg=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,M1=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Pc=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ys=(e,r=[0,0])=>{const{width:o,height:s}=Nn(e),a=e.origin??r,u=o*a[0],c=s*a[1];return{x:e.position.x-u,y:e.position.y-c}},P1=(e,r={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=e.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):Pc(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,il(a,Ga(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?sl(s):{x:0,y:0,width:0,height:0}},vs=(e,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return e.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=il(o,Ga(a)),s=!0)}),s?sl(o):{x:0,y:0,width:0,height:0}},Ic=(e,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,y=r.width/a,w=r.height/a,v=[];for(const g of e.values()){const{measured:x,selectable:S=!0,hidden:k=!1}=g;if(c&&!S||k)continue;const b=x.width??g.width??g.initialWidth??0,E=x.height??g.height??g.initialHeight??0,{x:I,y:_}=g.internals.positionAbsolute,j=Eg(h,p,y,w,I,_,b,E),L=b*E,$=u&&j>0;(!g.internals.handleBounds||$||j>=L||g.dragging)&&v.push(g)}return v},I1=(e,r)=>{const o=new Set;return e.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function R1(e,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return e.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=Nn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function T1({nodes:e,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(e.size===0)return!0;const h=R1(e,c),p=vs(h),y=Tc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(y,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function Ng({nodeId:e,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(e),h=c.parentId?o.get(c.parentId):void 0,{x:p,y}=h?h.internals.positionAbsolute:{x:0,y:0},w=c.origin??s;let v=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",Sn.error005());else{const{width:x,height:S}=Nn(h);x&&S&&(v=[[p,y],[p+x,y+S]])}else h&&xo(c.extent)&&(v=[[c.extent[0][0]+p,c.extent[0][1]+y],[c.extent[1][0]+p,c.extent[1][1]+y]]);const g=xo(v)?vo(r,v,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",Sn.error015())),{position:{x:g.x-p+(c.measured.width??0)*w[0],y:g.y-y+(c.measured.height??0)*w[1]},positionAbsolute:g}}async function L1({nodesToRemove:e=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(e.map(g=>g.id)),c=[];for(const g of o){if(g.deletable===!1)continue;const x=u.has(g.id),S=!x&&g.parentId&&c.find(k=>k.id===g.parentId);(x||S)&&c.push(g)}const h=new Set(r.map(g=>g.id)),p=s.filter(g=>g.deletable!==!1),w=I1(c,p);for(const g of p)h.has(g.id)&&!w.find(S=>S.id===g.id)&&w.push(g);if(!a)return{edges:w,nodes:c};const v=await a({nodes:c,edges:w});return typeof v=="boolean"?v?{edges:w,nodes:c}:{edges:[],nodes:[]}:v}const si=(e,r=0,o=1)=>Math.min(Math.max(e,r),o),vo=(e={x:0,y:0},r,o)=>({x:si(e.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:si(e.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function bg(e,r,o){const{width:s,height:a}=Nn(o),{x:u,y:c}=o.internals.positionAbsolute;return vo(e,[[u,c],[u+s,c+a]],r)}const Lh=(e,r,o)=>eo?-si(Math.abs(e-o),1,r)/r:0,Rc=(e,r,o=15,s=40)=>{const a=Lh(e.x,s,r.width-s)*o,u=Lh(e.y,s,r.height-s)*o;return[a,u]},il=(e,r)=>({x:Math.min(e.x,r.x),y:Math.min(e.y,r.y),x2:Math.max(e.x2,r.x2),y2:Math.max(e.y2,r.y2)}),yc=({x:e,y:r,width:o,height:s})=>({x:e,y:r,x2:e+o,y2:r+s}),sl=({x:e,y:r,x2:o,y2:s})=>({x:e,y:r,width:o-e,height:s-r}),ds=(e,r=[0,0])=>{var a,u;const{x:o,y:s}=Pc(e)?e.internals.positionAbsolute:ys(e,r);return{x:o,y:s,width:((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0,height:((u=e.measured)==null?void 0:u.height)??e.height??e.initialHeight??0}},Ga=(e,r=[0,0])=>{var a,u;const{x:o,y:s}=Pc(e)?e.internals.positionAbsolute:ys(e,r);return{x:o,y:s,x2:o+(((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0),y2:s+(((u=e.measured)==null?void 0:u.height)??e.height??e.initialHeight??0)}},jg=(e,r)=>sl(il(yc(e),yc(r))),Eg=(e,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(e+o,a+c)-Math.max(e,a)),y=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*y)},Ya=(e,r)=>Eg(e.x,e.y,e.width,e.height,r.x,r.y,r.width,r.height),Ah=e=>wn(e.width)&&wn(e.height)&&wn(e.x)&&wn(e.y),wn=e=>!isNaN(e)&&isFinite(e),Cg=(e,r)=>(o,s)=>{},xs=(e,r=[1,1])=>({x:r[0]*Math.round(e.x/r[0]),y:r[1]*Math.round(e.y/r[1])}),ws=({x:e,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(e-o)/a,y:(r-s)/a};return u?xs(h,c):h},ai=({x:e,y:r},[o,s,a])=>({x:e*a+o,y:r*a+s});function Jo(e,r){if(typeof e=="number")return Math.floor((r-r/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const o=parseFloat(e);if(!Number.isNaN(o))return Math.floor(o)}if(typeof e=="string"&&e.endsWith("%")){const o=parseFloat(e);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function A1(e,r,o){if(typeof e=="string"||typeof e=="number"){const s=Jo(e,o),a=Jo(e,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof e=="object"){const s=Jo(e.top??e.y??0,o),a=Jo(e.bottom??e.y??0,o),u=Jo(e.left??e.x??0,r),c=Jo(e.right??e.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function $1(e,r,o,s,a,u){const{x:c,y:h}=ai(e,[r,o,s]),{x:p,y}=ai({x:e.x+e.width,y:e.y+e.height},[r,o,s]),w=a-p,v=u-y;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(w),bottom:Math.floor(v)}}const Tc=(e,r,o,s,a,u)=>{const c=A1(u,r,o),h=(r-c.x)/e.width,p=(o-c.y)/e.height,y=Math.min(h,p),w=si(y,s,a),v=e.x+e.width/2,g=e.y+e.height/2,x=r/2-v*w,S=o/2-g*w,k=$1(e,x,S,w,r,o),b={left:Math.min(k.left-c.left,0),top:Math.min(k.top-c.top,0),right:Math.min(k.right-c.right,0),bottom:Math.min(k.bottom-c.bottom,0)};return{x:x-b.left+b.right,y:S-b.top+b.bottom,zoom:w}},fs=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function xo(e){return e!=null&&e!=="parent"}function Nn(e){var r,o;return{width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}}function Mg(e){var r,o;return(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth)!==void 0&&(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight)!==void 0}function Pg(e,r={width:0,height:0},o,s,a){const u={...e},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function $h(e,r){if(e.size!==r.size)return!1;for(const o of e)if(!r.has(o))return!1;return!0}function z1(){let e,r;return{promise:new Promise((s,a)=>{e=s,r=a}),resolve:e,reject:r}}function D1(e){return{...wg,...e||{}}}function ns(e,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=_n(e),h=ws({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y}=o?xs(h,r):h;return{xSnapped:p,ySnapped:y,...h}}const Lc=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ig=e=>{var r;return((r=e==null?void 0:e.getRootNode)==null?void 0:r.call(e))||(window==null?void 0:window.document)},O1=["INPUT","SELECT","TEXTAREA"];function Rg(e){var s,a;const r=((a=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:a[0])||e.target;return(r==null?void 0:r.nodeType)!==1?!1:O1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const Tg=e=>"clientX"in e,_n=(e,r)=>{var u,c;const o=Tg(e),s=o?e.clientX:(u=e.touches)==null?void 0:u[0].clientX,a=o?e.clientY:(c=e.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},zh=(e,r,o,s,a)=>{const u=r.querySelectorAll(`.${e}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:e,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...Lc(c)}})};function Lg({sourceX:e,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=e*.125+a*.375+c*.375+o*.125,y=r*.125+u*.375+h*.375+s*.125,w=Math.abs(p-e),v=Math.abs(y-r);return[p,y,w,v]}function Ca(e,r){return e>=0?.5*e:r*25*Math.sqrt(-e)}function Dh({pos:e,x1:r,y1:o,x2:s,y2:a,c:u}){switch(e){case ke.Left:return[r-Ca(r-s,u),o];case ke.Right:return[r+Ca(s-r,u),o];case ke.Top:return[r,o-Ca(o-a,u)];case ke.Bottom:return[r,o+Ca(a-o,u)]}}function Ag({sourceX:e,sourceY:r,sourcePosition:o=ke.Bottom,targetX:s,targetY:a,targetPosition:u=ke.Top,curvature:c=.25}){const[h,p]=Dh({pos:o,x1:e,y1:r,x2:s,y2:a,c}),[y,w]=Dh({pos:u,x1:s,y1:a,x2:e,y2:r,c}),[v,g,x,S]=Lg({sourceX:e,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:y,targetControlY:w});return[`M${e},${r} C${h},${p} ${y},${w} ${s},${a}`,v,g,x,S]}function $g({sourceX:e,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-e)/2,u=o0}const B1=({source:e,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${e}${r||""}-${o}${s||""}`,V1=(e,r)=>r.some(o=>o.source===e.source&&o.target===e.target&&(o.sourceHandle===e.sourceHandle||!o.sourceHandle&&!e.sourceHandle)&&(o.targetHandle===e.targetHandle||!o.targetHandle&&!e.targetHandle)),W1=(e,r,o={})=>{var u;if(!e.source||!e.target)return(u=o.onError)==null||u.call(o,"006",Sn.error006()),r;const s=o.getEdgeId||B1;let a;return kg(e)?a={...e}:a={...e,id:s(e)},V1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function zg({sourceX:e,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=$g({sourceX:e,sourceY:r,targetX:o,targetY:s});return[`M ${e},${r}L ${o},${s}`,a,u,c,h]}const Oh={[ke.Left]:{x:-1,y:0},[ke.Right]:{x:1,y:0},[ke.Top]:{x:0,y:-1},[ke.Bottom]:{x:0,y:1}},U1=({source:e,sourcePosition:r=ke.Bottom,target:o})=>r===ke.Left||r===ke.Right?e.xMath.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2));function G1({source:e,sourcePosition:r=ke.Bottom,target:o,targetPosition:s=ke.Top,center:a,offset:u,stepPosition:c}){const h=Oh[r],p=Oh[s],y={x:e.x+h.x*u,y:e.y+h.y*u},w={x:o.x+p.x*u,y:o.y+p.y*u},v=U1({source:y,sourcePosition:r,target:w}),g=v.x!==0?"x":"y",x=v[g];let S=[],k,b;const E={x:0,y:0},I={x:0,y:0},[,,_,j]=$g({sourceX:e.x,sourceY:e.y,targetX:o.x,targetY:o.y});if(h[g]*p[g]===-1){g==="x"?(k=a.x??y.x+(w.x-y.x)*c,b=a.y??(y.y+w.y)/2):(k=a.x??(y.x+w.x)/2,b=a.y??y.y+(w.y-y.y)*c);const U=[{x:k,y:y.y},{x:k,y:w.y}],q=[{x:y.x,y:b},{x:w.x,y:b}];h[g]===x?S=g==="x"?U:q:S=g==="x"?q:U}else{const U=[{x:y.x,y:w.y}],q=[{x:w.x,y:y.y}];if(g==="x"?S=h.x===x?q:U:S=h.y===x?U:q,r===s){const C=Math.abs(e[g]-o[g]);if(C<=u){const V=Math.min(u-1,u-C);h[g]===x?E[g]=(y[g]>e[g]?-1:1)*V:I[g]=(w[g]>o[g]?-1:1)*V}}if(r!==s){const C=g==="x"?"y":"x",V=h[g]===p[C],W=y[C]>w[C],Y=y[C]=Q?(k=(te.x+J.x)/2,b=S[0].y):(k=S[0].x,b=(te.y+J.y)/2)}const L={x:y.x+E.x,y:y.y+E.y},$={x:w.x+I.x,y:w.y+I.y};return[[e,...L.x!==S[0].x||L.y!==S[0].y?[L]:[],...S,...$.x!==S[S.length-1].x||$.y!==S[S.length-1].y?[$]:[],o],k,b,_,j]}function Y1(e,r,o,s){const a=Math.min(Fh(e,r)/2,Fh(r,o)/2,s),{x:u,y:c}=r;if(e.x===u&&u===o.x||e.y===c&&c===o.y)return`L${u} ${c}`;if(e.y===c){const y=e.xo.id===r):e[0])||null}function vc(e,r){return e?typeof e=="string"?e:`${r?`${r}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function q1(e,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return e.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const y=vc(p,r);u.has(y)||(c.push({id:y,color:p.color||o,...p}),u.add(y))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const Dg=1e3,K1=10,Ac={nodeOrigin:[0,0],nodeExtent:ls,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Q1={...Ac,checkEquality:!0};function $c(e,r){const o={...e};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function Z1(e,r,o){const s=$c(Ac,o);for(const a of e.values())if(a.parentId)Dc(a,e,r,s);else{const u=ys(a,s.nodeOrigin),c=xo(a.extent)?a.extent:s.nodeExtent,h=vo(u,c,Nn(a));a.internals.positionAbsolute=h}}function J1(e,r){if(!e.handles)return e.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of e.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:e.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function zc(e){return e==="manual"}function xc(e,r,o,s={}){var w,v;const a=$c(Q1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!zc(a.zIndexMode)?Dg:0;let p=e.length>0,y=!1;r.clear(),o.clear();for(const g of e){let x=c.get(g.id);if(a.checkEquality&&g===(x==null?void 0:x.internals.userNode))r.set(g.id,x);else{const S=ys(g,a.nodeOrigin),k=xo(g.extent)?g.extent:a.nodeExtent,b=vo(S,k,Nn(g));x={...a.defaults,...g,measured:{width:(w=g.measured)==null?void 0:w.width,height:(v=g.measured)==null?void 0:v.height},internals:{positionAbsolute:b,handleBounds:J1(g,x),z:Og(g,h,a.zIndexMode),userNode:g}},r.set(g.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(p=!1),g.parentId&&Dc(x,r,o,s,u),y||(y=g.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:y}}function e_(e,r){if(!e.parentId)return;const o=r.get(e.parentId);o?o.set(e.id,e):r.set(e.parentId,new Map([[e.id,e]]))}function Dc(e,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=$c(Ac,s),y=e.parentId,w=r.get(y);if(!w){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}e_(e,o),a&&!w.parentId&&w.internals.rootParentIndex===void 0&&p==="auto"&&(w.internals.rootParentIndex=++a.i,w.internals.z=w.internals.z+a.i*K1),a&&w.internals.rootParentIndex!==void 0&&(a.i=w.internals.rootParentIndex);const v=u&&!zc(p)?Dg:0,{x:g,y:x,z:S}=t_(e,w,c,h,v,p),{positionAbsolute:k}=e.internals,b=g!==k.x||x!==k.y;(b||S!==e.internals.z)&&r.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:g,y:x}:k,z:S}})}function Og(e,r,o){const s=wn(e.zIndex)?e.zIndex:0;return zc(o)?s:s+(e.selected?r:0)}function t_(e,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=Nn(e),y=ys(e,o),w=xo(e.extent)?vo(y,e.extent,p):y;let v=vo({x:c+w.x,y:h+w.y},s,p);e.extent==="parent"&&(v=bg(v,p,r));const g=Og(e,a,u),x=r.internals.z??0;return{x:v.x,y:v.y,z:x>=g?x+1:g}}function Oc(e,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of e){const p=r.get(h.parentId);if(!p)continue;const y=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ds(p),w=jg(y,h.rect);u.set(h.parentId,{expandedRect:w,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},y)=>{var _;const w=p.internals.positionAbsolute,v=Nn(p),g=p.origin??s,x=h.x0||S>0||E||I)&&(a.push({id:y,type:"position",position:{x:p.position.x-x+E,y:p.position.y-S+I}}),(_=o.get(y))==null||_.forEach(j=>{e.some(L=>L.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+x,y:j.position.y+S}})})),(v.width0){const x=Oc(g,r,o,a);y.push(...x)}return{changes:y,updatedInternals:p}}async function r_({delta:e,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!e.x&&!e.y)return!1;const c=await r.setViewportConstrained({x:o[0]+e.x,y:o[1]+e.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Wh(e,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${e}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${e}-${u}`;const y=s.get(c)||new Map;s.set(c,y.set(o,r))}}function Fg(e,r,o){e.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},y=`${a}-${c}--${u}-${h}`,w=`${u}-${h}--${a}-${c}`;Wh("source",p,w,e,a,c),Wh("target",p,y,e,u,h),r.set(s.id,s)}}function Hg(e,r){if(!e.parentId)return!1;const o=r.get(e.parentId);return o?o.selected?!0:Hg(o,r):!1}function Uh(e,r,o){var a;let s=e;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function o_(e,r,o,s){const a=new Map;for(const[u,c]of e)if((c.selected||c.id===s)&&(!c.parentId||!Hg(c,e))&&(c.draggable||r&&typeof c.draggable>"u")){const h=e.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Ku({nodeId:e,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[y,w]of r){const v=(c=o.get(y))==null?void 0:c.internals.userNode;v&&a.push({...v,position:w.position,dragging:s})}if(!e)return[a[0],a];const u=(h=o.get(e))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(e))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function i_({dragItems:e,snapGrid:r,x:o,y:s}){const a=e.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=xs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function s_({onNodeMouseDown:e,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,y={x:0,y:0},w=null,v=!1,g=null,x=!1,S=!1,k=null;function b({noDragClassName:I,handleSelector:_,domNode:j,isSelectable:L,nodeId:$,nodeClickDistance:F=0}){g=Gt(j);function U({x:ne,y:Q}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:Y,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:H,onError:R,updateNodePositions:z}=r();u={x:ne,y:Q};let re=!1;const oe=h.size>1,fe=oe&&V?yc(vs(h)):null,le=oe&&Y?i_({dragItems:h,snapGrid:W,x:ne,y:Q}):null;for(const[he,Z]of h){if(!C.has(he))continue;let se={x:ne-Z.distance.x,y:Q-Z.distance.y};Y&&(se=le?{x:Math.round(se.x+le.x),y:Math.round(se.y+le.y)}:xs(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:ye}=Z.internals,Me=ye.x-fe.x+V[0][0],Te=ye.x+Z.measured.width-fe.x2+V[1][0],Le=ye.y-fe.y+V[0][1],De=ye.y+Z.measured.height-fe.y2+V[1][1];me=[[Me,Le],[Te,De]]}const{position:Ne,positionAbsolute:we}=Ng({nodeId:he,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:R});re=re||Z.position.x!==Ne.x||Z.position.y!==Ne.y,Z.position=Ne,Z.internals.positionAbsolute=we}if(S=S||re,!!re&&(z(h,!0),k&&(s||D||!$&&H))){const[he,Z]=Ku({nodeId:$,dragItems:h,nodeLookup:C});s==null||s(k,h,he,Z),D==null||D(k,he,Z),$||H==null||H(k,Z)}}async function q(){if(!w)return;const{transform:ne,panBy:Q,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,Y]=Rc(y,w,C);(W!==0||Y!==0)&&(u.x=(u.x??0)-W/ne[2],u.y=(u.y??0)-Y/ne[2],await Q({x:W,y:Y})&&U(u)),c=requestAnimationFrame(q)}function te(ne){var oe;const{nodeLookup:Q,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:Y,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:R,unselectNodesAndEdges:z}=r();v=!0,(!D||!L)&&!C&&$&&((oe=Q.get($))!=null&&oe.selected||z()),L&&D&&$&&(e==null||e($));const re=ns(ne.sourceEvent,{transform:W,snapGrid:Y,snapToGrid:M,containerBounds:w});if(u=re,h=o_(Q,V,re,$),h.size>0&&(o||H||!$&&R)){const[fe,le]=Ku({nodeId:$,dragItems:h,nodeLookup:Q});o==null||o(ne.sourceEvent,h,fe,le),H==null||H(ne.sourceEvent,fe,le),$||R==null||R(ne.sourceEvent,le)}}const J=rg().clickDistance(F).on("start",ne=>{const{domNode:Q,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:Y}=r();w=(Q==null?void 0:Q.getBoundingClientRect())||null,x=!1,S=!1,k=ne.sourceEvent,C===0&&te(ne),u=ns(ne.sourceEvent,{transform:V,snapGrid:W,snapToGrid:Y,containerBounds:w}),y=_n(ne.sourceEvent,w)}).on("drag",ne=>{const{autoPanOnNodeDrag:Q,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:Y,nodeLookup:M}=r(),D=ns(ne.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:w});if(k=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||$&&!M.has($))&&(x=!0),!x){if(!p&&Q&&v&&(p=!0,q()),!v){const H=_n(ne.sourceEvent,w),R=H.x-y.x,z=H.y-y.y;Math.sqrt(R*R+z*z)>Y&&te(ne)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&v&&(y=_n(ne.sourceEvent,w),U(D))}}).on("end",ne=>{if(!v||x){x&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,v=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:Q,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(S&&(C(h,!1),S=!1),a||V||!$&&W){const[Y,M]=Ku({nodeId:$,dragItems:h,nodeLookup:Q,dragging:!1});a==null||a(ne.sourceEvent,h,Y,M),V==null||V(ne.sourceEvent,Y,M),$||W==null||W(ne.sourceEvent,M)}}}).filter(ne=>{const Q=ne.target;return!ne.button&&(!I||!Uh(Q,`.${I}`,j))&&(!_||Uh(Q,_,j))});g.call(J)}function E(){g==null||g.on(".drag",null)}return{update:b,destroy:E}}function a_(e,r,o){const s=[],a={x:e.x-o,y:e.y-o,width:o*2,height:o*2};for(const u of r.values())Ya(a,ds(u))>0&&s.push(u);return s}const l_=250;function u_(e,r,o,s){var h,p;let a=[],u=1/0;const c=a_(e,o,r+l_);for(const y of c){const w=[...((h=y.internals.handleBounds)==null?void 0:h.source)??[],...((p=y.internals.handleBounds)==null?void 0:p.target)??[]];for(const v of w){if(s.nodeId===v.nodeId&&s.type===v.type&&s.id===v.id)continue;const{x:g,y:x}=wo(y,v,v.position,!0),S=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(x-e.y,2));S>r||(S1){const y=s.type==="source"?"target":"source";return a.find(w=>w.type===y)??a[0]}return a[0]}function Bg(e,r,o,s,a,u=!1){var y,w,v;const c=s.get(e);if(!c)return null;const h=a==="strict"?(y=c.internals.handleBounds)==null?void 0:y[r]:[...((w=c.internals.handleBounds)==null?void 0:w.source)??[],...((v=c.internals.handleBounds)==null?void 0:v.target)??[]],p=(o?h==null?void 0:h.find(g=>g.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...wo(c,p,p.position,!0)}:p}function Vg(e,r){return e||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function c_(e,r){let o=null;return r?o=!0:e&&!r&&(o=!1),o}const Wg=()=>!0;function d_(e,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:y,autoPanOnConnect:w,flowId:v,panBy:g,cancelConnection:x,onConnectStart:S,onConnect:k,onConnectEnd:b,isValidConnection:E=Wg,onReconnectEnd:I,updateConnection:_,getTransform:j,getFromHandle:L,autoPanSpeed:$,dragThreshold:F=1,handleDomNode:U}){const q=Ig(e.target);let te=0,J;const{x:ne,y:Q}=_n(e),C=Vg(u,U),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const Y=Bg(a,C,s,p,r);if(!Y)return;let M=_n(e,V),D=!1,H=null,R=!1,z=null;function re(){if(!w||!V)return;const[Ne,we]=Rc(M,V,$);g({x:Ne,y:we}),te=requestAnimationFrame(re)}const oe={...Y,nodeId:a,type:C,position:Y.position},fe=p.get(a);let he={inProgress:!0,isValid:null,from:wo(fe,oe,ke.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Th[oe.position],toNode:null,pointer:M};function Z(){W=!0,_(he),S==null||S(e,{nodeId:a,handleId:s,handleType:C})}F===0&&Z();function se(Ne){if(!W){const{x:De,y:pe}=_n(Ne),$e=De-ne,Ve=pe-Q;if(!($e*$e+Ve*Ve>F*F))return;Z()}if(!L()||!oe){me(Ne);return}const we=j();M=_n(Ne,V),J=u_(ws(M,we,!1,[1,1]),o,p,oe),D||(re(),D=!0);const ye=Ug(Ne,{handle:J,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:E,doc:q,lib:y,flowId:v,nodeLookup:p});z=ye.handleDomNode,H=ye.connection,R=c_(!!J,ye.isValid);const Me=p.get(a),Te=Me?wo(Me,oe,ke.Left,!0):he.from,Le={...he,from:Te,isValid:R,to:ye.toHandle&&R?ai({x:ye.toHandle.x,y:ye.toHandle.y},we):M,toHandle:ye.toHandle,toPosition:R&&ye.toHandle?ye.toHandle.position:Th[oe.position],toNode:ye.toHandle?p.get(ye.toHandle.nodeId):null,pointer:M};_(Le),he=Le}function me(Ne){if(!("touches"in Ne&&Ne.touches.length>0)){if(W){(J||z)&&H&&R&&(k==null||k(H));const{inProgress:we,...ye}=he,Me={...ye,toPosition:he.toHandle?he.toPosition:null};b==null||b(Ne,Me),u&&(I==null||I(Ne,Me))}x(),cancelAnimationFrame(te),D=!1,R=!1,H=null,z=null,q.removeEventListener("mousemove",se),q.removeEventListener("mouseup",me),q.removeEventListener("touchmove",se),q.removeEventListener("touchend",me)}}q.addEventListener("mousemove",se),q.addEventListener("mouseup",me),q.addEventListener("touchmove",se),q.addEventListener("touchend",me)}function Ug(e,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:y=Wg,nodeLookup:w}){const v=u==="target",g=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x,y:S}=_n(e),k=c.elementFromPoint(x,S),b=k!=null&&k.classList.contains(`${h}-flow__handle`)?k:g,E={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const I=Vg(void 0,b),_=b.getAttribute("data-nodeid"),j=b.getAttribute("data-handleid"),L=b.classList.contains("connectable"),$=b.classList.contains("connectableend");if(!_||!I)return E;const F={source:v?_:s,sourceHandle:v?j:a,target:v?s:_,targetHandle:v?a:j};E.connection=F;const q=L&&$&&(o===ii.Strict?v&&I==="source"||!v&&I==="target":_!==s||j!==a);E.isValid=q&&y(F),E.toHandle=Bg(_,I,j,w,o,!0)}return E}const wc={onPointerDown:d_,isValid:Ug};function f_({domNode:e,panZoom:r,getTransform:o,getViewScale:s}){const a=Gt(e);function u({translateExtent:h,width:p,height:y,zoomStep:w=1,pannable:v=!0,zoomable:g=!0,inversePan:x=!1}){const S=_=>{if(_.sourceEvent.type!=="wheel"||!r)return;const j=o(),L=_.sourceEvent.ctrlKey&&fs()?10:1,$=-_.sourceEvent.deltaY*(_.sourceEvent.deltaMode===1?.05:_.sourceEvent.deltaMode?1:.002)*w,F=j[2]*Math.pow(2,$*L);r.scaleTo(F)};let k=[0,0];const b=_=>{(_.sourceEvent.type==="mousedown"||_.sourceEvent.type==="touchstart")&&(k=[_.sourceEvent.clientX??_.sourceEvent.touches[0].clientX,_.sourceEvent.clientY??_.sourceEvent.touches[0].clientY])},E=_=>{const j=o();if(_.sourceEvent.type!=="mousemove"&&_.sourceEvent.type!=="touchmove"||!r)return;const L=[_.sourceEvent.clientX??_.sourceEvent.touches[0].clientX,_.sourceEvent.clientY??_.sourceEvent.touches[0].clientY],$=[L[0]-k[0],L[1]-k[1]];k=L;const F=s()*Math.max(j[2],Math.log(j[2]))*(x?-1:1),U={x:j[0]-$[0]*F,y:j[1]-$[1]*F},q=[[0,0],[p,y]];r.setViewportConstrained({x:U.x,y:U.y,zoom:j[2]},q,h)},I=vg().on("start",b).on("zoom",v?E:null).on("zoom.wheel",g?S:null);a.call(I,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:vn}}const al=e=>({x:e.x,y:e.y,zoom:e.k}),Qu=({x:e,y:r,zoom:o})=>ol.translate(e,r).scale(o),zr=(e,r)=>e.target.closest(`.${r}`),Gg=(e,r)=>r===2&&Array.isArray(e)&&e.includes(2),h_=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Zu=(e,r=0,o=h_,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?e.transition().duration(r).ease(o).on("end",s):e},Yg=e=>{const r=e.ctrlKey&&fs()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*r};function p_({zoomPanValues:e,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:y}){return w=>{if(zr(w,r))return w.ctrlKey&&w.preventDefault(),!1;w.preventDefault(),w.stopImmediatePropagation();const v=o.property("__zoom").k||1;if(w.ctrlKey&&c){const b=vn(w),E=Yg(w),I=v*Math.pow(2,E);s.scaleTo(o,I,b,w);return}const g=w.deltaMode===1?20:1;let x=a===po.Vertical?0:w.deltaX*g,S=a===po.Horizontal?0:w.deltaY*g;!fs()&&w.shiftKey&&a!==po.Vertical&&(x=w.deltaY*g,S=0),s.translateBy(o,-(x/v)*u,-(S/v)*u,{internal:!0});const k=al(o.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?p==null||p(w,k):(e.isPanScrolling=!0,h==null||h(w,k)),e.panScrollTimeout=setTimeout(()=>{y==null||y(w,k),e.isPanScrolling=!1},150)}}function g_({noWheelClassName:e,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=zr(s,e);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function m_({zoomPanValues:e,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=al(s.transform);e.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function y_({zoomPanValues:e,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;e.usedRightMouseButton=!!(o&&Gg(r,e.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,al(u.transform)))}}function v_({zoomPanValues:e,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(e.isZoomingOrPanning=!1,u&&Gg(r,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),e.usedRightMouseButton=!1,s(!1),a)){const p=al(c.transform);e.prevViewport=p,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function x_({panActivationKeyPressed:e,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:y,lib:w,connectionInProgress:v}){return g=>{var E;const x=r||o,S=s&&g.ctrlKey,k=g.type==="wheel";if(g.button===1&&g.type==="mousedown"&&(zr(g,`${w}-flow__node`)||zr(g,`${w}-flow__edge`)||zr(g,`${w}-flow__selection`)||zr(g,`${w}-flow__nodesselection`)))return!0;if(!a&&!x&&!u&&!c&&!s||h||v&&!k||zr(g,p)&&k||zr(g,y)&&(!k||u&&k&&!r)||!s&&g.ctrlKey&&k)return!1;if(!s&&g.type==="touchstart"&&((E=g.touches)==null?void 0:E.length)>1)return g.preventDefault(),!1;if(!x&&!u&&!S&&k||!a&&(g.type==="mousedown"||g.type==="touchstart")||Array.isArray(a)&&!a.includes(g.button)&&g.type==="mousedown")return!1;const b=Array.isArray(a)&&a.includes(g.button)||!g.button||g.button<=1;return(!g.ctrlKey||k||e)&&b}}function w_({domNode:e,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const y={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},w=e.getBoundingClientRect();let v=[[0,0],[w.width,w.height]];const g=typeof ResizeObserver<"u"?new ResizeObserver(Q=>{const C=Q[0];C&&(v=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;g==null||g.observe(e);const x=vg().extent(()=>v).scaleExtent([r,o]).translateExtent(s),S=Gt(e).call(x);j({x:a.x,y:a.y,zoom:si(a.zoom,r,o)},[[0,0],[w.width,w.height]],s);const k=S.on("wheel.zoom"),b=S.on("dblclick.zoom");x.wheelDelta(Yg);async function E(Q,C){return S?new Promise(V=>{x==null||x.interpolate((C==null?void 0:C.interpolate)==="linear"?ts:Aa).transform(Zu(S,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),Q)}):!1}function I({noWheelClassName:Q,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:Y,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:H,preventScrolling:R,zoomOnPinch:z,zoomOnScroll:re,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:le,lib:he,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:Ne}){W&&!y.isZoomingOrPanning&&_();const we=Y&&!le&&!W;x.clickDistance(Ne?1/0:!wn(me)||me<0?0:me);const ye=we?p_({zoomPanValues:y,noWheelClassName:Q,d3Selection:S,d3Zoom:x,panOnScrollMode:D,panOnScrollSpeed:H,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):g_({noWheelClassName:Q,preventScrolling:R,d3ZoomHandler:k});S.on("wheel.zoom",ye,{passive:!1});const Me=m_({zoomPanValues:y,onDraggingChange:p,onPanZoomStart:c});x.on("start",Me);const Te=y_({zoomPanValues:y,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});x.on("zoom",Te);const Le=v_({zoomPanValues:y,panOnDrag:M,panOnScroll:Y,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});x.on("end",Le);const De=x_({panActivationKeyPressed:fe,zoomActivationKeyPressed:le,panOnDrag:M,zoomOnScroll:re,panOnScroll:Y,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:W,noPanClassName:C,noWheelClassName:Q,lib:he,connectionInProgress:se});x.filter(De),oe?S.on("dblclick.zoom",b):S.on("dblclick.zoom",null)}function _(){x.on("zoom",null)}async function j(Q,C,V){const W=Qu(Q),Y=x==null?void 0:x.constrain()(W,C,V);return Y&&await E(Y),Y}async function L(Q,C){const V=Qu(Q);return await E(V,C),V}function $(Q){if(S){const C=Qu(Q),V=S.property("__zoom");(V.k!==Q.zoom||V.x!==Q.x||V.y!==Q.y)&&(x==null||x.transform(S,C,null,{sync:!0}))}}function F(){const Q=S?yg(S.node()):{x:0,y:0,k:1};return{x:Q.x,y:Q.y,zoom:Q.k}}async function U(Q,C){return S?new Promise(V=>{x==null||x.interpolate((C==null?void 0:C.interpolate)==="linear"?ts:Aa).scaleTo(Zu(S,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),Q)}):!1}async function q(Q,C){return S?new Promise(V=>{x==null||x.interpolate((C==null?void 0:C.interpolate)==="linear"?ts:Aa).scaleBy(Zu(S,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),Q)}):!1}function te(Q){x==null||x.scaleExtent(Q)}function J(Q){x==null||x.translateExtent(Q)}function ne(Q){const C=!wn(Q)||Q<0?0:Q;x==null||x.clickDistance(C)}return{update:I,destroy:_,setViewport:L,setViewportConstrained:j,getViewport:F,scaleTo:U,scaleBy:q,setScaleExtent:te,setTranslateExtent:J,syncViewport:$,setClickDistance:ne}}var li;(function(e){e.Line="line",e.Handle="handle"})(li||(li={}));function __({width:e,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=e-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Gh(e){const r=e.includes("right")||e.includes("left"),o=e.includes("bottom")||e.includes("top"),s=e.includes("left"),a=e.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Ar(e,r){return Math.max(0,r-e)}function $r(e,r){return Math.max(0,e-r)}function Ma(e,r,o){return Math.max(0,r-e,e-o)}function Yh(e,r){return e?!r:r}function S_(e,r,o,s,a,u,c,h){let{affectsX:p,affectsY:y}=r;const{isHorizontal:w,isVertical:v}=r,g=w&&v,{xSnapped:x,ySnapped:S}=o,{minWidth:k,maxWidth:b,minHeight:E,maxHeight:I}=s,{x:_,y:j,width:L,height:$,aspectRatio:F}=e;let U=Math.floor(w?x-e.pointerX:0),q=Math.floor(v?S-e.pointerY:0);const te=L+(p?-U:U),J=$+(y?-q:q),ne=-u[0]*L,Q=-u[1]*$;let C=Ma(te,k,b),V=Ma(J,E,I);if(c){let M=0,D=0;p&&U<0?M=Ar(_+U+ne,c[0][0]):!p&&U>0&&(M=$r(_+te+ne,c[1][0])),y&&q<0?D=Ar(j+q+Q,c[0][1]):!y&&q>0&&(D=$r(j+J+Q,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&U>0?M=$r(_+U,h[0][0]):!p&&U<0&&(M=Ar(_+te,h[1][0])),y&&q>0?D=$r(j+q,h[0][1]):!y&&q<0&&(D=Ar(j+J,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(w){const M=Ma(te/F,E,I)*F;if(C=Math.max(C,M),c){let D=0;!p&&!y||p&&!y&&g?D=$r(j+Q+te/F,c[1][1])*F:D=Ar(j+Q+(p?U:-U)/F,c[0][1])*F,C=Math.max(C,D)}if(h){let D=0;!p&&!y||p&&!y&&g?D=Ar(j+te/F,h[1][1])*F:D=$r(j+(p?U:-U)/F,h[0][1])*F,C=Math.max(C,D)}}if(v){const M=Ma(J*F,k,b)/F;if(V=Math.max(V,M),c){let D=0;!p&&!y||y&&!p&&g?D=$r(_+J*F+ne,c[1][0])/F:D=Ar(_+(y?q:-q)*F+ne,c[0][0])/F,V=Math.max(V,D)}if(h){let D=0;!p&&!y||y&&!p&&g?D=Ar(_+J*F,h[1][0])/F:D=$r(_+(y?q:-q)*F,h[0][0])/F,V=Math.max(V,D)}}}q=q+(q<0?V:-V),U=U+(U<0?C:-C),a&&(g?te>J*F?q=(Yh(p,y)?-U:U)/F:U=(Yh(p,y)?-q:q)*F:w?(q=U/F,y=p):(U=q*F,p=y));const W=p?_+U:_,Y=y?j+q:j;return{width:L+(p?-U:U),height:$+(y?-q:q),x:u[0]*U*(p?-1:1)+W,y:u[1]*q*(y?-1:1)+Y}}const Xg={width:0,height:0,x:0,y:0},k_={...Xg,pointerX:0,pointerY:0,aspectRatio:1};function N_(e,r,o){const s=r.position.x+e.position.x,a=r.position.y+e.position.y,u=e.measured.width??0,c=e.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function b_({domNode:e,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Gt(e);let c={controlDirection:Gh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:y,boundaries:w,keepAspectRatio:v,resizeDirection:g,onResizeStart:x,onResize:S,onResizeEnd:k,shouldResize:b}){let E={...Xg},I={...k_};c={boundaries:w,resizeDirection:g,keepAspectRatio:v,controlDirection:Gh(y)};let _,j=null,L=[],$,F,U,q=!1;const te=rg().on("start",J=>{const{nodeLookup:ne,transform:Q,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:Y}=o();if(_=ne.get(r),!_)return;j=(Y==null?void 0:Y.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=ns(J.sourceEvent,{transform:Q,snapGrid:C,snapToGrid:V,containerBounds:j});E={width:_.measured.width??0,height:_.measured.height??0,x:_.position.x??0,y:_.position.y??0},I={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},$=void 0,F=xo(_.extent)?_.extent:void 0,_.parentId&&(_.extent==="parent"||_.expandParent)&&($=ne.get(_.parentId)),$&&_.extent==="parent"&&(F=[[0,0],[$.measured.width,$.measured.height]]),L=[],U=void 0;for(const[H,R]of ne)if(R.parentId===r&&(L.push({id:H,position:{...R.position},extent:R.extent}),R.extent==="parent"||R.expandParent)){const z=N_(R,_,R.origin??W);U?U=[[Math.min(z[0][0],U[0][0]),Math.min(z[0][1],U[0][1])],[Math.max(z[1][0],U[1][0]),Math.max(z[1][1],U[1][1])]]:U=z}x==null||x(J,{...E})}).on("drag",J=>{const{transform:ne,snapGrid:Q,snapToGrid:C,nodeOrigin:V}=o(),W=ns(J.sourceEvent,{transform:ne,snapGrid:Q,snapToGrid:C,containerBounds:j}),Y=[];if(!_)return;const{x:M,y:D,width:H,height:R}=E,z={},re=_.origin??V,{width:oe,height:fe,x:le,y:he}=S_(I,c.controlDirection,W,c.boundaries,c.keepAspectRatio,re,F,U),Z=oe!==H,se=fe!==R,me=le!==M&&Z,Ne=he!==D&&se;if(!me&&!Ne&&!Z&&!se)return;if((me||Ne||re[0]===1||re[1]===1)&&(z.x=me?le:E.x,z.y=Ne?he:E.y,E.x=z.x,E.y=z.y,L.length>0)){const Te=le-M,Le=he-D;for(const De of L)De.position={x:De.position.x-Te+re[0]*(oe-H),y:De.position.y-Le+re[1]*(fe-R)},Y.push(De)}if((Z||se)&&(z.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:E.width,z.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:E.height,E.width=z.width,E.height=z.height),$&&_.expandParent){const Te=re[0]*(z.width??0);z.x&&z.x{q&&(k==null||k(J,{...E}),a==null||a({...E}),q=!1)});u.call(te)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Ju={exports:{}},ec={},tc={exports:{}},nc={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Xh;function j_(){if(Xh)return nc;Xh=1;var e=ps();function r(v,g){return v===g&&(v!==0||1/v===1/g)||v!==v&&g!==g}var o=typeof Object.is=="function"?Object.is:r,s=e.useState,a=e.useEffect,u=e.useLayoutEffect,c=e.useDebugValue;function h(v,g){var x=g(),S=s({inst:{value:x,getSnapshot:g}}),k=S[0].inst,b=S[1];return u(function(){k.value=x,k.getSnapshot=g,p(k)&&b({inst:k})},[v,x,g]),a(function(){return p(k)&&b({inst:k}),v(function(){p(k)&&b({inst:k})})},[v]),c(x),x}function p(v){var g=v.getSnapshot;v=v.value;try{var x=g();return!o(v,x)}catch{return!0}}function y(v,g){return g()}var w=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:h;return nc.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:w,nc}var qh;function E_(){return qh||(qh=1,tc.exports=j_()),tc.exports}/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Kh;function C_(){if(Kh)return ec;Kh=1;var e=ps(),r=E_();function o(y,w){return y===w&&(y!==0||1/y===1/w)||y!==y&&w!==w}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=e.useRef,c=e.useEffect,h=e.useMemo,p=e.useDebugValue;return ec.useSyncExternalStoreWithSelector=function(y,w,v,g,x){var S=u(null);if(S.current===null){var k={hasValue:!1,value:null};S.current=k}else k=S.current;S=h(function(){function E($){if(!I){if(I=!0,_=$,$=g($),x!==void 0&&k.hasValue){var F=k.value;if(x(F,$))return j=F}return j=$}if(F=j,s(_,$))return F;var U=g($);return x!==void 0&&x(F,U)?(_=$,F):(_=$,j=U)}var I=!1,_,j,L=v===void 0?null:v;return[function(){return E(w())},L===null?void 0:function(){return E(L())}]},[w,v,g,x]);var b=a(y,S[0],S[1]);return c(function(){k.hasValue=!0,k.value=b},[b]),p(b),b},ec}var Qh;function M_(){return Qh||(Qh=1,Ju.exports=C_()),Ju.exports}var P_=M_();const I_=Op(P_),R_={},Zh=e=>{let r;const o=new Set,s=(w,v)=>{const g=typeof w=="function"?w(r):w;if(!Object.is(g,r)){const x=r;r=v??(typeof g!="object"||g===null)?g:Object.assign({},r,g),o.forEach(S=>S(r,x))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>y,subscribe:w=>(o.add(w),()=>o.delete(w)),destroy:()=>{(R_?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),o.clear()}},y=r=e(s,a,p);return p},T_=e=>e?Zh(e):Zh,{useDebugValue:L_}=M0,{useSyncExternalStoreWithSelector:A_}=I_,$_=e=>e;function qg(e,r=$_,o){const s=A_(e.subscribe,e.getState,e.getServerState||e.getInitialState,r,o);return L_(s),s}const Jh=(e,r)=>{const o=T_(e),s=(a,u=r)=>qg(o,a,u);return Object.assign(s,o),s},z_=(e,r)=>e?Jh(e,r):Jh;function et(e,r){if(Object.is(e,r))return!0;if(typeof e!="object"||e===null||typeof r!="object"||r===null)return!1;if(e instanceof Map&&r instanceof Map){if(e.size!==r.size)return!1;for(const[s,a]of e)if(!Object.is(a,r.get(s)))return!1;return!0}if(e instanceof Set&&r instanceof Set){if(e.size!==r.size)return!1;for(const s of e)if(!r.has(s))return!1;return!0}const o=Object.keys(e);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(e[s],r[s]))return!1;return!0}Fp();const ll=A.createContext(null),D_=ll.Provider,Kg=Sn.error001("react");function Fe(e,r){const o=A.useContext(ll);if(o===null)throw new Error(Kg);return qg(o,e,r)}function Ke(){const e=A.useContext(ll);if(e===null)throw new Error(Kg);return A.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const ep={display:"none"},O_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Qg="react-flow__node-desc",Zg="react-flow__edge-desc",F_="react-flow__aria-live",H_=e=>e.ariaLiveMessage,B_=e=>e.ariaLabelConfig;function V_({rfId:e}){const r=Fe(H_);return d.jsx("div",{id:`${F_}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:O_,children:r})}function W_({rfId:e,disableKeyboardA11y:r}){const o=Fe(B_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Qg}-${e}`,style:ep,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Zg}-${e}`,style:ep,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(V_,{rfId:e})]})}const ul=A.forwardRef(({position:e="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${e}`.split("-");return d.jsx("div",{className:st(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});ul.displayName="Panel";const tp="https://reactflow.dev?utm_source=attribution";function U_({proOptions:e,position:r="bottom-right"}){return e!=null&&e.hideAttribution?null:d.jsx(ul,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${tp}`,children:d.jsx("a",{href:tp,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const G_=e=>{const r=[],o=[];for(const[,s]of e.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of e.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},Pa=e=>e.id;function Y_(e,r){return et(e.selectedNodes.map(Pa),r.selectedNodes.map(Pa))&&et(e.selectedEdges.map(Pa),r.selectedEdges.map(Pa))}function X_({onSelectionChange:e}){const r=Ke(),{selectedNodes:o,selectedEdges:s}=Fe(G_,Y_);return A.useEffect(()=>{const a={nodes:o,edges:s};e==null||e(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,e]),null}const q_=e=>!!e.onSelectionChangeHandlers;function K_({onSelectionChange:e}){const r=Fe(q_);return e||r?d.jsx(X_,{onSelectionChange:e}):null}const Jg=[0,0],Q_={x:0,y:0,zoom:1},Z_=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],np=[...Z_,"rfId"],J_=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),rp={translateExtent:ls,nodeOrigin:Jg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function eS(e){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=Fe(J_,et),y=Ke();A.useEffect(()=>(p(e.defaultNodes,e.defaultEdges),()=>{w.current=rp,h()}),[]);const w=A.useRef(rp);return A.useEffect(()=>{for(const v of np){const g=e[v],x=w.current[v];g!==x&&(typeof e[v]>"u"||(v==="nodes"?r(g):v==="edges"?o(g):v==="minZoom"?s(g):v==="maxZoom"?a(g):v==="translateExtent"?u(g):v==="nodeExtent"?c(g):v==="ariaLabelConfig"?y.setState({ariaLabelConfig:D1(g)}):v==="fitView"?y.setState({fitViewQueued:g}):v==="fitViewOptions"?y.setState({fitViewOptions:g}):y.setState({[v]:g})))}w.current=e},np.map(v=>e[v])),null}function op(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function tS(e){var s;const[r,o]=A.useState(e==="system"?null:e);return A.useEffect(()=>{if(e!=="system"){o(e);return}const a=op(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[e]),r!==null?r:(s=op())!=null&&s.matches?"dark":"light"}const ip=typeof document<"u"?document:null;function hs(e=null,r={target:ip,actInsideInputWithModifier:!0}){const[o,s]=A.useState(!1),a=A.useRef(!1),u=A.useRef(new Set([])),[c,h]=A.useMemo(()=>{if(e!==null){const y=(Array.isArray(e)?e:[e]).filter(v=>typeof v=="string").map(v=>v.replace(/\+/g,` +`).replace(` + +`,` ++`).split(` +`)),w=y.reduce((v,g)=>v.concat(...g),[]);return[y,w]}return[[],[]]},[e]);return A.useEffect(()=>{const p=(r==null?void 0:r.target)??ip,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(e!==null){const w=x=>{var b,E;if(a.current=x.ctrlKey||x.metaKey||x.shiftKey||x.altKey,(!a.current||a.current&&!y)&&Rg(x))return!1;const k=ap(x.code,h);if(u.current.add(x[k]),sp(c,u.current,!1)){const I=((E=(b=x.composedPath)==null?void 0:b.call(x))==null?void 0:E[0])||x.target,_=(I==null?void 0:I.nodeName)==="BUTTON"||(I==null?void 0:I.nodeName)==="A";r.preventDefault!==!1&&(a.current||!_)&&x.preventDefault(),s(!0)}},v=x=>{const S=ap(x.code,h);sp(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(x[S]),x.key==="Meta"&&u.current.clear(),a.current=!1},g=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",w),p==null||p.addEventListener("keyup",v),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{p==null||p.removeEventListener("keydown",w),p==null||p.removeEventListener("keyup",v),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,s]),o}function sp(e,r,o){return e.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function ap(e,r){return r.includes(e)?"code":"key"}const nS=()=>{const e=Ke();return A.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=e.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=e.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=e.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>e.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=e.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=e.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>e.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=e.getState(),p=Tc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=e.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),y={x:r.x-h,y:r.y-p},w=o.snapGrid??a,v=o.snapToGrid??u;return ws(y,s,v,w)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=e.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=ai(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function em(e,r){const o=[],s=new Map,a=[];for(const u of e)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)rS(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function rS(e,r){switch(e.type){case"select":{r.selected=e.selected;break}case"position":{typeof e.position<"u"&&(r.position=e.position),typeof e.dragging<"u"&&(r.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(r.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(r.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(r.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(r.resizing=e.resizing);break}}}function oS(e,r){return em(e,r)}function iS(e,r){return em(e,r)}function co(e,r){return{id:e,type:"select",selected:r}}function ei(e,r=new Set,o=!1){const s=[];for(const[a,u]of e){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(co(u.id,c)))}return s}function lp({items:e=[],lookup:r}){var a;const o=[],s=new Map(e.map(u=>[u.id,u]));for(const[u,c]of e.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function up(e){return{id:e.id,type:"remove"}}const sS=Cg();function aS(e,r,o={}){return W1(e,r,{...o,onError:o.onError??sS})}const cp=e=>M1(e),lS=e=>kg(e);function tm(e){return A.forwardRef(e)}const nm=typeof window<"u"?A.useLayoutEffect:A.useEffect;function dp(e){const[r,o]=A.useState(BigInt(0)),[s]=A.useState(()=>uS(()=>o(a=>a+BigInt(1))));return nm(()=>{const a=s.get();a.length&&(e(a),s.reset())},[r]),s}function uS(e){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),e()}}}const rm=A.createContext(null);function cS({children:e}){const r=Ke(),o=A.useCallback(h=>{const{nodes:p=[],setNodes:y,hasDefaultNodes:w,onNodesChange:v,nodeLookup:g,fitViewQueued:x,onNodesChangeMiddlewareMap:S}=r.getState();let k=p;for(const E of h)k=typeof E=="function"?E(k):E;let b=lp({items:k,lookup:g});for(const E of S.values())b=E(b);w&&y(k),b.length>0?v==null||v(b):x&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:I,setNodes:_}=r.getState();E&&_(I)})},[]),s=dp(o),a=A.useCallback(h=>{const{edges:p=[],setEdges:y,hasDefaultEdges:w,onEdgesChange:v,edgeLookup:g}=r.getState();let x=p;for(const S of h)x=typeof S=="function"?S(x):S;w?y(x):v&&v(lp({items:x,lookup:g}))},[]),u=dp(a),c=A.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(rm.Provider,{value:c,children:e})}function dS(){const e=A.useContext(rm);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const fS=e=>!!e.panZoom;function cl(){const e=nS(),r=Ke(),o=dS(),s=Fe(fS),a=A.useMemo(()=>{const u=v=>r.getState().nodeLookup.get(v),c=v=>{o.nodeQueue.push(v)},h=v=>{o.edgeQueue.push(v)},p=v=>{var E,I;const{nodeLookup:g,nodeOrigin:x}=r.getState(),S=cp(v)?v:g.get(v.id),k=S.parentId?Pg(S.position,S.measured,S.parentId,g,x):S.position,b={...S,position:k,width:((E=S.measured)==null?void 0:E.width)??S.width,height:((I=S.measured)==null?void 0:I.height)??S.height};return ds(b)},y=(v,g,x={replace:!1})=>{c(S=>S.map(k=>{if(k.id===v){const b=typeof g=="function"?g(k):g;return x.replace&&cp(b)?b:{...k,...b}}return k}))},w=(v,g,x={replace:!1})=>{h(S=>S.map(k=>{if(k.id===v){const b=typeof g=="function"?g(k):g;return x.replace&&lS(b)?b:{...k,...b}}return k}))};return{getNodes:()=>r.getState().nodes.map(v=>({...v})),getNode:v=>{var g;return(g=u(v))==null?void 0:g.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:v=[]}=r.getState();return v.map(g=>({...g}))},getEdge:v=>r.getState().edgeLookup.get(v),setNodes:c,setEdges:h,addNodes:v=>{const g=Array.isArray(v)?v:[v];o.nodeQueue.push(x=>[...x,...g])},addEdges:v=>{const g=Array.isArray(v)?v:[v];o.edgeQueue.push(x=>[...x,...g])},toObject:()=>{const{nodes:v=[],edges:g=[],transform:x}=r.getState(),[S,k,b]=x;return{nodes:v.map(E=>({...E})),edges:g.map(E=>({...E})),viewport:{x:S,y:k,zoom:b}}},deleteElements:async({nodes:v=[],edges:g=[]})=>{const{nodes:x,edges:S,onNodesDelete:k,onEdgesDelete:b,triggerNodeChanges:E,triggerEdgeChanges:I,onDelete:_,onBeforeDelete:j}=r.getState(),{nodes:L,edges:$}=await L1({nodesToRemove:v,edgesToRemove:g,nodes:x,edges:S,onBeforeDelete:j}),F=$.length>0,U=L.length>0;if(F){const q=$.map(up);b==null||b($),I(q)}if(U){const q=L.map(up);k==null||k(L),E(q)}return(U||F)&&(_==null||_({nodes:L,edges:$})),{deletedNodes:L,deletedEdges:$}},getIntersectingNodes:(v,g=!0,x)=>{const S=Ah(v),k=S?v:p(v),b=x!==void 0;return k?(x||r.getState().nodes).filter(E=>{const I=r.getState().nodeLookup.get(E.id);if(I&&!S&&(E.id===v.id||!I.internals.positionAbsolute))return!1;const _=ds(b?E:I),j=Ya(_,k);return g&&j>0||j>=_.width*_.height||j>=k.width*k.height}):[]},isNodeIntersecting:(v,g,x=!0)=>{const k=Ah(v)?v:p(v);if(!k)return!1;const b=Ya(k,g);return x&&b>0||b>=g.width*g.height||b>=k.width*k.height},updateNode:y,updateNodeData:(v,g,x={replace:!1})=>{y(v,S=>{const k=typeof g=="function"?g(S):g;return x.replace?{...S,data:k}:{...S,data:{...S.data,...k}}},x)},updateEdge:w,updateEdgeData:(v,g,x={replace:!1})=>{w(v,S=>{const k=typeof g=="function"?g(S):g;return x.replace?{...S,data:k}:{...S,data:{...S.data,...k}}},x)},getNodesBounds:v=>{const{nodeLookup:g,nodeOrigin:x}=r.getState();return P1(v,{nodeLookup:g,nodeOrigin:x})},getHandleConnections:({type:v,id:g,nodeId:x})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${x}-${v}${g?`-${g}`:""}`))==null?void 0:S.values())??[])},getNodeConnections:({type:v,handleId:g,nodeId:x})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${x}${v?g?`-${v}-${g}`:`-${v}`:""}`))==null?void 0:S.values())??[])},fitView:async v=>{const g=r.getState().fitViewResolver??z1();return r.setState({fitViewQueued:!0,fitViewOptions:v,fitViewResolver:g}),o.nodeQueue.push(x=>[...x]),g.promise}}},[]);return A.useMemo(()=>({...a,...e,viewportInitialized:s}),[s])}const fp=e=>e.selected,hS=typeof window<"u"?window:void 0;function pS({deleteKeyCode:e,multiSelectionKeyCode:r}){const o=Ke(),{deleteElements:s}=cl(),a=hs(e,{actInsideInputWithModifier:!1}),u=hs(r,{target:hS});A.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(fp),edges:c.filter(fp)}),o.setState({nodesSelectionActive:!1})}},[a]),A.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function gS(e){const r=Ke();A.useEffect(()=>{const o=()=>{var a,u,c,h;if(!e.current||!(((u=(a=e.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=Lc(e.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",Sn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(e.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(e.current),()=>{window.removeEventListener("resize",o),s&&e.current&&s.unobserve(e.current)}}},[])}const dl={position:"absolute",width:"100%",height:"100%",top:0,left:0},mS=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function yS({onPaneContextMenu:e,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=po.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:y,translateExtent:w,minZoom:v,maxZoom:g,zoomActivationKeyCode:x,preventScrolling:S=!0,children:k,noWheelClassName:b,noPanClassName:E,onViewportChange:I,isControlledViewport:_,paneClickDistance:j,selectionOnDrag:L}){const $=Ke(),F=A.useRef(null),{userSelectionActive:U,lib:q,connectionInProgress:te}=Fe(mS,et),J=hs(x),ne=A.useRef();gS(F);const Q=A.useCallback(C=>{I==null||I({x:C[0],y:C[1],zoom:C[2]}),_||$.setState({transform:C})},[I,_]);return A.useEffect(()=>{if(F.current){ne.current=w_({domNode:F.current,minZoom:v,maxZoom:g,translateExtent:w,viewport:y,onDraggingChange:Y=>$.setState(M=>M.paneDragging===Y?M:{paneDragging:Y}),onPanZoomStart:(Y,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(Y,M),D==null||D(M)},onPanZoom:(Y,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(Y,M),D==null||D(M)},onPanZoomEnd:(Y,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(Y,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var Y;(Y=ne.current)==null||Y.destroy()}}},[]),A.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:e,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:J,preventScrolling:S,noPanClassName:E,userSelectionActive:U,noWheelClassName:b,lib:q,onTransformChange:Q,connectionInProgress:te,selectionOnDrag:L,paneClickDistance:j})},[e,r,o,s,a,u,c,h,p,J,S,E,U,b,q,Q,te,L,j]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:dl,children:k})}const vS=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function xS(){const{userSelectionActive:e,userSelectionRect:r}=Fe(vS,et);return e&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const rc=(e,r)=>o=>{o.target===r.current&&(e==null||e(o))},wS=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function _S({isSelecting:e,selectionKeyPressed:r,selectionMode:o=us.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:y,onPaneContextMenu:w,onPaneScroll:v,onPaneMouseEnter:g,onPaneMouseMove:x,onPaneMouseLeave:S,children:k}){const b=A.useRef(0),E=Ke(),{userSelectionActive:I,elementsSelectable:_,dragging:j,panBy:L,autoPanSpeed:$}=Fe(wS,et),F=_&&(e||I),U=A.useRef(null),q=A.useRef(),te=A.useRef(new Set),J=A.useRef(new Set),ne=A.useRef(!1),Q=A.useRef(!1),C=A.useRef({x:0,y:0}),V=A.useRef(!1),W=Z=>{if(Q.current||ne.current||E.getState().connection.inProgress){Q.current=!1,ne.current=!1;return}y==null||y(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},Y=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}w==null||w(Z)},M=v?Z=>v(Z):void 0,D=Z=>{Q.current&&(Z.stopPropagation(),Q.current=!1)},H=Z=>{var De,pe;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const Ne=Z.target===U.current;if(!Ne&&!!Z.target.closest(".nokey")||!e||!(c&&Ne||r)||Z.button!==0||!Z.isPrimary)return;(pe=(De=Z.target)==null?void 0:De.setPointerCapture)==null||pe.call(De,Z.pointerId),Q.current=!1;const{x:Me,y:Te}=_n(Z.nativeEvent,q.current),Le=ws({x:Me,y:Te},me);E.setState({userSelectionRect:{width:0,height:0,startX:Le.x,startY:Le.y,x:Me,y:Te}}),Ne||(Z.stopPropagation(),Z.preventDefault())};function R(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:Ne,nodeLookup:we,edgeLookup:ye,connectionLookup:Me,triggerNodeChanges:Te,triggerEdgeChanges:Le,defaultEdgeOptions:De}=E.getState(),pe={x:me.startX,y:me.startY},{x:$e,y:Ve}=ai(pe,Ne),Ue={startX:pe.x,startY:pe.y,x:Z<$e?Z:$e,y:semt.id)),J.current=new Set;const gt=(De==null?void 0:De.selectable)??!0;for(const mt of te.current){const Mt=Me.get(mt);if(Mt)for(const{edgeId:ct}of Mt.values()){const rt=ye.get(ct);rt&&(rt.selectable??gt)&&J.current.add(ct)}}if(!$h(wt,te.current)){const mt=ei(we,te.current,!0);Te(mt)}if(!$h(Xt,J.current)){const mt=ei(ye,J.current);Le(mt)}E.setState({userSelectionRect:Ue,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=Rc(C.current,q.current,$);L({x:Z,y:se}).then(me=>{if(!Q.current||!me){b.current=requestAnimationFrame(z);return}const{x:Ne,y:we}=C.current;R(Ne,we),b.current=requestAnimationFrame(z)})}const re=()=>{cancelAnimationFrame(b.current),b.current=0,V.current=!1};A.useEffect(()=>()=>re(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:Ne}=E.getState();if(!q.current||!se)return;const{x:we,y:ye}=_n(Z.nativeEvent,q.current);C.current={x:we,y:ye};const Me=ai({x:se.startX,y:se.startY},me);if(!Q.current){const Te=r?0:u;if(Math.hypot(we-Me.x,ye-Me.y)<=Te)return;Ne(),h==null||h(Z)}Q.current=!0,V.current||(z(),V.current=!0),R(we,ye)},fe=Z=>{var se,me;if(!F){Z.target===U.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!I&&Z.target===U.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),Q.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),re())},le=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),re()},he=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:st(["react-flow__pane",{draggable:he,dragging:j,selection:e}]),onClick:F?void 0:rc(W,U),onContextMenu:rc(Y,U),onWheel:rc(M,U),onPointerEnter:F?void 0:g,onPointerMove:F?oe:x,onPointerUp:fe,onPointerCancel:F?le:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:S,ref:U,style:dl,children:[k,d.jsx(xS,{})]})}function _c({id:e,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),y=h.get(e);if(!y){p==null||p("012",Sn.error012(e));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&c)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var w;return(w=s==null?void 0:s.current)==null?void 0:w.blur()})):a([e])}function om({nodeRef:e,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ke(),[p,y]=A.useState(!1),w=A.useRef();return A.useEffect(()=>{if(!r)return w.current=s_({getStoreItems:()=>h.getState(),onNodeMouseDown:v=>{_c({id:v,store:h,nodeRef:e})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var v;(v=w.current)==null||v.destroy(),w.current=void 0}},[r,h,e]),A.useEffect(()=>{r||!e.current||!w.current||w.current.update({noDragClassName:o,handleSelector:s,domNode:e.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,e,a,c]),p}const SS=e=>r=>r.selected&&(r.draggable||e&&typeof r.draggable>"u");function im(){const e=Ke();return A.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:y,nodeOrigin:w}=e.getState(),v=new Map,g=SS(c),x=a?u[0]:5,S=a?u[1]:5,k=o.direction.x*x*o.factor,b=o.direction.y*S*o.factor;for(const[,E]of y){if(!g(E))continue;let I={x:E.internals.positionAbsolute.x+k,y:E.internals.positionAbsolute.y+b};a&&(I=xs(I,u));const{position:_,positionAbsolute:j}=Ng({nodeId:E.id,nextPosition:I,nodeLookup:y,nodeExtent:s,nodeOrigin:w,onError:h});E.position=_,E.internals.positionAbsolute=j,v.set(E.id,E)}p(v)},[])}const Fc=A.createContext(null),kS=Fc.Provider;Fc.Consumer;const sm=()=>A.useContext(Fc),NS=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),am=A.createContext(null);function bS({children:e}){const r=Fe(NS,et);return d.jsx(am.Provider,{value:r,children:e})}function jS(){const e=A.useContext(am);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const ES={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},CS=(e,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:y}=c;if(!h&&!a)return ES;const w=(p==null?void 0:p.nodeId)===e&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===e&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:w,clickConnecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===ii.Strict?(h==null?void 0:h.type)!==o:e!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:w&&y}};function MS({type:e="source",position:r=ke.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:y,onMouseDown:w,onTouchStart:v,...g},x){var V,W;const S=c||null,k=e==="target",b=Ke(),E=sm(),{connectOnClick:I,noPanClassName:_,rfId:j}=jS(),{connectingFrom:L,connectingTo:$,clickConnecting:F,isPossibleEndHandle:U,connectionInProcess:q,clickConnectionInProcess:te,valid:J}=Fe(CS(E,S,e),et);E||(W=(V=b.getState()).onError)==null||W.call(V,"010",Sn.error010());const ne=Y=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=b.getState(),R={...M,...Y};if(H){const{edges:z,setEdges:re,onError:oe}=b.getState();re(aS(R,z,{onError:oe}))}D==null||D(R),h==null||h(R)},Q=Y=>{if(!E)return;const M=Tg(Y.nativeEvent);if(a&&(M&&Y.button===0||!M)){const D=b.getState();wc.onPointerDown(Y.nativeEvent,{handleDomNode:Y.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:k,handleId:S,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var R,z;return(z=(R=b.getState()).onConnectEnd)==null?void 0:z.call(R,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var R,z;return((z=(R=b.getState()).isValidConnection)==null?void 0:z.call(R,...H))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?w==null||w(Y):v==null||v(Y)},C=Y=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:R,isValidConnection:z,lib:re,rfId:oe,nodeLookup:fe,connection:le}=b.getState();if(!E||!H&&!a)return;if(!H){M==null||M(Y.nativeEvent,{nodeId:E,handleId:S,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:E,type:e,id:S}});return}const he=Ig(Y.target),Z=o||z,{connection:se,isValid:me}=wc.isValid(Y.nativeEvent,{handle:{nodeId:E,id:S,type:e},connectionMode:R,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:he,lib:re,nodeLookup:fe});me&&se&&ne(se);const Ne=structuredClone(le);delete Ne.inProgress,Ne.toPosition=Ne.toHandle?Ne.toHandle.position:null,D==null||D(Y,Ne),b.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":S,"data-nodeid":E,"data-handlepos":r,"data-id":`${j}-${E}-${S}-${e}`,className:st(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",_,y,{source:!k,target:k,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:L,connectingto:$,valid:J,connectionindicator:s&&(!q||U)&&(q||te?u:a)}]),onMouseDown:Q,onTouchStart:Q,onClick:I?C:void 0,ref:x,...g,children:p})}const ui=A.memo(tm(MS));function PS({data:e,isConnectable:r,sourcePosition:o=ke.Bottom}){return d.jsxs(d.Fragment,{children:[e==null?void 0:e.label,d.jsx(ui,{type:"source",position:o,isConnectable:r})]})}function IS({data:e,isConnectable:r,targetPosition:o=ke.Top,sourcePosition:s=ke.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(ui,{type:"target",position:o,isConnectable:r}),e==null?void 0:e.label,d.jsx(ui,{type:"source",position:s,isConnectable:r})]})}function RS(){return null}function TS({data:e,isConnectable:r,targetPosition:o=ke.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(ui,{type:"target",position:o,isConnectable:r}),e==null?void 0:e.label]})}const qa={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},hp={input:PS,default:IS,output:TS,group:RS};function LS(e){var r,o,s,a;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((r=e.style)==null?void 0:r.width),height:e.height??e.initialHeight??((o=e.style)==null?void 0:o.height)}:{width:e.width??((s=e.style)==null?void 0:s.width),height:e.height??((a=e.style)==null?void 0:a.height)}}const AS=e=>{const{width:r,height:o,x:s,y:a}=vs(e.nodeLookup,{filter:u=>!!u.selected});return{width:wn(r)?r:null,height:wn(o)?o:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${s}px,${a}px)`}};function $S({onSelectionContextMenu:e,noPanClassName:r,disableKeyboardA11y:o}){const s=Ke(),{width:a,height:u,transformString:c,userSelectionActive:h}=Fe(AS,et),p=im(),y=A.useRef(null);A.useEffect(()=>{var x;o||(x=y.current)==null||x.focus({preventScroll:!0})},[o]);const w=!h&&a!==null&&u!==null;if(om({nodeRef:y,disabled:!w}),!w)return null;const v=e?x=>{const S=s.getState().nodes.filter(k=>k.selected);e(x,S)}:void 0,g=x=>{Object.prototype.hasOwnProperty.call(qa,x.key)&&(x.preventDefault(),p({direction:qa[x.key],factor:x.shiftKey?4:1}))};return d.jsx("div",{className:st(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:o?void 0:-1,onKeyDown:o?void 0:g,style:{width:a,height:u}})})}const pp=typeof window<"u"?window:void 0,zS=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function lm({children:e,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:y,selectionOnDrag:w,selectionMode:v,onSelectionStart:g,onSelectionEnd:x,multiSelectionKeyCode:S,panActivationKeyCode:k,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:_,panOnScroll:j,panOnScrollSpeed:L,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:U,autoPanOnSelection:q,defaultViewport:te,translateExtent:J,minZoom:ne,maxZoom:Q,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:Y,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:R,userSelectionActive:z}=Fe(zS,et),re=hs(y,{target:pp}),oe=hs(k,{target:pp}),fe=oe||U,le=oe||j,he=w&&fe!==!0,Z=re||z||he;return pS({deleteKeyCode:p,multiSelectionKeyCode:S}),d.jsx(yS,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:_,panOnScroll:le,panActivationKeyPressed:oe,panOnScrollSpeed:L,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!re&&fe,defaultViewport:te,translateExtent:J,minZoom:ne,maxZoom:Q,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:W,noPanClassName:Y,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:he,children:d.jsxs(_S,{onSelectionStart:g,onSelectionEnd:x,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:v,selectionKeyPressed:re,paneClickDistance:h,selectionOnDrag:he,children:[e,R&&d.jsx($S,{onSelectionContextMenu:V,noPanClassName:Y,disableKeyboardA11y:M})]})})}lm.displayName="FlowRenderer";const DS=A.memo(lm),OS=e=>r=>e?Ic(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function FS(e){return Fe(A.useCallback(OS(e),[e]),et)}const HS=e=>e.updateNodeInternals;function BS(){const e=Fe(HS),[r]=A.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),e(s)}));return A.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function VS({node:e,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ke(),u=A.useRef(null),c=A.useRef(null),h=A.useRef(e.sourcePosition),p=A.useRef(e.targetPosition),y=A.useRef(r),w=o&&!!e.internals.handleBounds;return A.useEffect(()=>{u.current&&!e.hidden&&(!w||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[w,e.hidden]),A.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),A.useEffect(()=>{if(u.current){const v=y.current!==r,g=h.current!==e.sourcePosition,x=p.current!==e.targetPosition;(v||g||x)&&(y.current=r,h.current=e.sourcePosition,p.current=e.targetPosition,a.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:u.current,force:!0}]])))}},[e.id,r,e.sourcePosition,e.targetPosition]),u}function WS({id:e,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:y,nodesFocusable:w,resizeObserver:v,noDragClassName:g,noPanClassName:x,disableKeyboardA11y:S,rfId:k,nodeTypes:b,nodeClickDistance:E,onError:I}){const{node:_,internals:j,isParent:L}=Fe(Z=>{const se=Z.nodeLookup.get(e),me=Z.parentLookup.has(e);return{node:se,internals:se.internals,isParent:me}},et);let $=_.type||"default",F=(b==null?void 0:b[$])||hp[$];F===void 0&&(I==null||I("003",Sn.error003($)),$="default",F=(b==null?void 0:b.default)||hp.default);const U=!!(_.draggable||h&&typeof _.draggable>"u"),q=!!(_.selectable||p&&typeof _.selectable>"u"),te=!!(_.connectable||y&&typeof _.connectable>"u"),J=!!(_.focusable||w&&typeof _.focusable>"u"),ne=Ke(),Q=Mg(_),C=VS({node:_,nodeType:$,hasDimensions:Q,resizeObserver:v}),V=om({nodeRef:C,disabled:_.hidden||!U,noDragClassName:g,handleSelector:_.dragHandle,nodeId:e,isSelectable:q,nodeClickDistance:E}),W=im();if(_.hidden)return null;const Y=Nn(_),M=LS(_),D=q||U||r||o||s||a,H=o?Z=>o(Z,{...j.userNode}):void 0,R=s?Z=>s(Z,{...j.userNode}):void 0,z=a?Z=>a(Z,{...j.userNode}):void 0,re=u?Z=>u(Z,{...j.userNode}):void 0,oe=c?Z=>c(Z,{...j.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!U||me>0)&&_c({id:e,store:ne,nodeRef:C}),r&&r(Z,{...j.userNode})},le=Z=>{if(!(Rg(Z.nativeEvent)||S)){if(xg.includes(Z.key)&&q){const se=Z.key==="Escape";_c({id:e,store:ne,unselect:se,nodeRef:C})}else if(U&&_.selected&&Object.prototype.hasOwnProperty.call(qa,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),W({direction:qa[Z.key],factor:Z.shiftKey?4:1})}}},he=()=>{var Me;if(S||!((Me=C.current)!=null&&Me.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:Ne,setCenter:we}=ne.getState();if(!Ne)return;Ic(new Map([[e,_]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||we(_.position.x+Y.width/2,_.position.y+Y.height/2,{zoom:Z[2]})};return d.jsx("div",{className:st(["react-flow__node",`react-flow__node-${$}`,{[x]:U},_.className,{selected:_.selected,selectable:q,parent:L,draggable:U,dragging:V}]),ref:C,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:Q?"visible":"hidden",..._.style,...M},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:H,onMouseMove:R,onMouseLeave:z,onContextMenu:re,onClick:fe,onDoubleClick:oe,onKeyDown:J?le:void 0,tabIndex:J?0:void 0,onFocus:J?he:void 0,role:_.ariaRole??(J?"group":void 0),"aria-roledescription":"node","aria-describedby":S?void 0:`${Qg}-${k}`,"aria-label":_.ariaLabel,..._.domAttributes,children:d.jsx(kS,{value:e,children:d.jsx(F,{id:e,data:_.data,type:$,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:_.selected??!1,selectable:q,draggable:U,deletable:_.deletable??!0,isConnectable:te,sourcePosition:_.sourcePosition,targetPosition:_.targetPosition,dragging:V,dragHandle:_.dragHandle,zIndex:j.z,parentId:_.parentId,...Y})})})}var US=A.memo(WS);const GS=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function um(e){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=Fe(GS,et),u=FS(e.onlyRenderVisibleElements),c=BS();return d.jsx("div",{className:"react-flow__nodes",style:dl,children:u.map(h=>d.jsx(US,{id:h,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:a},h))})}um.displayName="NodeRenderer";const YS=A.memo(um);function XS(e){return Fe(A.useCallback(o=>{if(!e)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&H1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[e]),et)}const qS=({color:e="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...e&&{stroke:e}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},KS=({color:e="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...e&&{stroke:e,fill:e}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},gp={[cs.Arrow]:qS,[cs.ArrowClosed]:KS};function QS(e){const r=Ke();return A.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(gp,e)?gp[e]:((u=(a=r.getState()).onError)==null||u.call(a,"009",Sn.error009(e)),null)},[e])}const ZS=({id:e,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=QS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},cm=({defaultColor:e,rfId:r})=>{const o=Fe(u=>u.edges),s=Fe(u=>u.defaultEdgeOptions),a=A.useMemo(()=>q1(o,{id:r,defaultColor:e,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,e]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(ZS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};cm.displayName="MarkerDefinitions";var JS=A.memo(cm);function dm({x:e,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:y,...w}){const[v,g]=A.useState({x:1,y:0,width:0,height:0}),x=st(["react-flow__edge-textwrapper",y]),S=A.useRef(null);return A.useEffect(()=>{if(S.current){const k=S.current.getBBox();g({x:k.x,y:k.y,width:k.width,height:k.height})}},[o]),o?d.jsxs("g",{transform:`translate(${e-v.width/2} ${r-v.height/2})`,className:x,visibility:v.width?"visible":"hidden",...w,children:[a&&d.jsx("rect",{width:v.width+2*c[0],x:-c[0],y:-c[1],height:v.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:S,style:s,children:o}),p]}):null}dm.displayName="EdgeText";const ek=A.memo(dm);function _s({path:e,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:y=20,...w}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...w,d:e,fill:"none",className:st(["react-flow__edge-path",w.className])}),y?d.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,s&&wn(r)&&wn(o)?d.jsx(ek,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function mp({pos:e,x1:r,y1:o,x2:s,y2:a}){return e===ke.Left||e===ke.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function fm({sourceX:e,sourceY:r,sourcePosition:o=ke.Bottom,targetX:s,targetY:a,targetPosition:u=ke.Top}){const[c,h]=mp({pos:o,x1:e,y1:r,x2:s,y2:a}),[p,y]=mp({pos:u,x1:s,y1:a,x2:e,y2:r}),[w,v,g,x]=Lg({sourceX:e,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:y});return[`M${e},${r} C${c},${h} ${p},${y} ${s},${a}`,w,v,g,x]}function hm(e){return A.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:y,labelShowBg:w,labelBgStyle:v,labelBgPadding:g,labelBgBorderRadius:x,style:S,markerEnd:k,markerStart:b,interactionWidth:E})=>{const[I,_,j]=fm({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),L=e.isInternal?void 0:r;return d.jsx(_s,{id:L,path:I,labelX:_,labelY:j,label:p,labelStyle:y,labelShowBg:w,labelBgStyle:v,labelBgPadding:g,labelBgBorderRadius:x,style:S,markerEnd:k,markerStart:b,interactionWidth:E})})}const tk=hm({isInternal:!1}),pm=hm({isInternal:!0});tk.displayName="SimpleBezierEdge";pm.displayName="SimpleBezierEdgeInternal";function gm(e){return A.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:w,labelBgBorderRadius:v,style:g,sourcePosition:x=ke.Bottom,targetPosition:S=ke.Top,markerEnd:k,markerStart:b,pathOptions:E,interactionWidth:I})=>{const[_,j,L]=Xa({sourceX:o,sourceY:s,sourcePosition:x,targetX:a,targetY:u,targetPosition:S,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=e.isInternal?void 0:r;return d.jsx(_s,{id:$,path:_,labelX:j,labelY:L,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:w,labelBgBorderRadius:v,style:g,markerEnd:k,markerStart:b,interactionWidth:I})})}const mm=gm({isInternal:!1}),ym=gm({isInternal:!0});mm.displayName="SmoothStepEdge";ym.displayName="SmoothStepEdgeInternal";function vm(e){return A.memo(({id:r,...o})=>{var a;const s=e.isInternal?void 0:r;return d.jsx(mm,{...o,id:s,pathOptions:A.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const nk=vm({isInternal:!1}),xm=vm({isInternal:!0});nk.displayName="StepEdge";xm.displayName="StepEdgeInternal";function wm(e){return A.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:w,labelBgBorderRadius:v,style:g,markerEnd:x,markerStart:S,interactionWidth:k})=>{const[b,E,I]=zg({sourceX:o,sourceY:s,targetX:a,targetY:u}),_=e.isInternal?void 0:r;return d.jsx(_s,{id:_,path:b,labelX:E,labelY:I,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:w,labelBgBorderRadius:v,style:g,markerEnd:x,markerStart:S,interactionWidth:k})})}const rk=wm({isInternal:!1}),_m=wm({isInternal:!0});rk.displayName="StraightEdge";_m.displayName="StraightEdgeInternal";function Sm(e){return A.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=ke.Bottom,targetPosition:h=ke.Top,label:p,labelStyle:y,labelShowBg:w,labelBgStyle:v,labelBgPadding:g,labelBgBorderRadius:x,style:S,markerEnd:k,markerStart:b,pathOptions:E,interactionWidth:I})=>{const[_,j,L]=Ag({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=e.isInternal?void 0:r;return d.jsx(_s,{id:$,path:_,labelX:j,labelY:L,label:p,labelStyle:y,labelShowBg:w,labelBgStyle:v,labelBgPadding:g,labelBgBorderRadius:x,style:S,markerEnd:k,markerStart:b,interactionWidth:I})})}const ok=Sm({isInternal:!1}),km=Sm({isInternal:!0});ok.displayName="BezierEdge";km.displayName="BezierEdgeInternal";const yp={default:km,straight:_m,step:xm,smoothstep:ym,simplebezier:pm},vp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},ik=(e,r,o)=>o===ke.Left?e-r:o===ke.Right?e+r:e,sk=(e,r,o)=>o===ke.Top?e-r:o===ke.Bottom?e+r:e,xp="react-flow__edgeupdater";function wp({position:e,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:st([xp,`${xp}-${h}`]),cx:ik(r,s,e),cy:sk(o,s,e),r:s,stroke:"transparent",fill:"transparent"})}function ak({isReconnectable:e,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:y,onReconnectStart:w,onReconnectEnd:v,setReconnecting:g,setUpdateHover:x}){const S=Ke(),k=(j,L)=>{if(j.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:U,connectionRadius:q,lib:te,onConnectStart:J,cancelConnection:ne,nodeLookup:Q,rfId:C,panBy:V,updateConnection:W}=S.getState(),Y=L.type==="target",M=(R,z)=>{g(!1),v==null||v(R,o,L.type,z)},D=R=>y==null?void 0:y(o,R),H=(R,z)=>{g(!0),w==null||w(j,o,L.type),J==null||J(R,z)};wc.onPointerDown(j.nativeEvent,{autoPanOnConnect:$,connectionMode:U,connectionRadius:q,domNode:F,handleId:L.id,nodeId:L.nodeId,nodeLookup:Q,isTarget:Y,edgeUpdaterType:L.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...R)=>{var z,re;return((re=(z=S.getState()).isValidConnection)==null?void 0:re.call(z,...R))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...R)=>{var z,re;return(re=(z=S.getState()).onConnectEnd)==null?void 0:re.call(z,...R)},onReconnectEnd:M,updateConnection:W,getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,dragThreshold:S.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},b=j=>k(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=j=>k(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),I=()=>x(!0),_=()=>x(!1);return d.jsxs(d.Fragment,{children:[(e===!0||e==="source")&&d.jsx(wp,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:I,onMouseOut:_,type:"source"}),(e===!0||e==="target")&&d.jsx(wp,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:I,onMouseOut:_,type:"target"})]})}function lk({id:e,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,reconnectRadius:w,onReconnect:v,onReconnectStart:g,onReconnectEnd:x,rfId:S,edgeTypes:k,noPanClassName:b,onError:E,disableKeyboardA11y:I}){let _=Fe(we=>we.edgeLookup.get(e));const j=Fe(we=>we.defaultEdgeOptions);_=j?{...j,..._}:_;let L=_.type||"default",$=(k==null?void 0:k[L])||yp[L];$===void 0&&(E==null||E("011",Sn.error011(L)),L="default",$=(k==null?void 0:k.default)||yp.default);const F=!!(_.focusable||r&&typeof _.focusable>"u"),U=typeof v<"u"&&(_.reconnectable||o&&typeof _.reconnectable>"u"),q=!!(_.selectable||s&&typeof _.selectable>"u"),te=A.useRef(null),[J,ne]=A.useState(!1),[Q,C]=A.useState(!1),V=Ke(),{zIndex:W=_.zIndex,sourceX:Y,sourceY:M,targetX:D,targetY:H,sourcePosition:R,targetPosition:z}=Fe(A.useCallback(we=>{const ye=we.nodeLookup.get(_.source),Me=we.nodeLookup.get(_.target);if(!ye||!Me)return vp;const Te=X1({id:e,sourceNode:ye,targetNode:Me,sourceHandle:_.sourceHandle||null,targetHandle:_.targetHandle||null,connectionMode:we.connectionMode,onError:E}),Le=F1({selected:_.selected,zIndex:_.zIndex,sourceNode:ye,targetNode:Me,elevateOnSelect:we.elevateEdgesOnSelect,zIndexMode:we.zIndexMode});return{...Te||vp,zIndex:Le}},[_.source,_.target,_.sourceHandle,_.targetHandle,_.selected,_.zIndex,E]),et),re=A.useMemo(()=>_.markerStart?`url('#${vc(_.markerStart,S)}')`:void 0,[_.markerStart,S]),oe=A.useMemo(()=>_.markerEnd?`url('#${vc(_.markerEnd,S)}')`:void 0,[_.markerEnd,S]);if(_.hidden||Y===null||M===null||D===null||H===null)return null;const fe=we=>{var Le;const{addSelectedEdges:ye,unselectNodesAndEdges:Me,multiSelectionActive:Te}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),_.selected&&Te?(Me({nodes:[],edges:[_]}),(Le=te.current)==null||Le.blur()):ye([e])),a&&a(we,_)},le=u?we=>{u(we,{..._})}:void 0,he=c?we=>{c(we,{..._})}:void 0,Z=h?we=>{h(we,{..._})}:void 0,se=p?we=>{p(we,{..._})}:void 0,me=y?we=>{y(we,{..._})}:void 0,Ne=we=>{var ye;if(!I&&xg.includes(we.key)&&q){const{unselectNodesAndEdges:Me,addSelectedEdges:Te}=V.getState();we.key==="Escape"?((ye=te.current)==null||ye.blur(),Me({edges:[_]})):Te([e])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:st(["react-flow__edge",`react-flow__edge-${L}`,_.className,b,{selected:_.selected,animated:_.animated,inactive:!q&&!a,updating:J,selectable:q}]),onClick:fe,onDoubleClick:le,onContextMenu:he,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?Ne:void 0,tabIndex:F?0:void 0,role:_.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":_.ariaLabel===null?void 0:_.ariaLabel||`Edge from ${_.source} to ${_.target}`,"aria-describedby":F?`${Zg}-${S}`:void 0,ref:te,..._.domAttributes,children:[!Q&&d.jsx($,{id:e,source:_.source,target:_.target,type:_.type,selected:_.selected,animated:_.animated,selectable:q,deletable:_.deletable??!0,label:_.label,labelStyle:_.labelStyle,labelShowBg:_.labelShowBg,labelBgStyle:_.labelBgStyle,labelBgPadding:_.labelBgPadding,labelBgBorderRadius:_.labelBgBorderRadius,sourceX:Y,sourceY:M,targetX:D,targetY:H,sourcePosition:R,targetPosition:z,data:_.data,style:_.style,sourceHandleId:_.sourceHandle,targetHandleId:_.targetHandle,markerStart:re,markerEnd:oe,pathOptions:"pathOptions"in _?_.pathOptions:void 0,interactionWidth:_.interactionWidth}),U&&d.jsx(ak,{edge:_,isReconnectable:U,reconnectRadius:w,onReconnect:v,onReconnectStart:g,onReconnectEnd:x,sourceX:Y,sourceY:M,targetX:D,targetY:H,sourcePosition:R,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var uk=A.memo(lk);const ck=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Nm({defaultMarkerColor:e,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:y,onEdgeClick:w,reconnectRadius:v,onEdgeDoubleClick:g,onReconnectStart:x,onReconnectEnd:S,disableKeyboardA11y:k}){const{edgesFocusable:b,edgesReconnectable:E,elementsSelectable:I,onError:_}=Fe(ck,et),j=XS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(JS,{defaultColor:e,rfId:o}),j.map(L=>d.jsx(uk,{id:L,edgesFocusable:b,edgesReconnectable:E,elementsSelectable:I,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,onClick:w,reconnectRadius:v,onDoubleClick:g,onReconnectStart:x,onReconnectEnd:S,rfId:o,onError:_,edgeTypes:s,disableKeyboardA11y:k},L))]})}Nm.displayName="EdgeRenderer";const dk=A.memo(Nm),_p=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function fk({children:e}){const r=Ke(),o=A.useRef(null),[s]=A.useState(()=>r.getState().transform);return nm(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=_p(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:_p(s)},children:e})}function hk(e){const r=cl(),o=A.useRef(!1);A.useEffect(()=>{!o.current&&r.viewportInitialized&&e&&(setTimeout(()=>e(r),1),o.current=!0)},[e,r.viewportInitialized])}const pk=e=>{var r;return(r=e.panZoom)==null?void 0:r.syncViewport};function gk(e){const r=Fe(pk),o=Ke();return A.useEffect(()=>{e&&(r==null||r(e),o.setState({transform:[e.x,e.y,e.zoom]}))},[e,r]),null}function mk(e){return e.connection.inProgress?{...e.connection,to:ws(e.connection.to,e.transform)}:{...e.connection}}function yk(e){return mk}function vk(e){const r=yk();return Fe(r,et)}const xk=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function wk({containerStyle:e,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=Fe(xk,et);return!(u&&a&&p)?null:d.jsx("svg",{style:e,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:st(["react-flow__connection",Sg(h)]),children:d.jsx(bm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const bm=({style:e,type:r=Or.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:y,toNode:w,toHandle:v,toPosition:g,pointer:x}=vk();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:e,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:p,toPosition:g,connectionStatus:Sg(s),toNode:w,toHandle:v,pointer:x});let S="";const k={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:y.x,targetY:y.y,targetPosition:g};switch(r){case Or.Bezier:[S]=Ag(k);break;case Or.SimpleBezier:[S]=fm(k);break;case Or.Step:[S]=Xa({...k,borderRadius:0});break;case Or.SmoothStep:[S]=Xa(k);break;default:[S]=zg(k)}return d.jsx("path",{d:S,fill:"none",className:"react-flow__connection-path",style:e})};bm.displayName="ConnectionLine";const _k={};function Sp(e=_k){A.useRef(e),Ke(),A.useEffect(()=>{},[e])}function Sk(){Ke(),A.useRef(!1),A.useEffect(()=>{},[])}function jm({nodeTypes:e,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:w,onSelectionContextMenu:v,onSelectionStart:g,onSelectionEnd:x,connectionLineType:S,connectionLineStyle:k,connectionLineComponent:b,connectionLineContainerStyle:E,selectionKeyCode:I,selectionOnDrag:_,selectionMode:j,multiSelectionKeyCode:L,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:U,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:J,translateExtent:ne,minZoom:Q,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:Y,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:R,zoomOnDoubleClick:z,panOnDrag:re,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:le,onPaneMouseMove:he,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:Ne,nodeClickDistance:we,onEdgeContextMenu:ye,onEdgeMouseEnter:Me,onEdgeMouseMove:Te,onEdgeMouseLeave:Le,reconnectRadius:De,onReconnect:pe,onReconnectStart:$e,onReconnectEnd:Ve,noDragClassName:Ue,noWheelClassName:wt,noPanClassName:Xt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Mt,viewport:ct,onViewportChange:rt,nodesDraggable:Bn}){return Sp(e),Sp(r),Sk(),hk(o),gk(ct),d.jsx(DS,{onPaneClick:fe,onPaneMouseEnter:le,onPaneMouseMove:he,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:Ne,deleteKeyCode:U,selectionKeyCode:I,selectionOnDrag:_,selectionMode:j,onSelectionStart:g,onSelectionEnd:x,multiSelectionKeyCode:L,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:Y,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:R,panOnDrag:re,autoPanOnSelection:oe,defaultViewport:J,translateExtent:ne,minZoom:Q,maxZoom:C,onSelectionContextMenu:v,preventScrolling:V,noDragClassName:Ue,noWheelClassName:wt,noPanClassName:Xt,disableKeyboardA11y:gt,onViewportChange:rt,isControlledViewport:!!ct,children:d.jsxs(fk,{children:[d.jsx(dk,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:pe,onReconnectStart:$e,onReconnectEnd:Ve,onlyRenderVisibleElements:q,onEdgeContextMenu:ye,onEdgeMouseEnter:Me,onEdgeMouseMove:Te,onEdgeMouseLeave:Le,reconnectRadius:De,defaultMarkerColor:W,noPanClassName:Xt,disableKeyboardA11y:gt,rfId:Mt}),d.jsx(wk,{style:k,type:S,component:b,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(YS,{nodeTypes:e,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:w,nodeClickDistance:we,onlyRenderVisibleElements:q,noPanClassName:Xt,noDragClassName:Ue,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Mt,nodesDraggable:Bn}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}jm.displayName="GraphView";const kk=A.memo(jm),Nk=Cg(),kp=({nodes:e,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:y=2,nodeOrigin:w,nodeExtent:v,zIndexMode:g="basic"}={})=>{const x=new Map,S=new Map,k=new Map,b=new Map,E=s??r??[],I=o??e??[],_=w??[0,0],j=v??ls;Fg(k,b,E);const{nodesInitialized:L}=xc(I,x,S,{nodeOrigin:_,nodeExtent:j,zIndexMode:g});let $=[0,0,1];if(c&&a&&u){const F=vs(x,{filter:J=>!!((J.width||J.initialWidth)&&(J.height||J.initialHeight))}),{x:U,y:q,zoom:te}=Tc(F,a,u,p,y,(h==null?void 0:h.padding)??.1);$=[U,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:I,nodesInitialized:L,nodeLookup:x,parentLookup:S,edges:E,edgeLookup:b,connectionLookup:k,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:y,translateExtent:ls,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ii.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:_,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{..._g},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Nk,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:wg,zIndexMode:g,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},bk=({nodes:e,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:w,nodeExtent:v,zIndexMode:g})=>z_((x,S)=>{async function k(){const{nodeLookup:b,panZoom:E,fitViewOptions:I,fitViewResolver:_,width:j,height:L,minZoom:$,maxZoom:F}=S();E&&(await T1({nodes:b,width:j,height:L,panZoom:E,minZoom:$,maxZoom:F},I),_==null||_.resolve(!0),x({fitViewResolver:null}))}return{...kp({nodes:e,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:w,nodeExtent:v,defaultNodes:o,defaultEdges:s,zIndexMode:g}),setNodes:b=>{const{nodeLookup:E,parentLookup:I,nodeOrigin:_,nodeExtent:j,elevateNodesOnSelect:L,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:U}=S(),{nodesInitialized:q,hasSelectedNodes:te}=xc(b,E,I,{nodeOrigin:_,nodeExtent:j,elevateNodesOnSelect:L,checkEquality:!0,zIndexMode:F}),J=U&&te;$&&q?(k(),x({nodes:b,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:J})):x({nodes:b,nodesInitialized:q,nodesSelectionActive:J})},setEdges:b=>{const{connectionLookup:E,edgeLookup:I}=S();Fg(E,I,b),x({edges:b})},setDefaultNodesAndEdges:(b,E)=>{if(b){const{setNodes:I}=S();I(b),x({hasDefaultNodes:!0})}if(E){const{setEdges:I}=S();I(E),x({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:E,nodeLookup:I,parentLookup:_,domNode:j,nodeOrigin:L,nodeExtent:$,debug:F,fitViewQueued:U,zIndexMode:q}=S(),{changes:te,updatedInternals:J}=n_(b,I,_,j,L,$,q);J&&(Z1(I,_,{nodeOrigin:L,nodeExtent:$,zIndexMode:q}),U?(k(),x({fitViewQueued:!1,fitViewOptions:void 0})):x({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(b,E=!1)=>{const I=[];let _=[];const{nodeLookup:j,triggerNodeChanges:L,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:U}=S();for(const[q,te]of b){const J=j.get(q),ne=!!(J!=null&&J.expandParent&&(J!=null&&J.parentId)&&(te!=null&&te.position)),Q={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(J&&$.inProgress&&$.fromNode.id===J.id){const C=wo(J,$.fromHandle,ke.Left,!0);F({...$,from:C})}ne&&J.parentId&&I.push({id:q,parentId:J.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),_.push(Q)}if(I.length>0){const{parentLookup:q,nodeOrigin:te}=S(),J=Oc(I,j,q,te);_.push(...J)}for(const q of U.values())_=q(_);L(_)},triggerNodeChanges:b=>{const{onNodesChange:E,setNodes:I,nodes:_,hasDefaultNodes:j,debug:L}=S();if(b!=null&&b.length){if(j){const $=oS(b,_);I($)}L&&console.log("React Flow: trigger node changes",b),E==null||E(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:E,setEdges:I,edges:_,hasDefaultEdges:j,debug:L}=S();if(b!=null&&b.length){if(j){const $=iS(b,_);I($)}L&&console.log("React Flow: trigger edge changes",b),E==null||E(b)}},addSelectedNodes:b=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:_,triggerNodeChanges:j,triggerEdgeChanges:L}=S();if(E){const $=b.map(F=>co(F,!0));j($);return}j(ei(_,new Set([...b]),!0)),L(ei(I))},addSelectedEdges:b=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:_,triggerNodeChanges:j,triggerEdgeChanges:L}=S();if(E){const $=b.map(F=>co(F,!0));L($);return}L(ei(I,new Set([...b]))),j(ei(_,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:E}={})=>{const{edges:I,nodes:_,nodeLookup:j,triggerNodeChanges:L,triggerEdgeChanges:$}=S(),F=b||_,U=E||I,q=[];for(const J of F){if(!J.selected)continue;const ne=j.get(J.id);ne&&(ne.selected=!1),q.push(co(J.id,!1))}const te=[];for(const J of U)J.selected&&te.push(co(J.id,!1));L(q),$(te)},setMinZoom:b=>{const{panZoom:E,maxZoom:I}=S();E==null||E.setScaleExtent([b,I]),x({minZoom:b})},setMaxZoom:b=>{const{panZoom:E,minZoom:I}=S();E==null||E.setScaleExtent([I,b]),x({maxZoom:b})},setTranslateExtent:b=>{var E;(E=S().panZoom)==null||E.setTranslateExtent(b),x({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:E,triggerNodeChanges:I,triggerEdgeChanges:_,elementsSelectable:j}=S();if(!j)return;const L=E.reduce((F,U)=>U.selected?[...F,co(U.id,!1)]:F,[]),$=b.reduce((F,U)=>U.selected?[...F,co(U.id,!1)]:F,[]);I(L),_($)},setNodeExtent:b=>{const{nodes:E,nodeLookup:I,parentLookup:_,nodeOrigin:j,elevateNodesOnSelect:L,nodeExtent:$,zIndexMode:F}=S();b[0][0]===$[0][0]&&b[0][1]===$[0][1]&&b[1][0]===$[1][0]&&b[1][1]===$[1][1]||(xc(E,I,_,{nodeOrigin:j,nodeExtent:b,elevateNodesOnSelect:L,checkEquality:!1,zIndexMode:F}),x({nodeExtent:b}))},panBy:b=>{const{transform:E,width:I,height:_,panZoom:j,translateExtent:L}=S();return r_({delta:b,panZoom:j,transform:E,translateExtent:L,width:I,height:_})},setCenter:async(b,E,I)=>{const{width:_,height:j,maxZoom:L,panZoom:$}=S();if(!$)return!1;const F=typeof(I==null?void 0:I.zoom)<"u"?I.zoom:L;return await $.setViewport({x:_/2-b*F,y:j/2-E*F,zoom:F},{duration:I==null?void 0:I.duration,ease:I==null?void 0:I.ease,interpolate:I==null?void 0:I.interpolate}),!0},cancelConnection:()=>{x({connection:{..._g}})},updateConnection:b=>{x({connection:b})},reset:()=>x({...kp()})}},Object.is);function Em({initialNodes:e,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:y,nodeOrigin:w,nodeExtent:v,zIndexMode:g,children:x}){const[S]=A.useState(()=>bk({nodes:e,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:y,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:w,nodeExtent:v,zIndexMode:g}));return d.jsx(D_,{value:S,children:d.jsx(cS,{children:d.jsx(bS,{children:x})})})}function jk({children:e,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:y,maxZoom:w,nodeOrigin:v,nodeExtent:g,zIndexMode:x}){return A.useContext(ll)?d.jsx(d.Fragment,{children:e}):d.jsx(Em,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:y,initialMaxZoom:w,nodeOrigin:v,nodeExtent:g,zIndexMode:x,children:e})}const Ek={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Ck({nodes:e,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:y,onMove:w,onMoveStart:v,onMoveEnd:g,onConnect:x,onConnectStart:S,onConnectEnd:k,onClickConnectStart:b,onClickConnectEnd:E,onNodeMouseEnter:I,onNodeMouseMove:_,onNodeMouseLeave:j,onNodeContextMenu:L,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:U,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:J,onDelete:ne,onSelectionChange:Q,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:Y,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:R,connectionLineType:z=Or.Bezier,connectionLineStyle:re,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:le="Backspace",selectionKeyCode:he="Shift",selectionOnDrag:Z=!1,selectionMode:se=us.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:Ne=fs()?"Meta":"Control",zoomActivationKeyCode:we=fs()?"Meta":"Control",snapToGrid:ye,snapGrid:Me,onlyRenderVisibleElements:Te=!1,selectNodesOnDrag:Le,nodesDraggable:De,autoPanOnNodeFocus:pe,nodesConnectable:$e,nodesFocusable:Ve,nodeOrigin:Ue=Jg,edgesFocusable:wt,edgesReconnectable:Xt,elementsSelectable:gt=!0,defaultViewport:mt=Q_,minZoom:Mt=.5,maxZoom:ct=2,translateExtent:rt=ls,preventScrolling:Bn=!0,nodeExtent:Pt,defaultMarkerColor:bn="#b1b1b7",zoomOnScroll:di=!0,zoomOnPinch:Vn=!0,panOnScroll:So=!1,panOnScrollSpeed:dr=.5,panOnScrollMode:Br=po.Free,zoomOnDoubleClick:Wn=!0,panOnDrag:Vr=!0,onPaneClick:fr,onPaneMouseEnter:hr,onPaneMouseMove:Ht,onPaneMouseLeave:dt,onPaneScroll:Un,onPaneContextMenu:Gn,paneClickDistance:jn=1,nodeClickDistance:Yn=0,children:En,onReconnect:at,onReconnectStart:pr,onReconnectEnd:Cn,onEdgeContextMenu:It,onEdgeDoubleClick:on,onEdgeMouseEnter:ko,onEdgeMouseMove:tt,onEdgeMouseLeave:We,reconnectRadius:Mn=10,onNodesChange:Xn,onEdgesChange:sn,noDragClassName:Wr="nodrag",noWheelClassName:an="nowheel",noPanClassName:Rt="nopan",fitView:qt,fitViewOptions:qn,connectOnClick:No,attributionPosition:bo,proOptions:Tt,defaultEdgeOptions:Kn,elevateNodesOnSelect:Ur=!0,elevateEdgesOnSelect:Qn=!1,disableKeyboardA11y:gr=!1,autoPanOnConnect:Ye,autoPanOnNodeDrag:fi,autoPanOnSelection:Gr=!0,autoPanSpeed:jo,connectionRadius:mr,isValidConnection:hi,onError:Eo,style:Pn,id:_t,nodeDragThreshold:pi,connectionDragThreshold:yt,viewport:gi,onViewportChange:mi,width:Yr,height:In,colorMode:Zn="light",debug:Rn,onScroll:Kt,ariaLabelConfig:Xr,zIndexMode:qr="basic",...yr},Kr){const ln=_t||"1",Jn=tS(Zn),Co=A.useCallback(vr=>{vr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Kt==null||Kt(vr)},[Kt]);return d.jsx("div",{"data-testid":"rf__wrapper",...yr,onScroll:Co,style:{...Pn,...Ek},ref:Kr,className:st(["react-flow",a,Jn]),id:_t,role:"application",children:d.jsxs(jk,{nodes:e,edges:r,width:Yr,height:In,fitView:qt,fitViewOptions:qn,minZoom:Mt,maxZoom:ct,nodeOrigin:Ue,nodeExtent:Pt,zIndexMode:qr,children:[d.jsx(eS,{nodes:e,edges:r,defaultNodes:o,defaultEdges:s,onConnect:x,onConnectStart:S,onConnectEnd:k,onClickConnectStart:b,onClickConnectEnd:E,nodesDraggable:De,autoPanOnNodeFocus:pe,nodesConnectable:$e,nodesFocusable:Ve,edgesFocusable:wt,edgesReconnectable:Xt,elementsSelectable:gt,elevateNodesOnSelect:Ur,elevateEdgesOnSelect:Qn,minZoom:Mt,maxZoom:ct,nodeExtent:Pt,onNodesChange:Xn,onEdgesChange:sn,snapToGrid:ye,snapGrid:Me,connectionMode:R,translateExtent:rt,connectOnClick:No,defaultEdgeOptions:Kn,fitView:qt,fitViewOptions:qn,onNodesDelete:te,onEdgesDelete:J,onDelete:ne,onNodeDragStart:F,onNodeDrag:U,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:w,onMoveStart:v,onMoveEnd:g,noPanClassName:Rt,nodeOrigin:Ue,rfId:ln,autoPanOnConnect:Ye,autoPanOnNodeDrag:fi,autoPanSpeed:jo,onError:Eo,connectionRadius:mr,isValidConnection:hi,selectNodesOnDrag:Le,nodeDragThreshold:pi,connectionDragThreshold:yt,onBeforeDelete:H,debug:Rn,ariaLabelConfig:Xr,zIndexMode:qr}),d.jsx(kk,{onInit:y,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:I,onNodeMouseMove:_,onNodeMouseLeave:j,onNodeContextMenu:L,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:re,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:he,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:le,multiSelectionKeyCode:Ne,panActivationKeyCode:me,zoomActivationKeyCode:we,onlyRenderVisibleElements:Te,defaultViewport:mt,translateExtent:rt,minZoom:Mt,maxZoom:ct,preventScrolling:Bn,zoomOnScroll:di,zoomOnPinch:Vn,zoomOnDoubleClick:Wn,panOnScroll:So,panOnScrollSpeed:dr,panOnScrollMode:Br,panOnDrag:Vr,autoPanOnSelection:Gr,onPaneClick:fr,onPaneMouseEnter:hr,onPaneMouseMove:Ht,onPaneMouseLeave:dt,onPaneScroll:Un,onPaneContextMenu:Gn,paneClickDistance:jn,nodeClickDistance:Yn,onSelectionContextMenu:Y,onSelectionStart:M,onSelectionEnd:D,onReconnect:at,onReconnectStart:pr,onReconnectEnd:Cn,onEdgeContextMenu:It,onEdgeDoubleClick:on,onEdgeMouseEnter:ko,onEdgeMouseMove:tt,onEdgeMouseLeave:We,reconnectRadius:Mn,defaultMarkerColor:bn,noDragClassName:Wr,noWheelClassName:an,noPanClassName:Rt,rfId:ln,disableKeyboardA11y:gr,nodeExtent:Pt,viewport:gi,onViewportChange:mi,nodesDraggable:De}),d.jsx(K_,{onSelectionChange:Q}),En,d.jsx(U_,{proOptions:Tt,position:bo}),d.jsx(W_,{rfId:ln,disableKeyboardA11y:gr})]})})}var Mk=tm(Ck);function Pk({dimensions:e,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:st(["react-flow__background-pattern",o,s])})}function Ik({radius:e,className:r}){return d.jsx("circle",{cx:e,cy:e,r:e,className:st(["react-flow__background-pattern","dots",r])})}var Fr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Fr||(Fr={}));const Rk={[Fr.Dots]:1,[Fr.Lines]:1,[Fr.Cross]:6},Tk=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Cm({id:e,variant:r=Fr.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:y,patternClassName:w}){const v=A.useRef(null),{transform:g,patternId:x}=Fe(Tk,et),S=s||Rk[r],k=r===Fr.Dots,b=r===Fr.Cross,E=Array.isArray(o)?o:[o,o],I=[E[0]*g[2]||1,E[1]*g[2]||1],_=S*g[2],j=Array.isArray(u)?u:[u,u],L=b?[_,_]:I,$=[j[0]*g[2]+L[0]/2,j[1]*g[2]+L[1]/2],F=`${x}${e||""}`;return d.jsxs("svg",{className:st(["react-flow__background",y]),style:{...p,...dl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:v,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:g[0]%I[0],y:g[1]%I[1],width:I[0],height:I[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:k?d.jsx(Ik,{radius:_/2,className:w}):d.jsx(Pk,{dimensions:L,lineWidth:a,variant:r,className:w})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}Cm.displayName="Background";const Lk=A.memo(Cm);function Ak(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function $k(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function zk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function Dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Ok(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Ia({children:e,className:r,...o}){return d.jsx("button",{type:"button",className:st(["react-flow__controls-button",r]),...o,children:e})}const Fk=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Mm({style:e,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:y,children:w,position:v="bottom-left",orientation:g="vertical","aria-label":x}){const S=Ke(),{isInteractive:k,minZoomReached:b,maxZoomReached:E,ariaLabelConfig:I}=Fe(Fk,et),{zoomIn:_,zoomOut:j,fitView:L}=cl(),$=()=>{_(),u==null||u()},F=()=>{j(),c==null||c()},U=()=>{L(a),h==null||h()},q=()=>{S.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),p==null||p(!k)},te=g==="horizontal"?"horizontal":"vertical";return d.jsxs(ul,{className:st(["react-flow__controls",te,y]),position:v,style:e,"data-testid":"rf__controls","aria-label":x??I["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(Ia,{onClick:$,className:"react-flow__controls-zoomin",title:I["controls.zoomIn.ariaLabel"],"aria-label":I["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(Ak,{})}),d.jsx(Ia,{onClick:F,className:"react-flow__controls-zoomout",title:I["controls.zoomOut.ariaLabel"],"aria-label":I["controls.zoomOut.ariaLabel"],disabled:b,children:d.jsx($k,{})})]}),o&&d.jsx(Ia,{className:"react-flow__controls-fitview",onClick:U,title:I["controls.fitView.ariaLabel"],"aria-label":I["controls.fitView.ariaLabel"],children:d.jsx(zk,{})}),s&&d.jsx(Ia,{className:"react-flow__controls-interactive",onClick:q,title:I["controls.interactive.ariaLabel"],"aria-label":I["controls.interactive.ariaLabel"],children:k?d.jsx(Ok,{}):d.jsx(Dk,{})}),w]})}Mm.displayName="Controls";const Hk=A.memo(Mm);function Bk({id:e,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:y,borderRadius:w,shapeRendering:v,selected:g,onClick:x}){const{background:S,backgroundColor:k}=u||{},b=c||S||k;return d.jsx("rect",{className:st(["react-flow__minimap-node",{selected:g},y]),x:r,y:o,rx:w,ry:w,width:s,height:a,style:{fill:b,stroke:h,strokeWidth:p},shapeRendering:v,onClick:x?E=>x(E,e):void 0})}const Vk=A.memo(Bk),Wk=e=>e.nodes.map(r=>r.id),oc=e=>e instanceof Function?e:()=>e;function Uk({nodeStrokeColor:e,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=Vk,onClick:c}){const h=Fe(Wk,et),p=oc(r),y=oc(e),w=oc(o),v=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(g=>d.jsx(Yk,{id:g,nodeColorFunc:p,nodeStrokeColorFunc:y,nodeClassNameFunc:w,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:v},g))})}function Gk({id:e,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:y,x:w,y:v,width:g,height:x}=Fe(S=>{const k=S.nodeLookup.get(e);if(!k)return{node:void 0,x:0,y:0,width:0,height:0};const b=k.internals.userNode,{x:E,y:I}=k.internals.positionAbsolute,{width:_,height:j}=Nn(b);return{node:b,x:E,y:I,width:_,height:j}},et);return!y||y.hidden||!Mg(y)?null:d.jsx(h,{x:w,y:v,width:g,height:x,style:y.style,selected:!!y.selected,className:s(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:c,onClick:p,id:y.id})}const Yk=A.memo(Gk);var Xk=A.memo(Uk);const qk=200,Kk=150,Qk=e=>!e.hidden,Zk=e=>{const r={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:r,boundingRect:e.nodeLookup.size>0?jg(vs(e.nodeLookup,{filter:Qk}),r):r,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Np=(e,r)=>e.x===r.x&&e.y===r.y&&e.width===r.width&&e.height===r.height,Jk=(e,r)=>Np(e.viewBB,r.viewBB)&&Np(e.boundingRect,r.boundingRect)&&e.rfId===r.rfId&&e.panZoom===r.panZoom&&e.translateExtent===r.translateExtent&&e.flowWidth===r.flowWidth&&e.flowHeight===r.flowHeight&&e.ariaLabelConfig===r.ariaLabelConfig,eN="react-flow__minimap-desc";function Pm({style:e,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:y,maskStrokeColor:w,maskStrokeWidth:v,position:g="bottom-right",onClick:x,onNodeClick:S,pannable:k=!1,zoomable:b=!1,ariaLabel:E,inversePan:I,zoomStep:_=1,offsetScale:j=5}){const L=Ke(),$=A.useRef(null),{boundingRect:F,viewBB:U,rfId:q,panZoom:te,translateExtent:J,flowWidth:ne,flowHeight:Q,ariaLabelConfig:C}=Fe(Zk,Jk),V=(e==null?void 0:e.width)??qk,W=(e==null?void 0:e.height)??Kk,Y=F.width/V,M=F.height/W,D=Math.max(Y,M),H=D*V,R=D*W,z=j*D,re=F.x-(H-F.width)/2-z,oe=F.y-(R-F.height)/2-z,fe=H+z*2,le=R+z*2,he=`${eN}-${q}`,Z=A.useRef(0),se=A.useRef();Z.current=D,A.useEffect(()=>{if($.current&&te)return se.current=f_({domNode:$.current,panZoom:te,getTransform:()=>L.getState().transform,getViewScale:()=>Z.current}),()=>{var ye;(ye=se.current)==null||ye.destroy()}},[te]),A.useEffect(()=>{var ye;(ye=se.current)==null||ye.update({translateExtent:J,width:ne,height:Q,inversePan:I,pannable:k,zoomStep:_,zoomable:b})},[k,b,I,_,J,ne,Q]);const me=x?ye=>{var Le;const[Me,Te]=((Le=se.current)==null?void 0:Le.pointer(ye))||[0,0];x(ye,{x:Me,y:Te})}:void 0,Ne=S?A.useCallback((ye,Me)=>{const Te=L.getState().nodeLookup.get(Me).internals.userNode;S(ye,Te)},[]):void 0,we=E??C["minimap.ariaLabel"];return d.jsx(ul,{position:g,style:{...e,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof w=="string"?w:void 0,"--xy-minimap-mask-stroke-width-props":typeof v=="number"?v*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:st(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${re} ${oe} ${fe} ${le}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":he,ref:$,onClick:me,children:[we&&d.jsx("title",{id:he,children:we}),d.jsx(Xk,{onClick:Ne,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${re-z},${oe-z}h${fe+z*2}v${le+z*2}h${-fe-z*2}z + M${U.x},${U.y}h${U.width}v${U.height}h${-U.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Pm.displayName="MiniMap";const tN=A.memo(Pm),nN=e=>r=>e?`${Math.max(1/r.transform[2],1)}`:void 0,rN={[li.Line]:"right",[li.Handle]:"bottom-right"};function oN({nodeId:e,position:r,variant:o=li.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:y=Number.MAX_VALUE,maxHeight:w=Number.MAX_VALUE,keepAspectRatio:v=!1,resizeDirection:g,autoScale:x=!0,shouldResize:S,onResizeStart:k,onResize:b,onResizeEnd:E}){const I=sm(),_=typeof e=="string"?e:I,j=Ke(),L=A.useRef(null),$=o===li.Handle,F=Fe(A.useCallback(nN($&&x),[$,x]),et),U=A.useRef(null),q=r??rN[o];A.useEffect(()=>{if(!(!L.current||!_))return U.current||(U.current=b_({domNode:L.current,nodeId:_,getStoreItems:()=>{const{nodeLookup:J,transform:ne,snapGrid:Q,snapToGrid:C,nodeOrigin:V,domNode:W}=j.getState();return{nodeLookup:J,transform:ne,snapGrid:Q,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(J,ne)=>{const{triggerNodeChanges:Q,nodeLookup:C,parentLookup:V,nodeOrigin:W}=j.getState(),Y=[],M={x:J.x,y:J.y},D=C.get(_);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,R=J.width??D.measured.width??0,z=J.height??D.measured.height??0,re={id:D.id,parentId:D.parentId,rect:{width:R,height:z,...Pg({x:J.x??D.position.x,y:J.y??D.position.y},{width:R,height:z},D.parentId,C,H)}},oe=Oc([re],C,V,W);Y.push(...oe),M.x=J.x?Math.max(H[0]*R,J.x):void 0,M.y=J.y?Math.max(H[1]*z,J.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:_,type:"position",position:{...M}};Y.push(H)}if(J.width!==void 0&&J.height!==void 0){const R={id:_,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:J.width,height:J.height}};Y.push(R)}for(const H of ne){const R={...H,type:"position"};Y.push(R)}Q(Y)},onEnd:({width:J,height:ne})=>{const Q={id:_,type:"dimensions",resizing:!1,dimensions:{width:J,height:ne}};j.getState().triggerNodeChanges([Q])}})),U.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:y,maxHeight:w},keepAspectRatio:v,resizeDirection:g,onResizeStart:k,onResize:b,onResizeEnd:E,shouldResize:S}),()=>{var J;(J=U.current)==null||J.destroy()}},[q,h,p,y,w,v,k,b,E,S]);const te=q.split("-");return d.jsx("div",{className:st(["react-flow__resize-control","nodrag",...te,o,s]),ref:L,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}A.memo(oN);const iN={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"react.server_action":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function On(e){return iN[e]??8}const jt=208,Fn=64,Hr=88,fl=28,sN=8;function aN(e){if(!e.length)return Number.NaN;const r=[...e].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function Im(e,r=[]){const o=new Map;if(!e.length)return o;const s=new Map;for(const _ of e){const j=On(_.type),L=s.get(j)??[];L.push(_),s.set(j,L)}const u=[...s.keys()].sort((_,j)=>_-j).map(_=>[...s.get(_)??[]].sort((j,L)=>j.name.localeCompare(L.name)||j.id.localeCompare(L.id))),c=new Set(e.map(_=>_.id)),h=new Map,p=new Map;for(const _ of e)h.set(_.id,[]),p.set(_.id,[]);for(const _ of r)!c.has(_.src)||!c.has(_.dst)||_.src===_.dst||(p.get(_.src).push(_.dst),h.get(_.dst).push(_.src));const y=new Map;u.forEach((_,j)=>{for(const L of _)y.set(L.id,j)});const w=new Map,v=()=>{for(const _ of u)_.forEach((j,L)=>w.set(j.id,L))};v();const g=(_,j)=>{const L=_.map(($,F)=>{const U=j($.id).map(te=>w.get(te)).filter(te=>te!==void 0),q=aN(U);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return L.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),L.map($=>$.n)},x=_=>j=>y.get(j)===_;for(let _=0;_(h.get(L)??[]).filter(x(j-1))),v();for(let j=u.length-2;j>=0;j--)u[j]=g(u[j],L=>(p.get(L)??[]).filter(x(j+1))),v()}const S=jt+Hr,k=Fn+fl,b=Math.max(...u.map(_=>_.length),1),E=[];let I=0;for(let _=0;_U.id)),L=new Set((u[_+1]??[]).map(U=>U.id));let $=0;if(L.size)for(const U of r)j.has(U.src)&&L.has(U.dst)&&($+=1);const F=Math.min(120,Math.max(0,($-2)*12));I+=S+F}return u.forEach((_,j)=>{const L=(b-_.length)*k/2;_.forEach(($,F)=>{o.set($.id,{x:E[j]??0,y:L+F*k})})}),o}const Sc=[{id:"layers",label:"Architecture layers"},{id:"flow",label:"Edge flow"},{id:"tree",label:"Spanning tree"},{id:"radial",label:"Radial"},{id:"concentric",label:"Concentric layers"},{id:"circle",label:"Circle"},{id:"clusters",label:"Type clusters"},{id:"grid",label:"Compact grid"},{id:"force",label:"Force directed"}],lN=new Set(Sc.map(e=>e.id)),Rm="loadpath.graphLayout",uN=8,cN=64,dN=jt+32,go=jt+Hr,Ka=Fn+fl,Tm=new Set(["django.route","react.route","react.page","react.server_action","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),Lm=90;function fN(e=()=>document.createElement("canvas")){var r;try{const o=e(),s=o.getContext("webgl2")||o.getContext("webgl")||o.getContext("experimental-webgl");if(!s)return!1;const a=(r=s.getExtension)==null?void 0:r.call(s,"WEBGL_lose_context");return a==null||a.loseContext(),!0}catch{return!1}}function hN(e,r,o){return e==="3d"&&r==null&&o!==!0?"2d":e}const Am=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),bp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.server_action":"#e76f51","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},pN=160,gN=.42,mN=100,jp=.45,yN=.8,$m={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function zm(e){return e.startsWith("react.")?"react":e.startsWith("openapi.")||e.startsWith("graphql.")||e.startsWith("fastapi.")?"stitch":e.startsWith("arch.")?"arch":"django"}function Ob(e){return bp[e]?bp[e]:e.startsWith("react.")?"#9d4edd":e.startsWith("openapi.")?"#00bbf9":"#4a5568"}function vN(e,r=typeof navigator<"u"&&!!navigator.webdriver){return r?"2d":e>=Lm?"3d":"2d"}function xN(e){return e>=Lm?"overview":"full"}function wN(e,r,o=1){const s=new Set([e]);let a=new Set([e]);for(let u=0;uo.families.has(zm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Am.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?wN(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function SN(e,r){const o=r.trim().toLowerCase();return o?e.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function kN(e,r,o,s){const a=new Set(e.map(k=>k.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const k of r){if(!a.has(k.src)||!a.has(k.dst))continue;const b=u.get(k.src)??[];b.push({dst:k.dst,id:k.id}),u.set(k.src,b);const E=c.get(k.dst)??[];E.push({src:k.src,id:k.id}),c.set(k.dst,E)}const h=new Set(e.filter(k=>Tm.has(k.type)).map(k=>k.id)),p=h.size?h:a,y=new Set,w=[o];for(;w.length;){const k=w.pop();if(!y.has(k)){y.add(k);for(const b of u.get(k)??[])y.has(b.dst)||w.push(b.dst)}}const v=new Set([o]),g=[...p].filter(k=>y.has(k)),x=new Set(g);for(;g.length;){const k=g.pop();v.add(k);for(const b of c.get(k)??[])y.has(b.src)&&!x.has(b.src)&&(x.add(b.src),g.push(b.src))}const S=new Set;for(const k of r)v.has(k.src)&&v.has(k.dst)&&S.add(k.id);return{nodeIds:v,edgeIds:S}}const Ep=16,NN=28;function Cp(e){return(e.context||"").trim()}function Fb(e){return e.confidence!g&&x?1:g&&!x?-1:g.localeCompare(x));const h=new Map(u.map((g,x)=>[g,x])),p=(u.length-1)/2,y=Om(o),w=[...new Set([...s.values()].map(g=>g.x))].sort((g,x)=>g-x),v=new Map(w.map((g,x)=>[g,x]));for(const g of e){const x=s.get(g.id)??{x:0,y:0},k=((h.get(Cp(g))??0)-p)*mN;if(y){const b=v.get(x.x)??0;a.set(g.id,{x:b*pN,y:-x.y*gN,z:k})}else a.set(g.id,{x:x.x*jp,y:-x.y*jp,z:k})}return a}function jN(e){return e==="layers"||e==="flow"?"slab":e==="radial"||e==="concentric"||e==="circle"?"ring":"none"}function Bb(e,r,o="layers"){var u;if(!e.length)return[];const s=jN(o);if(s==="none")return[];if(s==="ring")return CN(e,r);const a=new Map;for(const c of e){const h=Math.round((((u=r.get(c.id))==null?void 0:u.x)??0)*10)/10,p=a.get(h)??[];p.push(c),a.set(h,p)}return[...a.entries()].sort((c,h)=>c[0]-h[0]).map(([,c])=>EN(c,r,o))}function Dm(e,r){const o=new Map;for(const u of e){const c=On(u.type);o.set(c,(o.get(c)||0)+1)}let s=-1,a=0;for(const[u,c]of o)c>a&&(s=u,a=c);return r==="flow"&&as[0]-a[0]).map(([,s])=>{let a=0,u=0;for(const h of s){const p=r.get(h.id)??{x:0,y:0,z:0};a+=Math.hypot(p.x,p.y),u+=p.z}const c=a/s.length;return{shape:"ring",x:0,y:0,z:u/s.length,extentY:0,extentZ:0,radius:c,label:c<12?"":Dm(s,"radial"),count:s.length}}).filter(s=>s.radius>=12)}function MN(){try{if(typeof localStorage>"u")return"layers";const e=localStorage.getItem(Rm);return e&&lN.has(e)?e:"layers"}catch{return"layers"}}function PN(e){try{if(typeof localStorage>"u")return;localStorage.setItem(Rm,e)}catch{}}function Om(e){return e==="layers"||e==="flow"}function IN(e){if(!e.length)return Number.NaN;const r=[...e].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function rn(e,r){return e.name.localeCompare(r.name)||e.id.localeCompare(r.id)}function Fm(e,r){return On(e.type)-On(r.type)||rn(e,r)}function Hc(e,r,o){e.forEach((s,a)=>{const u=-Math.PI/2+2*Math.PI*a/Math.max(e.length,1);o.set(s.id,{x:Math.cos(u)*r,y:Math.sin(u)*r})})}function Bc(e,r){return Math.max(r*go,e<=1?r===0?0:jt:e*dN/(2*Math.PI))}function RN(e,r){const o=new Map;if(!e.length)return o;const s=new Set(e.flat().map(S=>S.id)),a=new Map,u=new Map;for(const S of e.flat())a.set(S.id,[]),u.set(S.id,[]);for(const S of r)!s.has(S.src)||!s.has(S.dst)||S.src===S.dst||(u.get(S.src).push(S.dst),a.get(S.dst).push(S.src));const c=new Map;e.forEach((S,k)=>{for(const b of S)c.set(b.id,k)});const h=new Map,p=()=>{for(const S of e)S.forEach((k,b)=>h.set(k.id,b))};p();const y=(S,k)=>{const b=S.map((E,I)=>{const _=k(E.id).map(L=>h.get(L)).filter(L=>L!==void 0),j=IN(_);return{n:E,bary:Number.isNaN(j)?I:j,name:E.name,id:E.id}});return b.sort((E,I)=>E.bary-I.bary||E.name.localeCompare(I.name)||E.id.localeCompare(I.id)),b.map(E=>E.n)},w=S=>k=>c.get(k)===S;for(let S=0;S(a.get(b)??[]).filter(w(k-1))),p();for(let k=e.length-2;k>=0;k--)e[k]=y(e[k],b=>(u.get(b)??[]).filter(w(k+1))),p()}const v=jt+Hr,g=Fn+fl,x=Math.max(...e.map(S=>S.length),1);return e.forEach((S,k)=>{const b=(x-S.length)*g/2;S.forEach((E,I)=>{o.set(E.id,{x:k*v,y:b+I*g})})}),o}function TN(e,r){const o=new Set(e.map(h=>h.id)),s=Math.max(e.length-1,0),a=new Map;for(const h of e)a.set(h.id,0);for(let h=0;h(a.get(y.dst)||0)&&(a.set(y.dst,w),p=!0)}if(!p)break}const u=new Map;for(const h of e){const p=a.get(h.id)||0,y=u.get(p)??[];y.push(h),u.set(p,y)}const c=[...u.keys()].sort((h,p)=>h-p).map(h=>(u.get(h)??[]).sort(rn));return RN(c,r)}function LN(e,r){const o=new Map;if(!e.length)return o;const s=new Set(e.map(g=>g.id)),a=new Map,u=new Map;for(const g of e)a.set(g.id,[]),u.set(g.id,0);for(const g of r)!s.has(g.src)||!s.has(g.dst)||g.src===g.dst||(a.get(g.src).push(g.dst),a.get(g.dst).push(g.src),u.set(g.src,(u.get(g.src)||0)+1),u.set(g.dst,(u.get(g.dst)||0)+1));const c=[...e].sort((g,x)=>(u.get(x.id)||0)-(u.get(g.id)||0)||rn(g,x))[0]??e[0],h=new Map,p=[[c]];h.set(c.id,0);const y=[c];for(;y.length;){const g=y.shift(),x=h.get(g.id)||0,S=(a.get(g.id)??[]).map(k=>e.find(b=>b.id===k)).filter(k=>!!k).sort(rn);for(const k of S){if(h.has(k.id))continue;h.set(k.id,x+1);const b=p[x+1]??[];b.push(k),p[x+1]=b,y.push(k)}}const w=e.filter(g=>!h.has(g.id)).sort(rn);w.length&&p.push(w);const v=jt+32;return p.forEach((g,x)=>{if(x===0&&g.length===1){o.set(g[0].id,{x:0,y:0});return}const S=Math.max(x*(jt+Hr),g.length<=1?jt:g.length*v/(2*Math.PI));g.forEach((k,b)=>{const E=-Math.PI/2+2*Math.PI*b/g.length;o.set(k.id,{x:Math.cos(E)*S,y:Math.sin(E)*S})})}),o}function AN(e){const r=new Map,o=[...e].sort((c,h)=>On(c.type)-On(h.type)||rn(c,h)),s=Math.max(1,Math.ceil(Math.sqrt(o.length))),a=jt+Hr,u=Fn+fl;return o.forEach((c,h)=>{r.set(c.id,{x:h%s*a,y:Math.floor(h/s)*u})}),r}function $N(e){const r=new Map,o=[...e].sort(Fm);return o.length<=1?(o[0]&&r.set(o[0].id,{x:0,y:0}),r):(Hc(o,Bc(o.length,1),r),r)}function zN(e){const r=new Map;if(!e.length)return r;const o=new Map;for(const a of e){const u=On(a.type),c=o.get(u)??[];c.push(a),o.set(u,c)}return[...o.keys()].sort((a,u)=>a-u).forEach((a,u)=>{const c=(o.get(a)??[]).sort(rn);if(u===0&&c.length===1){r.set(c[0].id,{x:0,y:0});return}Hc(c,Bc(c.length,u===0?1:u),r)}),r}function DN(e){const r=new Map;if(!e.length)return r;const o=new Map;for(const h of e){const p=o.get(h.type)??[];p.push(h),o.set(h.type,p)}const a=[...o.keys()].sort((h,p)=>On(h)-On(p)||h.localeCompare(p)).map(h=>{const p=(o.get(h)??[]).sort(rn),y=Math.max(1,Math.ceil(Math.sqrt(p.length))),w=Math.ceil(p.length/y);return{members:p,cols:y,width:Math.max(0,y-1)*go,height:Math.max(0,w-1)*Ka}}),u=Math.max(...a.map(h=>Math.hypot(h.width,h.height)/2+jt),jt),c=a.length<=1?0:Math.max(go,a.length*(u*2+Hr)/(2*Math.PI));return a.forEach((h,p)=>{const y=a.length===1?0:-Math.PI/2+2*Math.PI*p/a.length,w=Math.cos(y)*c,v=Math.sin(y)*c;h.members.forEach((g,x)=>{const S=x%h.cols,k=Math.floor(x/h.cols);r.set(g.id,{x:w-h.width/2+S*go,y:v-h.height/2+k*Ka})})}),r}function ON(e,r){const o=new Map;if(!e.length)return o;const s=new Map(e.map(x=>[x.id,x])),a=new Set(s.keys()),u=new Map,c=new Map;for(const x of e)u.set(x.id,[]),c.set(x.id,0);for(const x of r)!a.has(x.src)||!a.has(x.dst)||x.src===x.dst||(u.get(x.src).push(x.dst),c.set(x.dst,(c.get(x.dst)||0)+1));for(const[x,S]of u){const k=[...new Set(S)];k.sort((b,E)=>rn(s.get(b),s.get(E))),u.set(x,k)}const h=e.filter(x=>(c.get(x.id)||0)===0).sort(rn);if(!h.length){const x=[...e].sort((S,k)=>{var b,E;return(((b=u.get(k.id))==null?void 0:b.length)||0)-(((E=u.get(S.id))==null?void 0:E.length)||0)||rn(S,k)})[0];h.push(x)}const p=new Set,y=new Map;for(const x of e)y.set(x.id,[]);const w=x=>{p.add(x);for(const S of u.get(x)??[])p.has(S)||(y.get(x).push(S),w(S))};for(const x of h)p.has(x.id)||w(x.id);for(const x of[...e].sort(rn))p.has(x.id)||(h.push(x),w(x.id));let v=0;const g=(x,S)=>{const k=y.get(x)??[];if(!k.length){o.set(x,{x:v*go,y:S*Ka}),v+=1;return}const b=v;for(const E of k)g(E,S+1);o.set(x,{x:(b+v-1)/2*go,y:S*Ka})};for(const x of h)o.has(x.id)||g(x.id,0);return o}function FN(e,r){const o=jt+24,s=Fn+16;for(let a=0;a<8;a++)for(let u=0;ug.id)),h=[],p=new Set;for(const g of r){if(!c.has(g.src)||!c.has(g.dst)||g.src===g.dst)continue;const x=g.src[g.id,g])),a=[];VN.has(e.type)&&a.push("sink"),WN.has(e.type)&&a.push("contract");const u=e.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.ninja_schema&&a.push("ninja schema"),u.next_app&&a.push("app router"),u.typed_client&&a.push(String(u.typed_client)),u.e2e&&a.push("e2e"),u.filterset===!0&&a.push("filterset");const c=o.filter(g=>g.dst===e.id),h=o.filter(g=>g.src===e.id),p=c.slice(0,Ra).map(g=>Ta(g,s,g.src)),y=h.slice(0,Ra).map(g=>Ta(g,s,g.dst)),w=e.file_path?`${e.file_path}${e.start_line?`:${e.start_line}`:""}`:void 0,v={type:e.type,typeLabel:rs(ci(e.type)),layer:$m[On(e.type)]??"other",purpose:XN(e.type),name:e.name,qualifiedName:e.qualified_name,file:w,context:e.context,roles:a,facts:QN(u).filter(g=>!(g.key==="app"&&g.value===e.context)),inputs:p,outputs:y,extraInputs:Math.max(0,c.length-Ra),extraOutputs:Math.max(0,h.length-Ra),degreeIn:c.length,degreeOut:h.length,inputKinds:Rp(c.map(g=>Ta(g,s,g.src))),outputKinds:Rp(h.map(g=>Ta(g,s,g.dst))),pathSummary:""};return v.pathSummary=KN(v),v}function Rp(e){const r=new Map;for(const o of e){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function KN(e){const r=e.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=e.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Ta(e,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?rs(ci(s.type)):"",edgeType:e.type,edgeLabel:rs(e.type),inferred:e.confidence<.8}}function QN(e){const r=[...Pp.filter(a=>a in e),...Object.keys(e).filter(a=>!Pp.includes(a)&&!Ip.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||Ip.has(a)||YN.has(a))continue;s.add(a);const u=ZN(a,e[a]);u!=null&&o.push({key:a,label:UN[a]??rs(a),value:u})}return o}function ZN(e,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!GN.has(e)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return JN(e,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,BN),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function JN(e,r){const o=r.slice(0,4).map(a=>{if(e==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(e==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const Tp=12,Lp=.2,eb=.8,Qa=20,tb=Fn;function nb(e,r,o){const s=o??Im(e,r),a=[...new Set([...s.values()].map(p=>p.x))].sort((p,y)=>p-y),u=[];for(const p of r){const y=s.get(p.src),w=s.get(p.dst);if(!y||!w)continue;const v=y.y+Fn/2,g=w.y+Fn/2;if(Math.abs(v-g)S.y0-k.y0||S.y1-k.y1||S.id.localeCompare(k.id)),w=ib(y),v=Math.max(0,...w.values())+1,g=y[0].sourceX,x=rb(a,g);for(const S of y){const k=sb(w.get(S.id)??0,v),b=g+Qa+Math.max(1,x-2*Qa)*k;h.set(S.id,ob(S.sourceX,S.targetX,b))}}return h}function rb(e,r){const o=r-jt,s=e.find(a=>a>o+1);return s===void 0?Hr:Math.max(Hr,s-r)}function ob(e,r,o){const s=r-e-2*Qa;return s<1?.5:Math.min(1,Math.max(0,(o-e-Qa)/s))}function ib(e){const r=[],o=new Map;for(const s of e){let a=-1;for(let u=0;ur[u]+tb){a=u;break}a<0?(a=r.length,r.push(s.y1)):r[a]=Math.max(r[a],s.y1),o.set(s.id,a)}return o}function sb(e,r){return r<=1?.5:Lp+(eb-Lp)*e/(r-1)}const ab=new Set,lb=A.lazy(()=>q0(()=>import("./LayeredGraph3D-DIGrA9CU.js"),[],import.meta.url).then(e=>({default:e.LayeredGraph3D})));class Bm extends A.Component{constructor(){super(...arguments);ih(this,"state",{failed:!1})}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?this.props.fallback:this.props.children}}const Ap=d.jsx("p",{className:"muted graph-3d-hint","data-testid":"graph-3d-fallback",children:"WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map."}),ub={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"},Za={n:ke.Top,e:ke.Right,s:ke.Bottom,w:ke.Left};function cb(e,r){const o=r.x-e.x,s=r.y-e.y;return Math.abs(o)>=Math.abs(s)?o>=0?{source:"e",target:"w"}:{source:"w",target:"e"}:s>=0?{source:"s",target:"n"}:{source:"n",target:"s"}}function db({data:e,selected:r}){const o=(e.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",e.dim?"dim":"",o].filter(Boolean).join(" "),children:[["n","e","s","w"].map(s=>d.jsx(ui,{id:`tgt-${s}`,type:"target",position:Za[s],isConnectable:!1},`tgt-${s}`)),d.jsx("div",{className:"t",children:ci(e.type)}),d.jsx("div",{className:"n",title:e.name,children:Dr(e.name)}),["n","e","s","w"].map(s=>d.jsx(ui,{id:`src-${s}`,type:"source",position:Za[s],isConnectable:!1},`src-${s}`))]})}const fb={load:db},hb=new Set(["django","react","stitch","arch"]);function pb({id:e,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:y,label:w,labelStyle:v,labelShowBg:g,labelBgStyle:x,labelBgPadding:S,labelBgBorderRadius:k,data:b,interactionWidth:E}){const[I,_,j]=Xa({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(_s,{id:e,path:I,labelX:_,labelY:j,label:w,labelStyle:v,labelShowBg:g,labelBgStyle:x,labelBgPadding:S,labelBgBorderRadius:k,style:h,markerEnd:p,markerStart:y,interactionWidth:E})}const gb={loadstep:pb};function mb({topologyKey:e}){const{fitView:r}=cl();return A.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,e]),null}function yb(e,r,o=null,s={}){const a=new Map(e.map(v=>[v.id,v])),u=s.layout??"layers",c=Om(u),h=Hm(e,r,u),p=nb(e,r,h),y=e.map(v=>{var S;const g=((S=s.roles)==null?void 0:S[v.id])||[],x=!!s.testOverlay&&!g.includes("tested")&&!g.includes("untested")&&!g.includes("test")&&!g.includes("seed");return{id:v.id,type:"load",position:h.get(v.id)??{x:0,y:0},data:{name:v.name,type:v.type,file:v.file_path,roles:g,dim:x},selected:o===v.id,sourcePosition:ke.Right,targetPosition:ke.Left,width:jt,height:Fn,style:{width:jt,height:Fn}}}),w=r.filter(v=>a.has(v.src)&&a.has(v.dst)).map(v=>{const g=ub[v.weight]||"var(--edge-cheap)",x=!!(o&&(v.src===o||v.dst===o)),S=h.get(v.src)??{x:0,y:0},k=h.get(v.dst)??{x:0,y:0},b=c?{source:"e",target:"w"}:cb(S,k);return{id:v.id,source:v.src,target:v.dst,sourceHandle:`src-${b.source}`,targetHandle:`tgt-${b.target}`,sourcePosition:Za[b.source],targetPosition:Za[b.target],type:c?"loadstep":"default",animated:v.weight==="critical",data:{stepPosition:p.get(v.id)??.5},style:{stroke:g,strokeWidth:v.weight==="critical"?2.4:1.2,strokeDasharray:v.confidence<.8?"6 4":void 0},markerEnd:{type:cs.ArrowClosed,width:14,height:14,color:g},label:x?v.type.replaceAll("_"," "):void 0,labelStyle:x?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:x?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:x?[3,5]:void 0,labelBgBorderRadius:x?4:void 0}});return{rfNodes:y,rfEdges:w}}function vb({node:e,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:y}){const w=qN(e,r,o);return A.useEffect(()=>{const v=g=>{g.key==="Escape"&&s()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:w.typeLabel}),d.jsx("div",{className:"inspector-roles",children:w.roles.map(v=>d.jsx("span",{className:"inspector-chip",children:v},v))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Dr(w.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:w.purpose}),w.context?d.jsx("div",{className:"muted",children:Dr(w.context)}):null,w.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Dr(w.file)}),c&&e.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(e.file_path,e.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Dr(w.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",w.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[w.degreeIn," in · ",w.degreeOut," out"]}),w.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:w.pathSummary}):null,w.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:w.facts.map(v=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:v.label}),d.jsx("dd",{children:Dr(v.value)})]},v.key))}):null,d.jsx($p,{title:"Inputs",testId:"graph-inspector-inputs",links:w.inputs,extra:w.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx($p,{title:"Outputs",testId:"graph-inspector-outputs",links:w.outputs,extra:w.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:y?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(e.id),children:"What if this changes"}):null,y?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>y(e.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:e.id),children:h?"Unpin":"Pin"}):null]})]})}function $p({title:e,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[e,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Dr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Dr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function xb({nodes:e,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:y,repoPath:w,onOpenFile:v,pinnedId:g,onPin:x}){const[S,k]=A.useState(null),b=a!==void 0?a:S,E=pe=>{a===void 0&&k(pe),u==null||u(pe)},[I,_]=A.useState(null),[j,L]=A.useState(null),[$,F]=A.useState(()=>MN()),[U,q]=A.useState(new Set(hb)),[te,J]=A.useState(!1),[ne,Q]=A.useState(""),[C,V]=A.useState(!1),[W,Y]=A.useState(null),M=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;A.useEffect(()=>{const pe=()=>Y(fN());if(typeof window.requestIdleCallback=="function"){const Ve=window.requestIdleCallback(pe);return()=>window.cancelIdleCallback(Ve)}const $e=window.setTimeout(pe,0);return()=>window.clearTimeout($e)},[]);const D=I??vN(e.length),H=hN(D,I,W),R=j??xN(e.length),z=te?b:null,re=A.useMemo(()=>p?kN(e,r,p):null,[e,r,p]),oe=re?e.filter(pe=>re.nodeIds.has(pe.id)):e,fe=re?r.filter(pe=>re.edgeIds.has(pe.id)):r,le=A.useMemo(()=>_N(oe,fe,{detail:R,families:U,focusId:z,neighborhoodOnly:!!z}),[oe,fe,R,U,z]),he=A.useMemo(()=>`${$}|${le.nodes.map(pe=>pe.id).join("\0")}|${le.edges.map(pe=>pe.id).join("\0")}`,[$,le.nodes,le.edges]),Z=b?e.find(pe=>pe.id===b)??null:null,{rfNodes:se,rfEdges:me}=A.useMemo(()=>{const pe=yb(le.nodes,le.edges,b,{roles:c,testOverlay:h,layout:$});return M&&(pe.rfEdges=pe.rfEdges.map($e=>({...$e,animated:!1}))),pe},[le.nodes,le.edges,b,M,c,h,$]);A.useEffect(()=>{if(!s)return;const pe=e.find($e=>$e.file_path===s);pe&&E(pe.id)},[s,e]);const Ne=A.useMemo(()=>SN(e,ne),[e,ne]),we=(pe,$e)=>{E($e.id)},ye=()=>{E(null),J(!1)},Me=Z?d.jsx(vb,{node:Z,nodes:e,edges:r,onClose:ye,onWhatIf:o,onSelect:E,onOpenFile:v,pinned:g===Z.id,onPin:x,onIsolate:y?pe=>{y(p===pe?null:pe)}:void 0}):null,Te=pe=>{q($e=>{const Ve=new Set($e);if(Ve.has(pe)){if(Ve.size===1)return $e;Ve.delete(pe)}else Ve.add(pe);return Ve})},Le=A.useMemo(()=>{const pe=new Set;for(const $e of e)pe.add(zm($e.type));return pe},[e]),De=e.length-le.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:H==="2d"?"active":"","aria-pressed":H==="2d",onClick:()=>_("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:H==="3d"?"active":"","aria-pressed":H==="3d",onClick:()=>_("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:R==="overview"?"active":"","aria-pressed":R==="overview",onClick:()=>L("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:R==="full"?"active":"","aria-pressed":R==="full",onClick:()=>L("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(pe=>Le.has(pe)).map(pe=>d.jsx("button",{type:"button","data-testid":`graph-family-${pe}`,className:U.has(pe)?"active":"","aria-pressed":U.has(pe),onClick:()=>Te(pe),children:pe},pe))}),d.jsxs("label",{className:"graph-layout",children:["Layout",d.jsx("select",{id:"graph-layout","data-testid":"graph-layout",value:$,"aria-label":"Graph layout algorithm",onChange:pe=>{var Ve;const $e=(Ve=Sc.find(Ue=>Ue.id===pe.target.value))==null?void 0:Ve.id;$e&&(F($e),PN($e))},children:Sc.map(pe=>d.jsx("option",{value:pe.id,children:pe.label},pe.id))})]}),d.jsx("button",{type:"button",className:te?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>J(pe=>!pe),children:te?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>y==null?void 0:y(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:ne,onChange:pe=>{Q(pe.target.value),V(!0)},onFocus:()=>V(!0),onBlur:()=>window.setTimeout(()=>V(!1),150)}),C&&ne.trim()&&Ne.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:Ne.map(pe=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:$e=>$e.preventDefault(),onClick:()=>{E(pe.id),Q(""),V(!1)},children:[pe.name,d.jsx("span",{className:"muted",children:ci(pe.type)})]})},pe.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[le.nodes.length," nodes · ",le.edges.length," edges",De?` · ${De} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:e.length===0?d.jsxs("div",{className:"empty graph-walk-empty","data-testid":"graph-walk-empty",children:[d.jsx("h2",{children:"No typed nodes on this walk"}),d.jsx("p",{children:"This range did not hit models, views, routes, or React pages Loadpath extracts. Open the architecture map for the indexed graph."})]}):H==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Same layout as the 2D map, with bounded context on the depth axis. Dashed edges are inferred. Drag to orbit, scroll to zoom, click a node to inspect it."}),W===!1?Ap:W===null?d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}):d.jsx(Bm,{fallback:Ap,children:d.jsx(A.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(lb,{nodes:le.nodes,edges:le.edges,selectedId:b,neighborIds:z?le.neighborIds:ab,layout:$,nodeRoles:c,testOverlay:h,onSelect:pe=>{E(pe),pe||J(!1)}})})}),Me]}):d.jsxs(Em,{children:[d.jsxs(Mk,{nodes:se,edges:me,nodeTypes:fb,edgeTypes:gb,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:we,onPaneClick:ye,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(mb,{topologyKey:he}),d.jsx(Lk,{}),d.jsx(tN,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(Hk,{})]}),Me]})})]})}function ic(e){return d.jsx(Bm,{fallback:d.jsx("p",{className:"muted graph-3d-hint","data-testid":"graph-crash-fallback",children:"The graph failed to render. Switch to 2D map or another layout."}),children:d.jsx(xb,{...e})})}function Vm(){const e=localStorage.getItem("loadpath.editor")||"auto";return e==="cursor"||e==="vscode"||e==="system"?e:"auto"}function wb(e){localStorage.setItem("loadpath.editor",e)}async function _b(e,r,o,s=Vm()){try{const a=await Re.openEditor(e,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const zp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],Sb=["preset","branch","tag","commit"];function kb(e){var a;if(!(e!=null&&e.git))return[...zp];const r=((a=e.presets)!=null&&a.length?e.presets:zp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of e.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of e.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of e.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function Nb(e,r){const o=r.trim().toLowerCase();return o?e.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):e}function bb(e){return Sb.map(r=>({group:r,items:e.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function jb(e){return e==="preset"?"Common":e==="branch"?"Branches":e==="tag"?"Tags":"Recent commits"}function Dp({value:e,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=A.useId(),p=A.useRef(null),[y,w]=A.useState(!1),[v,g]=A.useState(null),[x,S]=A.useState(0),k=A.useMemo(()=>{const j=kb(u);return v===null?j:Nb(j,v)},[u,v]),b=A.useMemo(()=>bb(k),[k]);A.useEffect(()=>{y&&c()},[y,c]),A.useEffect(()=>{S(0)},[v,y]);const E=()=>{w(!1),g(null)},I=j=>{r(j.value),E()},_=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!y){w(!0);return}S(L=>Math.min(L+1,Math.max(k.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!y)return;S(L=>Math.max(L-1,0))}else if(j.key==="Enter"&&y){j.preventDefault();const L=k[x];L&&I(L)}else j.key==="Escape"&&y&&(j.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:e,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":h,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),y&&g(j.target.value)},onKeyDown:_}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:j=>j.preventDefault(),onClick:()=>y?E():w(!0),children:d.jsx(G0,{})})]}),y?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(j=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:jb(j.group)}),j.items.map(L=>{const $=k.indexOf(L);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===x,className:$===x?"combo-option active":"combo-option","data-testid":`ref-option-${L.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>S($),onClick:()=>I(L),children:[d.jsx("span",{className:"combo-label",children:L.label}),L.detail?d.jsx("span",{className:"combo-detail",children:L.detail}):null]},`${L.group}:${L.value}`)})]},j.group))}):null]})}function Eb({initialPath:e,onSelect:r,onClose:o}){const[s,a]=A.useState(null),[u,c]=A.useState(e),[h,p]=A.useState(null),[y,w]=A.useState(""),[v,g]=A.useState(!1),x=A.useRef(null),S=A.useRef(0),k=async _=>{const j=S.current+1;S.current=j,g(!0);try{const L=await Re.browse(_);if(S.current!==j)return;a(L),c(L.path),p(L.is_git?L.path:null),w("")}catch(L){if(S.current!==j)return;w(L instanceof Error?L.message:String(L))}finally{S.current===j&&g(!1)}};A.useEffect(()=>{var _,j;k(e),(_=x.current)==null||_.focus(),(j=x.current)==null||j.select()},[e]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",I=_=>{_.key==="Escape"&&(_.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:I,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:_=>_.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:_=>{_.preventDefault(),k(u)},children:[d.jsx("input",{ref:x,"data-testid":"explorer-path",value:u,onChange:_=>c(_.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void k(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void k(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?d.jsx("div",{className:"error",role:"alert",children:y}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":v,children:s!=null&&s.entries.length?s.entries.map(_=>{const j=h===_.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":_.path,onClick:()=>p(_.path),onDoubleClick:()=>void k(_.path),children:[d.jsx(Bp,{}),d.jsx("span",{className:"explorer-name",children:_.name}),_.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},_.path)}):d.jsx("div",{className:"muted explorer-empty",children:v?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const Cb={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},Mb=new Set(["scan","extract","boot","stitch"]);function Pb(e){const r=e.phase||"";if(!r||r==="idle")return null;const o=Cb[r];if(!o)return null;if(o.start===o.end)return o.end;const s=e.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(e.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function Ib(e){return!e.phase||e.phase==="idle"?null:typeof e.percent=="number"&&Number.isFinite(e.percent)?Math.max(0,Math.min(100,Math.round(e.percent))):Pb(e)}const Ja=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],Rb="obsidian",Wm="loadpath.theme";function Tb(e){return Ja.some(r=>r.id===e)}function Um(){try{const e=localStorage.getItem(Wm)||"";if(Tb(e))return e}catch{}return Rb}function Lb(e){var r;return((r=Ja.find(o=>o.id===e))==null?void 0:r.group)==="light"?"light":"dark"}function Gm(e){document.documentElement.dataset.theme=e,document.documentElement.style.colorScheme=Lb(e);try{localStorage.setItem(Wm,e)}catch{}}const sc=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:H0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:B0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:V0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:W0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:U0}];function ac(e,r,o){let s;try{s=new URL(e)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function Ab(){var yi,Mo,vi,xi,wi,Po,Qr,un,cn,dn;const[e,r]=A.useState("review"),[o,s]=A.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=A.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=A.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,y]=A.useState(null),[w,v]=A.useState(null),[g,x]=A.useState(null),[S,k]=A.useState([]),[b,E]=A.useState("review"),[I,_]=A.useState(""),[j,L]=A.useState(""),[$,F]=A.useState(null),[U,q]=A.useState(!1),[te,J]=A.useState(!1),[ne,Q]=A.useState(""),[C,V]=A.useState({}),[W,Y]=A.useState([]),[M,D]=A.useState([]),[H,R]=A.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,re]=A.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=A.useState(localStorage.getItem("loadpath.prNumber")||""),[le,he]=A.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=A.useState(0),[me,Ne]=A.useState(""),[we,ye]=A.useState(Um),[Me,Te]=A.useState(!1),[Le,De]=A.useState(!1),[pe,$e]=A.useState(!1),[Ve,Ue]=A.useState(null),[wt,Xt]=A.useState(null),[gt,mt]=A.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Mt,ct]=A.useState(null),[rt,Bn]=A.useState(localStorage.getItem("loadpath.watch")==="1"),[Pt,bn]=A.useState([]),[di,Vn]=A.useState(null),[So,dr]=A.useState(null),[Br,Wn]=A.useState(null),[Vr,fr]=A.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[hr,Ht]=A.useState(null),[dt,Un]=A.useState(null),[Gn,jn]=A.useState(!1),[Yn,En]=A.useState(!1),at=A.useRef(o);at.current=o;const pr=A.useRef(le);pr.current=le;const Cn=A.useRef(!1);Cn.current=Le;const It=A.useRef(""),on=A.useRef(""),ko=P=>{ye(P),Gm(P)},tt=A.useRef(""),We=P=>{tt.current=P,L(P)},Mn=P=>{let G=0,ce=!1;F(0);const Ee=()=>{Re.indexProgress(P).then(Ie=>{if(!tt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&We(Ie.message),Mb.has(Ie.phase))ce=!0;else if(!ce)return;const xr=Ib(Ie);xr!=null&&(Ie.phase==="scan"&&!Ie.done?G=xr:G=Math.max(G,xr),F(G))}).catch(()=>{})};Ee();const Pe=window.setInterval(Ee,250);return()=>{window.clearInterval(Pe),F(null)}};A.useEffect(()=>{Re.settings().then(V).catch(()=>{}).finally(()=>Te(!0)),Re.repos().then(P=>k(P.repos)).catch(()=>{})},[]);const Xn=()=>o.trim()?!0:(_("Point at a local repository path first."),!1);A.useEffect(()=>{if(e!=="architecture"||!o.trim())return;const P=o;let G=!1;return on.current!==P&&Kn(P),Re.config(P).then(ce=>{!G&&at.current===P&&dr(ce)}).catch(()=>{}),Re.architectureHealth(P).then(ce=>{!G&&at.current===P&&Wn(ce)}).catch(()=>{}),()=>{G=!0}},[e,o]);const sn=P=>{at.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==It.current&&(It.current="",Ht(null))},Wr=A.useCallback(P=>{const G=(P??at.current).trim();return!G||It.current===G?Promise.resolve():(It.current=G,Re.gitRefs(G).then(ce=>{at.current.trim()===G&&Ht(ce)}).catch(()=>{It.current===G&&(It.current="",Ht(null))}))},[]),an=(P,G)=>{u(P),h(G),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",G)},Rt=(P,G,ce)=>{re(P),R(G),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",G),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},qt=P=>{y(P),se(0),Ue(wt&&P.nodes.some(G=>G.id===wt)?wt:null),ct(null),Vn(null),P.what_if||(v(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},qn=async P=>{try{const G=await Re.reviews(P);bn(G.reviews)}catch{bn([])}},No=async P=>{try{Wn(await Re.architectureHealth(P))}catch{Wn(null)}},bo=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,Tt=A.useCallback(async(P=z)=>{var G;try{const ce=await Re.scmRepos(P);D(ce.repos),(G=ce.user)!=null&&G.login&&V(Ee=>({...Ee,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);A.useEffect(()=>{if(e!=="prs")return;let P=!1;return Tt(z).catch(()=>{P||D([])}),()=>{P=!0}},[e,z,Tt]),A.useEffect(()=>{if(!dt)return;let P=!1,G=0;const ce=async()=>{try{const Ee=await Re.githubOAuthPoll(dt.flow_id);if(P)return;if(Ee.status==="complete"){Un(null);const Pe=await Re.settings();V(Pe),Q(Ee.user?`Signed in to GitHub as ${Ee.user}`:"Signed in to GitHub"),Tt("github");return}if(Ee.status==="pending"||Ee.status==="slow_down"){G=window.setTimeout(ce,Math.max(Ee.interval||dt.interval,5)*1e3);return}Un(null),_(Ee.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Ee){if(P)return;Un(null),_(Ee instanceof Error?Ee.message:String(Ee))}};return G=window.setTimeout(ce,Math.max(dt.interval,5)*1e3),()=>{P=!0,window.clearTimeout(G)}},[dt,Tt]),A.useEffect(()=>{if(!Gn)return;let P=!1,G=0;const ce=Date.now(),Ee=async()=>{try{const Pe=await Re.oauthStatus();if(P)return;if(Pe.bitbucket.connected){jn(!1);const Ie=await Re.settings();V(Ie),Q(Pe.bitbucket.user?`Signed in to Bitbucket as ${Pe.bitbucket.user}`:"Signed in to Bitbucket"),Tt("bitbucket");return}if(Date.now()-ce>18e4){jn(!1),_("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Ee,1500)}catch(Pe){if(P)return;jn(!1),_(Pe instanceof Error?Pe.message:String(Pe))}};return G=window.setTimeout(Ee,1500),()=>{P=!0,window.clearTimeout(G)}},[Gn,Tt]),A.useEffect(()=>{if(!Yn)return;let P=!1,G=0;const ce=Date.now(),Ee=async()=>{try{const Pe=await Re.oauthStatus();if(P)return;if(Pe.gitlab.connected){En(!1);const Ie=await Re.settings();V(Ie),Q(Pe.gitlab.user?`Signed in to GitLab as ${Pe.gitlab.user}`:"Signed in to GitLab"),Tt("gitlab");return}if(Date.now()-ce>18e4){En(!1),_("GitLab sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Ee,1500)}catch(Pe){if(P)return;En(!1),_(Pe instanceof Error?Pe.message:String(Pe))}};return G=window.setTimeout(Ee,1500),()=>{P=!0,window.clearTimeout(G)}},[Yn,Tt]);const Kn=async(P=o,G=!1)=>{if(!P.trim())return null;on.current=P,J(!0);try{const ce=await Re.architecture(P,!1);at.current===P&&x(ce);const Ee=Re.architectureGraph(P).then(Pe=>{at.current===P&&x(Ie=>Ie&&{...Ie,nodes:Pe.nodes,edges:Pe.edges,graph_pending:!1})});return Ee.catch(()=>{x(Pe=>Pe&&at.current===P?{...Pe,graph_pending:!1}:Pe)}).finally(()=>{on.current===P&&J(!1)}),G&&await Ee,ce}catch(ce){throw at.current===P&&J(!1),ce}},Ur=async P=>{const G=P.trim();if(!(!G||G===at.current)){if(tt.current){_("Wait for the current job to finish before switching workspace.");return}_(""),Q(""),y(null),v(null),x(null),E("architecture"),sn(G),q(!0),We(`Loading ${F0(G)}…`);try{await Promise.all([Kn(G),Wr(G)])}catch(ce){at.current===G&&_(ce instanceof Error?ce.message:String(ce))}finally{at.current===G&&(We(""),q(!1))}}},Qn=async()=>{if(tt.current||!Xn())return;_(""),Q(""),We("Tracing load path…"),sn(o),an(a,c);const P=Mn(o);try{const G=await Re.review(o,a,c,!0,pr.current);qt(G),E("review"),r("review"),await Re.repos().then(ce=>k(ce.repos)).catch(()=>{}),await Promise.all([Kn(o),qn(o),No(o)])}catch(G){_(G instanceof Error?G.message:String(G))}finally{P(),We("")}},gr=async(P=!0)=>{if(tt.current||!Xn())return;_(""),Q(""),We(P?"Indexing…":"Full reindex…"),sn(o);const G=Mn(o);try{await Re.index(o,P);const ce=await Kn(o);await Re.repos().then(Ee=>k(Ee.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){_(ce instanceof Error?ce.message:String(ce))}finally{G(),We("")}},Ye=async()=>{if(!tt.current&&Xn()){_(""),Q(""),We("Detecting layout…"),sn(o);try{const P=await Re.init(o);Q(P.message),await Re.repos().then(G=>k(G.repos)).catch(()=>{})}catch(P){_(P instanceof Error?P.message:String(P))}finally{We("")}}},fi=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),Q("Copied markdown brief")}catch(P){_(P instanceof Error?P.message:String(P))}},Gr=async()=>{if(!tt.current){if(p!=null&&p.what_if){_("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){_("Pick a pull request first (Pull requests tab), then post the brief.");return}We("Posting Loadpath brief…");try{const P=await Re.postComment(z,H,Number(oe),p.markdown);Q(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){_(P instanceof Error?P.message:String(P))}finally{We("")}}},jo=async()=>{if(!tt.current){_(""),We("Fetching pull requests…");try{const P=await Re.prs(z,H,"open",o.trim()||void 0);Y(P.pull_requests);const G=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());G!=null&&G.local_path&&sn(G.local_path)}catch(P){_(P instanceof Error?P.message:String(P))}finally{We("")}}},mr=async()=>{_("");try{const P=await Re.githubOAuthStart();Un(P),ac(P.verification_uri_complete,"github.com","/login/device")}catch(P){_(P instanceof Error?P.message:String(P))}},hi=async()=>{_("");try{const P=await Re.bitbucketOAuthStart();jn(!0),ac(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){jn(!1),_(P instanceof Error?P.message:String(P))}},Eo=async()=>{_("");try{const P=await Re.gitlabOAuthStart();En(!0),ac(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){En(!1),_(P instanceof Error?P.message:String(P))}},Pn=async P=>{if(!(tt.current||!o.trim())){_(""),We("Walking what-if path…");try{const G=await Re.whatIf(o,P);Q(`${G.title} — ${G.confidence.level} · ${(G.sinks||[]).length} sinks`),qt({...G,markdown:G.markdown||"",index:G.index||(p==null?void 0:p.index),workspace:G.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(G){_(G instanceof Error?G.message:String(G))}finally{We("")}}},_t=()=>{if(w){qt(w),E("review"),r("review"),Q("Restored the last git-range walk");return}y(null),se(0),Ue(null),ct(null),Vn(null),E("architecture"),r("architecture"),Q("")},pi=async P=>{var Pe;if(tt.current)return;Rt(P.provider,P.repo,String(P.number));const G=M.find(Ie=>Ie.slug.toLowerCase()===P.repo.toLowerCase());G!=null&&G.local_path&&sn(G.local_path),_(""),We(`Fetching ${P.provider} #${P.number}…`);const ce=(G==null?void 0:G.local_path)||o,Ee=ce?Mn(ce):()=>{};try{const Ie=await Re.reviewPr(P.provider,P.repo,P.number,(G==null?void 0:G.local_path)||o||void 0);qt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&sn(Ie.pull_request.repo_path),an(String(Ie.base||P.target_branch),String(Ie.head||P.source_branch)),E("review"),r("review"),typeof((Pe=Ie.pull_request)==null?void 0:Pe.repo_path)=="string"&&qn(Ie.pull_request.repo_path)}catch(Ie){an(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),_(Ie instanceof Error?Ie.message:String(Ie))}finally{Ee(),We("")}},yt=async P=>{_("");try{V(await Re.oauthDisconnect(P)),z===P&&D([]),Q(`Disconnected ${P}`)}catch(G){_(G instanceof Error?G.message:String(G))}},gi=async P=>{P.preventDefault();const G=new FormData(P.currentTarget),ce={github_token:String(G.get("github_token")||""),github_oauth_client_id:String(G.get("github_oauth_client_id")||""),github_host:String(G.get("github_host")||""),gitlab_token:String(G.get("gitlab_token")||""),gitlab_host:String(G.get("gitlab_host")||""),gitlab_oauth_client_id:String(G.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(G.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(G.get("bitbucket_token")||""),bitbucket_username:String(G.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(G.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(G.get("bitbucket_oauth_client_secret")||""),ai_provider:String(G.get("ai_provider")||"none"),ai_api_key:String(G.get("ai_api_key")||""),ai_model:String(G.get("ai_model")||""),ai_base_url:String(G.get("ai_base_url")||"")},Ee=S.length?{...ce,workspaces:S.map(Pe=>({path:Pe.path,name:Pe.name}))}:ce;try{V(await Re.saveSettings(Ee)),Q("Settings saved on this machine")}catch(Pe){_(Pe instanceof Error?Pe.message:String(Pe))}},mi=async()=>{if(!(!p||tt.current)){We("Residual analysis…");try{const P=await Re.residual(p);Ne(P.note)}catch(P){_(P instanceof Error?P.message:String(P))}finally{We("")}}},Yr=A.useRef(Qn);Yr.current=Qn;const In=A.useRef(e);In.current=e;const Zn=A.useRef(!1);Zn.current=pe;const Rn=A.useRef(p);Rn.current=p;const Kt=A.useRef(Z);Kt.current=Z,A.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),G=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!G){fr(!1);return}let ce=!1;return Re.getReview(G,P).then(Ee=>{ce||(qt(Ee),an(Ee.base||localStorage.getItem("loadpath.base")||"HEAD~1",Ee.head||localStorage.getItem("loadpath.head")||"HEAD"),qn(G),No(G))}).catch(()=>{}).finally(()=>{ce||fr(!1)}),()=>{ce=!0}},[]);const Xr=A.useRef("");A.useEffect(()=>{if(!rt||!o.trim())return;let P=!1;const G=async()=>{try{const Ee=await Re.workspaceStatus(o);if(P)return;Xr.current&&Ee.fingerprint!==Xr.current&&!tt.current&&(he(!0),pr.current=!0,localStorage.setItem("loadpath.dirty","1"),Yr.current()),Xr.current=Ee.fingerprint}catch{}};G();const ce=window.setInterval(G,2e3);return()=>{P=!0,window.clearInterval(ce)}},[rt,o]),A.useEffect(()=>{const P=G=>{var Pe;if((G.metaKey||G.ctrlKey)&&G.key.toLowerCase()==="k"){G.preventDefault(),$e(Ie=>!Ie);return}if(Zn.current){G.key==="Escape"&&(G.preventDefault(),$e(!1));return}if(Cn.current){G.key==="Escape"&&(G.preventDefault(),De(!1));return}const ce=G.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){G.key==="Escape"&&ce.blur();return}if(G.key==="Escape"){_(""),Q(""),Ue(wt),ct(null);return}if(G.key==="j"||G.key==="k"){const Ie=((Pe=Rn.current)==null?void 0:Pe.read_order)||[];if(!Ie.length)return;G.preventDefault();const _i=Kt.current,xr=G.key==="j"?Math.min(Ie.length-1,_i+1):Math.max(0,_i-1);se(xr);return}const Ee=sc.find(Ie=>Ie.shortcut===G.key);if(Ee&&!G.metaKey&&!G.ctrlKey&&!G.altKey&&r(Ee.id),(G.metaKey||G.ctrlKey)&&G.key==="Enter"){if(In.current==="settings"||In.current==="prs"||tt.current)return;G.preventDefault(),Yr.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const qr=async(P,G)=>{if(!o.trim())return;const ce=await _b(o,P,G);ce.ok?Q(ce.message):_(ce.message)},yr=async()=>{if(p)try{const P=await Re.exportHtml(p),G=URL.createObjectURL(P),ce=document.createElement("a");ce.href=G,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(G),Q("Saved HTML brief")}catch(P){_(P instanceof Error?P.message:String(P))}},Kr=async P=>{if(o.trim()){We("Loading stored review…");try{const G=await Re.getReview(o,P);qt(G),an(G.base||a,G.head||c),E("review"),r("review");const ce=Pt.findIndex(Pe=>Pe.id===P),Ee=ce>=0?Pt[ce+1]:void 0;if(Ee)try{Vn(await Re.reviewDiff(o,P,Ee.id))}catch{Vn(null)}}catch(G){_(G instanceof Error?G.message:String(G))}finally{We("")}}},ln={selectedId:Ve,onSelect:Ue,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Mt,onIsolate:ct,repoPath:o,onOpenFile:qr,pinnedId:wt,onPin:Xt},Jn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void Qn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:w?"Back to git-range walk":"Exit what-if walk",run:_t}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void gr(!0)},{id:"watch",group:"Run",label:rt?"Stop watching working tree":"Watch working tree",run:()=>{const P=!rt;Bn(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void yr()},...sc.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:ci(P.type),run:()=>{Ue(P.id),r("graph")}})),...Pt.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void Kr(P.id)}))],Co=A.useMemo(()=>b==="architecture"?(g==null?void 0:g.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,g,p]),vr=A.useMemo(()=>b==="architecture"?(g==null?void 0:g.edges)??[]:(p==null?void 0:p.edges)??[],[b,g,p]),Be=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:g!=null&&g.indexed?`${g.counts.nodes} nodes · ${g.counts.edges} edges`:"Not indexed",Ss=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),sc.map(P=>{const G=P.icon,ce=e===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(G,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:we,onChange:P=>ko(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Ja.filter(G=>G.group===P).map(G=>d.jsx("option",{value:G.id,children:G.label},G.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:j||Be}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[j?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:$!=null?"progressbar":"status","aria-label":j,"aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:j})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[S.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:S.some(P=>P.path===o)?o:"",disabled:!!j,"aria-busy":U,onChange:P=>{P.target.value&&Ur(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),S.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const G=P.target.value;s(G),G.trim()!==It.current&&(It.current="",Ht(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>De(!0),children:d.jsx(Bp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(Dp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>an(P,c),placeholder:"base",refs:hr,onNeedRefs:Wr})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(Dp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>an(a,P),placeholder:"head",refs:hr,onNeedRefs:Wr})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:le?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":le,onClick:()=>{const P=!le;he(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:le?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:rt?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":rt,onClick:()=>{const P=!rt;Bn(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:rt?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!j,onClick:Ye,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!j,onClick:()=>gr(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!j,onClick:Qn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[I?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:I}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>_(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>Q(""),"aria-label":"Dismiss",children:"×"})]}):null,((yi=p==null?void 0:p.index)!=null&&yi.stale||g!=null&&g.stale)&&(e==="review"||e==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((Mo=p==null?void 0:p.index)==null?void 0:Mo.django_boot)==="failed"||(g==null?void 0:g.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((vi=p==null?void 0:p.index)==null?void 0:vi.django_boot_detail)||(g==null?void 0:g.django_boot_detail)||"django.setup() failed"}):null,(xi=p==null?void 0:p.workspace)!=null&&xi.dirty_overlaps_review&&e==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((wi=p.node)==null?void 0:wi.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:_t,children:w?"Back to git range":"Back to architecture"})]}):null,U?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:j||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":U||te,children:[e==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx($b,{review:p,findings:Ss,aiNote:me,busy:!!j,tourIndex:Z,onTour:se,onAskAi:mi,onCopy:fi,onPost:Gr,onSelect:Ue,onOpenFile:qr,onExport:yr,history:Pt,diff:di,onReopen:Kr,onWaiver:(P,G)=>{o.trim()&&Re.addWaiver(o,P,G||void 0,"from review").then(ce=>{dr(ce),Q(`Waived ${P} in loadpath.yml`)})}}):Vr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(ic,{nodes:p.nodes,edges:p.edges,onWhatIf:Pn,focusPath:(Po=p.read_order[Z])==null?void 0:Po.path,...ln}):null})]}),e==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:g!=null&&g.indexed?d.jsx(zb,{architecture:g,busy:!!j,onReindex:()=>gr(!1),onReview:Qn,onSelect:Ue,config:So,health:Br,onSaveConfig:P=>{Re.saveConfig(o,P).then(G=>{dr(G),Q("Wrote loadpath.yml")})},onWaiver:(P,G,ce)=>{Re.addWaiver(o,P,G,ce).then(Ee=>{dr(Ee),Q(`Waived ${P}`)})}}):U?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||g!=null&&g.graph_pending)&&!((g==null?void 0:g.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(Qr=g==null?void 0:g.counts)!=null&&Qr.nodes?`${g.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):g!=null&&g.indexed?d.jsx(ic,{nodes:g.nodes,edges:g.edges,onWhatIf:Pn,...ln,isolateSource:null,onIsolate:void 0}):null})]}),e==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),Co.length||b==="review"&&p||g!=null&&g.indexed&&!(te||g!=null&&g.graph_pending)?d.jsx(ic,{nodes:Co,edges:vr,onWhatIf:Pn,...ln,...b==="architecture"?{isolateSource:null,onIsolate:void 0,nodeRoles:void 0,testOverlay:!1}:{}}):te||g!=null&&g.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),e==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Rt(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Rt(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!j||!bo(z),onClick:()=>{Tt(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!j,onClick:jo,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var G;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((G=P.loadpath.level)==null?void 0:G.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void pi(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),e==="settings"&&Me&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:gi,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ja.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:we===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>ko(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:Vm(),onChange:P=>wb(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void yt("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!dt||!C.github_oauth_ready,onClick:()=>void mr(),children:dt?"Waiting for GitHub…":"Sign in with GitHub"})})]}),dt?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:dt.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void yt("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Yn||!C.gitlab_oauth_ready,onClick:()=>void Eo(),children:Yn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void yt("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:Gn||!C.bitbucket_oauth_ready,onClick:()=>void hi(),children:Gn?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((un=C.ai)==null?void 0:un.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((cn=C.ai)==null?void 0:cn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((dn=C.ai)==null?void 0:dn.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(z0,{open:pe,actions:Jn,onClose:()=>$e(!1)}),Le?d.jsx(Eb,{initialPath:o,onClose:()=>De(!1),onSelect:P=>{if(tt.current){_("Wait for the current job to finish before switching workspace.");return}De(!1),Ur(P)}}):null]})}function $b({review:e,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:y,onOpenFile:w,onExport:v,history:g,diff:x,onReopen:S,onWaiver:k}){var E,I,_,j,L,$,F,U,q,te,J,ne,Q,C,V,W,Y;const b=[...new Set(e.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${e.confidence.level}`,children:[d.jsxs("div",{className:`level ${e.confidence.level}`,children:[e.confidence.level.toUpperCase()," — ",e.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,e.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,e.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,e.change_kinds.map(M=>d.jsx("span",{className:"chip",children:rs(M)},M)),(E=e.contract_break)!=null&&E.kind&&e.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${e.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",e.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[e.confidence.covered_sinks,"/",e.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:e.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:e.headline}),(e.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(e.checklist||[]).filter(M=>M.status==="todo").length})]}),(e.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>k(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,e.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:e.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",e.index.counts.nodes," nodes / ",e.index.counts.edges," edges",e.index.reindex_skipped?" from an unchanged index":e.index.reindexed?" after an incremental refresh":" from the existing index",e.index.django_boot&&e.index.django_boot!=="off"?` · Django boot ${e.index.django_boot}`:"",(I=e.workspace)!=null&&I.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:e.read_order.length})]}),e.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>w(M.path),children:"Open"})]},M.path)),e.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=e.read_order.length-1,onClick:()=>u(Math.min(e.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",e.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:e.clusters.length})]}),e.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:e.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(Ym,{cards:e.deepening}),(j=(_=e.contract_break)==null?void 0:_.reasons)!=null&&j.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:e.contract_break.kind})]}),e.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(L=e.contract_break.sides)==null?void 0:L.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:e.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=e.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:e.auth.note}),(e.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(e.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(U=e.suggested_tests)==null?void 0:U.length})]}),(e.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=e.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:e.trend.note}),(e.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",lc(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:e.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),e.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),g.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:g.length})]}),x?d.jsx("div",{className:"muted",children:x.note}):null,g.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===e.id?"history-item current":"history-item",onClick:()=>S(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?lc(M.created_at):""})]},M.id))]}):null,(J=(te=e.evolution)==null?void 0:te.notes)!=null&&J.length||(Q=(ne=e.evolution)==null?void 0:ne.hotspots)!=null&&Q.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=e.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=e.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:v,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!e.what_if,title:e.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:e.suggested_reviewers.join(", ")||"—"}),(W=e.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",e.codeowners_reviewers.join(", ")]}):null,(Y=e.knowledge_owners)!=null&&Y.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",e.knowledge_owners.join(", ")]}):null]})}function zb({architecture:e,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var w;const y=e.findings.filter(v=>!v.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",e.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[e.indexed_at?`Last index ${lc(e.indexed_at)}`:"Indexed",e.incremental?" · incremental":" · full",e.stale?" · stale":"",e.django_boot&&e.django_boot!=="off"?` · Django boot ${e.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[e.counts.edges," edges"]}),e.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(e.contexts).map(v=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v.name})," — ",(v.django_apps||[]).join(", ")||"no apps"," ·"," ",(v.owners||[]).join(", ")||"unowned"]},v.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(e.rules||[]).length})]}),(e.rules||[]).map(v=>d.jsx("div",{className:"muted",children:v},v))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:y.length})]}),y.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):y.map(v=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>v.node_id&&a(v.node_id),children:[d.jsx("span",{className:`chip ${v.severity}`,children:v.severity}),v.message]})},v.rule+v.message))]}),d.jsx(Ym,{cards:e.deepening}),(w=c==null?void 0:c.points)!=null&&w.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(v=>d.jsx("i",{className:v.level||"",title:`${v.level} · ${v.findings} findings`,style:{height:`${8+Math.min(24,(v.findings||0)*4)}px`}},v.id||v.created_at))}),Object.entries(c.contexts).map(([v,g])=>{var x;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v})," — last ",((x=g[g.length-1])==null?void 0:x.findings)??0," findings"]},v)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(D0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(e.type_counts||{}).sort((v,g)=>g[1]-v[1]).slice(0,12).map(([v,g])=>d.jsxs("tr",{children:[d.jsx("td",{children:ci(v)}),d.jsx("td",{children:g})]},v))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function Ym({cards:e}){const r=e||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:O0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}Gm(Um());L0.createRoot(document.getElementById("root")).render(d.jsx(A.StrictMode,{children:d.jsx(Ab,{})}));export{Bb as a,Ob as c,Fb as i,d as j,Hb as l,bN as n,A as r,ci as t}; diff --git a/src/loadpath/static/assets/index-DuTMxUNT.js b/src/loadpath/static/assets/index-DuTMxUNT.js deleted file mode 100644 index f7f94de..0000000 --- a/src/loadpath/static/assets/index-DuTMxUNT.js +++ /dev/null @@ -1,62 +0,0 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function Lp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Hu={exports:{}},Ki={},Bu={exports:{}},Ae={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var ih;function h0(){if(ih)return Ae;ih=1;var e=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),v=Symbol.iterator;function g(R){return R===null||typeof R!="object"?null:(R=v&&R[v]||R["@@iterator"],typeof R=="function"?R:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,k={};function j(R,z,re){this.props=R,this.context=z,this.refs=k,this.updater=re||w}j.prototype.isReactComponent={},j.prototype.setState=function(R,z){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,z,"setState")},j.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function E(){}E.prototype=j.prototype;function I(R,z,re){this.props=R,this.context=z,this.refs=k,this.updater=re||w}var _=I.prototype=new E;_.constructor=I,S(_,j.prototype),_.isPureReactComponent=!0;var b=Array.isArray,L=Object.prototype.hasOwnProperty,$={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function Y(R,z,re){var oe,fe={},he=null,pe=null;if(z!=null)for(oe in z.ref!==void 0&&(pe=z.ref),z.key!==void 0&&(he=""+z.key),z)L.call(z,oe)&&!F.hasOwnProperty(oe)&&(fe[oe]=z[oe]);var Z=arguments.length-2;if(Z===1)fe.children=re;else if(1>>1,z=M[R];if(0>>1;Ra(fe,H))hea(pe,fe)?(M[R]=pe,M[he]=H,R=he):(M[R]=fe,M[oe]=H,R=oe);else if(hea(pe,H))M[R]=pe,M[he]=H,R=he;else break e}}return D}function a(M,D){var H=M.sortIndex-D.sortIndex;return H!==0?H:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();e.unstable_now=function(){return c.now()-h}}var p=[],y=[],x=1,v=null,g=3,w=!1,S=!1,k=!1,j=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function _(M){for(var D=o(y);D!==null;){if(D.callback===null)s(y);else if(D.startTime<=M)s(y),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(y)}}function b(M){if(k=!1,_(M),!S)if(o(p)!==null)S=!0,W(L);else{var D=o(y);D!==null&&U(b,D.startTime-M)}}function L(M,D){S=!1,k&&(k=!1,E(Y),Y=-1),w=!0;var H=g;try{for(_(D),v=o(p);v!==null&&(!(v.expirationTime>D)||M&&!J());){var R=v.callback;if(typeof R=="function"){v.callback=null,g=v.priorityLevel;var z=R(v.expirationTime<=D);D=e.unstable_now(),typeof z=="function"?v.callback=z:v===o(p)&&s(p),_(D)}else s(p);v=o(p)}if(v!==null)var re=!0;else{var oe=o(y);oe!==null&&U(b,oe.startTime-D),re=!1}return re}finally{v=null,g=H,w=!1}}var $=!1,F=null,Y=-1,q=5,te=-1;function J(){return!(e.unstable_now()-teM||125R?(M.sortIndex=H,r(y,M),o(p)===null&&M===o(y)&&(k?(E(Y),Y=-1):k=!0,U(b,H-R))):(M.sortIndex=z,r(p,M),S||w||(S=!0,W(L))),M},e.unstable_shouldYield=J,e.unstable_wrapCallback=function(M){var D=g;return function(){var H=g;g=D;try{return M.apply(this,arguments)}finally{g=H}}}})(Uu)),Uu}var ch;function v0(){return ch||(ch=1,Wu.exports=y0()),Wu.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var dh;function x0(){if(dh)return Ot;dh=1;var e=ps(),r=v0();function o(t){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+t,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},v={};function g(t){return p.call(v,t)?!0:p.call(x,t)?!1:y.test(t)?v[t]=!0:(x[t]=!0,!1)}function w(t,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function S(t,n,i,l){if(n===null||typeof n>"u"||w(t,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function k(t,n,i,l,f,m,N){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=t,this.type=n,this.sanitizeURL=m,this.removeEmptyString=N}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){j[t]=new k(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var n=t[0];j[n]=new k(n,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){j[t]=new k(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){j[t]=new k(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){j[t]=new k(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){j[t]=new k(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){j[t]=new k(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){j[t]=new k(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){j[t]=new k(t,5,!1,t.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function I(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var n=t.replace(E,I);j[n]=new k(n,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var n=t.replace(E,I);j[n]=new k(n,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var n=t.replace(E,I);j[n]=new k(n,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){j[t]=new k(t,1,!1,t.toLowerCase(),null,!1,!1)}),j.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){j[t]=new k(t,1,!1,t.toLowerCase(),null,!0,!0)});function _(t,n,i,l){var f=j.hasOwnProperty(n)?j[n]:null;(f!==null?f.type!==0:l||!(2T||f[N]!==m[T]){var O=` -`+f[N].replace(" at new "," at ");return t.displayName&&O.includes("")&&(O=O.replace("",t.displayName)),O}while(1<=N&&0<=T);break}}}finally{re=!1,Error.prepareStackTrace=i}return(t=t?t.displayName||t.name:"")?z(t):""}function fe(t){switch(t.tag){case 5:return z(t.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return t=oe(t.type,!1),t;case 11:return t=oe(t.type.render,!1),t;case 1:return t=oe(t.type,!0),t;default:return""}}function he(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case F:return"Fragment";case $:return"Portal";case q:return"Profiler";case Y:return"StrictMode";case Q:return"Suspense";case C:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case J:return(t.displayName||"Context")+".Consumer";case te:return(t._context.displayName||"Context")+".Provider";case ne:var n=t.render;return t=t.displayName,t||(t=n.displayName||n.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case V:return n=t.displayName||null,n!==null?n:he(t.type)||"Memo";case W:n=t._payload,t=t._init;try{return he(t(n))}catch{}}return null}function pe(t){var n=t.type;switch(t.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=n.render,t=t.displayName||t.name||"",n.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===Y?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function se(t){var n=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(t){var n=se(t)?"checked":"value",i=Object.getOwnPropertyDescriptor(t.constructor.prototype,n),l=""+t[n];if(!t.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,m=i.set;return Object.defineProperty(t,n,{configurable:!0,get:function(){return f.call(this)},set:function(N){l=""+N,m.call(this,N)}}),Object.defineProperty(t,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(N){l=""+N},stopTracking:function(){t._valueTracker=null,delete t[n]}}}}function Ne(t){t._valueTracker||(t._valueTracker=me(t))}function we(t){if(!t)return!1;var n=t._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return t&&(l=se(t)?t.checked?"true":"false":t.value),t=l,t!==i?(n.setValue(t),!0):!1}function ve(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Pe(t,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??t._wrapperState.initialChecked})}function ue(t,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),t._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function je(t,n){n=n.checked,n!=null&&_(t,"checked",n,!1)}function Le(t,n){je(t,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&t.value===""||t.value!=i)&&(t.value=""+i):t.value!==""+i&&(t.value=""+i);else if(l==="submit"||l==="reset"){t.removeAttribute("value");return}n.hasOwnProperty("value")?lt(t,n.type,i):n.hasOwnProperty("defaultValue")&<(t,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(t.defaultChecked=!!n.defaultChecked)}function nt(t,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+t._wrapperState.initialValue,i||n===t.value||(t.value=n),t.defaultValue=n}i=t.name,i!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,i!==""&&(t.name=i)}function lt(t,n,i){(n!=="number"||ve(t.ownerDocument)!==t)&&(i==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+i&&(t.defaultValue=""+i))}var ut=Array.isArray;function Ge(t,n,i,l){if(t=t.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=et.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;n.firstChild;)t.appendChild(n.firstChild)}});function Pt(t,n){if(n){var i=t.firstChild;if(i&&i===t.lastChild&&i.nodeType===3){i.nodeValue=n;return}}t.textContent=n}var bn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},di=["Webkit","ms","Moz","O"];Object.keys(bn).forEach(function(t){di.forEach(function(n){n=n+t.charAt(0).toUpperCase()+t.substring(1),bn[n]=bn[t]})});function Vn(t,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||bn.hasOwnProperty(t)&&bn[t]?(""+n).trim():n+"px"}function So(t,n){t=t.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=Vn(i,n[i],l);i==="float"&&(i="cssFloat"),l?t.setProperty(i,f):t[i]=f}}var dr=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Br(t,n){if(n){if(dr[t]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,t));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function Wn(t,n){if(t.indexOf("-")===-1)return typeof n.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Vr=null;function fr(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var hr=null,Ht=null,dt=null;function Un(t){if(t=Ai(t)){if(typeof hr!="function")throw Error(o(280));var n=t.stateNode;n&&(n=zs(n),hr(t.stateNode,t.type,n))}}function Yn(t){Ht?dt?dt.push(t):dt=[t]:Ht=t}function En(){if(Ht){var t=Ht,n=dt;if(dt=Ht=null,Un(t),n)for(t=0;t>>=0,t===0?32:31-(gi(t)/mi|0)|0}var Rn=64,Zn=4194304;function Tn(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Kt(t,n){var i=t.pendingLanes;if(i===0)return 0;var l=0,f=t.suspendedLanes,m=t.pingedLanes,N=i&268435455;if(N!==0){var T=N&~f;T!==0?l=Tn(T):(m&=N,m!==0&&(l=Tn(m)))}else N=i&~f,N!==0?l=Tn(N):m!==0&&(l=Tn(m));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,m=n&-n,f>=m||f===16&&(m&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=t.entangledLanes,n!==0)for(t=t.entanglements,n&=l;0i;i++)n.push(t);return n}function Jn(t,n,i){t.pendingLanes|=n,n!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,n=31-yt(n),t[n]=i}function Co(t,n){var i=t.pendingLanes&~n;t.pendingLanes=n,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=n,t.mutableReadLanes&=n,t.entangledLanes&=n,n=t.entanglements;var l=t.eventTimes;for(t=t.expirationTimes;0=bi),Qc=" ",Zc=!1;function Jc(t,n){switch(t){case"keyup":return ly.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ed(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var To=!1;function cy(t,n){switch(t){case"compositionend":return ed(n);case"keypress":return n.which!==32?null:(Zc=!0,Qc);case"textInput":return t=n.data,t===Qc&&Zc?null:t;default:return null}}function dy(t,n){if(To)return t==="compositionend"||!_l&&Jc(t,n)?(t=Uc(),bs=gl=wr=null,To=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-t};t=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=ad(i)}}function ud(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?ud(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function cd(){for(var t=window,n=ve();n instanceof t.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)t=n.contentWindow;else break;n=ve(t.document)}return n}function Nl(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n&&(n==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||n==="textarea"||t.contentEditable==="true")}function wy(t){var n=cd(),i=t.focusedElem,l=t.selectionRange;if(n!==i&&i&&i.ownerDocument&&ud(i.ownerDocument.documentElement,i)){if(l!==null&&Nl(i)){if(n=l.start,t=l.end,t===void 0&&(t=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(t,i.value.length);else if(t=(n=i.ownerDocument||document)&&n.defaultView||window,t.getSelection){t=t.getSelection();var f=i.textContent.length,m=Math.min(l.start,f);l=l.end===void 0?m:Math.min(l.end,f),!t.extend&&m>l&&(f=l,l=m,m=f),f=ld(i,m);var N=ld(i,l);f&&N&&(t.rangeCount!==1||t.anchorNode!==f.node||t.anchorOffset!==f.offset||t.focusNode!==N.node||t.focusOffset!==N.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),t.removeAllRanges(),m>l?(t.addRange(n),t.extend(N.node,N.offset)):(n.setEnd(N.node,N.offset),t.addRange(n)))}}for(n=[],t=i;t=t.parentNode;)t.nodeType===1&&n.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Lo=null,jl=null,Pi=null,bl=!1;function dd(t,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;bl||Lo==null||Lo!==ve(l)||(l=Lo,"selectionStart"in l&&Nl(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),Pi&&Mi(Pi,l)||(Pi=l,l=Ls(jl,"onSelect"),0Oo||(t.current=Dl[Oo],Dl[Oo]=null,Oo--)}function Be(t,n){Oo++,Dl[Oo]=t.current,t.current=n}var Nr={},St=kr(Nr),Lt=kr(!1),Jr=Nr;function Fo(t,n){var i=t.type.contextTypes;if(!i)return Nr;var l=t.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},m;for(m in i)f[m]=n[m];return l&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=n,t.__reactInternalMemoizedMaskedChildContext=f),f}function At(t){return t=t.childContextTypes,t!=null}function Ds(){Ue(Lt),Ue(St)}function bd(t,n,i){if(St.current!==Nr)throw Error(o(168));Be(St,n),Be(Lt,i)}function Ed(t,n,i){var l=t.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(t)||"Unknown",f));return H({},i,l)}function Os(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Nr,Jr=St.current,Be(St,t),Be(Lt,Lt.current),!0}function Cd(t,n,i){var l=t.stateNode;if(!l)throw Error(o(169));i?(t=Ed(t,n,Jr),l.__reactInternalMemoizedMergedChildContext=t,Ue(Lt),Ue(St),Be(St,t)):Ue(Lt),Be(Lt,i)}var tr=null,Fs=!1,Ol=!1;function Md(t){tr===null?tr=[t]:tr.push(t)}function Ry(t){Fs=!0,Md(t)}function jr(){if(!Ol&&tr!==null){Ol=!0;var t=0,n=Fe;try{var i=tr;for(Fe=1;t>=N,f-=N,nr=1<<32-yt(n)+f|i<Me?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=ie(X,Ee,K[Me],de);if(Oe===null){Ee===null&&(Ee=pt);break}t&&Ee&&Oe.alternate===null&&n(X,Ee),B=m(Oe,B,Me),be===null?Se=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Me===K.length)return i(X,Ee),Xe&&to(X,Me),Se;if(Ee===null){for(;MeMe?(pt=Ee,Ee=null):pt=Ee.sibling;var Lr=ie(X,Ee,Oe.value,de);if(Lr===null){Ee===null&&(Ee=pt);break}t&&Ee&&Lr.alternate===null&&n(X,Ee),B=m(Lr,B,Me),be===null?Se=Lr:be.sibling=Lr,be=Lr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&to(X,Me),Se;if(Ee===null){for(;!Oe.done;Me++,Oe=K.next())Oe=le(X,Oe.value,de),Oe!==null&&(B=m(Oe,B,Me),be===null?Se=Oe:be.sibling=Oe,be=Oe);return Xe&&to(X,Me),Se}for(Ee=l(X,Ee);!Oe.done;Me++,Oe=K.next())Oe=ge(Ee,X,Me,Oe.value,de),Oe!==null&&(t&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Me:Oe.key),B=m(Oe,B,Me),be===null?Se=Oe:be.sibling=Oe,be=Oe);return t&&Ee.forEach(function(f0){return n(X,f0)}),Xe&&to(X,Me),Se}function tt(X,B,K,de){if(typeof K=="object"&&K!==null&&K.type===F&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case L:e:{for(var Se=K.key,be=B;be!==null;){if(be.key===Se){if(Se=K.type,Se===F){if(be.tag===7){i(X,be.sibling),B=f(be,K.props.children),B.return=X,X=B;break e}}else if(be.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===W&&Ad(Se)===be.type){i(X,be.sibling),B=f(be,K.props),B.ref=$i(X,be,K),B.return=X,X=B;break e}i(X,be);break}else n(X,be);be=be.sibling}K.type===F?(B=uo(K.props.children,X.mode,de,K.key),B.return=X,X=B):(de=pa(K.type,K.key,K.props,null,X.mode,de),de.ref=$i(X,B,K),de.return=X,X=de)}return N(X);case $:e:{for(be=K.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===K.containerInfo&&B.stateNode.implementation===K.implementation){i(X,B.sibling),B=f(B,K.children||[]),B.return=X,X=B;break e}else{i(X,B);break}else n(X,B);B=B.sibling}B=$u(K,X.mode,de),B.return=X,X=B}return N(X);case W:return be=K._init,tt(X,B,be(K._payload),de)}if(ut(K))return xe(X,B,K,de);if(D(K))return _e(X,B,K,de);Ws(X,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,B!==null&&B.tag===6?(i(X,B.sibling),B=f(B,K),B.return=X,X=B):(i(X,B),B=Au(K,X.mode,de),B.return=X,X=B),N(X)):i(X,B)}return tt}var Wo=$d(!0),zd=$d(!1),Us=kr(null),Ys=null,Uo=null,Ul=null;function Yl(){Ul=Uo=Ys=null}function Gl(t){var n=Us.current;Ue(Us),t._currentValue=n}function Xl(t,n,i){for(;t!==null;){var l=t.alternate;if((t.childLanes&n)!==n?(t.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),t===i)break;t=t.return}}function Yo(t,n){Ys=t,Ul=Uo=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&n)!==0&&($t=!0),t.firstContext=null)}function Jt(t){var n=t._currentValue;if(Ul!==t)if(t={context:t,memoizedValue:n,next:null},Uo===null){if(Ys===null)throw Error(o(308));Uo=t,Ys.dependencies={lanes:0,firstContext:t}}else Uo=Uo.next=t;return n}var no=null;function ql(t){no===null?no=[t]:no.push(t)}function Dd(t,n,i,l){var f=n.interleaved;return f===null?(i.next=i,ql(n)):(i.next=f.next,f.next=i),n.interleaved=i,or(t,l)}function or(t,n){t.lanes|=n;var i=t.alternate;for(i!==null&&(i.lanes|=n),i=t,t=t.return;t!==null;)t.childLanes|=n,i=t.alternate,i!==null&&(i.childLanes|=n),i=t,t=t.return;return i.tag===3?i.stateNode:null}var br=!1;function Kl(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Od(t,n){t=t.updateQueue,n.updateQueue===t&&(n.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function ir(t,n){return{eventTime:t,lane:n,tag:0,payload:null,callback:null,next:null}}function Er(t,n,i){var l=t.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,or(t,i)}return f=l.interleaved,f===null?(n.next=n,ql(l)):(n.next=f.next,f.next=n),l.interleaved=n,or(t,i)}function Gs(t,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=t.pendingLanes,i|=l,n.lanes=i,vr(t,i)}}function Fd(t,n){var i=t.updateQueue,l=t.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,m=null;if(i=i.firstBaseUpdate,i!==null){do{var N={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};m===null?f=m=N:m=m.next=N,i=i.next}while(i!==null);m===null?f=m=n:m=m.next=n}else f=m=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:m,shared:l.shared,effects:l.effects},t.updateQueue=i;return}t=i.lastBaseUpdate,t===null?i.firstBaseUpdate=n:t.next=n,i.lastBaseUpdate=n}function Xs(t,n,i,l){var f=t.updateQueue;br=!1;var m=f.firstBaseUpdate,N=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,ee=O.next;O.next=null,N===null?m=ee:N.next=ee,N=O;var ae=t.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==N&&(T===null?ae.firstBaseUpdate=ee:T.next=ee,ae.lastBaseUpdate=O))}if(m!==null){var le=f.baseState;N=0,ae=ee=O=null,T=m;do{var ie=T.lane,ge=T.eventTime;if((l&ie)===ie){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=t,_e=T;switch(ie=n,ge=i,_e.tag){case 1:if(xe=_e.payload,typeof xe=="function"){le=xe.call(ge,le,ie);break e}le=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=_e.payload,ie=typeof xe=="function"?xe.call(ge,le,ie):xe,ie==null)break e;le=H({},le,ie);break e;case 2:br=!0}}T.callback!==null&&T.lane!==0&&(t.flags|=64,ie=f.effects,ie===null?f.effects=[T]:ie.push(T))}else ge={eventTime:ge,lane:ie,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(ee=ae=ge,O=le):ae=ae.next=ge,N|=ie;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;ie=T,T=ie.next,ie.next=null,f.lastBaseUpdate=ie,f.shared.pending=null}}while(!0);if(ae===null&&(O=le),f.baseState=O,f.firstBaseUpdate=ee,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do N|=f.lane,f=f.next;while(f!==n)}else m===null&&(f.shared.lanes=0);io|=N,t.lanes=N,t.memoizedState=le}}function Hd(t,n,i){if(t=n.effects,n.effects=null,t!==null)for(n=0;ni?i:4,t(!0);var l=tu.transition;tu.transition={};try{t(!1),n()}finally{Fe=i,tu.transition=l}}function af(){return en().memoizedState}function $y(t,n,i){var l=Ir(t);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},lf(t))uf(n,i);else if(i=Dd(t,n,i,l),i!==null){var f=Ct();yn(i,t,l,f),cf(i,n,l)}}function zy(t,n,i){var l=Ir(t),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(lf(t))uf(n,f);else{var m=t.alternate;if(t.lanes===0&&(m===null||m.lanes===0)&&(m=n.lastRenderedReducer,m!==null))try{var N=n.lastRenderedState,T=m(N,i);if(f.hasEagerState=!0,f.eagerState=T,fn(T,N)){var O=n.interleaved;O===null?(f.next=f,ql(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Dd(t,n,f,l),i!==null&&(f=Ct(),yn(i,t,l,f),cf(i,n,l))}}function lf(t){var n=t.alternate;return t===Ke||n!==null&&n===Ke}function uf(t,n){Fi=Qs=!0;var i=t.pending;i===null?n.next=n:(n.next=i.next,i.next=n),t.pending=n}function cf(t,n,i){if((i&4194240)!==0){var l=n.lanes;l&=t.pendingLanes,i|=l,n.lanes=i,vr(t,i)}}var ea={readContext:Jt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},Dy={readContext:Jt,useCallback:function(t,n){return $n().memoizedState=[t,n===void 0?null:n],t},useContext:Jt,useEffect:Zd,useImperativeHandle:function(t,n,i){return i=i!=null?i.concat([t]):null,Zs(4194308,4,tf.bind(null,n,t),i)},useLayoutEffect:function(t,n){return Zs(4194308,4,t,n)},useInsertionEffect:function(t,n){return Zs(4,2,t,n)},useMemo:function(t,n){var i=$n();return n=n===void 0?null:n,t=t(),i.memoizedState=[t,n],t},useReducer:function(t,n,i){var l=$n();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:n},l.queue=t,t=t.dispatch=$y.bind(null,Ke,t),[l.memoizedState,t]},useRef:function(t){var n=$n();return t={current:t},n.memoizedState=t},useState:Kd,useDebugValue:lu,useDeferredValue:function(t){return $n().memoizedState=t},useTransition:function(){var t=Kd(!1),n=t[0];return t=Ay.bind(null,t[1]),$n().memoizedState=t,[n,t]},useMutableSource:function(){},useSyncExternalStore:function(t,n,i){var l=Ke,f=$n();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(oo&30)!==0||Ud(l,n,i)}f.memoizedState=i;var m={value:i,getSnapshot:n};return f.queue=m,Zd(Gd.bind(null,l,m,t),[t]),l.flags|=2048,Vi(9,Yd.bind(null,l,m,i,n),void 0,null),i},useId:function(){var t=$n(),n=ht.identifierPrefix;if(Xe){var i=rr,l=nr;i=(l&~(1<<32-yt(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Hi++,0<\/script>",t=t.removeChild(t.firstChild)):typeof l.is=="string"?t=N.createElement(i,{is:l.is}):(t=N.createElement(i),i==="select"&&(N=t,l.multiple?N.multiple=!0:l.size&&(N.size=l.size))):t=N.createElementNS(t,i),t[Ln]=n,t[Li]=l,Pf(t,n,!1,!1),n.stateNode=t;e:{switch(N=Wn(i,l),i){case"dialog":We("cancel",t),We("close",t),f=l;break;case"iframe":case"object":case"embed":We("load",t),f=l;break;case"video":case"audio":for(f=0;fQo&&(n.flags|=128,l=!0,Wi(m,!1),n.lanes=4194304)}else{if(!l)if(t=qs(N),t!==null){if(n.flags|=128,l=!0,i=t.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Wi(m,!0),m.tail===null&&m.tailMode==="hidden"&&!N.alternate&&!Xe)return Nt(n),null}else 2*Ve()-m.renderingStartTime>Qo&&i!==1073741824&&(n.flags|=128,l=!0,Wi(m,!1),n.lanes=4194304);m.isBackwards?(N.sibling=n.child,n.child=N):(i=m.last,i!==null?i.sibling=N:n.child=N,m.last=N)}return m.tail!==null?(n=m.tail,m.rendering=n,m.tail=n.sibling,m.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return Ru(),l=n.memoizedState!==null,t!==null&&t.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Ut&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Yy(t,n){switch(Hl(n),n.tag){case 1:return At(n.type)&&Ds(),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return Go(),Ue(Lt),Ue(St),eu(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 5:return Zl(n),null;case 13:if(Ue(qe),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(o(340));Vo()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Go(),null;case 10:return Gl(n.type._context),null;case 22:case 23:return Ru(),null;case 24:return null;default:return null}}var oa=!1,jt=!1,Gy=typeof WeakSet=="function"?WeakSet:Set,ye=null;function qo(t,n){var i=t.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Je(t,n,l)}else i.current=null}function wu(t,n,i){try{i()}catch(l){Je(t,n,l)}}var Tf=!1;function Xy(t,n){if(Rl=Ns,t=cd(),Nl(t)){if("selectionStart"in t)var i={start:t.selectionStart,end:t.selectionEnd};else e:{i=(i=t.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,m=l.focusNode;l=l.focusOffset;try{i.nodeType,m.nodeType}catch{i=null;break e}var N=0,T=-1,O=-1,ee=0,ae=0,le=t,ie=null;t:for(;;){for(var ge;le!==i||f!==0&&le.nodeType!==3||(T=N+f),le!==m||l!==0&&le.nodeType!==3||(O=N+l),le.nodeType===3&&(N+=le.nodeValue.length),(ge=le.firstChild)!==null;)ie=le,le=ge;for(;;){if(le===t)break t;if(ie===i&&++ee===f&&(T=N),ie===m&&++ae===l&&(O=N),(ge=le.nextSibling)!==null)break;le=ie,ie=le.parentNode}le=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(Tl={focusedElem:t,selectionRange:i},Ns=!1,ye=n;ye!==null;)if(n=ye,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,ye=t;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var _e=xe.memoizedProps,tt=xe.memoizedState,X=n.stateNode,B=X.getSnapshotBeforeUpdate(n.elementType===n.type?_e:pn(n.type,_e),tt);X.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var K=n.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Je(n,n.return,de)}if(t=n.sibling,t!==null){t.return=n.return,ye=t;break}ye=n.return}return xe=Tf,Tf=!1,xe}function Ui(t,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&t)===t){var m=f.destroy;f.destroy=void 0,m!==void 0&&wu(n,i,m)}f=f.next}while(f!==l)}}function ia(t,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&t)===t){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function _u(t){var n=t.ref;if(n!==null){var i=t.stateNode;switch(t.tag){case 5:t=i;break;default:t=i}typeof n=="function"?n(t):n.current=t}}function Lf(t){var n=t.alternate;n!==null&&(t.alternate=null,Lf(n)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(n=t.stateNode,n!==null&&(delete n[Ln],delete n[Li],delete n[zl],delete n[Py],delete n[Iy])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function Af(t){return t.tag===5||t.tag===3||t.tag===4}function $f(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Af(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Su(t,n,i){var l=t.tag;if(l===5||l===6)t=t.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(t,n):i.insertBefore(t,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(t,i)):(n=i,n.appendChild(t)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=$s));else if(l!==4&&(t=t.child,t!==null))for(Su(t,n,i),t=t.sibling;t!==null;)Su(t,n,i),t=t.sibling}function ku(t,n,i){var l=t.tag;if(l===5||l===6)t=t.stateNode,n?i.insertBefore(t,n):i.appendChild(t);else if(l!==4&&(t=t.child,t!==null))for(ku(t,n,i),t=t.sibling;t!==null;)ku(t,n,i),t=t.sibling}var vt=null,gn=!1;function Cr(t,n,i){for(i=i.child;i!==null;)zf(t,n,i),i=i.sibling}function zf(t,n,i){if(_t&&typeof _t.onCommitFiberUnmount=="function")try{_t.onCommitFiberUnmount(In,i)}catch{}switch(i.tag){case 5:jt||qo(i,n);case 6:var l=vt,f=gn;vt=null,Cr(t,n,i),vt=l,gn=f,vt!==null&&(gn?(t=vt,i=i.stateNode,t.nodeType===8?t.parentNode.removeChild(i):t.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(gn?(t=vt,i=i.stateNode,t.nodeType===8?$l(t.parentNode,i):t.nodeType===1&&$l(t,i),ki(t)):$l(vt,i.stateNode));break;case 4:l=vt,f=gn,vt=i.stateNode.containerInfo,gn=!0,Cr(t,n,i),vt=l,gn=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var m=f,N=m.destroy;m=m.tag,N!==void 0&&((m&2)!==0||(m&4)!==0)&&wu(i,n,N),f=f.next}while(f!==l)}Cr(t,n,i);break;case 1:if(!jt&&(qo(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Je(i,n,T)}Cr(t,n,i);break;case 21:Cr(t,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,Cr(t,n,i),jt=l):Cr(t,n,i);break;default:Cr(t,n,i)}}function Df(t){var n=t.updateQueue;if(n!==null){t.updateQueue=null;var i=t.stateNode;i===null&&(i=t.stateNode=new Gy),n.forEach(function(l){var f=r0.bind(null,t,l);i.has(l)||(i.add(l),l.then(f,f))})}}function mn(t,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=N),l&=~m}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Ky(l/1960))-l,10t?16:t,Pr===null)var l=!1;else{if(t=Pr,Pr=null,ca=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=t.current;ye!==null;){var m=ye,N=m.child;if((ye.flags&16)!==0){var T=m.deletions;if(T!==null){for(var O=0;OVe()-bu?ao(t,0):ju|=i),Dt(t,n)}function Qf(t,n){n===0&&((t.mode&1)===0?n=1:(n=Zn,Zn<<=1,(Zn&130023424)===0&&(Zn=4194304)));var i=Ct();t=or(t,n),t!==null&&(Jn(t,n,i),Dt(t,i))}function n0(t){var n=t.memoizedState,i=0;n!==null&&(i=n.retryLane),Qf(t,i)}function r0(t,n){var i=0;switch(t.tag){case 13:var l=t.stateNode,f=t.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=t.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Qf(t,i)}var Zf;Zf=function(t,n,i){if(t!==null)if(t.memoizedProps!==n.pendingProps||Lt.current)$t=!0;else{if((t.lanes&i)===0&&(n.flags&128)===0)return $t=!1,Wy(t,n,i);$t=(t.flags&131072)!==0}else $t=!1,Xe&&(n.flags&1048576)!==0&&Pd(n,Bs,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;ra(t,n),t=n.pendingProps;var f=Fo(n,St.current);Yo(n,i),f=ru(null,n,l,t,f,i);var m=ou();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,At(l)?(m=!0,Os(n)):m=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Kl(n),f.updater=ta,n.stateNode=f,f._reactInternals=n,cu(n,l,t,i),n=pu(null,n,l,!0,m,i)):(n.tag=0,Xe&&m&&Fl(n),Et(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(ra(t,n),t=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=i0(l),t=pn(l,t),f){case 0:n=hu(null,n,l,t,i);break e;case 1:n=Nf(null,n,l,t,i);break e;case 11:n=xf(null,n,l,t,i);break e;case 14:n=wf(null,n,l,pn(l.type,t),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:pn(l,f),hu(t,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:pn(l,f),Nf(t,n,l,f,i);case 3:e:{if(jf(n),t===null)throw Error(o(387));l=n.pendingProps,m=n.memoizedState,f=m.element,Od(t,n),Xs(n,l,null,i);var N=n.memoizedState;if(l=N.element,m.isDehydrated)if(m={element:l,isDehydrated:!1,cache:N.cache,pendingSuspenseBoundaries:N.pendingSuspenseBoundaries,transitions:N.transitions},n.updateQueue.baseState=m,n.memoizedState=m,n.flags&256){f=Xo(Error(o(423)),n),n=bf(t,n,l,i,f);break e}else if(l!==f){f=Xo(Error(o(424)),n),n=bf(t,n,l,i,f);break e}else for(Wt=Sr(n.stateNode.containerInfo.firstChild),Vt=n,Xe=!0,hn=null,i=zd(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Vo(),l===f){n=sr(t,n,i);break e}Et(t,n,l,i)}n=n.child}return n;case 5:return Bd(n),t===null&&Vl(n),l=n.type,f=n.pendingProps,m=t!==null?t.memoizedProps:null,N=f.children,Ll(l,f)?N=null:m!==null&&Ll(l,m)&&(n.flags|=32),kf(t,n),Et(t,n,N,i),n.child;case 6:return t===null&&Vl(n),null;case 13:return Ef(t,n,i);case 4:return Ql(n,n.stateNode.containerInfo),l=n.pendingProps,t===null?n.child=Wo(n,null,l,i):Et(t,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:pn(l,f),xf(t,n,l,f,i);case 7:return Et(t,n,n.pendingProps,i),n.child;case 8:return Et(t,n,n.pendingProps.children,i),n.child;case 12:return Et(t,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,m=n.memoizedProps,N=f.value,Be(Us,l._currentValue),l._currentValue=N,m!==null)if(fn(m.value,N)){if(m.children===f.children&&!Lt.current){n=sr(t,n,i);break e}}else for(m=n.child,m!==null&&(m.return=n);m!==null;){var T=m.dependencies;if(T!==null){N=m.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(m.tag===1){O=ir(-1,i&-i),O.tag=2;var ee=m.updateQueue;if(ee!==null){ee=ee.shared;var ae=ee.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),ee.pending=O}}m.lanes|=i,O=m.alternate,O!==null&&(O.lanes|=i),Xl(m.return,i,n),T.lanes|=i;break}O=O.next}}else if(m.tag===10)N=m.type===n.type?null:m.child;else if(m.tag===18){if(N=m.return,N===null)throw Error(o(341));N.lanes|=i,T=N.alternate,T!==null&&(T.lanes|=i),Xl(N,i,n),N=m.sibling}else N=m.child;if(N!==null)N.return=m;else for(N=m;N!==null;){if(N===n){N=null;break}if(m=N.sibling,m!==null){m.return=N.return,N=m;break}N=N.return}m=N}Et(t,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Yo(n,i),f=Jt(f),l=l(f),n.flags|=1,Et(t,n,l,i),n.child;case 14:return l=n.type,f=pn(l,n.pendingProps),f=pn(l.type,f),wf(t,n,l,f,i);case 15:return _f(t,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:pn(l,f),ra(t,n),n.tag=1,At(l)?(t=!0,Os(n)):t=!1,Yo(n,i),ff(n,l,f),cu(n,l,f,i),pu(null,n,l,!0,t,i);case 19:return Mf(t,n,i);case 22:return Sf(t,n,i)}throw Error(o(156,n.tag))};function Jf(t,n){return Kn(t,n)}function o0(t,n,i,l){this.tag=t,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function nn(t,n,i,l){return new o0(t,n,i,l)}function Lu(t){return t=t.prototype,!(!t||!t.isReactComponent)}function i0(t){if(typeof t=="function")return Lu(t)?1:0;if(t!=null){if(t=t.$$typeof,t===ne)return 11;if(t===V)return 14}return 2}function Tr(t,n){var i=t.alternate;return i===null?(i=nn(t.tag,n,t.key,t.mode),i.elementType=t.elementType,i.type=t.type,i.stateNode=t.stateNode,i.alternate=t,t.alternate=i):(i.pendingProps=n,i.type=t.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=t.flags&14680064,i.childLanes=t.childLanes,i.lanes=t.lanes,i.child=t.child,i.memoizedProps=t.memoizedProps,i.memoizedState=t.memoizedState,i.updateQueue=t.updateQueue,n=t.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=t.sibling,i.index=t.index,i.ref=t.ref,i}function pa(t,n,i,l,f,m){var N=2;if(l=t,typeof t=="function")Lu(t)&&(N=1);else if(typeof t=="string")N=5;else e:switch(t){case F:return uo(i.children,f,m,n);case Y:N=8,f|=8;break;case q:return t=nn(12,i,n,f|2),t.elementType=q,t.lanes=m,t;case Q:return t=nn(13,i,n,f),t.elementType=Q,t.lanes=m,t;case C:return t=nn(19,i,n,f),t.elementType=C,t.lanes=m,t;case U:return ga(i,f,m,n);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case te:N=10;break e;case J:N=9;break e;case ne:N=11;break e;case V:N=14;break e;case W:N=16,l=null;break e}throw Error(o(130,t==null?t:typeof t,""))}return n=nn(N,i,n,f),n.elementType=t,n.type=l,n.lanes=m,n}function uo(t,n,i,l){return t=nn(7,t,l,n),t.lanes=i,t}function ga(t,n,i,l){return t=nn(22,t,l,n),t.elementType=U,t.lanes=i,t.stateNode={isHidden:!1},t}function Au(t,n,i){return t=nn(6,t,null,n),t.lanes=i,t}function $u(t,n,i){return n=nn(4,t.children!==null?t.children:[],t.key,n),n.lanes=i,n.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},n}function s0(t,n,i,l,f){this.tag=n,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ln(0),this.expirationTimes=ln(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ln(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function zu(t,n,i,l,f,m,N,T,O){return t=new s0(t,n,i,T,O),n===1?(n=1,m===!0&&(n|=8)):n=0,m=nn(3,null,null,n),t.current=m,m.stateNode=t,m.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Kl(m),t}function a0(t,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),Vu.exports=x0(),Vu.exports}var hh;function w0(){if(hh)return Sa;hh=1;var e=Ap();return Sa.createRoot=e.createRoot,Sa.hydrateRoot=e.hydrateRoot,Sa}var _0=w0();function $p(e,r="Request failed"){const o=(e||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function $e(e,r){const o=await fetch(e,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error($p(s,o.statusText||"Request failed"))}return o.json()}const S0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Te={health:()=>$e("/api/health"),settings:()=>$e("/api/settings"),saveSettings:e=>{const r={...e};for(const o of S0)r[o]===""&&delete r[o];return $e("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>$e("/api/repos"),browse:e=>$e(`/api/fs${e?`?path=${encodeURIComponent(e)}`:""}`),gitRefs:(e,r=50)=>$e(`/api/git/refs?repo_path=${encodeURIComponent(e)}&limit=${r}`),index:(e,r=!0)=>$e("/api/index",{method:"POST",body:JSON.stringify({repo_path:e,incremental:r})}),indexStatus:e=>$e(`/api/index?repo_path=${encodeURIComponent(e)}`),indexProgress:e=>$e(`/api/index/progress?repo_path=${encodeURIComponent(e)}`),architecture:(e,r=!0)=>$e(`/api/architecture?repo_path=${encodeURIComponent(e)}&graph=${r?"1":"0"}`),architectureGraph:e=>$e(`/api/architecture/graph?repo_path=${encodeURIComponent(e)}`),review:(e,r,o,s=!0,a=!1)=>$e("/api/review",{method:"POST",body:JSON.stringify({repo_path:e,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(e,r)=>$e("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:e,node_id:r})}),reviewPr:(e,r,o,s)=>$e("/api/prs/review",{method:"POST",body:JSON.stringify({provider:e,repo:r,number:o,repo_path:s||null})}),init:(e,r=!1)=>$e("/api/init",{method:"POST",body:JSON.stringify({repo_path:e,overwrite:r})}),postComment:(e,r,o,s)=>$e("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:e,repo:r,number:o,markdown:s})}),graph:(e,r="full")=>$e(`/api/graph?repo_path=${encodeURIComponent(e)}&scope=${r}`),prs:(e,r,o="open",s)=>$e("/api/prs",{method:"POST",body:JSON.stringify({provider:e,repo:r,state:o,repo_path:s||null})}),scmRepos:e=>$e(`/api/scm/repos?provider=${encodeURIComponent(e)}`),oauthStatus:()=>$e("/api/oauth/status"),githubOAuthStart:()=>$e("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:e=>$e("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:e})}),bitbucketOAuthStart:()=>$e("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>$e("/api/oauth/gitlab/start"),oauthDisconnect:e=>$e("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:e})}),residual:e=>$e("/api/ai/residual",{method:"POST",body:JSON.stringify({review:e})}),reviews:e=>$e(`/api/reviews?repo_path=${encodeURIComponent(e)}`),getReview:(e,r)=>$e(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(e)}`),reviewDiff:(e,r,o)=>$e(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(e)}&other=${encodeURIComponent(o)}`),config:e=>$e(`/api/config?repo_path=${encodeURIComponent(e)}`),saveConfig:(e,r)=>$e("/api/config",{method:"PUT",body:JSON.stringify({repo_path:e,...r})}),addWaiver:(e,r,o,s)=>$e("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:e,rule:r,node:o||null,reason:s||""})}),marks:(e,r)=>$e(`/api/marks?repo_path=${encodeURIComponent(e)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:e=>$e(`/api/architecture/health?repo_path=${encodeURIComponent(e)}`),workspaceStatus:e=>$e(`/api/workspace/status?repo_path=${encodeURIComponent(e)}`),openEditor:(e,r,o,s)=>$e("/api/open",{method:"POST",body:JSON.stringify({repo_path:e,path:r,line:o||null,editor:s||null})}),exportHtml:e=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:e})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error($p(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(e,r,o,s)=>$e("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:e,edges:r,source_id:o,target_id:s||null})})};function k0(e,r){const o=r.trim().toLowerCase();return o?e.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):e}function N0({open:e,actions:r,onClose:o}){const[s,a]=A.useState(""),[u,c]=A.useState(0),h=A.useRef(null),p=A.useMemo(()=>k0(r,s),[r,s]);if(A.useEffect(()=>{if(!e)return;a(""),c(0);const g=window.setTimeout(()=>{var w;return(w=h.current)==null?void 0:w.focus()},0);return()=>window.clearTimeout(g)},[e]),A.useEffect(()=>{c(0)},[s]),!e)return null;const y=p.slice(0,40),x=y[Math.min(u,Math.max(y.length-1,0))],v=g=>{g&&(o(),g.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:g=>{g.target===g.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:g=>a(g.target.value),onKeyDown:g=>{g.key==="Escape"?(g.preventDefault(),o()):g.key==="ArrowDown"?(g.preventDefault(),c(w=>Math.min(Math.max(y.length-1,0),w+1))):g.key==="ArrowUp"?(g.preventDefault(),c(w=>Math.max(0,w-1))):g.key==="Enter"&&(g.preventDefault(),v(x))}}),d.jsxs("ul",{children:[y.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,y.map((g,w)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:w===u?"active":"",onMouseEnter:()=>c(w),onClick:()=>v(g),children:[d.jsx("span",{children:g.label}),g.hint?d.jsx("span",{className:"muted",children:g.hint}):null]})},g.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function j0({config:e,busy:r,onSave:o,onWaiver:s}){const[a,u]=A.useState(e),[c,h]=A.useState(e.available_rules[0]||""),[p,y]=A.useState(""),[x,v]=A.useState("");A.useEffect(()=>{u(e)},[e]);const g=Object.entries(a.contexts||{}),w=(I,_,b)=>{const L=a.contexts[I];if(!L)return;const $=F=>F.split(",").map(Y=>Y.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[I]:{...L,[_]:_==="name"?b:$(b)}}})},S=(I,_)=>{const b=_.trim();if(!b||b===I)return;const{[I]:L,...$}=a.contexts;L&&u({...a,contexts:{...$,[b]:{...L,name:b}}})},k=()=>{let I=1;for(;a.contexts[`context-${I}`];)I+=1;const _=`context-${I}`;u({...a,contexts:{...a.contexts,[_]:{name:_,django_apps:[],react:[],public_api:[],owners:[]}}})},j=I=>{const{[I]:_,...b}=a.contexts;u({...a,contexts:b})},E=I=>{const _=a.rules.includes(I);u({...a,rules:_?a.rules.filter(b=>b!==I):[...a.rules,I]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),g.map(([I,_])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:I})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:I,"data-testid":`config-context-name-${I}`,onBlur:b=>S(I,b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(_.django_apps||[]).join(", "),onChange:b=>w(I,"django_apps",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(_.react||[]).join(", "),onChange:b=>w(I,"react",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(_.public_api||[]).join(", "),onChange:b=>w(I,"public_api",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(_.owners||[]).join(", "),onChange:b=>w(I,"owners",b.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>j(I),children:"Remove context"})]},I)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:k,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(I=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(I),onChange:()=>E(I)}),I]},I))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((I,_)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:I.rule}),I.node?` · ${I.node}`:"",I.reason?` — ${I.reason}`:""]},`${I.rule}:${I.node}:${_}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:I=>h(I.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(I=>d.jsx("option",{value:I,children:I},I))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:I=>y(I.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:I=>v(I.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function rs(e){return e.replaceAll("_"," ")}function b0(e){return e.replaceAll("_"," ")}function ci(e){return e.split(".").pop()||e}function lc(e){if(!e)return"";const r=new Date(e);return Number.isNaN(r.getTime())?e:r.toLocaleString()}function E0(e){return e.split(/[\\/]/).filter(Boolean).pop()||e}function Dr(e){return e.replace(/([/\\._:@-])/g,"$1​")}function _o({className:e,children:r}){return d.jsx("svg",{className:e,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function C0({className:e}){return d.jsxs(_o,{className:e,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function M0({className:e}){return d.jsxs(_o,{className:e,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function P0({className:e}){return d.jsxs(_o,{className:e,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function I0({className:e}){return d.jsxs(_o,{className:e,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function R0({className:e}){return d.jsxs(_o,{className:e,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function zp({className:e}){return d.jsx(_o,{className:e,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function T0({className:e}){return d.jsx(_o,{className:e,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const L0="modulepreload",A0=function(e,r){return new URL(e,r).href},ph={},$0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(v=>Promise.resolve(v).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),y=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=A0(x,s),x in ph)return;ph[x]=!0;const v=x.endsWith(".css"),g=v?'[rel="stylesheet"]':"";if(!!s)for(let k=h.length-1;k>=0;k--){const j=h[k];if(j.href===x&&(!v||j.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${g}`))return;const S=document.createElement("link");if(S.rel=v?"stylesheet":L0,v||(S.as="script"),S.crossOrigin="",S.href=x,y&&S.setAttribute("nonce",y),document.head.appendChild(S),v)return new Promise((k,j)=>{S.addEventListener("load",k),S.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function ot(e){if(typeof e=="string"||typeof e=="number")return""+e;let r="";if(Array.isArray(e))for(let o=0,s;o{}};function el(){for(var e=0,r=arguments.length,o={},s;e=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}La.prototype=el.prototype={constructor:La,on:function(e,r){var o=this._,s=D0(e+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),mh.hasOwnProperty(r)?{space:mh[r],local:e}:e}function F0(e){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===uc&&r.documentElement.namespaceURI===uc?r.createElement(e):r.createElementNS(o,e)}}function H0(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Dp(e){var r=tl(e);return(r.local?H0:F0)(r)}function B0(){}function kc(e){return e==null?B0:function(){return this.querySelector(e)}}function V0(e){typeof e!="function"&&(e=kc(e));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=_&&(_=I+1);!(L=j[_])&&++_=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function pv(e){e||(e=gv);function r(v,g){return v&&g?e(v.__data__,g.__data__):!v-!g}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:e>=r?0:NaN}function mv(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function yv(){return Array.from(this)}function vv(){for(var e=this._groups,r=0,o=e.length;r1?this.each((r==null?Mv:typeof r=="function"?Iv:Pv)(e,r,o??"")):ri(this.node(),e)}function ri(e,r){return e.style.getPropertyValue(r)||Vp(e).getComputedStyle(e,null).getPropertyValue(r)}function Tv(e){return function(){delete this[e]}}function Lv(e,r){return function(){this[e]=r}}function Av(e,r){return function(){var o=r.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function $v(e,r){return arguments.length>1?this.each((r==null?Tv:typeof r=="function"?Av:Lv)(e,r)):this.node()[e]}function Wp(e){return e.trim().split(/^|\s+/)}function Nc(e){return e.classList||new Up(e)}function Up(e){this._node=e,this._names=Wp(e.getAttribute("class")||"")}Up.prototype={add:function(e){var r=this._names.indexOf(e);r<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var r=this._names.indexOf(e);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Yp(e,r){for(var o=Nc(e),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function cx(e){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>e;function cc(e,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:y,dispatch:x}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:x}})}cc.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function wx(e){return!e.ctrlKey&&!e.button}function _x(){return this.parentNode}function Sx(e,r){return r??{x:e.x,y:e.y}}function kx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Zp(){var e=wx,r=_x,o=Sx,s=kx,a={},u=el("start","drag","end"),c=0,h,p,y,x,v=0;function g(b){b.on("mousedown.drag",w).filter(s).on("touchstart.drag",j).on("touchmove.drag",E,xx).on("touchend.drag touchcancel.drag",I).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(b,L){if(!(x||!e.call(this,b,L))){var $=_(this,r.call(this,b,L),b,L,"mouse");$&&(Yt(b.view).on("mousemove.drag",S,os).on("mouseup.drag",k,os),Kp(b.view),Yu(b),y=!1,h=b.clientX,p=b.clientY,$("start",b))}}function S(b){if(ti(b),!y){var L=b.clientX-h,$=b.clientY-p;y=L*L+$*$>v}a.mouse("drag",b)}function k(b){Yt(b.view).on("mousemove.drag mouseup.drag",null),Qp(b.view,y),ti(b),a.mouse("end",b)}function j(b,L){if(e.call(this,b,L)){var $=b.changedTouches,F=r.call(this,b,L),Y=$.length,q,te;for(q=0;q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?Na(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?Na(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=jx.exec(e))?new Ft(r[1],r[2],r[3],1):(r=bx.exec(e))?new Ft(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=Ex.exec(e))?Na(r[1],r[2],r[3],r[4]):(r=Cx.exec(e))?Na(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=Mx.exec(e))?kh(r[1],r[2]/100,r[3]/100,1):(r=Px.exec(e))?kh(r[1],r[2]/100,r[3]/100,r[4]):yh.hasOwnProperty(e)?wh(yh[e]):e==="transparent"?new Ft(NaN,NaN,NaN,0):null}function wh(e){return new Ft(e>>16&255,e>>8&255,e&255,1)}function Na(e,r,o,s){return s<=0&&(e=r=o=NaN),new Ft(e,r,o,s)}function Tx(e){return e instanceof ms||(e=mo(e)),e?(e=e.rgb(),new Ft(e.r,e.g,e.b,e.opacity)):new Ft}function dc(e,r,o,s){return arguments.length===1?Tx(e):new Ft(e,r,o,s??1)}function Ft(e,r,o,s){this.r=+e,this.g=+r,this.b=+o,this.opacity=+s}jc(Ft,dc,Jp(ms,{brighter(e){return e=e==null?Fa:Math.pow(Fa,e),new Ft(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?is:Math.pow(is,e),new Ft(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ft(ho(this.r),ho(this.g),ho(this.b),Ha(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:_h,formatHex:_h,formatHex8:Lx,formatRgb:Sh,toString:Sh}));function _h(){return`#${fo(this.r)}${fo(this.g)}${fo(this.b)}`}function Lx(){return`#${fo(this.r)}${fo(this.g)}${fo(this.b)}${fo((isNaN(this.opacity)?1:this.opacity)*255)}`}function Sh(){const e=Ha(this.opacity);return`${e===1?"rgb(":"rgba("}${ho(this.r)}, ${ho(this.g)}, ${ho(this.b)}${e===1?")":`, ${e})`}`}function Ha(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ho(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function fo(e){return e=ho(e),(e<16?"0":"")+e.toString(16)}function kh(e,r,o,s){return s<=0?e=r=o=NaN:o<=0||o>=1?e=r=NaN:r<=0&&(e=NaN),new xn(e,r,o,s)}function eg(e){if(e instanceof xn)return new xn(e.h,e.s,e.l,e.opacity);if(e instanceof ms||(e=mo(e)),!e)return new xn;if(e instanceof xn)return e;e=e.rgb();var r=e.r/255,o=e.g/255,s=e.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new xn(c,h,p,e.opacity)}function Ax(e,r,o,s){return arguments.length===1?eg(e):new xn(e,r,o,s??1)}function xn(e,r,o,s){this.h=+e,this.s=+r,this.l=+o,this.opacity=+s}jc(xn,Ax,Jp(ms,{brighter(e){return e=e==null?Fa:Math.pow(Fa,e),new xn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?is:Math.pow(is,e),new xn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,r=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Ft(Gu(e>=240?e-240:e+120,a,s),Gu(e,a,s),Gu(e<120?e+240:e-120,a,s),this.opacity)},clamp(){return new xn(Nh(this.h),ja(this.s),ja(this.l),Ha(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Ha(this.opacity);return`${e===1?"hsl(":"hsla("}${Nh(this.h)}, ${ja(this.s)*100}%, ${ja(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Nh(e){return e=(e||0)%360,e<0?e+360:e}function ja(e){return Math.max(0,Math.min(1,e||0))}function Gu(e,r,o){return(e<60?r+(o-r)*e/60:e<180?o:e<240?r+(o-r)*(240-e)/60:r)*255}const bc=e=>()=>e;function $x(e,r){return function(o){return e+o*r}}function zx(e,r,o){return e=Math.pow(e,o),r=Math.pow(r,o)-e,o=1/o,function(s){return Math.pow(e+s*r,o)}}function Dx(e){return(e=+e)==1?tg:function(r,o){return o-r?zx(r,o,e):bc(isNaN(r)?o:r)}}function tg(e,r){var o=r-e;return o?$x(e,o):bc(isNaN(e)?r:e)}const Ba=(function e(r){var o=Dx(r);function s(a,u){var c=o((a=dc(a)).r,(u=dc(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),y=tg(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=y(x),a+""}}return s.gamma=e,s})(1);function Ox(e,r){r||(r=[]);var o=e?Math.min(r.length,e.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Dn(s,a)})),o=Xu.lastIndex;return o180?x+=360:x-y>180&&(y+=360),g.push({i:v.push(a(v)+"rotate(",null,s)-2,x:Dn(y,x)})):x&&v.push(a(v)+"rotate("+x+s)}function h(y,x,v,g){y!==x?g.push({i:v.push(a(v)+"skewX(",null,s)-2,x:Dn(y,x)}):x&&v.push(a(v)+"skewX("+x+s)}function p(y,x,v,g,w,S){if(y!==v||x!==g){var k=w.push(a(w)+"scale(",null,",",null,")");S.push({i:k-4,x:Dn(y,v)},{i:k-2,x:Dn(x,g)})}else(v!==1||g!==1)&&w.push(a(w)+"scale("+v+","+g+")")}return function(y,x){var v=[],g=[];return y=e(y),x=e(x),u(y.translateX,y.translateY,x.translateX,x.translateY,v,g),c(y.rotate,x.rotate,v,g),h(y.skewX,x.skewX,v,g),p(y.scaleX,y.scaleY,x.scaleX,x.scaleY,v,g),y=x=null,function(w){for(var S=-1,k=g.length,j;++S=0&&e._call.call(void 0,r),e=e._next;--oi}function Eh(){yo=(Wa=as.now())+nl,oi=Ji=0;try{ew()}finally{oi=0,nw(),yo=0}}function tw(){var e=as.now(),r=e-Wa;r>ig&&(nl-=r,Wa=e)}function nw(){for(var e,r=Va,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),e=r,r=r._next):(o=r._next,r._next=null,r=e?e._next=o:Va=o);es=e,pc(s)}function pc(e){if(!oi){Ji&&(Ji=clearTimeout(Ji));var r=e-yo;r>24?(e<1/0&&(Ji=setTimeout(Eh,e-as.now()-nl)),Qi&&(Qi=clearInterval(Qi))):(Qi||(Wa=as.now(),Qi=setInterval(tw,ig)),oi=1,sg(Eh))}}function Ch(e,r,o){var s=new Ua;return r=r==null?0:+r,s.restart(a=>{s.stop(),e(a+r)},r,o),s}var rw=el("start","end","cancel","interrupt"),ow=[],lg=0,Mh=1,gc=2,$a=3,Ph=4,mc=5,za=6;function rl(e,r,o,s,a,u){var c=e.__transition;if(!c)e.__transition={};else if(o in c)return;iw(e,o,{name:r,index:s,group:a,on:rw,tween:ow,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:lg})}function Cc(e,r){var o=Nn(e,r);if(o.state>lg)throw new Error("too late; already scheduled");return o}function Hn(e,r){var o=Nn(e,r);if(o.state>$a)throw new Error("too late; already running");return o}function Nn(e,r){var o=e.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function iw(e,r,o){var s=e.__transition,a;s[r]=o,o.timer=ag(u,0,o.time);function u(y){o.state=Mh,o.timer.restart(c,o.delay,o.time),o.delay<=y&&c(y-o.delay)}function c(y){var x,v,g,w;if(o.state!==Mh)return p();for(x in s)if(w=s[x],w.name===o.name){if(w.state===$a)return Ch(c);w.state===Ph?(w.state=za,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete s[x]):+xgc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function Aw(e,r,o){var s,a,u=Lw(r)?Cc:Hn;return function(){var c=u(this,e),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function $w(e,r){var o=this._id;return arguments.length<2?Nn(this.node(),o).on.on(e):this.each(Aw(o,e,r))}function zw(e){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==e)return;r&&r.removeChild(this)}}function Dw(){return this.on("end.remove",zw(this._id))}function Ow(e){var r=this._name,o=this._id;typeof e!="function"&&(e=kc(e));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>e;function c1(e,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function ur(e,r,o){this.k=e,this.x=r,this.y=o}ur.prototype={constructor:ur,scale:function(e){return e===1?this:new ur(this.k*e,this.x,this.y)},translate:function(e,r){return e===0&r===0?this:new ur(this.k,this.x+this.k*e,this.y+this.k*r)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ol=new ur(1,0,0);fg.prototype=ur.prototype;function fg(e){for(;!e.__zoom;)if(!(e=e.parentNode))return ol;return e.__zoom}function qu(e){e.stopImmediatePropagation()}function Zi(e){e.preventDefault(),e.stopImmediatePropagation()}function d1(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function f1(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Ih(){return this.__zoom||ol}function h1(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function p1(){return navigator.maxTouchPoints||"ontouchstart"in this}function g1(e,r,o){var s=e.invertX(r[0][0])-o[0][0],a=e.invertX(r[1][0])-o[1][0],u=e.invertY(r[0][1])-o[0][1],c=e.invertY(r[1][1])-o[1][1];return e.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function hg(){var e=d1,r=f1,o=g1,s=h1,a=p1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Aa,y=el("start","zoom","end"),x,v,g,w=500,S=150,k=0,j=10;function E(C){C.property("__zoom",Ih).on("wheel.zoom",Y,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",J).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",Q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",Ih),C!==M?L(C,V,W,U):M.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(C,V,W,U){E.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},E.scaleTo=function(C,V,W,U){E.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,H=W==null?b(M):typeof W=="function"?W.apply(this,arguments):W,R=D.invert(H),z=typeof V=="function"?V.apply(this,arguments):V;return o(_(I(D,z),H,R),M,c)},W,U)},E.translateBy=function(C,V,W,U){E.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},E.translateTo=function(C,V,W,U,M){E.transform(C,function(){var D=r.apply(this,arguments),H=this.__zoom,R=U==null?b(D):typeof U=="function"?U.apply(this,arguments):U;return o(ol.translate(R[0],R[1]).scale(H.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function I(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new ur(V,C.x,C.y)}function _(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new ur(C.k,U,M)}function b(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function L(C,V,W,U){C.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,H=$(M,D).event(U),R=r.apply(M,D),z=W==null?b(R):typeof W=="function"?W.apply(M,D):W,re=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(z).concat(re/oe.k),fe.invert(z).concat(re/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=re/Z[2];pe=new ur(se,z[0]-Z[0]*se,z[1]-Z[1]*se)}H.zoom(null,pe)}})}function $(C,V,W){return!W&&C.__zooming||new F(C,V)}function F(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Yt(this.that).datum();y.call(C,this.that,new c1(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:y}),V)}};function Y(C,...V){if(!e.apply(this,arguments))return;var W=$(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=vn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Da(this),W.start()}Zi(C),W.wheel=setTimeout(H,S),W.zoom("mouse",o(_(I(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function H(){W.wheel=null,W.end()}}function q(C,...V){if(g||!e.apply(this,arguments))return;var W=C.currentTarget,U=$(this,V,!0).event(C),M=Yt(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",re,!0),D=vn(C,W),H=C.clientX,R=C.clientY;Kp(C.view),qu(C),U.mouse=[D,this.__zoom.invert(D)],Da(this),U.start();function z(oe){if(Zi(oe),!U.moved){var fe=oe.clientX-H,he=oe.clientY-R;U.moved=fe*fe+he*he>k}U.event(oe).zoom("mouse",o(_(U.that.__zoom,U.mouse[0]=vn(oe,W),U.mouse[1]),U.extent,c))}function re(oe){M.on("mousemove.zoom mouseup.zoom",null),Qp(oe.view,U.moved),Zi(oe),U.event(oe).end()}}function te(C,...V){if(e.apply(this,arguments)){var W=this.__zoom,U=vn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),H=o(_(I(W,D),U,M),r.apply(this,V),c);Zi(C),h>0?Yt(this).transition().duration(h).call(L,H,U,C):Yt(this).call(E.transform,H,U,C)}}function J(C,...V){if(e.apply(this,arguments)){var W=C.touches,U=W.length,M=$(this,V,C.changedTouches.length===U).event(C),D,H,R,z;for(qu(C),H=0;H`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ls=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],pg=["Enter"," ","Escape"],gg={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:r,y:o})=>`Moved selected node ${e}. New position, x: ${r}, y: ${o}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var ii;(function(e){e.Strict="strict",e.Loose="loose"})(ii||(ii={}));var po;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(po||(po={}));var us;(function(e){e.Partial="partial",e.Full="full"})(us||(us={}));const mg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Or;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Or||(Or={}));var cs;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(cs||(cs={}));var ke;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ke||(ke={}));const Rh={[ke.Left]:ke.Right,[ke.Right]:ke.Left,[ke.Top]:ke.Bottom,[ke.Bottom]:ke.Top};function yg(e){return e===null?null:e?"valid":"invalid"}const vg=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,m1=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Pc=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ys=(e,r=[0,0])=>{const{width:o,height:s}=jn(e),a=e.origin??r,u=o*a[0],c=s*a[1];return{x:e.position.x-u,y:e.position.y-c}},y1=(e,r={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=e.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):Pc(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,il(a,Ya(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?sl(s):{x:0,y:0,width:0,height:0}},vs=(e,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return e.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=il(o,Ya(a)),s=!0)}),s?sl(o):{x:0,y:0,width:0,height:0}},Ic=(e,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,y=r.width/a,x=r.height/a,v=[];for(const g of e.values()){const{measured:w,selectable:S=!0,hidden:k=!1}=g;if(c&&!S||k)continue;const j=w.width??g.width??g.initialWidth??0,E=w.height??g.height??g.initialHeight??0,{x:I,y:_}=g.internals.positionAbsolute,b=Sg(h,p,y,x,I,_,j,E),L=j*E,$=u&&b>0;(!g.internals.handleBounds||$||b>=L||g.dragging)&&v.push(g)}return v},v1=(e,r)=>{const o=new Set;return e.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function x1(e,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return e.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=jn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function w1({nodes:e,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(e.size===0)return!0;const h=x1(e,c),p=vs(h),y=Tc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(y,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function xg({nodeId:e,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(e),h=c.parentId?o.get(c.parentId):void 0,{x:p,y}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let v=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",Sn.error005());else{const{width:w,height:S}=jn(h);w&&S&&(v=[[p,y],[p+w,y+S]])}else h&&xo(c.extent)&&(v=[[c.extent[0][0]+p,c.extent[0][1]+y],[c.extent[1][0]+p,c.extent[1][1]+y]]);const g=xo(v)?vo(r,v,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",Sn.error015())),{position:{x:g.x-p+(c.measured.width??0)*x[0],y:g.y-y+(c.measured.height??0)*x[1]},positionAbsolute:g}}async function _1({nodesToRemove:e=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(e.map(g=>g.id)),c=[];for(const g of o){if(g.deletable===!1)continue;const w=u.has(g.id),S=!w&&g.parentId&&c.find(k=>k.id===g.parentId);(w||S)&&c.push(g)}const h=new Set(r.map(g=>g.id)),p=s.filter(g=>g.deletable!==!1),x=v1(c,p);for(const g of p)h.has(g.id)&&!x.find(S=>S.id===g.id)&&x.push(g);if(!a)return{edges:x,nodes:c};const v=await a({nodes:c,edges:x});return typeof v=="boolean"?v?{edges:x,nodes:c}:{edges:[],nodes:[]}:v}const si=(e,r=0,o=1)=>Math.min(Math.max(e,r),o),vo=(e={x:0,y:0},r,o)=>({x:si(e.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:si(e.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function wg(e,r,o){const{width:s,height:a}=jn(o),{x:u,y:c}=o.internals.positionAbsolute;return vo(e,[[u,c],[u+s,c+a]],r)}const Th=(e,r,o)=>eo?-si(Math.abs(e-o),1,r)/r:0,Rc=(e,r,o=15,s=40)=>{const a=Th(e.x,s,r.width-s)*o,u=Th(e.y,s,r.height-s)*o;return[a,u]},il=(e,r)=>({x:Math.min(e.x,r.x),y:Math.min(e.y,r.y),x2:Math.max(e.x2,r.x2),y2:Math.max(e.y2,r.y2)}),yc=({x:e,y:r,width:o,height:s})=>({x:e,y:r,x2:e+o,y2:r+s}),sl=({x:e,y:r,x2:o,y2:s})=>({x:e,y:r,width:o-e,height:s-r}),ds=(e,r=[0,0])=>{var a,u;const{x:o,y:s}=Pc(e)?e.internals.positionAbsolute:ys(e,r);return{x:o,y:s,width:((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0,height:((u=e.measured)==null?void 0:u.height)??e.height??e.initialHeight??0}},Ya=(e,r=[0,0])=>{var a,u;const{x:o,y:s}=Pc(e)?e.internals.positionAbsolute:ys(e,r);return{x:o,y:s,x2:o+(((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0),y2:s+(((u=e.measured)==null?void 0:u.height)??e.height??e.initialHeight??0)}},_g=(e,r)=>sl(il(yc(e),yc(r))),Sg=(e,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(e+o,a+c)-Math.max(e,a)),y=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*y)},Ga=(e,r)=>Sg(e.x,e.y,e.width,e.height,r.x,r.y,r.width,r.height),Lh=e=>wn(e.width)&&wn(e.height)&&wn(e.x)&&wn(e.y),wn=e=>!isNaN(e)&&isFinite(e),kg=(e,r)=>(o,s)=>{},xs=(e,r=[1,1])=>({x:r[0]*Math.round(e.x/r[0]),y:r[1]*Math.round(e.y/r[1])}),ws=({x:e,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(e-o)/a,y:(r-s)/a};return u?xs(h,c):h},ai=({x:e,y:r},[o,s,a])=>({x:e*a+o,y:r*a+s});function Jo(e,r){if(typeof e=="number")return Math.floor((r-r/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const o=parseFloat(e);if(!Number.isNaN(o))return Math.floor(o)}if(typeof e=="string"&&e.endsWith("%")){const o=parseFloat(e);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function S1(e,r,o){if(typeof e=="string"||typeof e=="number"){const s=Jo(e,o),a=Jo(e,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof e=="object"){const s=Jo(e.top??e.y??0,o),a=Jo(e.bottom??e.y??0,o),u=Jo(e.left??e.x??0,r),c=Jo(e.right??e.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function k1(e,r,o,s,a,u){const{x:c,y:h}=ai(e,[r,o,s]),{x:p,y}=ai({x:e.x+e.width,y:e.y+e.height},[r,o,s]),x=a-p,v=u-y;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(v)}}const Tc=(e,r,o,s,a,u)=>{const c=S1(u,r,o),h=(r-c.x)/e.width,p=(o-c.y)/e.height,y=Math.min(h,p),x=si(y,s,a),v=e.x+e.width/2,g=e.y+e.height/2,w=r/2-v*x,S=o/2-g*x,k=k1(e,w,S,x,r,o),j={left:Math.min(k.left-c.left,0),top:Math.min(k.top-c.top,0),right:Math.min(k.right-c.right,0),bottom:Math.min(k.bottom-c.bottom,0)};return{x:w-j.left+j.right,y:S-j.top+j.bottom,zoom:x}},fs=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function xo(e){return e!=null&&e!=="parent"}function jn(e){var r,o;return{width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}}function Ng(e){var r,o;return(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth)!==void 0&&(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight)!==void 0}function jg(e,r={width:0,height:0},o,s,a){const u={...e},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function Ah(e,r){if(e.size!==r.size)return!1;for(const o of e)if(!r.has(o))return!1;return!0}function N1(){let e,r;return{promise:new Promise((s,a)=>{e=s,r=a}),resolve:e,reject:r}}function j1(e){return{...gg,...e||{}}}function ns(e,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=_n(e),h=ws({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y}=o?xs(h,r):h;return{xSnapped:p,ySnapped:y,...h}}const Lc=e=>({width:e.offsetWidth,height:e.offsetHeight}),bg=e=>{var r;return((r=e==null?void 0:e.getRootNode)==null?void 0:r.call(e))||(window==null?void 0:window.document)},b1=["INPUT","SELECT","TEXTAREA"];function Eg(e){var s,a;const r=((a=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:a[0])||e.target;return(r==null?void 0:r.nodeType)!==1?!1:b1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const Cg=e=>"clientX"in e,_n=(e,r)=>{var u,c;const o=Cg(e),s=o?e.clientX:(u=e.touches)==null?void 0:u[0].clientX,a=o?e.clientY:(c=e.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},$h=(e,r,o,s,a)=>{const u=r.querySelectorAll(`.${e}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:e,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...Lc(c)}})};function Mg({sourceX:e,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=e*.125+a*.375+c*.375+o*.125,y=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-e),v=Math.abs(y-r);return[p,y,x,v]}function Ca(e,r){return e>=0?.5*e:r*25*Math.sqrt(-e)}function zh({pos:e,x1:r,y1:o,x2:s,y2:a,c:u}){switch(e){case ke.Left:return[r-Ca(r-s,u),o];case ke.Right:return[r+Ca(s-r,u),o];case ke.Top:return[r,o-Ca(o-a,u)];case ke.Bottom:return[r,o+Ca(a-o,u)]}}function Pg({sourceX:e,sourceY:r,sourcePosition:o=ke.Bottom,targetX:s,targetY:a,targetPosition:u=ke.Top,curvature:c=.25}){const[h,p]=zh({pos:o,x1:e,y1:r,x2:s,y2:a,c}),[y,x]=zh({pos:u,x1:s,y1:a,x2:e,y2:r,c}),[v,g,w,S]=Mg({sourceX:e,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:y,targetControlY:x});return[`M${e},${r} C${h},${p} ${y},${x} ${s},${a}`,v,g,w,S]}function Ig({sourceX:e,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-e)/2,u=o0}const M1=({source:e,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${e}${r||""}-${o}${s||""}`,P1=(e,r)=>r.some(o=>o.source===e.source&&o.target===e.target&&(o.sourceHandle===e.sourceHandle||!o.sourceHandle&&!e.sourceHandle)&&(o.targetHandle===e.targetHandle||!o.targetHandle&&!e.targetHandle)),I1=(e,r,o={})=>{var u;if(!e.source||!e.target)return(u=o.onError)==null||u.call(o,"006",Sn.error006()),r;const s=o.getEdgeId||M1;let a;return vg(e)?a={...e}:a={...e,id:s(e)},P1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function Rg({sourceX:e,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=Ig({sourceX:e,sourceY:r,targetX:o,targetY:s});return[`M ${e},${r}L ${o},${s}`,a,u,c,h]}const Dh={[ke.Left]:{x:-1,y:0},[ke.Right]:{x:1,y:0},[ke.Top]:{x:0,y:-1},[ke.Bottom]:{x:0,y:1}},R1=({source:e,sourcePosition:r=ke.Bottom,target:o})=>r===ke.Left||r===ke.Right?e.xMath.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2));function T1({source:e,sourcePosition:r=ke.Bottom,target:o,targetPosition:s=ke.Top,center:a,offset:u,stepPosition:c}){const h=Dh[r],p=Dh[s],y={x:e.x+h.x*u,y:e.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},v=R1({source:y,sourcePosition:r,target:x}),g=v.x!==0?"x":"y",w=v[g];let S=[],k,j;const E={x:0,y:0},I={x:0,y:0},[,,_,b]=Ig({sourceX:e.x,sourceY:e.y,targetX:o.x,targetY:o.y});if(h[g]*p[g]===-1){g==="x"?(k=a.x??y.x+(x.x-y.x)*c,j=a.y??(y.y+x.y)/2):(k=a.x??(y.x+x.x)/2,j=a.y??y.y+(x.y-y.y)*c);const Y=[{x:k,y:y.y},{x:k,y:x.y}],q=[{x:y.x,y:j},{x:x.x,y:j}];h[g]===w?S=g==="x"?Y:q:S=g==="x"?q:Y}else{const Y=[{x:y.x,y:x.y}],q=[{x:x.x,y:y.y}];if(g==="x"?S=h.x===w?q:Y:S=h.y===w?Y:q,r===s){const C=Math.abs(e[g]-o[g]);if(C<=u){const V=Math.min(u-1,u-C);h[g]===w?E[g]=(y[g]>e[g]?-1:1)*V:I[g]=(x[g]>o[g]?-1:1)*V}}if(r!==s){const C=g==="x"?"y":"x",V=h[g]===p[C],W=y[C]>x[C],U=y[C]=Q?(k=(te.x+J.x)/2,j=S[0].y):(k=S[0].x,j=(te.y+J.y)/2)}const L={x:y.x+E.x,y:y.y+E.y},$={x:x.x+I.x,y:x.y+I.y};return[[e,...L.x!==S[0].x||L.y!==S[0].y?[L]:[],...S,...$.x!==S[S.length-1].x||$.y!==S[S.length-1].y?[$]:[],o],k,j,_,b]}function L1(e,r,o,s){const a=Math.min(Oh(e,r)/2,Oh(r,o)/2,s),{x:u,y:c}=r;if(e.x===u&&u===o.x||e.y===c&&c===o.y)return`L${u} ${c}`;if(e.y===c){const y=e.xo.id===r):e[0])||null}function vc(e,r){return e?typeof e=="string"?e:`${r?`${r}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function $1(e,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return e.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const y=vc(p,r);u.has(y)||(c.push({id:y,color:p.color||o,...p}),u.add(y))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const Tg=1e3,z1=10,Ac={nodeOrigin:[0,0],nodeExtent:ls,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},D1={...Ac,checkEquality:!0};function $c(e,r){const o={...e};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function O1(e,r,o){const s=$c(Ac,o);for(const a of e.values())if(a.parentId)Dc(a,e,r,s);else{const u=ys(a,s.nodeOrigin),c=xo(a.extent)?a.extent:s.nodeExtent,h=vo(u,c,jn(a));a.internals.positionAbsolute=h}}function F1(e,r){if(!e.handles)return e.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of e.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:e.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function zc(e){return e==="manual"}function xc(e,r,o,s={}){var x,v;const a=$c(D1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!zc(a.zIndexMode)?Tg:0;let p=e.length>0,y=!1;r.clear(),o.clear();for(const g of e){let w=c.get(g.id);if(a.checkEquality&&g===(w==null?void 0:w.internals.userNode))r.set(g.id,w);else{const S=ys(g,a.nodeOrigin),k=xo(g.extent)?g.extent:a.nodeExtent,j=vo(S,k,jn(g));w={...a.defaults,...g,measured:{width:(x=g.measured)==null?void 0:x.width,height:(v=g.measured)==null?void 0:v.height},internals:{positionAbsolute:j,handleBounds:F1(g,w),z:Lg(g,h,a.zIndexMode),userNode:g}},r.set(g.id,w)}(w.measured===void 0||w.measured.width===void 0||w.measured.height===void 0)&&!w.hidden&&(p=!1),g.parentId&&Dc(w,r,o,s,u),y||(y=g.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:y}}function H1(e,r){if(!e.parentId)return;const o=r.get(e.parentId);o?o.set(e.id,e):r.set(e.parentId,new Map([[e.id,e]]))}function Dc(e,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=$c(Ac,s),y=e.parentId,x=r.get(y);if(!x){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}H1(e,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*z1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const v=u&&!zc(p)?Tg:0,{x:g,y:w,z:S}=B1(e,x,c,h,v,p),{positionAbsolute:k}=e.internals,j=g!==k.x||w!==k.y;(j||S!==e.internals.z)&&r.set(e.id,{...e,internals:{...e.internals,positionAbsolute:j?{x:g,y:w}:k,z:S}})}function Lg(e,r,o){const s=wn(e.zIndex)?e.zIndex:0;return zc(o)?s:s+(e.selected?r:0)}function B1(e,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=jn(e),y=ys(e,o),x=xo(e.extent)?vo(y,e.extent,p):y;let v=vo({x:c+x.x,y:h+x.y},s,p);e.extent==="parent"&&(v=wg(v,p,r));const g=Lg(e,a,u),w=r.internals.z??0;return{x:v.x,y:v.y,z:w>=g?w+1:g}}function Oc(e,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of e){const p=r.get(h.parentId);if(!p)continue;const y=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ds(p),x=_g(y,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},y)=>{var _;const x=p.internals.positionAbsolute,v=jn(p),g=p.origin??s,w=h.x0||S>0||E||I)&&(a.push({id:y,type:"position",position:{x:p.position.x-w+E,y:p.position.y-S+I}}),(_=o.get(y))==null||_.forEach(b=>{e.some(L=>L.id===b.id)||a.push({id:b.id,type:"position",position:{x:b.position.x+w,y:b.position.y+S}})})),(v.width0){const w=Oc(g,r,o,a);y.push(...w)}return{changes:y,updatedInternals:p}}async function W1({delta:e,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!e.x&&!e.y)return!1;const c=await r.setViewportConstrained({x:o[0]+e.x,y:o[1]+e.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Vh(e,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${e}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${e}-${u}`;const y=s.get(c)||new Map;s.set(c,y.set(o,r))}}function Ag(e,r,o){e.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},y=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Vh("source",p,x,e,a,c),Vh("target",p,y,e,u,h),r.set(s.id,s)}}function $g(e,r){if(!e.parentId)return!1;const o=r.get(e.parentId);return o?o.selected?!0:$g(o,r):!1}function Wh(e,r,o){var a;let s=e;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function U1(e,r,o,s){const a=new Map;for(const[u,c]of e)if((c.selected||c.id===s)&&(!c.parentId||!$g(c,e))&&(c.draggable||r&&typeof c.draggable>"u")){const h=e.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Ku({nodeId:e,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[y,x]of r){const v=(c=o.get(y))==null?void 0:c.internals.userNode;v&&a.push({...v,position:x.position,dragging:s})}if(!e)return[a[0],a];const u=(h=o.get(e))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(e))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function Y1({dragItems:e,snapGrid:r,x:o,y:s}){const a=e.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=xs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function G1({onNodeMouseDown:e,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,y={x:0,y:0},x=null,v=!1,g=null,w=!1,S=!1,k=null;function j({noDragClassName:I,handleSelector:_,domNode:b,isSelectable:L,nodeId:$,nodeClickDistance:F=0}){g=Yt(b);function Y({x:ne,y:Q}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:H,onError:R,updateNodePositions:z}=r();u={x:ne,y:Q};let re=!1;const oe=h.size>1,fe=oe&&V?yc(vs(h)):null,he=oe&&U?Y1({dragItems:h,snapGrid:W,x:ne,y:Q}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:ne-Z.distance.x,y:Q-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:xs(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:ve}=Z.internals,Pe=ve.x-fe.x+V[0][0],ue=ve.x+Z.measured.width-fe.x2+V[1][0],je=ve.y-fe.y+V[0][1],Le=ve.y+Z.measured.height-fe.y2+V[1][1];me=[[Pe,je],[ue,Le]]}const{position:Ne,positionAbsolute:we}=xg({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:R});re=re||Z.position.x!==Ne.x||Z.position.y!==Ne.y,Z.position=Ne,Z.internals.positionAbsolute=we}if(S=S||re,!!re&&(z(h,!0),k&&(s||D||!$&&H))){const[pe,Z]=Ku({nodeId:$,dragItems:h,nodeLookup:C});s==null||s(k,h,pe,Z),D==null||D(k,pe,Z),$||H==null||H(k,Z)}}async function q(){if(!x)return;const{transform:ne,panBy:Q,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=Rc(y,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/ne[2],u.y=(u.y??0)-U/ne[2],await Q({x:W,y:U})&&Y(u)),c=requestAnimationFrame(q)}function te(ne){var oe;const{nodeLookup:Q,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:R,unselectNodesAndEdges:z}=r();v=!0,(!D||!L)&&!C&&$&&((oe=Q.get($))!=null&&oe.selected||z()),L&&D&&$&&(e==null||e($));const re=ns(ne.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=re,h=U1(Q,V,re,$),h.size>0&&(o||H||!$&&R)){const[fe,he]=Ku({nodeId:$,dragItems:h,nodeLookup:Q});o==null||o(ne.sourceEvent,h,fe,he),H==null||H(ne.sourceEvent,fe,he),$||R==null||R(ne.sourceEvent,he)}}const J=Zp().clickDistance(F).on("start",ne=>{const{domNode:Q,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(Q==null?void 0:Q.getBoundingClientRect())||null,w=!1,S=!1,k=ne.sourceEvent,C===0&&te(ne),u=ns(ne.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),y=_n(ne.sourceEvent,x)}).on("drag",ne=>{const{autoPanOnNodeDrag:Q,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=ns(ne.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(k=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||$&&!M.has($))&&(w=!0),!w){if(!p&&Q&&v&&(p=!0,q()),!v){const H=_n(ne.sourceEvent,x),R=H.x-y.x,z=H.y-y.y;Math.sqrt(R*R+z*z)>U&&te(ne)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&v&&(y=_n(ne.sourceEvent,x),Y(D))}}).on("end",ne=>{if(!v||w){w&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,v=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:Q,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(S&&(C(h,!1),S=!1),a||V||!$&&W){const[U,M]=Ku({nodeId:$,dragItems:h,nodeLookup:Q,dragging:!1});a==null||a(ne.sourceEvent,h,U,M),V==null||V(ne.sourceEvent,U,M),$||W==null||W(ne.sourceEvent,M)}}}).filter(ne=>{const Q=ne.target;return!ne.button&&(!I||!Wh(Q,`.${I}`,b))&&(!_||Wh(Q,_,b))});g.call(J)}function E(){g==null||g.on(".drag",null)}return{update:j,destroy:E}}function X1(e,r,o){const s=[],a={x:e.x-o,y:e.y-o,width:o*2,height:o*2};for(const u of r.values())Ga(a,ds(u))>0&&s.push(u);return s}const q1=250;function K1(e,r,o,s){var h,p;let a=[],u=1/0;const c=X1(e,o,r+q1);for(const y of c){const x=[...((h=y.internals.handleBounds)==null?void 0:h.source)??[],...((p=y.internals.handleBounds)==null?void 0:p.target)??[]];for(const v of x){if(s.nodeId===v.nodeId&&s.type===v.type&&s.id===v.id)continue;const{x:g,y:w}=wo(y,v,v.position,!0),S=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(w-e.y,2));S>r||(S1){const y=s.type==="source"?"target":"source";return a.find(x=>x.type===y)??a[0]}return a[0]}function zg(e,r,o,s,a,u=!1){var y,x,v;const c=s.get(e);if(!c)return null;const h=a==="strict"?(y=c.internals.handleBounds)==null?void 0:y[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((v=c.internals.handleBounds)==null?void 0:v.target)??[]],p=(o?h==null?void 0:h.find(g=>g.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...wo(c,p,p.position,!0)}:p}function Dg(e,r){return e||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function Q1(e,r){let o=null;return r?o=!0:e&&!r&&(o=!1),o}const Og=()=>!0;function Z1(e,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:y,autoPanOnConnect:x,flowId:v,panBy:g,cancelConnection:w,onConnectStart:S,onConnect:k,onConnectEnd:j,isValidConnection:E=Og,onReconnectEnd:I,updateConnection:_,getTransform:b,getFromHandle:L,autoPanSpeed:$,dragThreshold:F=1,handleDomNode:Y}){const q=bg(e.target);let te=0,J;const{x:ne,y:Q}=_n(e),C=Dg(u,Y),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=zg(a,C,s,p,r);if(!U)return;let M=_n(e,V),D=!1,H=null,R=!1,z=null;function re(){if(!x||!V)return;const[Ne,we]=Rc(M,V,$);g({x:Ne,y:we}),te=requestAnimationFrame(re)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:wo(fe,oe,ke.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Rh[oe.position],toNode:null,pointer:M};function Z(){W=!0,_(pe),S==null||S(e,{nodeId:a,handleId:s,handleType:C})}F===0&&Z();function se(Ne){if(!W){const{x:Le,y:nt}=_n(Ne),lt=Le-ne,ut=nt-Q;if(!(lt*lt+ut*ut>F*F))return;Z()}if(!L()||!oe){me(Ne);return}const we=b();M=_n(Ne,V),J=K1(ws(M,we,!1,[1,1]),o,p,oe),D||(re(),D=!0);const ve=Fg(Ne,{handle:J,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:E,doc:q,lib:y,flowId:v,nodeLookup:p});z=ve.handleDomNode,H=ve.connection,R=Q1(!!J,ve.isValid);const Pe=p.get(a),ue=Pe?wo(Pe,oe,ke.Left,!0):pe.from,je={...pe,from:ue,isValid:R,to:ve.toHandle&&R?ai({x:ve.toHandle.x,y:ve.toHandle.y},we):M,toHandle:ve.toHandle,toPosition:R&&ve.toHandle?ve.toHandle.position:Rh[oe.position],toNode:ve.toHandle?p.get(ve.toHandle.nodeId):null,pointer:M};_(je),pe=je}function me(Ne){if(!("touches"in Ne&&Ne.touches.length>0)){if(W){(J||z)&&H&&R&&(k==null||k(H));const{inProgress:we,...ve}=pe,Pe={...ve,toPosition:pe.toHandle?pe.toPosition:null};j==null||j(Ne,Pe),u&&(I==null||I(Ne,Pe))}w(),cancelAnimationFrame(te),D=!1,R=!1,H=null,z=null,q.removeEventListener("mousemove",se),q.removeEventListener("mouseup",me),q.removeEventListener("touchmove",se),q.removeEventListener("touchend",me)}}q.addEventListener("mousemove",se),q.addEventListener("mouseup",me),q.addEventListener("touchmove",se),q.addEventListener("touchend",me)}function Fg(e,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:y=Og,nodeLookup:x}){const v=u==="target",g=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:w,y:S}=_n(e),k=c.elementFromPoint(w,S),j=k!=null&&k.classList.contains(`${h}-flow__handle`)?k:g,E={handleDomNode:j,isValid:!1,connection:null,toHandle:null};if(j){const I=Dg(void 0,j),_=j.getAttribute("data-nodeid"),b=j.getAttribute("data-handleid"),L=j.classList.contains("connectable"),$=j.classList.contains("connectableend");if(!_||!I)return E;const F={source:v?_:s,sourceHandle:v?b:a,target:v?s:_,targetHandle:v?a:b};E.connection=F;const q=L&&$&&(o===ii.Strict?v&&I==="source"||!v&&I==="target":_!==s||b!==a);E.isValid=q&&y(F),E.toHandle=zg(_,I,b,x,o,!0)}return E}const wc={onPointerDown:Z1,isValid:Fg};function J1({domNode:e,panZoom:r,getTransform:o,getViewScale:s}){const a=Yt(e);function u({translateExtent:h,width:p,height:y,zoomStep:x=1,pannable:v=!0,zoomable:g=!0,inversePan:w=!1}){const S=_=>{if(_.sourceEvent.type!=="wheel"||!r)return;const b=o(),L=_.sourceEvent.ctrlKey&&fs()?10:1,$=-_.sourceEvent.deltaY*(_.sourceEvent.deltaMode===1?.05:_.sourceEvent.deltaMode?1:.002)*x,F=b[2]*Math.pow(2,$*L);r.scaleTo(F)};let k=[0,0];const j=_=>{(_.sourceEvent.type==="mousedown"||_.sourceEvent.type==="touchstart")&&(k=[_.sourceEvent.clientX??_.sourceEvent.touches[0].clientX,_.sourceEvent.clientY??_.sourceEvent.touches[0].clientY])},E=_=>{const b=o();if(_.sourceEvent.type!=="mousemove"&&_.sourceEvent.type!=="touchmove"||!r)return;const L=[_.sourceEvent.clientX??_.sourceEvent.touches[0].clientX,_.sourceEvent.clientY??_.sourceEvent.touches[0].clientY],$=[L[0]-k[0],L[1]-k[1]];k=L;const F=s()*Math.max(b[2],Math.log(b[2]))*(w?-1:1),Y={x:b[0]-$[0]*F,y:b[1]-$[1]*F},q=[[0,0],[p,y]];r.setViewportConstrained({x:Y.x,y:Y.y,zoom:b[2]},q,h)},I=hg().on("start",j).on("zoom",v?E:null).on("zoom.wheel",g?S:null);a.call(I,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:vn}}const al=e=>({x:e.x,y:e.y,zoom:e.k}),Qu=({x:e,y:r,zoom:o})=>ol.translate(e,r).scale(o),zr=(e,r)=>e.target.closest(`.${r}`),Hg=(e,r)=>r===2&&Array.isArray(e)&&e.includes(2),e_=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Zu=(e,r=0,o=e_,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?e.transition().duration(r).ease(o).on("end",s):e},Bg=e=>{const r=e.ctrlKey&&fs()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*r};function t_({zoomPanValues:e,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:y}){return x=>{if(zr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const v=o.property("__zoom").k||1;if(x.ctrlKey&&c){const j=vn(x),E=Bg(x),I=v*Math.pow(2,E);s.scaleTo(o,I,j,x);return}const g=x.deltaMode===1?20:1;let w=a===po.Vertical?0:x.deltaX*g,S=a===po.Horizontal?0:x.deltaY*g;!fs()&&x.shiftKey&&a!==po.Vertical&&(w=x.deltaY*g,S=0),s.translateBy(o,-(w/v)*u,-(S/v)*u,{internal:!0});const k=al(o.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?p==null||p(x,k):(e.isPanScrolling=!0,h==null||h(x,k)),e.panScrollTimeout=setTimeout(()=>{y==null||y(x,k),e.isPanScrolling=!1},150)}}function n_({noWheelClassName:e,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=zr(s,e);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function r_({zoomPanValues:e,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=al(s.transform);e.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function o_({zoomPanValues:e,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;e.usedRightMouseButton=!!(o&&Hg(r,e.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,al(u.transform)))}}function i_({zoomPanValues:e,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(e.isZoomingOrPanning=!1,u&&Hg(r,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),e.usedRightMouseButton=!1,s(!1),a)){const p=al(c.transform);e.prevViewport=p,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function s_({panActivationKeyPressed:e,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:y,lib:x,connectionInProgress:v}){return g=>{var E;const w=r||o,S=s&&g.ctrlKey,k=g.type==="wheel";if(g.button===1&&g.type==="mousedown"&&(zr(g,`${x}-flow__node`)||zr(g,`${x}-flow__edge`)||zr(g,`${x}-flow__selection`)||zr(g,`${x}-flow__nodesselection`)))return!0;if(!a&&!w&&!u&&!c&&!s||h||v&&!k||zr(g,p)&&k||zr(g,y)&&(!k||u&&k&&!r)||!s&&g.ctrlKey&&k)return!1;if(!s&&g.type==="touchstart"&&((E=g.touches)==null?void 0:E.length)>1)return g.preventDefault(),!1;if(!w&&!u&&!S&&k||!a&&(g.type==="mousedown"||g.type==="touchstart")||Array.isArray(a)&&!a.includes(g.button)&&g.type==="mousedown")return!1;const j=Array.isArray(a)&&a.includes(g.button)||!g.button||g.button<=1;return(!g.ctrlKey||k||e)&&j}}function a_({domNode:e,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const y={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=e.getBoundingClientRect();let v=[[0,0],[x.width,x.height]];const g=typeof ResizeObserver<"u"?new ResizeObserver(Q=>{const C=Q[0];C&&(v=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;g==null||g.observe(e);const w=hg().extent(()=>v).scaleExtent([r,o]).translateExtent(s),S=Yt(e).call(w);b({x:a.x,y:a.y,zoom:si(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const k=S.on("wheel.zoom"),j=S.on("dblclick.zoom");w.wheelDelta(Bg);async function E(Q,C){return S?new Promise(V=>{w==null||w.interpolate((C==null?void 0:C.interpolate)==="linear"?ts:Aa).transform(Zu(S,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),Q)}):!1}function I({noWheelClassName:Q,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:H,preventScrolling:R,zoomOnPinch:z,zoomOnScroll:re,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:Ne}){W&&!y.isZoomingOrPanning&&_();const we=U&&!he&&!W;w.clickDistance(Ne?1/0:!wn(me)||me<0?0:me);const ve=we?t_({zoomPanValues:y,noWheelClassName:Q,d3Selection:S,d3Zoom:w,panOnScrollMode:D,panOnScrollSpeed:H,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):n_({noWheelClassName:Q,preventScrolling:R,d3ZoomHandler:k});S.on("wheel.zoom",ve,{passive:!1});const Pe=r_({zoomPanValues:y,onDraggingChange:p,onPanZoomStart:c});w.on("start",Pe);const ue=o_({zoomPanValues:y,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});w.on("zoom",ue);const je=i_({zoomPanValues:y,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});w.on("end",je);const Le=s_({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:re,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:W,noPanClassName:C,noWheelClassName:Q,lib:pe,connectionInProgress:se});w.filter(Le),oe?S.on("dblclick.zoom",j):S.on("dblclick.zoom",null)}function _(){w.on("zoom",null)}async function b(Q,C,V){const W=Qu(Q),U=w==null?void 0:w.constrain()(W,C,V);return U&&await E(U),U}async function L(Q,C){const V=Qu(Q);return await E(V,C),V}function $(Q){if(S){const C=Qu(Q),V=S.property("__zoom");(V.k!==Q.zoom||V.x!==Q.x||V.y!==Q.y)&&(w==null||w.transform(S,C,null,{sync:!0}))}}function F(){const Q=S?fg(S.node()):{x:0,y:0,k:1};return{x:Q.x,y:Q.y,zoom:Q.k}}async function Y(Q,C){return S?new Promise(V=>{w==null||w.interpolate((C==null?void 0:C.interpolate)==="linear"?ts:Aa).scaleTo(Zu(S,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),Q)}):!1}async function q(Q,C){return S?new Promise(V=>{w==null||w.interpolate((C==null?void 0:C.interpolate)==="linear"?ts:Aa).scaleBy(Zu(S,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),Q)}):!1}function te(Q){w==null||w.scaleExtent(Q)}function J(Q){w==null||w.translateExtent(Q)}function ne(Q){const C=!wn(Q)||Q<0?0:Q;w==null||w.clickDistance(C)}return{update:I,destroy:_,setViewport:L,setViewportConstrained:b,getViewport:F,scaleTo:Y,scaleBy:q,setScaleExtent:te,setTranslateExtent:J,syncViewport:$,setClickDistance:ne}}var li;(function(e){e.Line="line",e.Handle="handle"})(li||(li={}));function l_({width:e,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=e-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Uh(e){const r=e.includes("right")||e.includes("left"),o=e.includes("bottom")||e.includes("top"),s=e.includes("left"),a=e.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Ar(e,r){return Math.max(0,r-e)}function $r(e,r){return Math.max(0,e-r)}function Ma(e,r,o){return Math.max(0,r-e,e-o)}function Yh(e,r){return e?!r:r}function u_(e,r,o,s,a,u,c,h){let{affectsX:p,affectsY:y}=r;const{isHorizontal:x,isVertical:v}=r,g=x&&v,{xSnapped:w,ySnapped:S}=o,{minWidth:k,maxWidth:j,minHeight:E,maxHeight:I}=s,{x:_,y:b,width:L,height:$,aspectRatio:F}=e;let Y=Math.floor(x?w-e.pointerX:0),q=Math.floor(v?S-e.pointerY:0);const te=L+(p?-Y:Y),J=$+(y?-q:q),ne=-u[0]*L,Q=-u[1]*$;let C=Ma(te,k,j),V=Ma(J,E,I);if(c){let M=0,D=0;p&&Y<0?M=Ar(_+Y+ne,c[0][0]):!p&&Y>0&&(M=$r(_+te+ne,c[1][0])),y&&q<0?D=Ar(b+q+Q,c[0][1]):!y&&q>0&&(D=$r(b+J+Q,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&Y>0?M=$r(_+Y,h[0][0]):!p&&Y<0&&(M=Ar(_+te,h[1][0])),y&&q>0?D=$r(b+q,h[0][1]):!y&&q<0&&(D=Ar(b+J,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=Ma(te/F,E,I)*F;if(C=Math.max(C,M),c){let D=0;!p&&!y||p&&!y&&g?D=$r(b+Q+te/F,c[1][1])*F:D=Ar(b+Q+(p?Y:-Y)/F,c[0][1])*F,C=Math.max(C,D)}if(h){let D=0;!p&&!y||p&&!y&&g?D=Ar(b+te/F,h[1][1])*F:D=$r(b+(p?Y:-Y)/F,h[0][1])*F,C=Math.max(C,D)}}if(v){const M=Ma(J*F,k,j)/F;if(V=Math.max(V,M),c){let D=0;!p&&!y||y&&!p&&g?D=$r(_+J*F+ne,c[1][0])/F:D=Ar(_+(y?q:-q)*F+ne,c[0][0])/F,V=Math.max(V,D)}if(h){let D=0;!p&&!y||y&&!p&&g?D=Ar(_+J*F,h[1][0])/F:D=$r(_+(y?q:-q)*F,h[0][0])/F,V=Math.max(V,D)}}}q=q+(q<0?V:-V),Y=Y+(Y<0?C:-C),a&&(g?te>J*F?q=(Yh(p,y)?-Y:Y)/F:Y=(Yh(p,y)?-q:q)*F:x?(q=Y/F,y=p):(Y=q*F,p=y));const W=p?_+Y:_,U=y?b+q:b;return{width:L+(p?-Y:Y),height:$+(y?-q:q),x:u[0]*Y*(p?-1:1)+W,y:u[1]*q*(y?-1:1)+U}}const Vg={width:0,height:0,x:0,y:0},c_={...Vg,pointerX:0,pointerY:0,aspectRatio:1};function d_(e,r,o){const s=r.position.x+e.position.x,a=r.position.y+e.position.y,u=e.measured.width??0,c=e.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function f_({domNode:e,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Yt(e);let c={controlDirection:Uh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:y,boundaries:x,keepAspectRatio:v,resizeDirection:g,onResizeStart:w,onResize:S,onResizeEnd:k,shouldResize:j}){let E={...Vg},I={...c_};c={boundaries:x,resizeDirection:g,keepAspectRatio:v,controlDirection:Uh(y)};let _,b=null,L=[],$,F,Y,q=!1;const te=Zp().on("start",J=>{const{nodeLookup:ne,transform:Q,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(_=ne.get(r),!_)return;b=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=ns(J.sourceEvent,{transform:Q,snapGrid:C,snapToGrid:V,containerBounds:b});E={width:_.measured.width??0,height:_.measured.height??0,x:_.position.x??0,y:_.position.y??0},I={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},$=void 0,F=xo(_.extent)?_.extent:void 0,_.parentId&&(_.extent==="parent"||_.expandParent)&&($=ne.get(_.parentId)),$&&_.extent==="parent"&&(F=[[0,0],[$.measured.width,$.measured.height]]),L=[],Y=void 0;for(const[H,R]of ne)if(R.parentId===r&&(L.push({id:H,position:{...R.position},extent:R.extent}),R.extent==="parent"||R.expandParent)){const z=d_(R,_,R.origin??W);Y?Y=[[Math.min(z[0][0],Y[0][0]),Math.min(z[0][1],Y[0][1])],[Math.max(z[1][0],Y[1][0]),Math.max(z[1][1],Y[1][1])]]:Y=z}w==null||w(J,{...E})}).on("drag",J=>{const{transform:ne,snapGrid:Q,snapToGrid:C,nodeOrigin:V}=o(),W=ns(J.sourceEvent,{transform:ne,snapGrid:Q,snapToGrid:C,containerBounds:b}),U=[];if(!_)return;const{x:M,y:D,width:H,height:R}=E,z={},re=_.origin??V,{width:oe,height:fe,x:he,y:pe}=u_(I,c.controlDirection,W,c.boundaries,c.keepAspectRatio,re,F,Y),Z=oe!==H,se=fe!==R,me=he!==M&&Z,Ne=pe!==D&&se;if(!me&&!Ne&&!Z&&!se)return;if((me||Ne||re[0]===1||re[1]===1)&&(z.x=me?he:E.x,z.y=Ne?pe:E.y,E.x=z.x,E.y=z.y,L.length>0)){const ue=he-M,je=pe-D;for(const Le of L)Le.position={x:Le.position.x-ue+re[0]*(oe-H),y:Le.position.y-je+re[1]*(fe-R)},U.push(Le)}if((Z||se)&&(z.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:E.width,z.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:E.height,E.width=z.width,E.height=z.height),$&&_.expandParent){const ue=re[0]*(z.width??0);z.x&&z.x{q&&(k==null||k(J,{...E}),a==null||a({...E}),q=!1)});u.call(te)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Ju={exports:{}},ec={},tc={exports:{}},nc={};/** - * @license React - * use-sync-external-store-shim.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Gh;function h_(){if(Gh)return nc;Gh=1;var e=ps();function r(v,g){return v===g&&(v!==0||1/v===1/g)||v!==v&&g!==g}var o=typeof Object.is=="function"?Object.is:r,s=e.useState,a=e.useEffect,u=e.useLayoutEffect,c=e.useDebugValue;function h(v,g){var w=g(),S=s({inst:{value:w,getSnapshot:g}}),k=S[0].inst,j=S[1];return u(function(){k.value=w,k.getSnapshot=g,p(k)&&j({inst:k})},[v,w,g]),a(function(){return p(k)&&j({inst:k}),v(function(){p(k)&&j({inst:k})})},[v]),c(w),w}function p(v){var g=v.getSnapshot;v=v.value;try{var w=g();return!o(v,w)}catch{return!0}}function y(v,g){return g()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:h;return nc.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:x,nc}var Xh;function p_(){return Xh||(Xh=1,tc.exports=h_()),tc.exports}/** - * @license React - * use-sync-external-store-shim/with-selector.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var qh;function g_(){if(qh)return ec;qh=1;var e=ps(),r=p_();function o(y,x){return y===x&&(y!==0||1/y===1/x)||y!==y&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=e.useRef,c=e.useEffect,h=e.useMemo,p=e.useDebugValue;return ec.useSyncExternalStoreWithSelector=function(y,x,v,g,w){var S=u(null);if(S.current===null){var k={hasValue:!1,value:null};S.current=k}else k=S.current;S=h(function(){function E($){if(!I){if(I=!0,_=$,$=g($),w!==void 0&&k.hasValue){var F=k.value;if(w(F,$))return b=F}return b=$}if(F=b,s(_,$))return F;var Y=g($);return w!==void 0&&w(F,Y)?(_=$,F):(_=$,b=Y)}var I=!1,_,b,L=v===void 0?null:v;return[function(){return E(x())},L===null?void 0:function(){return E(L())}]},[x,v,g,w]);var j=a(y,S[0],S[1]);return c(function(){k.hasValue=!0,k.value=j},[j]),p(j),j},ec}var Kh;function m_(){return Kh||(Kh=1,Ju.exports=g_()),Ju.exports}var y_=m_();const v_=Lp(y_),x_={},Qh=e=>{let r;const o=new Set,s=(x,v)=>{const g=typeof x=="function"?x(r):x;if(!Object.is(g,r)){const w=r;r=v??(typeof g!="object"||g===null)?g:Object.assign({},r,g),o.forEach(S=>S(r,w))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>y,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(x_?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),o.clear()}},y=r=e(s,a,p);return p},w_=e=>e?Qh(e):Qh,{useDebugValue:__}=m0,{useSyncExternalStoreWithSelector:S_}=v_,k_=e=>e;function Wg(e,r=k_,o){const s=S_(e.subscribe,e.getState,e.getServerState||e.getInitialState,r,o);return __(s),s}const Zh=(e,r)=>{const o=w_(e),s=(a,u=r)=>Wg(o,a,u);return Object.assign(s,o),s},N_=(e,r)=>e?Zh(e,r):Zh;function Qe(e,r){if(Object.is(e,r))return!0;if(typeof e!="object"||e===null||typeof r!="object"||r===null)return!1;if(e instanceof Map&&r instanceof Map){if(e.size!==r.size)return!1;for(const[s,a]of e)if(!Object.is(a,r.get(s)))return!1;return!0}if(e instanceof Set&&r instanceof Set){if(e.size!==r.size)return!1;for(const s of e)if(!r.has(s))return!1;return!0}const o=Object.keys(e);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(e[s],r[s]))return!1;return!0}Ap();const ll=A.createContext(null),j_=ll.Provider,Ug=Sn.error001("react");function De(e,r){const o=A.useContext(ll);if(o===null)throw new Error(Ug);return Wg(o,e,r)}function Ye(){const e=A.useContext(ll);if(e===null)throw new Error(Ug);return A.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Jh={display:"none"},b_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Yg="react-flow__node-desc",Gg="react-flow__edge-desc",E_="react-flow__aria-live",C_=e=>e.ariaLiveMessage,M_=e=>e.ariaLabelConfig;function P_({rfId:e}){const r=De(C_);return d.jsx("div",{id:`${E_}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:b_,children:r})}function I_({rfId:e,disableKeyboardA11y:r}){const o=De(M_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Yg}-${e}`,style:Jh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Gg}-${e}`,style:Jh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(P_,{rfId:e})]})}const ul=A.forwardRef(({position:e="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${e}`.split("-");return d.jsx("div",{className:ot(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});ul.displayName="Panel";const ep="https://reactflow.dev?utm_source=attribution";function R_({proOptions:e,position:r="bottom-right"}){return e!=null&&e.hideAttribution?null:d.jsx(ul,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${ep}`,children:d.jsx("a",{href:ep,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const T_=e=>{const r=[],o=[];for(const[,s]of e.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of e.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},Pa=e=>e.id;function L_(e,r){return Qe(e.selectedNodes.map(Pa),r.selectedNodes.map(Pa))&&Qe(e.selectedEdges.map(Pa),r.selectedEdges.map(Pa))}function A_({onSelectionChange:e}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(T_,L_);return A.useEffect(()=>{const a={nodes:o,edges:s};e==null||e(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,e]),null}const $_=e=>!!e.onSelectionChangeHandlers;function z_({onSelectionChange:e}){const r=De($_);return e||r?d.jsx(A_,{onSelectionChange:e}):null}const Xg=[0,0],D_={x:0,y:0,zoom:1},O_=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],tp=[...O_,"rfId"],F_=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),np={translateExtent:ls,nodeOrigin:Xg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function H_(e){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(F_,Qe),y=Ye();A.useEffect(()=>(p(e.defaultNodes,e.defaultEdges),()=>{x.current=np,h()}),[]);const x=A.useRef(np);return A.useEffect(()=>{for(const v of tp){const g=e[v],w=x.current[v];g!==w&&(typeof e[v]>"u"||(v==="nodes"?r(g):v==="edges"?o(g):v==="minZoom"?s(g):v==="maxZoom"?a(g):v==="translateExtent"?u(g):v==="nodeExtent"?c(g):v==="ariaLabelConfig"?y.setState({ariaLabelConfig:j1(g)}):v==="fitView"?y.setState({fitViewQueued:g}):v==="fitViewOptions"?y.setState({fitViewOptions:g}):y.setState({[v]:g})))}x.current=e},tp.map(v=>e[v])),null}function rp(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function B_(e){var s;const[r,o]=A.useState(e==="system"?null:e);return A.useEffect(()=>{if(e!=="system"){o(e);return}const a=rp(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[e]),r!==null?r:(s=rp())!=null&&s.matches?"dark":"light"}const op=typeof document<"u"?document:null;function hs(e=null,r={target:op,actInsideInputWithModifier:!0}){const[o,s]=A.useState(!1),a=A.useRef(!1),u=A.useRef(new Set([])),[c,h]=A.useMemo(()=>{if(e!==null){const y=(Array.isArray(e)?e:[e]).filter(v=>typeof v=="string").map(v=>v.replace(/\+/g,` -`).replace(` - -`,` -+`).split(` -`)),x=y.reduce((v,g)=>v.concat(...g),[]);return[y,x]}return[[],[]]},[e]);return A.useEffect(()=>{const p=(r==null?void 0:r.target)??op,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(e!==null){const x=w=>{var j,E;if(a.current=w.ctrlKey||w.metaKey||w.shiftKey||w.altKey,(!a.current||a.current&&!y)&&Eg(w))return!1;const k=sp(w.code,h);if(u.current.add(w[k]),ip(c,u.current,!1)){const I=((E=(j=w.composedPath)==null?void 0:j.call(w))==null?void 0:E[0])||w.target,_=(I==null?void 0:I.nodeName)==="BUTTON"||(I==null?void 0:I.nodeName)==="A";r.preventDefault!==!1&&(a.current||!_)&&w.preventDefault(),s(!0)}},v=w=>{const S=sp(w.code,h);ip(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(w[S]),w.key==="Meta"&&u.current.clear(),a.current=!1},g=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",v),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",v),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,s]),o}function ip(e,r,o){return e.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function sp(e,r){return r.includes(e)?"code":"key"}const V_=()=>{const e=Ye();return A.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=e.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=e.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=e.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>e.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=e.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=e.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>e.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=e.getState(),p=Tc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=e.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),y={x:r.x-h,y:r.y-p},x=o.snapGrid??a,v=o.snapToGrid??u;return ws(y,s,v,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=e.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=ai(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function qg(e,r){const o=[],s=new Map,a=[];for(const u of e)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)W_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function W_(e,r){switch(e.type){case"select":{r.selected=e.selected;break}case"position":{typeof e.position<"u"&&(r.position=e.position),typeof e.dragging<"u"&&(r.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(r.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(r.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(r.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(r.resizing=e.resizing);break}}}function U_(e,r){return qg(e,r)}function Y_(e,r){return qg(e,r)}function co(e,r){return{id:e,type:"select",selected:r}}function ei(e,r=new Set,o=!1){const s=[];for(const[a,u]of e){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(co(u.id,c)))}return s}function ap({items:e=[],lookup:r}){var a;const o=[],s=new Map(e.map(u=>[u.id,u]));for(const[u,c]of e.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function lp(e){return{id:e.id,type:"remove"}}const G_=kg();function X_(e,r,o={}){return I1(e,r,{...o,onError:o.onError??G_})}const up=e=>m1(e),q_=e=>vg(e);function Kg(e){return A.forwardRef(e)}const Qg=typeof window<"u"?A.useLayoutEffect:A.useEffect;function cp(e){const[r,o]=A.useState(BigInt(0)),[s]=A.useState(()=>K_(()=>o(a=>a+BigInt(1))));return Qg(()=>{const a=s.get();a.length&&(e(a),s.reset())},[r]),s}function K_(e){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),e()}}}const Zg=A.createContext(null);function Q_({children:e}){const r=Ye(),o=A.useCallback(h=>{const{nodes:p=[],setNodes:y,hasDefaultNodes:x,onNodesChange:v,nodeLookup:g,fitViewQueued:w,onNodesChangeMiddlewareMap:S}=r.getState();let k=p;for(const E of h)k=typeof E=="function"?E(k):E;let j=ap({items:k,lookup:g});for(const E of S.values())j=E(j);x&&y(k),j.length>0?v==null||v(j):w&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:I,setNodes:_}=r.getState();E&&_(I)})},[]),s=cp(o),a=A.useCallback(h=>{const{edges:p=[],setEdges:y,hasDefaultEdges:x,onEdgesChange:v,edgeLookup:g}=r.getState();let w=p;for(const S of h)w=typeof S=="function"?S(w):S;x?y(w):v&&v(ap({items:w,lookup:g}))},[]),u=cp(a),c=A.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Zg.Provider,{value:c,children:e})}function Z_(){const e=A.useContext(Zg);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const J_=e=>!!e.panZoom;function cl(){const e=V_(),r=Ye(),o=Z_(),s=De(J_),a=A.useMemo(()=>{const u=v=>r.getState().nodeLookup.get(v),c=v=>{o.nodeQueue.push(v)},h=v=>{o.edgeQueue.push(v)},p=v=>{var E,I;const{nodeLookup:g,nodeOrigin:w}=r.getState(),S=up(v)?v:g.get(v.id),k=S.parentId?jg(S.position,S.measured,S.parentId,g,w):S.position,j={...S,position:k,width:((E=S.measured)==null?void 0:E.width)??S.width,height:((I=S.measured)==null?void 0:I.height)??S.height};return ds(j)},y=(v,g,w={replace:!1})=>{c(S=>S.map(k=>{if(k.id===v){const j=typeof g=="function"?g(k):g;return w.replace&&up(j)?j:{...k,...j}}return k}))},x=(v,g,w={replace:!1})=>{h(S=>S.map(k=>{if(k.id===v){const j=typeof g=="function"?g(k):g;return w.replace&&q_(j)?j:{...k,...j}}return k}))};return{getNodes:()=>r.getState().nodes.map(v=>({...v})),getNode:v=>{var g;return(g=u(v))==null?void 0:g.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:v=[]}=r.getState();return v.map(g=>({...g}))},getEdge:v=>r.getState().edgeLookup.get(v),setNodes:c,setEdges:h,addNodes:v=>{const g=Array.isArray(v)?v:[v];o.nodeQueue.push(w=>[...w,...g])},addEdges:v=>{const g=Array.isArray(v)?v:[v];o.edgeQueue.push(w=>[...w,...g])},toObject:()=>{const{nodes:v=[],edges:g=[],transform:w}=r.getState(),[S,k,j]=w;return{nodes:v.map(E=>({...E})),edges:g.map(E=>({...E})),viewport:{x:S,y:k,zoom:j}}},deleteElements:async({nodes:v=[],edges:g=[]})=>{const{nodes:w,edges:S,onNodesDelete:k,onEdgesDelete:j,triggerNodeChanges:E,triggerEdgeChanges:I,onDelete:_,onBeforeDelete:b}=r.getState(),{nodes:L,edges:$}=await _1({nodesToRemove:v,edgesToRemove:g,nodes:w,edges:S,onBeforeDelete:b}),F=$.length>0,Y=L.length>0;if(F){const q=$.map(lp);j==null||j($),I(q)}if(Y){const q=L.map(lp);k==null||k(L),E(q)}return(Y||F)&&(_==null||_({nodes:L,edges:$})),{deletedNodes:L,deletedEdges:$}},getIntersectingNodes:(v,g=!0,w)=>{const S=Lh(v),k=S?v:p(v),j=w!==void 0;return k?(w||r.getState().nodes).filter(E=>{const I=r.getState().nodeLookup.get(E.id);if(I&&!S&&(E.id===v.id||!I.internals.positionAbsolute))return!1;const _=ds(j?E:I),b=Ga(_,k);return g&&b>0||b>=_.width*_.height||b>=k.width*k.height}):[]},isNodeIntersecting:(v,g,w=!0)=>{const k=Lh(v)?v:p(v);if(!k)return!1;const j=Ga(k,g);return w&&j>0||j>=g.width*g.height||j>=k.width*k.height},updateNode:y,updateNodeData:(v,g,w={replace:!1})=>{y(v,S=>{const k=typeof g=="function"?g(S):g;return w.replace?{...S,data:k}:{...S,data:{...S.data,...k}}},w)},updateEdge:x,updateEdgeData:(v,g,w={replace:!1})=>{x(v,S=>{const k=typeof g=="function"?g(S):g;return w.replace?{...S,data:k}:{...S,data:{...S.data,...k}}},w)},getNodesBounds:v=>{const{nodeLookup:g,nodeOrigin:w}=r.getState();return y1(v,{nodeLookup:g,nodeOrigin:w})},getHandleConnections:({type:v,id:g,nodeId:w})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${w}-${v}${g?`-${g}`:""}`))==null?void 0:S.values())??[])},getNodeConnections:({type:v,handleId:g,nodeId:w})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${w}${v?g?`-${v}-${g}`:`-${v}`:""}`))==null?void 0:S.values())??[])},fitView:async v=>{const g=r.getState().fitViewResolver??N1();return r.setState({fitViewQueued:!0,fitViewOptions:v,fitViewResolver:g}),o.nodeQueue.push(w=>[...w]),g.promise}}},[]);return A.useMemo(()=>({...a,...e,viewportInitialized:s}),[s])}const dp=e=>e.selected,eS=typeof window<"u"?window:void 0;function tS({deleteKeyCode:e,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=cl(),a=hs(e,{actInsideInputWithModifier:!1}),u=hs(r,{target:eS});A.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(dp),edges:c.filter(dp)}),o.setState({nodesSelectionActive:!1})}},[a]),A.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function nS(e){const r=Ye();A.useEffect(()=>{const o=()=>{var a,u,c,h;if(!e.current||!(((u=(a=e.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=Lc(e.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",Sn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(e.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(e.current),()=>{window.removeEventListener("resize",o),s&&e.current&&s.unobserve(e.current)}}},[])}const dl={position:"absolute",width:"100%",height:"100%",top:0,left:0},rS=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function oS({onPaneContextMenu:e,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=po.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:y,translateExtent:x,minZoom:v,maxZoom:g,zoomActivationKeyCode:w,preventScrolling:S=!0,children:k,noWheelClassName:j,noPanClassName:E,onViewportChange:I,isControlledViewport:_,paneClickDistance:b,selectionOnDrag:L}){const $=Ye(),F=A.useRef(null),{userSelectionActive:Y,lib:q,connectionInProgress:te}=De(rS,Qe),J=hs(w),ne=A.useRef();nS(F);const Q=A.useCallback(C=>{I==null||I({x:C[0],y:C[1],zoom:C[2]}),_||$.setState({transform:C})},[I,_]);return A.useEffect(()=>{if(F.current){ne.current=a_({domNode:F.current,minZoom:v,maxZoom:g,translateExtent:x,viewport:y,onDraggingChange:U=>$.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var U;(U=ne.current)==null||U.destroy()}}},[]),A.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:e,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:J,preventScrolling:S,noPanClassName:E,userSelectionActive:Y,noWheelClassName:j,lib:q,onTransformChange:Q,connectionInProgress:te,selectionOnDrag:L,paneClickDistance:b})},[e,r,o,s,a,u,c,h,p,J,S,E,Y,j,q,Q,te,L,b]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:dl,children:k})}const iS=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function sS(){const{userSelectionActive:e,userSelectionRect:r}=De(iS,Qe);return e&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const rc=(e,r)=>o=>{o.target===r.current&&(e==null||e(o))},aS=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function lS({isSelecting:e,selectionKeyPressed:r,selectionMode:o=us.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:y,onPaneContextMenu:x,onPaneScroll:v,onPaneMouseEnter:g,onPaneMouseMove:w,onPaneMouseLeave:S,children:k}){const j=A.useRef(0),E=Ye(),{userSelectionActive:I,elementsSelectable:_,dragging:b,panBy:L,autoPanSpeed:$}=De(aS,Qe),F=_&&(e||I),Y=A.useRef(null),q=A.useRef(),te=A.useRef(new Set),J=A.useRef(new Set),ne=A.useRef(!1),Q=A.useRef(!1),C=A.useRef({x:0,y:0}),V=A.useRef(!1),W=Z=>{if(Q.current||ne.current||E.getState().connection.inProgress){Q.current=!1,ne.current=!1;return}y==null||y(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=v?Z=>v(Z):void 0,D=Z=>{Q.current&&(Z.stopPropagation(),Q.current=!1)},H=Z=>{var Le,nt;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const Ne=Z.target===Y.current;if(!Ne&&!!Z.target.closest(".nokey")||!e||!(c&&Ne||r)||Z.button!==0||!Z.isPrimary)return;(nt=(Le=Z.target)==null?void 0:Le.setPointerCapture)==null||nt.call(Le,Z.pointerId),Q.current=!1;const{x:Pe,y:ue}=_n(Z.nativeEvent,q.current),je=ws({x:Pe,y:ue},me);E.setState({userSelectionRect:{width:0,height:0,startX:je.x,startY:je.y,x:Pe,y:ue}}),Ne||(Z.stopPropagation(),Z.preventDefault())};function R(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:Ne,nodeLookup:we,edgeLookup:ve,connectionLookup:Pe,triggerNodeChanges:ue,triggerEdgeChanges:je,defaultEdgeOptions:Le}=E.getState(),nt={x:me.startX,y:me.startY},{x:lt,y:ut}=ai(nt,Ne),Ge={startX:nt.x,startY:nt.y,x:Zmt.id)),J.current=new Set;const gt=(Le==null?void 0:Le.selectable)??!0;for(const mt of te.current){const Mt=Pe.get(mt);if(Mt)for(const{edgeId:ct}of Mt.values()){const et=ve.get(ct);et&&(et.selectable??gt)&&J.current.add(ct)}}if(!Ah(wt,te.current)){const mt=ei(we,te.current,!0);ue(mt)}if(!Ah(Xt,J.current)){const mt=ei(ve,J.current);je(mt)}E.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=Rc(C.current,q.current,$);L({x:Z,y:se}).then(me=>{if(!Q.current||!me){j.current=requestAnimationFrame(z);return}const{x:Ne,y:we}=C.current;R(Ne,we),j.current=requestAnimationFrame(z)})}const re=()=>{cancelAnimationFrame(j.current),j.current=0,V.current=!1};A.useEffect(()=>()=>re(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:Ne}=E.getState();if(!q.current||!se)return;const{x:we,y:ve}=_n(Z.nativeEvent,q.current);C.current={x:we,y:ve};const Pe=ai({x:se.startX,y:se.startY},me);if(!Q.current){const ue=r?0:u;if(Math.hypot(we-Pe.x,ve-Pe.y)<=ue)return;Ne(),h==null||h(Z)}Q.current=!0,V.current||(z(),V.current=!0),R(we,ve)},fe=Z=>{var se,me;if(!F){Z.target===Y.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!I&&Z.target===Y.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),Q.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),re())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),re()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:ot(["react-flow__pane",{draggable:pe,dragging:b,selection:e}]),onClick:F?void 0:rc(W,Y),onContextMenu:rc(U,Y),onWheel:rc(M,Y),onPointerEnter:F?void 0:g,onPointerMove:F?oe:w,onPointerUp:fe,onPointerCancel:F?he:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:S,ref:Y,style:dl,children:[k,d.jsx(sS,{})]})}function _c({id:e,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),y=h.get(e);if(!y){p==null||p("012",Sn.error012(e));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&c)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([e])}function Jg({nodeRef:e,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,y]=A.useState(!1),x=A.useRef();return A.useEffect(()=>{if(!r)return x.current=G1({getStoreItems:()=>h.getState(),onNodeMouseDown:v=>{_c({id:v,store:h,nodeRef:e})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var v;(v=x.current)==null||v.destroy(),x.current=void 0}},[r,h,e]),A.useEffect(()=>{r||!e.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:e.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,e,a,c]),p}const uS=e=>r=>r.selected&&(r.draggable||e&&typeof r.draggable>"u");function em(){const e=Ye();return A.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:y,nodeOrigin:x}=e.getState(),v=new Map,g=uS(c),w=a?u[0]:5,S=a?u[1]:5,k=o.direction.x*w*o.factor,j=o.direction.y*S*o.factor;for(const[,E]of y){if(!g(E))continue;let I={x:E.internals.positionAbsolute.x+k,y:E.internals.positionAbsolute.y+j};a&&(I=xs(I,u));const{position:_,positionAbsolute:b}=xg({nodeId:E.id,nextPosition:I,nodeLookup:y,nodeExtent:s,nodeOrigin:x,onError:h});E.position=_,E.internals.positionAbsolute=b,v.set(E.id,E)}p(v)},[])}const Fc=A.createContext(null),cS=Fc.Provider;Fc.Consumer;const tm=()=>A.useContext(Fc),dS=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),nm=A.createContext(null);function fS({children:e}){const r=De(dS,Qe);return d.jsx(nm.Provider,{value:r,children:e})}function hS(){const e=A.useContext(nm);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const pS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},gS=(e,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:y}=c;if(!h&&!a)return pS;const x=(p==null?void 0:p.nodeId)===e&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===e&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===ii.Strict?(h==null?void 0:h.type)!==o:e!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&y}};function mS({type:e="source",position:r=ke.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:y,onMouseDown:x,onTouchStart:v,...g},w){var V,W;const S=c||null,k=e==="target",j=Ye(),E=tm(),{connectOnClick:I,noPanClassName:_,rfId:b}=hS(),{connectingFrom:L,connectingTo:$,clickConnecting:F,isPossibleEndHandle:Y,connectionInProcess:q,clickConnectionInProcess:te,valid:J}=De(gS(E,S,e),Qe);E||(W=(V=j.getState()).onError)==null||W.call(V,"010",Sn.error010());const ne=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=j.getState(),R={...M,...U};if(H){const{edges:z,setEdges:re,onError:oe}=j.getState();re(X_(R,z,{onError:oe}))}D==null||D(R),h==null||h(R)},Q=U=>{if(!E)return;const M=Cg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=j.getState();wc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:k,handleId:S,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var R,z;return(z=(R=j.getState()).onConnectEnd)==null?void 0:z.call(R,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var R,z;return((z=(R=j.getState()).isValidConnection)==null?void 0:z.call(R,...H))??!0}),getTransform:()=>j.getState().transform,getFromHandle:()=>j.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):v==null||v(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:R,isValidConnection:z,lib:re,rfId:oe,nodeLookup:fe,connection:he}=j.getState();if(!E||!H&&!a)return;if(!H){M==null||M(U.nativeEvent,{nodeId:E,handleId:S,handleType:e}),j.setState({connectionClickStartHandle:{nodeId:E,type:e,id:S}});return}const pe=bg(U.target),Z=o||z,{connection:se,isValid:me}=wc.isValid(U.nativeEvent,{handle:{nodeId:E,id:S,type:e},connectionMode:R,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:pe,lib:re,nodeLookup:fe});me&&se&&ne(se);const Ne=structuredClone(he);delete Ne.inProgress,Ne.toPosition=Ne.toHandle?Ne.toHandle.position:null,D==null||D(U,Ne),j.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":S,"data-nodeid":E,"data-handlepos":r,"data-id":`${b}-${E}-${S}-${e}`,className:ot(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",_,y,{source:!k,target:k,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:L,connectingto:$,valid:J,connectionindicator:s&&(!q||Y)&&(q||te?u:a)}]),onMouseDown:Q,onTouchStart:Q,onClick:I?C:void 0,ref:w,...g,children:p})}const ui=A.memo(Kg(mS));function yS({data:e,isConnectable:r,sourcePosition:o=ke.Bottom}){return d.jsxs(d.Fragment,{children:[e==null?void 0:e.label,d.jsx(ui,{type:"source",position:o,isConnectable:r})]})}function vS({data:e,isConnectable:r,targetPosition:o=ke.Top,sourcePosition:s=ke.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(ui,{type:"target",position:o,isConnectable:r}),e==null?void 0:e.label,d.jsx(ui,{type:"source",position:s,isConnectable:r})]})}function xS(){return null}function wS({data:e,isConnectable:r,targetPosition:o=ke.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(ui,{type:"target",position:o,isConnectable:r}),e==null?void 0:e.label]})}const qa={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},fp={input:yS,default:vS,output:wS,group:xS};function _S(e){var r,o,s,a;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((r=e.style)==null?void 0:r.width),height:e.height??e.initialHeight??((o=e.style)==null?void 0:o.height)}:{width:e.width??((s=e.style)==null?void 0:s.width),height:e.height??((a=e.style)==null?void 0:a.height)}}const SS=e=>{const{width:r,height:o,x:s,y:a}=vs(e.nodeLookup,{filter:u=>!!u.selected});return{width:wn(r)?r:null,height:wn(o)?o:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${s}px,${a}px)`}};function kS({onSelectionContextMenu:e,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(SS,Qe),p=em(),y=A.useRef(null);A.useEffect(()=>{var w;o||(w=y.current)==null||w.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Jg({nodeRef:y,disabled:!x}),!x)return null;const v=e?w=>{const S=s.getState().nodes.filter(k=>k.selected);e(w,S)}:void 0,g=w=>{Object.prototype.hasOwnProperty.call(qa,w.key)&&(w.preventDefault(),p({direction:qa[w.key],factor:w.shiftKey?4:1}))};return d.jsx("div",{className:ot(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:o?void 0:-1,onKeyDown:o?void 0:g,style:{width:a,height:u}})})}const hp=typeof window<"u"?window:void 0,NS=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function rm({children:e,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:y,selectionOnDrag:x,selectionMode:v,onSelectionStart:g,onSelectionEnd:w,multiSelectionKeyCode:S,panActivationKeyCode:k,zoomActivationKeyCode:j,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:_,panOnScroll:b,panOnScrollSpeed:L,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:Y,autoPanOnSelection:q,defaultViewport:te,translateExtent:J,minZoom:ne,maxZoom:Q,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:R,userSelectionActive:z}=De(NS,Qe),re=hs(y,{target:hp}),oe=hs(k,{target:hp}),fe=oe||Y,he=oe||b,pe=x&&fe!==!0,Z=re||z||pe;return tS({deleteKeyCode:p,multiSelectionKeyCode:S}),d.jsx(oS,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:_,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:L,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!re&&fe,defaultViewport:te,translateExtent:J,minZoom:ne,maxZoom:Q,zoomActivationKeyCode:j,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(lS,{onSelectionStart:g,onSelectionEnd:w,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:v,selectionKeyPressed:re,paneClickDistance:h,selectionOnDrag:pe,children:[e,R&&d.jsx(kS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}rm.displayName="FlowRenderer";const jS=A.memo(rm),bS=e=>r=>e?Ic(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function ES(e){return De(A.useCallback(bS(e),[e]),Qe)}const CS=e=>e.updateNodeInternals;function MS(){const e=De(CS),[r]=A.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),e(s)}));return A.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function PS({node:e,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=A.useRef(null),c=A.useRef(null),h=A.useRef(e.sourcePosition),p=A.useRef(e.targetPosition),y=A.useRef(r),x=o&&!!e.internals.handleBounds;return A.useEffect(()=>{u.current&&!e.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,e.hidden]),A.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),A.useEffect(()=>{if(u.current){const v=y.current!==r,g=h.current!==e.sourcePosition,w=p.current!==e.targetPosition;(v||g||w)&&(y.current=r,h.current=e.sourcePosition,p.current=e.targetPosition,a.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:u.current,force:!0}]])))}},[e.id,r,e.sourcePosition,e.targetPosition]),u}function IS({id:e,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:y,nodesFocusable:x,resizeObserver:v,noDragClassName:g,noPanClassName:w,disableKeyboardA11y:S,rfId:k,nodeTypes:j,nodeClickDistance:E,onError:I}){const{node:_,internals:b,isParent:L}=De(Z=>{const se=Z.nodeLookup.get(e),me=Z.parentLookup.has(e);return{node:se,internals:se.internals,isParent:me}},Qe);let $=_.type||"default",F=(j==null?void 0:j[$])||fp[$];F===void 0&&(I==null||I("003",Sn.error003($)),$="default",F=(j==null?void 0:j.default)||fp.default);const Y=!!(_.draggable||h&&typeof _.draggable>"u"),q=!!(_.selectable||p&&typeof _.selectable>"u"),te=!!(_.connectable||y&&typeof _.connectable>"u"),J=!!(_.focusable||x&&typeof _.focusable>"u"),ne=Ye(),Q=Ng(_),C=PS({node:_,nodeType:$,hasDimensions:Q,resizeObserver:v}),V=Jg({nodeRef:C,disabled:_.hidden||!Y,noDragClassName:g,handleSelector:_.dragHandle,nodeId:e,isSelectable:q,nodeClickDistance:E}),W=em();if(_.hidden)return null;const U=jn(_),M=_S(_),D=q||Y||r||o||s||a,H=o?Z=>o(Z,{...b.userNode}):void 0,R=s?Z=>s(Z,{...b.userNode}):void 0,z=a?Z=>a(Z,{...b.userNode}):void 0,re=u?Z=>u(Z,{...b.userNode}):void 0,oe=c?Z=>c(Z,{...b.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!Y||me>0)&&_c({id:e,store:ne,nodeRef:C}),r&&r(Z,{...b.userNode})},he=Z=>{if(!(Eg(Z.nativeEvent)||S)){if(pg.includes(Z.key)&&q){const se=Z.key==="Escape";_c({id:e,store:ne,unselect:se,nodeRef:C})}else if(Y&&_.selected&&Object.prototype.hasOwnProperty.call(qa,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),W({direction:qa[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Pe;if(S||!((Pe=C.current)!=null&&Pe.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:Ne,setCenter:we}=ne.getState();if(!Ne)return;Ic(new Map([[e,_]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||we(_.position.x+U.width/2,_.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:ot(["react-flow__node",`react-flow__node-${$}`,{[w]:Y},_.className,{selected:_.selected,selectable:q,parent:L,draggable:Y,dragging:V}]),ref:C,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:Q?"visible":"hidden",..._.style,...M},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:H,onMouseMove:R,onMouseLeave:z,onContextMenu:re,onClick:fe,onDoubleClick:oe,onKeyDown:J?he:void 0,tabIndex:J?0:void 0,onFocus:J?pe:void 0,role:_.ariaRole??(J?"group":void 0),"aria-roledescription":"node","aria-describedby":S?void 0:`${Yg}-${k}`,"aria-label":_.ariaLabel,..._.domAttributes,children:d.jsx(cS,{value:e,children:d.jsx(F,{id:e,data:_.data,type:$,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:_.selected??!1,selectable:q,draggable:Y,deletable:_.deletable??!0,isConnectable:te,sourcePosition:_.sourcePosition,targetPosition:_.targetPosition,dragging:V,dragHandle:_.dragHandle,zIndex:b.z,parentId:_.parentId,...U})})})}var RS=A.memo(IS);const TS=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function om(e){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(TS,Qe),u=ES(e.onlyRenderVisibleElements),c=MS();return d.jsx("div",{className:"react-flow__nodes",style:dl,children:u.map(h=>d.jsx(RS,{id:h,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:a},h))})}om.displayName="NodeRenderer";const LS=A.memo(om);function AS(e){return De(A.useCallback(o=>{if(!e)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&C1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[e]),Qe)}const $S=({color:e="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...e&&{stroke:e}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},zS=({color:e="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...e&&{stroke:e,fill:e}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},pp={[cs.Arrow]:$S,[cs.ArrowClosed]:zS};function DS(e){const r=Ye();return A.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(pp,e)?pp[e]:((u=(a=r.getState()).onError)==null||u.call(a,"009",Sn.error009(e)),null)},[e])}const OS=({id:e,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=DS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},im=({defaultColor:e,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=A.useMemo(()=>$1(o,{id:r,defaultColor:e,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,e]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(OS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};im.displayName="MarkerDefinitions";var FS=A.memo(im);function sm({x:e,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:y,...x}){const[v,g]=A.useState({x:1,y:0,width:0,height:0}),w=ot(["react-flow__edge-textwrapper",y]),S=A.useRef(null);return A.useEffect(()=>{if(S.current){const k=S.current.getBBox();g({x:k.x,y:k.y,width:k.width,height:k.height})}},[o]),o?d.jsxs("g",{transform:`translate(${e-v.width/2} ${r-v.height/2})`,className:w,visibility:v.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:v.width+2*c[0],x:-c[0],y:-c[1],height:v.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:S,style:s,children:o}),p]}):null}sm.displayName="EdgeText";const HS=A.memo(sm);function _s({path:e,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:y=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:e,fill:"none",className:ot(["react-flow__edge-path",x.className])}),y?d.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,s&&wn(r)&&wn(o)?d.jsx(HS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function gp({pos:e,x1:r,y1:o,x2:s,y2:a}){return e===ke.Left||e===ke.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function am({sourceX:e,sourceY:r,sourcePosition:o=ke.Bottom,targetX:s,targetY:a,targetPosition:u=ke.Top}){const[c,h]=gp({pos:o,x1:e,y1:r,x2:s,y2:a}),[p,y]=gp({pos:u,x1:s,y1:a,x2:e,y2:r}),[x,v,g,w]=Mg({sourceX:e,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:y});return[`M${e},${r} C${c},${h} ${p},${y} ${s},${a}`,x,v,g,w]}function lm(e){return A.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:g,labelBgBorderRadius:w,style:S,markerEnd:k,markerStart:j,interactionWidth:E})=>{const[I,_,b]=am({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),L=e.isInternal?void 0:r;return d.jsx(_s,{id:L,path:I,labelX:_,labelY:b,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:g,labelBgBorderRadius:w,style:S,markerEnd:k,markerStart:j,interactionWidth:E})})}const BS=lm({isInternal:!1}),um=lm({isInternal:!0});BS.displayName="SimpleBezierEdge";um.displayName="SimpleBezierEdgeInternal";function cm(e){return A.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:g,sourcePosition:w=ke.Bottom,targetPosition:S=ke.Top,markerEnd:k,markerStart:j,pathOptions:E,interactionWidth:I})=>{const[_,b,L]=Xa({sourceX:o,sourceY:s,sourcePosition:w,targetX:a,targetY:u,targetPosition:S,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=e.isInternal?void 0:r;return d.jsx(_s,{id:$,path:_,labelX:b,labelY:L,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:g,markerEnd:k,markerStart:j,interactionWidth:I})})}const dm=cm({isInternal:!1}),fm=cm({isInternal:!0});dm.displayName="SmoothStepEdge";fm.displayName="SmoothStepEdgeInternal";function hm(e){return A.memo(({id:r,...o})=>{var a;const s=e.isInternal?void 0:r;return d.jsx(dm,{...o,id:s,pathOptions:A.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const VS=hm({isInternal:!1}),pm=hm({isInternal:!0});VS.displayName="StepEdge";pm.displayName="StepEdgeInternal";function gm(e){return A.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:g,markerEnd:w,markerStart:S,interactionWidth:k})=>{const[j,E,I]=Rg({sourceX:o,sourceY:s,targetX:a,targetY:u}),_=e.isInternal?void 0:r;return d.jsx(_s,{id:_,path:j,labelX:E,labelY:I,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:g,markerEnd:w,markerStart:S,interactionWidth:k})})}const WS=gm({isInternal:!1}),mm=gm({isInternal:!0});WS.displayName="StraightEdge";mm.displayName="StraightEdgeInternal";function ym(e){return A.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=ke.Bottom,targetPosition:h=ke.Top,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:g,labelBgBorderRadius:w,style:S,markerEnd:k,markerStart:j,pathOptions:E,interactionWidth:I})=>{const[_,b,L]=Pg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=e.isInternal?void 0:r;return d.jsx(_s,{id:$,path:_,labelX:b,labelY:L,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:g,labelBgBorderRadius:w,style:S,markerEnd:k,markerStart:j,interactionWidth:I})})}const US=ym({isInternal:!1}),vm=ym({isInternal:!0});US.displayName="BezierEdge";vm.displayName="BezierEdgeInternal";const mp={default:vm,straight:mm,step:pm,smoothstep:fm,simplebezier:um},yp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},YS=(e,r,o)=>o===ke.Left?e-r:o===ke.Right?e+r:e,GS=(e,r,o)=>o===ke.Top?e-r:o===ke.Bottom?e+r:e,vp="react-flow__edgeupdater";function xp({position:e,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:ot([vp,`${vp}-${h}`]),cx:YS(r,s,e),cy:GS(o,s,e),r:s,stroke:"transparent",fill:"transparent"})}function XS({isReconnectable:e,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:y,onReconnectStart:x,onReconnectEnd:v,setReconnecting:g,setUpdateHover:w}){const S=Ye(),k=(b,L)=>{if(b.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:Y,connectionRadius:q,lib:te,onConnectStart:J,cancelConnection:ne,nodeLookup:Q,rfId:C,panBy:V,updateConnection:W}=S.getState(),U=L.type==="target",M=(R,z)=>{g(!1),v==null||v(R,o,L.type,z)},D=R=>y==null?void 0:y(o,R),H=(R,z)=>{g(!0),x==null||x(b,o,L.type),J==null||J(R,z)};wc.onPointerDown(b.nativeEvent,{autoPanOnConnect:$,connectionMode:Y,connectionRadius:q,domNode:F,handleId:L.id,nodeId:L.nodeId,nodeLookup:Q,isTarget:U,edgeUpdaterType:L.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...R)=>{var z,re;return((re=(z=S.getState()).isValidConnection)==null?void 0:re.call(z,...R))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...R)=>{var z,re;return(re=(z=S.getState()).onConnectEnd)==null?void 0:re.call(z,...R)},onReconnectEnd:M,updateConnection:W,getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,dragThreshold:S.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},j=b=>k(b,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=b=>k(b,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),I=()=>w(!0),_=()=>w(!1);return d.jsxs(d.Fragment,{children:[(e===!0||e==="source")&&d.jsx(xp,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:j,onMouseEnter:I,onMouseOut:_,type:"source"}),(e===!0||e==="target")&&d.jsx(xp,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:I,onMouseOut:_,type:"target"})]})}function qS({id:e,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,reconnectRadius:x,onReconnect:v,onReconnectStart:g,onReconnectEnd:w,rfId:S,edgeTypes:k,noPanClassName:j,onError:E,disableKeyboardA11y:I}){let _=De(we=>we.edgeLookup.get(e));const b=De(we=>we.defaultEdgeOptions);_=b?{...b,..._}:_;let L=_.type||"default",$=(k==null?void 0:k[L])||mp[L];$===void 0&&(E==null||E("011",Sn.error011(L)),L="default",$=(k==null?void 0:k.default)||mp.default);const F=!!(_.focusable||r&&typeof _.focusable>"u"),Y=typeof v<"u"&&(_.reconnectable||o&&typeof _.reconnectable>"u"),q=!!(_.selectable||s&&typeof _.selectable>"u"),te=A.useRef(null),[J,ne]=A.useState(!1),[Q,C]=A.useState(!1),V=Ye(),{zIndex:W=_.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:R,targetPosition:z}=De(A.useCallback(we=>{const ve=we.nodeLookup.get(_.source),Pe=we.nodeLookup.get(_.target);if(!ve||!Pe)return yp;const ue=A1({id:e,sourceNode:ve,targetNode:Pe,sourceHandle:_.sourceHandle||null,targetHandle:_.targetHandle||null,connectionMode:we.connectionMode,onError:E}),je=E1({selected:_.selected,zIndex:_.zIndex,sourceNode:ve,targetNode:Pe,elevateOnSelect:we.elevateEdgesOnSelect,zIndexMode:we.zIndexMode});return{...ue||yp,zIndex:je}},[_.source,_.target,_.sourceHandle,_.targetHandle,_.selected,_.zIndex,E]),Qe),re=A.useMemo(()=>_.markerStart?`url('#${vc(_.markerStart,S)}')`:void 0,[_.markerStart,S]),oe=A.useMemo(()=>_.markerEnd?`url('#${vc(_.markerEnd,S)}')`:void 0,[_.markerEnd,S]);if(_.hidden||U===null||M===null||D===null||H===null)return null;const fe=we=>{var je;const{addSelectedEdges:ve,unselectNodesAndEdges:Pe,multiSelectionActive:ue}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),_.selected&&ue?(Pe({nodes:[],edges:[_]}),(je=te.current)==null||je.blur()):ve([e])),a&&a(we,_)},he=u?we=>{u(we,{..._})}:void 0,pe=c?we=>{c(we,{..._})}:void 0,Z=h?we=>{h(we,{..._})}:void 0,se=p?we=>{p(we,{..._})}:void 0,me=y?we=>{y(we,{..._})}:void 0,Ne=we=>{var ve;if(!I&&pg.includes(we.key)&&q){const{unselectNodesAndEdges:Pe,addSelectedEdges:ue}=V.getState();we.key==="Escape"?((ve=te.current)==null||ve.blur(),Pe({edges:[_]})):ue([e])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:ot(["react-flow__edge",`react-flow__edge-${L}`,_.className,j,{selected:_.selected,animated:_.animated,inactive:!q&&!a,updating:J,selectable:q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?Ne:void 0,tabIndex:F?0:void 0,role:_.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":_.ariaLabel===null?void 0:_.ariaLabel||`Edge from ${_.source} to ${_.target}`,"aria-describedby":F?`${Gg}-${S}`:void 0,ref:te,..._.domAttributes,children:[!Q&&d.jsx($,{id:e,source:_.source,target:_.target,type:_.type,selected:_.selected,animated:_.animated,selectable:q,deletable:_.deletable??!0,label:_.label,labelStyle:_.labelStyle,labelShowBg:_.labelShowBg,labelBgStyle:_.labelBgStyle,labelBgPadding:_.labelBgPadding,labelBgBorderRadius:_.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:R,targetPosition:z,data:_.data,style:_.style,sourceHandleId:_.sourceHandle,targetHandleId:_.targetHandle,markerStart:re,markerEnd:oe,pathOptions:"pathOptions"in _?_.pathOptions:void 0,interactionWidth:_.interactionWidth}),Y&&d.jsx(XS,{edge:_,isReconnectable:Y,reconnectRadius:x,onReconnect:v,onReconnectStart:g,onReconnectEnd:w,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:R,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var KS=A.memo(qS);const QS=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function xm({defaultMarkerColor:e,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:y,onEdgeClick:x,reconnectRadius:v,onEdgeDoubleClick:g,onReconnectStart:w,onReconnectEnd:S,disableKeyboardA11y:k}){const{edgesFocusable:j,edgesReconnectable:E,elementsSelectable:I,onError:_}=De(QS,Qe),b=AS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(FS,{defaultColor:e,rfId:o}),b.map(L=>d.jsx(KS,{id:L,edgesFocusable:j,edgesReconnectable:E,elementsSelectable:I,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,onClick:x,reconnectRadius:v,onDoubleClick:g,onReconnectStart:w,onReconnectEnd:S,rfId:o,onError:_,edgeTypes:s,disableKeyboardA11y:k},L))]})}xm.displayName="EdgeRenderer";const ZS=A.memo(xm),wp=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function JS({children:e}){const r=Ye(),o=A.useRef(null),[s]=A.useState(()=>r.getState().transform);return Qg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=wp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:wp(s)},children:e})}function ek(e){const r=cl(),o=A.useRef(!1);A.useEffect(()=>{!o.current&&r.viewportInitialized&&e&&(setTimeout(()=>e(r),1),o.current=!0)},[e,r.viewportInitialized])}const tk=e=>{var r;return(r=e.panZoom)==null?void 0:r.syncViewport};function nk(e){const r=De(tk),o=Ye();return A.useEffect(()=>{e&&(r==null||r(e),o.setState({transform:[e.x,e.y,e.zoom]}))},[e,r]),null}function rk(e){return e.connection.inProgress?{...e.connection,to:ws(e.connection.to,e.transform)}:{...e.connection}}function ok(e){return rk}function ik(e){const r=ok();return De(r,Qe)}const sk=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function ak({containerStyle:e,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(sk,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:e,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:ot(["react-flow__connection",yg(h)]),children:d.jsx(wm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const wm=({style:e,type:r=Or.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:y,toNode:x,toHandle:v,toPosition:g,pointer:w}=ik();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:e,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:p,toPosition:g,connectionStatus:yg(s),toNode:x,toHandle:v,pointer:w});let S="";const k={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:y.x,targetY:y.y,targetPosition:g};switch(r){case Or.Bezier:[S]=Pg(k);break;case Or.SimpleBezier:[S]=am(k);break;case Or.Step:[S]=Xa({...k,borderRadius:0});break;case Or.SmoothStep:[S]=Xa(k);break;default:[S]=Rg(k)}return d.jsx("path",{d:S,fill:"none",className:"react-flow__connection-path",style:e})};wm.displayName="ConnectionLine";const lk={};function _p(e=lk){A.useRef(e),Ye(),A.useEffect(()=>{},[e])}function uk(){Ye(),A.useRef(!1),A.useEffect(()=>{},[])}function _m({nodeTypes:e,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:v,onSelectionStart:g,onSelectionEnd:w,connectionLineType:S,connectionLineStyle:k,connectionLineComponent:j,connectionLineContainerStyle:E,selectionKeyCode:I,selectionOnDrag:_,selectionMode:b,multiSelectionKeyCode:L,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:Y,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:J,translateExtent:ne,minZoom:Q,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:R,zoomOnDoubleClick:z,panOnDrag:re,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:Ne,nodeClickDistance:we,onEdgeContextMenu:ve,onEdgeMouseEnter:Pe,onEdgeMouseMove:ue,onEdgeMouseLeave:je,reconnectRadius:Le,onReconnect:nt,onReconnectStart:lt,onReconnectEnd:ut,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:Xt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Mt,viewport:ct,onViewportChange:et,nodesDraggable:Bn}){return _p(e),_p(r),uk(),ek(o),nk(ct),d.jsx(jS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:Ne,deleteKeyCode:Y,selectionKeyCode:I,selectionOnDrag:_,selectionMode:b,onSelectionStart:g,onSelectionEnd:w,multiSelectionKeyCode:L,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:R,panOnDrag:re,autoPanOnSelection:oe,defaultViewport:J,translateExtent:ne,minZoom:Q,maxZoom:C,onSelectionContextMenu:v,preventScrolling:V,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:Xt,disableKeyboardA11y:gt,onViewportChange:et,isControlledViewport:!!ct,children:d.jsxs(JS,{children:[d.jsx(ZS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:nt,onReconnectStart:lt,onReconnectEnd:ut,onlyRenderVisibleElements:q,onEdgeContextMenu:ve,onEdgeMouseEnter:Pe,onEdgeMouseMove:ue,onEdgeMouseLeave:je,reconnectRadius:Le,defaultMarkerColor:W,noPanClassName:Xt,disableKeyboardA11y:gt,rfId:Mt}),d.jsx(ak,{style:k,type:S,component:j,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(LS,{nodeTypes:e,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,nodeClickDistance:we,onlyRenderVisibleElements:q,noPanClassName:Xt,noDragClassName:Ge,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Mt,nodesDraggable:Bn}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}_m.displayName="GraphView";const ck=A.memo(_m),dk=kg(),Sp=({nodes:e,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:y=2,nodeOrigin:x,nodeExtent:v,zIndexMode:g="basic"}={})=>{const w=new Map,S=new Map,k=new Map,j=new Map,E=s??r??[],I=o??e??[],_=x??[0,0],b=v??ls;Ag(k,j,E);const{nodesInitialized:L}=xc(I,w,S,{nodeOrigin:_,nodeExtent:b,zIndexMode:g});let $=[0,0,1];if(c&&a&&u){const F=vs(w,{filter:J=>!!((J.width||J.initialWidth)&&(J.height||J.initialHeight))}),{x:Y,y:q,zoom:te}=Tc(F,a,u,p,y,(h==null?void 0:h.padding)??.1);$=[Y,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:I,nodesInitialized:L,nodeLookup:w,parentLookup:S,edges:E,edgeLookup:j,connectionLookup:k,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:y,translateExtent:ls,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ii.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:_,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...mg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:dk,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:gg,zIndexMode:g,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},fk=({nodes:e,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,zIndexMode:g})=>N_((w,S)=>{async function k(){const{nodeLookup:j,panZoom:E,fitViewOptions:I,fitViewResolver:_,width:b,height:L,minZoom:$,maxZoom:F}=S();E&&(await w1({nodes:j,width:b,height:L,panZoom:E,minZoom:$,maxZoom:F},I),_==null||_.resolve(!0),w({fitViewResolver:null}))}return{...Sp({nodes:e,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,defaultNodes:o,defaultEdges:s,zIndexMode:g}),setNodes:j=>{const{nodeLookup:E,parentLookup:I,nodeOrigin:_,nodeExtent:b,elevateNodesOnSelect:L,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:Y}=S(),{nodesInitialized:q,hasSelectedNodes:te}=xc(j,E,I,{nodeOrigin:_,nodeExtent:b,elevateNodesOnSelect:L,checkEquality:!0,zIndexMode:F}),J=Y&&te;$&&q?(k(),w({nodes:j,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:J})):w({nodes:j,nodesInitialized:q,nodesSelectionActive:J})},setEdges:j=>{const{connectionLookup:E,edgeLookup:I}=S();Ag(E,I,j),w({edges:j})},setDefaultNodesAndEdges:(j,E)=>{if(j){const{setNodes:I}=S();I(j),w({hasDefaultNodes:!0})}if(E){const{setEdges:I}=S();I(E),w({hasDefaultEdges:!0})}},updateNodeInternals:j=>{const{triggerNodeChanges:E,nodeLookup:I,parentLookup:_,domNode:b,nodeOrigin:L,nodeExtent:$,debug:F,fitViewQueued:Y,zIndexMode:q}=S(),{changes:te,updatedInternals:J}=V1(j,I,_,b,L,$,q);J&&(O1(I,_,{nodeOrigin:L,nodeExtent:$,zIndexMode:q}),Y?(k(),w({fitViewQueued:!1,fitViewOptions:void 0})):w({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(j,E=!1)=>{const I=[];let _=[];const{nodeLookup:b,triggerNodeChanges:L,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:Y}=S();for(const[q,te]of j){const J=b.get(q),ne=!!(J!=null&&J.expandParent&&(J!=null&&J.parentId)&&(te!=null&&te.position)),Q={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(J&&$.inProgress&&$.fromNode.id===J.id){const C=wo(J,$.fromHandle,ke.Left,!0);F({...$,from:C})}ne&&J.parentId&&I.push({id:q,parentId:J.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),_.push(Q)}if(I.length>0){const{parentLookup:q,nodeOrigin:te}=S(),J=Oc(I,b,q,te);_.push(...J)}for(const q of Y.values())_=q(_);L(_)},triggerNodeChanges:j=>{const{onNodesChange:E,setNodes:I,nodes:_,hasDefaultNodes:b,debug:L}=S();if(j!=null&&j.length){if(b){const $=U_(j,_);I($)}L&&console.log("React Flow: trigger node changes",j),E==null||E(j)}},triggerEdgeChanges:j=>{const{onEdgesChange:E,setEdges:I,edges:_,hasDefaultEdges:b,debug:L}=S();if(j!=null&&j.length){if(b){const $=Y_(j,_);I($)}L&&console.log("React Flow: trigger edge changes",j),E==null||E(j)}},addSelectedNodes:j=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:_,triggerNodeChanges:b,triggerEdgeChanges:L}=S();if(E){const $=j.map(F=>co(F,!0));b($);return}b(ei(_,new Set([...j]),!0)),L(ei(I))},addSelectedEdges:j=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:_,triggerNodeChanges:b,triggerEdgeChanges:L}=S();if(E){const $=j.map(F=>co(F,!0));L($);return}L(ei(I,new Set([...j]))),b(ei(_,new Set,!0))},unselectNodesAndEdges:({nodes:j,edges:E}={})=>{const{edges:I,nodes:_,nodeLookup:b,triggerNodeChanges:L,triggerEdgeChanges:$}=S(),F=j||_,Y=E||I,q=[];for(const J of F){if(!J.selected)continue;const ne=b.get(J.id);ne&&(ne.selected=!1),q.push(co(J.id,!1))}const te=[];for(const J of Y)J.selected&&te.push(co(J.id,!1));L(q),$(te)},setMinZoom:j=>{const{panZoom:E,maxZoom:I}=S();E==null||E.setScaleExtent([j,I]),w({minZoom:j})},setMaxZoom:j=>{const{panZoom:E,minZoom:I}=S();E==null||E.setScaleExtent([I,j]),w({maxZoom:j})},setTranslateExtent:j=>{var E;(E=S().panZoom)==null||E.setTranslateExtent(j),w({translateExtent:j})},resetSelectedElements:()=>{const{edges:j,nodes:E,triggerNodeChanges:I,triggerEdgeChanges:_,elementsSelectable:b}=S();if(!b)return;const L=E.reduce((F,Y)=>Y.selected?[...F,co(Y.id,!1)]:F,[]),$=j.reduce((F,Y)=>Y.selected?[...F,co(Y.id,!1)]:F,[]);I(L),_($)},setNodeExtent:j=>{const{nodes:E,nodeLookup:I,parentLookup:_,nodeOrigin:b,elevateNodesOnSelect:L,nodeExtent:$,zIndexMode:F}=S();j[0][0]===$[0][0]&&j[0][1]===$[0][1]&&j[1][0]===$[1][0]&&j[1][1]===$[1][1]||(xc(E,I,_,{nodeOrigin:b,nodeExtent:j,elevateNodesOnSelect:L,checkEquality:!1,zIndexMode:F}),w({nodeExtent:j}))},panBy:j=>{const{transform:E,width:I,height:_,panZoom:b,translateExtent:L}=S();return W1({delta:j,panZoom:b,transform:E,translateExtent:L,width:I,height:_})},setCenter:async(j,E,I)=>{const{width:_,height:b,maxZoom:L,panZoom:$}=S();if(!$)return!1;const F=typeof(I==null?void 0:I.zoom)<"u"?I.zoom:L;return await $.setViewport({x:_/2-j*F,y:b/2-E*F,zoom:F},{duration:I==null?void 0:I.duration,ease:I==null?void 0:I.ease,interpolate:I==null?void 0:I.interpolate}),!0},cancelConnection:()=>{w({connection:{...mg}})},updateConnection:j=>{w({connection:j})},reset:()=>w({...Sp()})}},Object.is);function Sm({initialNodes:e,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:y,nodeOrigin:x,nodeExtent:v,zIndexMode:g,children:w}){const[S]=A.useState(()=>fk({nodes:e,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:y,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:v,zIndexMode:g}));return d.jsx(j_,{value:S,children:d.jsx(Q_,{children:d.jsx(fS,{children:w})})})}function hk({children:e,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:y,maxZoom:x,nodeOrigin:v,nodeExtent:g,zIndexMode:w}){return A.useContext(ll)?d.jsx(d.Fragment,{children:e}):d.jsx(Sm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:y,initialMaxZoom:x,nodeOrigin:v,nodeExtent:g,zIndexMode:w,children:e})}const pk={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function gk({nodes:e,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:y,onMove:x,onMoveStart:v,onMoveEnd:g,onConnect:w,onConnectStart:S,onConnectEnd:k,onClickConnectStart:j,onClickConnectEnd:E,onNodeMouseEnter:I,onNodeMouseMove:_,onNodeMouseLeave:b,onNodeContextMenu:L,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:Y,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:J,onDelete:ne,onSelectionChange:Q,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:R,connectionLineType:z=Or.Bezier,connectionLineStyle:re,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=us.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:Ne=fs()?"Meta":"Control",zoomActivationKeyCode:we=fs()?"Meta":"Control",snapToGrid:ve,snapGrid:Pe,onlyRenderVisibleElements:ue=!1,selectNodesOnDrag:je,nodesDraggable:Le,autoPanOnNodeFocus:nt,nodesConnectable:lt,nodesFocusable:ut,nodeOrigin:Ge=Xg,edgesFocusable:wt,edgesReconnectable:Xt,elementsSelectable:gt=!0,defaultViewport:mt=D_,minZoom:Mt=.5,maxZoom:ct=2,translateExtent:et=ls,preventScrolling:Bn=!0,nodeExtent:Pt,defaultMarkerColor:bn="#b1b1b7",zoomOnScroll:di=!0,zoomOnPinch:Vn=!0,panOnScroll:So=!1,panOnScrollSpeed:dr=.5,panOnScrollMode:Br=po.Free,zoomOnDoubleClick:Wn=!0,panOnDrag:Vr=!0,onPaneClick:fr,onPaneMouseEnter:hr,onPaneMouseMove:Ht,onPaneMouseLeave:dt,onPaneScroll:Un,onPaneContextMenu:Yn,paneClickDistance:En=1,nodeClickDistance:Gn=0,children:Cn,onReconnect:it,onReconnectStart:pr,onReconnectEnd:Mn,onEdgeContextMenu:It,onEdgeDoubleClick:on,onEdgeMouseEnter:ko,onEdgeMouseMove:Ze,onEdgeMouseLeave:He,reconnectRadius:Pn=10,onNodesChange:Xn,onEdgesChange:sn,noDragClassName:Wr="nodrag",noWheelClassName:an="nowheel",noPanClassName:Rt="nopan",fitView:qt,fitViewOptions:qn,connectOnClick:No,attributionPosition:jo,proOptions:Tt,defaultEdgeOptions:Kn,elevateNodesOnSelect:Ur=!0,elevateEdgesOnSelect:Qn=!1,disableKeyboardA11y:gr=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:fi,autoPanOnSelection:Yr=!0,autoPanSpeed:bo,connectionRadius:mr,isValidConnection:hi,onError:Eo,style:In,id:_t,nodeDragThreshold:pi,connectionDragThreshold:yt,viewport:gi,onViewportChange:mi,width:Gr,height:Rn,colorMode:Zn="light",debug:Tn,onScroll:Kt,ariaLabelConfig:Xr,zIndexMode:qr="basic",...yr},Kr){const ln=_t||"1",Jn=B_(Zn),Co=A.useCallback(vr=>{vr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Kt==null||Kt(vr)},[Kt]);return d.jsx("div",{"data-testid":"rf__wrapper",...yr,onScroll:Co,style:{...In,...pk},ref:Kr,className:ot(["react-flow",a,Jn]),id:_t,role:"application",children:d.jsxs(hk,{nodes:e,edges:r,width:Gr,height:Rn,fitView:qt,fitViewOptions:qn,minZoom:Mt,maxZoom:ct,nodeOrigin:Ge,nodeExtent:Pt,zIndexMode:qr,children:[d.jsx(H_,{nodes:e,edges:r,defaultNodes:o,defaultEdges:s,onConnect:w,onConnectStart:S,onConnectEnd:k,onClickConnectStart:j,onClickConnectEnd:E,nodesDraggable:Le,autoPanOnNodeFocus:nt,nodesConnectable:lt,nodesFocusable:ut,edgesFocusable:wt,edgesReconnectable:Xt,elementsSelectable:gt,elevateNodesOnSelect:Ur,elevateEdgesOnSelect:Qn,minZoom:Mt,maxZoom:ct,nodeExtent:Pt,onNodesChange:Xn,onEdgesChange:sn,snapToGrid:ve,snapGrid:Pe,connectionMode:R,translateExtent:et,connectOnClick:No,defaultEdgeOptions:Kn,fitView:qt,fitViewOptions:qn,onNodesDelete:te,onEdgesDelete:J,onDelete:ne,onNodeDragStart:F,onNodeDrag:Y,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:v,onMoveEnd:g,noPanClassName:Rt,nodeOrigin:Ge,rfId:ln,autoPanOnConnect:Ve,autoPanOnNodeDrag:fi,autoPanSpeed:bo,onError:Eo,connectionRadius:mr,isValidConnection:hi,selectNodesOnDrag:je,nodeDragThreshold:pi,connectionDragThreshold:yt,onBeforeDelete:H,debug:Tn,ariaLabelConfig:Xr,zIndexMode:qr}),d.jsx(ck,{onInit:y,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:I,onNodeMouseMove:_,onNodeMouseLeave:b,onNodeContextMenu:L,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:re,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:Ne,panActivationKeyCode:me,zoomActivationKeyCode:we,onlyRenderVisibleElements:ue,defaultViewport:mt,translateExtent:et,minZoom:Mt,maxZoom:ct,preventScrolling:Bn,zoomOnScroll:di,zoomOnPinch:Vn,zoomOnDoubleClick:Wn,panOnScroll:So,panOnScrollSpeed:dr,panOnScrollMode:Br,panOnDrag:Vr,autoPanOnSelection:Yr,onPaneClick:fr,onPaneMouseEnter:hr,onPaneMouseMove:Ht,onPaneMouseLeave:dt,onPaneScroll:Un,onPaneContextMenu:Yn,paneClickDistance:En,nodeClickDistance:Gn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:it,onReconnectStart:pr,onReconnectEnd:Mn,onEdgeContextMenu:It,onEdgeDoubleClick:on,onEdgeMouseEnter:ko,onEdgeMouseMove:Ze,onEdgeMouseLeave:He,reconnectRadius:Pn,defaultMarkerColor:bn,noDragClassName:Wr,noWheelClassName:an,noPanClassName:Rt,rfId:ln,disableKeyboardA11y:gr,nodeExtent:Pt,viewport:gi,onViewportChange:mi,nodesDraggable:Le}),d.jsx(z_,{onSelectionChange:Q}),Cn,d.jsx(R_,{proOptions:Tt,position:jo}),d.jsx(I_,{rfId:ln,disableKeyboardA11y:gr})]})})}var mk=Kg(gk);function yk({dimensions:e,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:ot(["react-flow__background-pattern",o,s])})}function vk({radius:e,className:r}){return d.jsx("circle",{cx:e,cy:e,r:e,className:ot(["react-flow__background-pattern","dots",r])})}var Fr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Fr||(Fr={}));const xk={[Fr.Dots]:1,[Fr.Lines]:1,[Fr.Cross]:6},wk=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function km({id:e,variant:r=Fr.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:y,patternClassName:x}){const v=A.useRef(null),{transform:g,patternId:w}=De(wk,Qe),S=s||xk[r],k=r===Fr.Dots,j=r===Fr.Cross,E=Array.isArray(o)?o:[o,o],I=[E[0]*g[2]||1,E[1]*g[2]||1],_=S*g[2],b=Array.isArray(u)?u:[u,u],L=j?[_,_]:I,$=[b[0]*g[2]+L[0]/2,b[1]*g[2]+L[1]/2],F=`${w}${e||""}`;return d.jsxs("svg",{className:ot(["react-flow__background",y]),style:{...p,...dl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:v,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:g[0]%I[0],y:g[1]%I[1],width:I[0],height:I[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:k?d.jsx(vk,{radius:_/2,className:x}):d.jsx(yk,{dimensions:L,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}km.displayName="Background";const _k=A.memo(km);function Sk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function kk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Nk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function jk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function bk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Ia({children:e,className:r,...o}){return d.jsx("button",{type:"button",className:ot(["react-flow__controls-button",r]),...o,children:e})}const Ek=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Nm({style:e,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:y,children:x,position:v="bottom-left",orientation:g="vertical","aria-label":w}){const S=Ye(),{isInteractive:k,minZoomReached:j,maxZoomReached:E,ariaLabelConfig:I}=De(Ek,Qe),{zoomIn:_,zoomOut:b,fitView:L}=cl(),$=()=>{_(),u==null||u()},F=()=>{b(),c==null||c()},Y=()=>{L(a),h==null||h()},q=()=>{S.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),p==null||p(!k)},te=g==="horizontal"?"horizontal":"vertical";return d.jsxs(ul,{className:ot(["react-flow__controls",te,y]),position:v,style:e,"data-testid":"rf__controls","aria-label":w??I["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(Ia,{onClick:$,className:"react-flow__controls-zoomin",title:I["controls.zoomIn.ariaLabel"],"aria-label":I["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(Sk,{})}),d.jsx(Ia,{onClick:F,className:"react-flow__controls-zoomout",title:I["controls.zoomOut.ariaLabel"],"aria-label":I["controls.zoomOut.ariaLabel"],disabled:j,children:d.jsx(kk,{})})]}),o&&d.jsx(Ia,{className:"react-flow__controls-fitview",onClick:Y,title:I["controls.fitView.ariaLabel"],"aria-label":I["controls.fitView.ariaLabel"],children:d.jsx(Nk,{})}),s&&d.jsx(Ia,{className:"react-flow__controls-interactive",onClick:q,title:I["controls.interactive.ariaLabel"],"aria-label":I["controls.interactive.ariaLabel"],children:k?d.jsx(bk,{}):d.jsx(jk,{})}),x]})}Nm.displayName="Controls";const Ck=A.memo(Nm);function Mk({id:e,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:y,borderRadius:x,shapeRendering:v,selected:g,onClick:w}){const{background:S,backgroundColor:k}=u||{},j=c||S||k;return d.jsx("rect",{className:ot(["react-flow__minimap-node",{selected:g},y]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:j,stroke:h,strokeWidth:p},shapeRendering:v,onClick:w?E=>w(E,e):void 0})}const Pk=A.memo(Mk),Ik=e=>e.nodes.map(r=>r.id),oc=e=>e instanceof Function?e:()=>e;function Rk({nodeStrokeColor:e,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=Pk,onClick:c}){const h=De(Ik,Qe),p=oc(r),y=oc(e),x=oc(o),v=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(g=>d.jsx(Lk,{id:g,nodeColorFunc:p,nodeStrokeColorFunc:y,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:v},g))})}function Tk({id:e,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:y,x,y:v,width:g,height:w}=De(S=>{const k=S.nodeLookup.get(e);if(!k)return{node:void 0,x:0,y:0,width:0,height:0};const j=k.internals.userNode,{x:E,y:I}=k.internals.positionAbsolute,{width:_,height:b}=jn(j);return{node:j,x:E,y:I,width:_,height:b}},Qe);return!y||y.hidden||!Ng(y)?null:d.jsx(h,{x,y:v,width:g,height:w,style:y.style,selected:!!y.selected,className:s(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:c,onClick:p,id:y.id})}const Lk=A.memo(Tk);var Ak=A.memo(Rk);const $k=200,zk=150,Dk=e=>!e.hidden,Ok=e=>{const r={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:r,boundingRect:e.nodeLookup.size>0?_g(vs(e.nodeLookup,{filter:Dk}),r):r,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},kp=(e,r)=>e.x===r.x&&e.y===r.y&&e.width===r.width&&e.height===r.height,Fk=(e,r)=>kp(e.viewBB,r.viewBB)&&kp(e.boundingRect,r.boundingRect)&&e.rfId===r.rfId&&e.panZoom===r.panZoom&&e.translateExtent===r.translateExtent&&e.flowWidth===r.flowWidth&&e.flowHeight===r.flowHeight&&e.ariaLabelConfig===r.ariaLabelConfig,Hk="react-flow__minimap-desc";function jm({style:e,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:y,maskStrokeColor:x,maskStrokeWidth:v,position:g="bottom-right",onClick:w,onNodeClick:S,pannable:k=!1,zoomable:j=!1,ariaLabel:E,inversePan:I,zoomStep:_=1,offsetScale:b=5}){const L=Ye(),$=A.useRef(null),{boundingRect:F,viewBB:Y,rfId:q,panZoom:te,translateExtent:J,flowWidth:ne,flowHeight:Q,ariaLabelConfig:C}=De(Ok,Fk),V=(e==null?void 0:e.width)??$k,W=(e==null?void 0:e.height)??zk,U=F.width/V,M=F.height/W,D=Math.max(U,M),H=D*V,R=D*W,z=b*D,re=F.x-(H-F.width)/2-z,oe=F.y-(R-F.height)/2-z,fe=H+z*2,he=R+z*2,pe=`${Hk}-${q}`,Z=A.useRef(0),se=A.useRef();Z.current=D,A.useEffect(()=>{if($.current&&te)return se.current=J1({domNode:$.current,panZoom:te,getTransform:()=>L.getState().transform,getViewScale:()=>Z.current}),()=>{var ve;(ve=se.current)==null||ve.destroy()}},[te]),A.useEffect(()=>{var ve;(ve=se.current)==null||ve.update({translateExtent:J,width:ne,height:Q,inversePan:I,pannable:k,zoomStep:_,zoomable:j})},[k,j,I,_,J,ne,Q]);const me=w?ve=>{var je;const[Pe,ue]=((je=se.current)==null?void 0:je.pointer(ve))||[0,0];w(ve,{x:Pe,y:ue})}:void 0,Ne=S?A.useCallback((ve,Pe)=>{const ue=L.getState().nodeLookup.get(Pe).internals.userNode;S(ve,ue)},[]):void 0,we=E??C["minimap.ariaLabel"];return d.jsx(ul,{position:g,style:{...e,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof v=="number"?v*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:ot(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${re} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:$,onClick:me,children:[we&&d.jsx("title",{id:pe,children:we}),d.jsx(Ak,{onClick:Ne,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${re-z},${oe-z}h${fe+z*2}v${he+z*2}h${-fe-z*2}z - M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}jm.displayName="MiniMap";const Bk=A.memo(jm),Vk=e=>r=>e?`${Math.max(1/r.transform[2],1)}`:void 0,Wk={[li.Line]:"right",[li.Handle]:"bottom-right"};function Uk({nodeId:e,position:r,variant:o=li.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:y=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:v=!1,resizeDirection:g,autoScale:w=!0,shouldResize:S,onResizeStart:k,onResize:j,onResizeEnd:E}){const I=tm(),_=typeof e=="string"?e:I,b=Ye(),L=A.useRef(null),$=o===li.Handle,F=De(A.useCallback(Vk($&&w),[$,w]),Qe),Y=A.useRef(null),q=r??Wk[o];A.useEffect(()=>{if(!(!L.current||!_))return Y.current||(Y.current=f_({domNode:L.current,nodeId:_,getStoreItems:()=>{const{nodeLookup:J,transform:ne,snapGrid:Q,snapToGrid:C,nodeOrigin:V,domNode:W}=b.getState();return{nodeLookup:J,transform:ne,snapGrid:Q,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(J,ne)=>{const{triggerNodeChanges:Q,nodeLookup:C,parentLookup:V,nodeOrigin:W}=b.getState(),U=[],M={x:J.x,y:J.y},D=C.get(_);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,R=J.width??D.measured.width??0,z=J.height??D.measured.height??0,re={id:D.id,parentId:D.parentId,rect:{width:R,height:z,...jg({x:J.x??D.position.x,y:J.y??D.position.y},{width:R,height:z},D.parentId,C,H)}},oe=Oc([re],C,V,W);U.push(...oe),M.x=J.x?Math.max(H[0]*R,J.x):void 0,M.y=J.y?Math.max(H[1]*z,J.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:_,type:"position",position:{...M}};U.push(H)}if(J.width!==void 0&&J.height!==void 0){const R={id:_,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:J.width,height:J.height}};U.push(R)}for(const H of ne){const R={...H,type:"position"};U.push(R)}Q(U)},onEnd:({width:J,height:ne})=>{const Q={id:_,type:"dimensions",resizing:!1,dimensions:{width:J,height:ne}};b.getState().triggerNodeChanges([Q])}})),Y.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:y,maxHeight:x},keepAspectRatio:v,resizeDirection:g,onResizeStart:k,onResize:j,onResizeEnd:E,shouldResize:S}),()=>{var J;(J=Y.current)==null||J.destroy()}},[q,h,p,y,x,v,k,j,E,S]);const te=q.split("-");return d.jsx("div",{className:ot(["react-flow__resize-control","nodrag",...te,o,s]),ref:L,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}A.memo(Uk);const Yk={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"react.server_action":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function kn(e){return Yk[e]??8}const bt=208,Fn=64,Hr=88,fl=28,Gk=8;function Xk(e){if(!e.length)return Number.NaN;const r=[...e].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function bm(e,r=[]){const o=new Map;if(!e.length)return o;const s=new Map;for(const _ of e){const b=kn(_.type),L=s.get(b)??[];L.push(_),s.set(b,L)}const u=[...s.keys()].sort((_,b)=>_-b).map(_=>[...s.get(_)??[]].sort((b,L)=>b.name.localeCompare(L.name)||b.id.localeCompare(L.id))),c=new Set(e.map(_=>_.id)),h=new Map,p=new Map;for(const _ of e)h.set(_.id,[]),p.set(_.id,[]);for(const _ of r)!c.has(_.src)||!c.has(_.dst)||_.src===_.dst||(p.get(_.src).push(_.dst),h.get(_.dst).push(_.src));const y=new Map;u.forEach((_,b)=>{for(const L of _)y.set(L.id,b)});const x=new Map,v=()=>{for(const _ of u)_.forEach((b,L)=>x.set(b.id,L))};v();const g=(_,b)=>{const L=_.map(($,F)=>{const Y=b($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=Xk(Y);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return L.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),L.map($=>$.n)},w=_=>b=>y.get(b)===_;for(let _=0;_(h.get(L)??[]).filter(w(b-1))),v();for(let b=u.length-2;b>=0;b--)u[b]=g(u[b],L=>(p.get(L)??[]).filter(w(b+1))),v()}const S=bt+Hr,k=Fn+fl,j=Math.max(...u.map(_=>_.length),1),E=[];let I=0;for(let _=0;_Y.id)),L=new Set((u[_+1]??[]).map(Y=>Y.id));let $=0;if(L.size)for(const Y of r)b.has(Y.src)&&L.has(Y.dst)&&($+=1);const F=Math.min(120,Math.max(0,($-2)*12));I+=S+F}return u.forEach((_,b)=>{const L=(j-_.length)*k/2;_.forEach(($,F)=>{o.set($.id,{x:E[b]??0,y:L+F*k})})}),o}const Sc=[{id:"layers",label:"Architecture layers"},{id:"flow",label:"Edge flow"},{id:"tree",label:"Spanning tree"},{id:"radial",label:"Radial"},{id:"concentric",label:"Concentric layers"},{id:"circle",label:"Circle"},{id:"clusters",label:"Type clusters"},{id:"grid",label:"Compact grid"},{id:"force",label:"Force directed"}],qk=new Set(Sc.map(e=>e.id)),Em="loadpath.graphLayout",Kk=8,Qk=64,Zk=bt+32,go=bt+Hr,Ka=Fn+fl,Jk=new Set(["django.route","react.route","react.page","react.server_action","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),Cm=90,eN=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),Np={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.server_action":"#e76f51","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},tN=Math.PI*(3-Math.sqrt(5)),Mm=220,nN=26,rN={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function Pm(e){return e.startsWith("react.")?"react":e.startsWith("openapi.")||e.startsWith("graphql.")||e.startsWith("fastapi.")?"stitch":e.startsWith("arch.")?"arch":"django"}function wj(e){return Np[e]?Np[e]:e.startsWith("react.")?"#9d4edd":e.startsWith("openapi.")?"#00bbf9":"#4a5568"}function oN(e){return e>=Cm?"3d":"2d"}function iN(e){return e>=Cm?"overview":"full"}function sN(e,r,o=1){const s=new Set([e]);let a=new Set([e]);for(let u=0;uo.families.has(Pm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!eN.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?sN(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function lN(e,r){const o=r.trim().toLowerCase();return o?e.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function uN(e,r,o,s){const a=new Set(e.map(k=>k.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const k of r){if(!a.has(k.src)||!a.has(k.dst))continue;const j=u.get(k.src)??[];j.push({dst:k.dst,id:k.id}),u.set(k.src,j);const E=c.get(k.dst)??[];E.push({src:k.src,id:k.id}),c.set(k.dst,E)}const h=new Set(e.filter(k=>Jk.has(k.type)).map(k=>k.id)),p=h.size?h:a,y=new Set,x=[o];for(;x.length;){const k=x.pop();if(!y.has(k)){y.add(k);for(const j of u.get(k)??[])y.has(j.dst)||x.push(j.dst)}}const v=new Set([o]),g=[...p].filter(k=>y.has(k)),w=new Set(g);for(;g.length;){const k=g.pop();v.add(k);for(const j of c.get(k)??[])y.has(j.src)&&!w.has(j.src)&&(w.add(j.src),g.push(j.src))}const S=new Set;for(const k of r)v.has(k.src)&&v.has(k.dst)&&S.add(k.id);return{nodeIds:v,edgeIds:S}}function _j(e){const r=new Map;for(const s of e){const a=kn(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*Mm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=nN*Math.sqrt(h+1),y=h*tN;o.set(c.id,{x:u,y:p*Math.cos(y),z:p*Math.sin(y)})})}return o}function Sj(e){const r=new Map;for(const o of e){const s=kn(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*Mm,count:s}))}function cN(){try{if(typeof localStorage>"u")return"layers";const e=localStorage.getItem(Em);return e&&qk.has(e)?e:"layers"}catch{return"layers"}}function dN(e){try{if(typeof localStorage>"u")return;localStorage.setItem(Em,e)}catch{}}function fN(e){return e==="layers"||e==="flow"}function hN(e){if(!e.length)return Number.NaN;const r=[...e].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function rn(e,r){return e.name.localeCompare(r.name)||e.id.localeCompare(r.id)}function Im(e,r){return kn(e.type)-kn(r.type)||rn(e,r)}function Hc(e,r,o){e.forEach((s,a)=>{const u=-Math.PI/2+2*Math.PI*a/Math.max(e.length,1);o.set(s.id,{x:Math.cos(u)*r,y:Math.sin(u)*r})})}function Bc(e,r){return Math.max(r*go,e<=1?r===0?0:bt:e*Zk/(2*Math.PI))}function pN(e,r){const o=new Map;if(!e.length)return o;const s=new Set(e.flat().map(S=>S.id)),a=new Map,u=new Map;for(const S of e.flat())a.set(S.id,[]),u.set(S.id,[]);for(const S of r)!s.has(S.src)||!s.has(S.dst)||S.src===S.dst||(u.get(S.src).push(S.dst),a.get(S.dst).push(S.src));const c=new Map;e.forEach((S,k)=>{for(const j of S)c.set(j.id,k)});const h=new Map,p=()=>{for(const S of e)S.forEach((k,j)=>h.set(k.id,j))};p();const y=(S,k)=>{const j=S.map((E,I)=>{const _=k(E.id).map(L=>h.get(L)).filter(L=>L!==void 0),b=hN(_);return{n:E,bary:Number.isNaN(b)?I:b,name:E.name,id:E.id}});return j.sort((E,I)=>E.bary-I.bary||E.name.localeCompare(I.name)||E.id.localeCompare(I.id)),j.map(E=>E.n)},x=S=>k=>c.get(k)===S;for(let S=0;S(a.get(j)??[]).filter(x(k-1))),p();for(let k=e.length-2;k>=0;k--)e[k]=y(e[k],j=>(u.get(j)??[]).filter(x(k+1))),p()}const v=bt+Hr,g=Fn+fl,w=Math.max(...e.map(S=>S.length),1);return e.forEach((S,k)=>{const j=(w-S.length)*g/2;S.forEach((E,I)=>{o.set(E.id,{x:k*v,y:j+I*g})})}),o}function gN(e,r){const o=new Set(e.map(h=>h.id)),s=Math.max(e.length-1,0),a=new Map;for(const h of e)a.set(h.id,0);for(let h=0;h(a.get(y.dst)||0)&&(a.set(y.dst,x),p=!0)}if(!p)break}const u=new Map;for(const h of e){const p=a.get(h.id)||0,y=u.get(p)??[];y.push(h),u.set(p,y)}const c=[...u.keys()].sort((h,p)=>h-p).map(h=>(u.get(h)??[]).sort(rn));return pN(c,r)}function mN(e,r){const o=new Map;if(!e.length)return o;const s=new Set(e.map(g=>g.id)),a=new Map,u=new Map;for(const g of e)a.set(g.id,[]),u.set(g.id,0);for(const g of r)!s.has(g.src)||!s.has(g.dst)||g.src===g.dst||(a.get(g.src).push(g.dst),a.get(g.dst).push(g.src),u.set(g.src,(u.get(g.src)||0)+1),u.set(g.dst,(u.get(g.dst)||0)+1));const c=[...e].sort((g,w)=>(u.get(w.id)||0)-(u.get(g.id)||0)||rn(g,w))[0]??e[0],h=new Map,p=[[c]];h.set(c.id,0);const y=[c];for(;y.length;){const g=y.shift(),w=h.get(g.id)||0,S=(a.get(g.id)??[]).map(k=>e.find(j=>j.id===k)).filter(k=>!!k).sort(rn);for(const k of S){if(h.has(k.id))continue;h.set(k.id,w+1);const j=p[w+1]??[];j.push(k),p[w+1]=j,y.push(k)}}const x=e.filter(g=>!h.has(g.id)).sort(rn);x.length&&p.push(x);const v=bt+32;return p.forEach((g,w)=>{if(w===0&&g.length===1){o.set(g[0].id,{x:0,y:0});return}const S=Math.max(w*(bt+Hr),g.length<=1?bt:g.length*v/(2*Math.PI));g.forEach((k,j)=>{const E=-Math.PI/2+2*Math.PI*j/g.length;o.set(k.id,{x:Math.cos(E)*S,y:Math.sin(E)*S})})}),o}function yN(e){const r=new Map,o=[...e].sort((c,h)=>kn(c.type)-kn(h.type)||rn(c,h)),s=Math.max(1,Math.ceil(Math.sqrt(o.length))),a=bt+Hr,u=Fn+fl;return o.forEach((c,h)=>{r.set(c.id,{x:h%s*a,y:Math.floor(h/s)*u})}),r}function vN(e){const r=new Map,o=[...e].sort(Im);return o.length<=1?(o[0]&&r.set(o[0].id,{x:0,y:0}),r):(Hc(o,Bc(o.length,1),r),r)}function xN(e){const r=new Map;if(!e.length)return r;const o=new Map;for(const a of e){const u=kn(a.type),c=o.get(u)??[];c.push(a),o.set(u,c)}return[...o.keys()].sort((a,u)=>a-u).forEach((a,u)=>{const c=(o.get(a)??[]).sort(rn);if(u===0&&c.length===1){r.set(c[0].id,{x:0,y:0});return}Hc(c,Bc(c.length,u===0?1:u),r)}),r}function wN(e){const r=new Map;if(!e.length)return r;const o=new Map;for(const h of e){const p=o.get(h.type)??[];p.push(h),o.set(h.type,p)}const a=[...o.keys()].sort((h,p)=>kn(h)-kn(p)||h.localeCompare(p)).map(h=>{const p=(o.get(h)??[]).sort(rn),y=Math.max(1,Math.ceil(Math.sqrt(p.length))),x=Math.ceil(p.length/y);return{members:p,cols:y,width:Math.max(0,y-1)*go,height:Math.max(0,x-1)*Ka}}),u=Math.max(...a.map(h=>Math.hypot(h.width,h.height)/2+bt),bt),c=a.length<=1?0:Math.max(go,a.length*(u*2+Hr)/(2*Math.PI));return a.forEach((h,p)=>{const y=a.length===1?0:-Math.PI/2+2*Math.PI*p/a.length,x=Math.cos(y)*c,v=Math.sin(y)*c;h.members.forEach((g,w)=>{const S=w%h.cols,k=Math.floor(w/h.cols);r.set(g.id,{x:x-h.width/2+S*go,y:v-h.height/2+k*Ka})})}),r}function _N(e,r){const o=new Map;if(!e.length)return o;const s=new Map(e.map(w=>[w.id,w])),a=new Set(s.keys()),u=new Map,c=new Map;for(const w of e)u.set(w.id,[]),c.set(w.id,0);for(const w of r)!a.has(w.src)||!a.has(w.dst)||w.src===w.dst||(u.get(w.src).push(w.dst),c.set(w.dst,(c.get(w.dst)||0)+1));for(const[w,S]of u){const k=[...new Set(S)];k.sort((j,E)=>rn(s.get(j),s.get(E))),u.set(w,k)}const h=e.filter(w=>(c.get(w.id)||0)===0).sort(rn);if(!h.length){const w=[...e].sort((S,k)=>{var j,E;return(((j=u.get(k.id))==null?void 0:j.length)||0)-(((E=u.get(S.id))==null?void 0:E.length)||0)||rn(S,k)})[0];h.push(w)}const p=new Set,y=new Map;for(const w of e)y.set(w.id,[]);const x=w=>{p.add(w);for(const S of u.get(w)??[])p.has(S)||(y.get(w).push(S),x(S))};for(const w of h)p.has(w.id)||x(w.id);for(const w of[...e].sort(rn))p.has(w.id)||(h.push(w),x(w.id));let v=0;const g=(w,S)=>{const k=y.get(w)??[];if(!k.length){o.set(w,{x:v*go,y:S*Ka}),v+=1;return}const j=v;for(const E of k)g(E,S+1);o.set(w,{x:(j+v-1)/2*go,y:S*Ka})};for(const w of h)o.has(w.id)||g(w.id,0);return o}function SN(e,r){const o=bt+24,s=Fn+16;for(let a=0;a<8;a++)for(let u=0;ug.id)),h=[],p=new Set;for(const g of r){if(!c.has(g.src)||!c.has(g.dst)||g.src===g.dst)continue;const w=g.src[g.id,g])),a=[];bN.has(e.type)&&a.push("sink"),EN.has(e.type)&&a.push("contract");const u=e.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.ninja_schema&&a.push("ninja schema"),u.next_app&&a.push("app router"),u.typed_client&&a.push(String(u.typed_client)),u.e2e&&a.push("e2e"),u.filterset===!0&&a.push("filterset");const c=o.filter(g=>g.dst===e.id),h=o.filter(g=>g.src===e.id),p=c.slice(0,Ra).map(g=>Ta(g,s,g.src)),y=h.slice(0,Ra).map(g=>Ta(g,s,g.dst)),x=e.file_path?`${e.file_path}${e.start_line?`:${e.start_line}`:""}`:void 0,v={type:e.type,typeLabel:rs(ci(e.type)),layer:rN[kn(e.type)]??"other",purpose:IN(e.type),name:e.name,qualifiedName:e.qualified_name,file:x,context:e.context,roles:a,facts:LN(u).filter(g=>!(g.key==="app"&&g.value===e.context)),inputs:p,outputs:y,extraInputs:Math.max(0,c.length-Ra),extraOutputs:Math.max(0,h.length-Ra),degreeIn:c.length,degreeOut:h.length,inputKinds:Cp(c.map(g=>Ta(g,s,g.src))),outputKinds:Cp(h.map(g=>Ta(g,s,g.dst))),pathSummary:""};return v.pathSummary=TN(v),v}function Cp(e){const r=new Map;for(const o of e){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function TN(e){const r=e.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=e.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Ta(e,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?rs(ci(s.type)):"",edgeType:e.type,edgeLabel:rs(e.type),inferred:e.confidence<.8}}function LN(e){const r=[...bp.filter(a=>a in e),...Object.keys(e).filter(a=>!bp.includes(a)&&!Ep.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||Ep.has(a)||PN.has(a))continue;s.add(a);const u=AN(a,e[a]);u!=null&&o.push({key:a,label:CN[a]??rs(a),value:u})}return o}function AN(e,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!MN.has(e)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return $N(e,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,jN),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function $N(e,r){const o=r.slice(0,4).map(a=>{if(e==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(e==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const Mp=12,Pp=.2,zN=.8,Qa=20,DN=Fn;function ON(e,r,o){const s=o??bm(e,r),a=[...new Set([...s.values()].map(p=>p.x))].sort((p,y)=>p-y),u=[];for(const p of r){const y=s.get(p.src),x=s.get(p.dst);if(!y||!x)continue;const v=y.y+Fn/2,g=x.y+Fn/2;if(Math.abs(v-g)S.y0-k.y0||S.y1-k.y1||S.id.localeCompare(k.id)),x=BN(y),v=Math.max(0,...x.values())+1,g=y[0].sourceX,w=FN(a,g);for(const S of y){const k=VN(x.get(S.id)??0,v),j=g+Qa+Math.max(1,w-2*Qa)*k;h.set(S.id,HN(S.sourceX,S.targetX,j))}}return h}function FN(e,r){const o=r-bt,s=e.find(a=>a>o+1);return s===void 0?Hr:Math.max(Hr,s-r)}function HN(e,r,o){const s=r-e-2*Qa;return s<1?.5:Math.min(1,Math.max(0,(o-e-Qa)/s))}function BN(e){const r=[],o=new Map;for(const s of e){let a=-1;for(let u=0;ur[u]+DN){a=u;break}a<0?(a=r.length,r.push(s.y1)):r[a]=Math.max(r[a],s.y1),o.set(s.id,a)}return o}function VN(e,r){return r<=1?.5:Pp+(zN-Pp)*e/(r-1)}const WN=new Set,UN=A.lazy(()=>$0(()=>import("./LayeredGraph3D-BCjRMvyT.js"),[],import.meta.url).then(e=>({default:e.LayeredGraph3D}))),YN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"},Za={n:ke.Top,e:ke.Right,s:ke.Bottom,w:ke.Left};function GN(e,r){const o=r.x-e.x,s=r.y-e.y;return Math.abs(o)>=Math.abs(s)?o>=0?{source:"e",target:"w"}:{source:"w",target:"e"}:s>=0?{source:"s",target:"n"}:{source:"n",target:"s"}}function XN({data:e,selected:r}){const o=(e.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",e.dim?"dim":"",o].filter(Boolean).join(" "),children:[["n","e","s","w"].map(s=>d.jsx(ui,{id:`tgt-${s}`,type:"target",position:Za[s],isConnectable:!1},`tgt-${s}`)),d.jsx("div",{className:"t",children:ci(e.type)}),d.jsx("div",{className:"n",title:e.name,children:Dr(e.name)}),["n","e","s","w"].map(s=>d.jsx(ui,{id:`src-${s}`,type:"source",position:Za[s],isConnectable:!1},`src-${s}`))]})}const qN={load:XN},KN=new Set(["django","react","stitch","arch"]);function QN({id:e,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:y,label:x,labelStyle:v,labelShowBg:g,labelBgStyle:w,labelBgPadding:S,labelBgBorderRadius:k,data:j,interactionWidth:E}){const[I,_,b]=Xa({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(j==null?void 0:j.stepPosition)??.5});return d.jsx(_s,{id:e,path:I,labelX:_,labelY:b,label:x,labelStyle:v,labelShowBg:g,labelBgStyle:w,labelBgPadding:S,labelBgBorderRadius:k,style:h,markerEnd:p,markerStart:y,interactionWidth:E})}const ZN={loadstep:QN};function JN({topologyKey:e}){const{fitView:r}=cl();return A.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,e]),null}function ej(e,r,o=null,s={}){const a=new Map(e.map(v=>[v.id,v])),u=s.layout??"layers",c=fN(u),h=NN(e,r,u),p=ON(e,r,h),y=e.map(v=>{var S;const g=((S=s.roles)==null?void 0:S[v.id])||[],w=!!s.testOverlay&&!g.includes("tested")&&!g.includes("untested")&&!g.includes("test")&&!g.includes("seed");return{id:v.id,type:"load",position:h.get(v.id)??{x:0,y:0},data:{name:v.name,type:v.type,file:v.file_path,roles:g,dim:w},selected:o===v.id,sourcePosition:ke.Right,targetPosition:ke.Left,width:bt,height:Fn,style:{width:bt,height:Fn}}}),x=r.filter(v=>a.has(v.src)&&a.has(v.dst)).map(v=>{const g=YN[v.weight]||"var(--edge-cheap)",w=!!(o&&(v.src===o||v.dst===o)),S=h.get(v.src)??{x:0,y:0},k=h.get(v.dst)??{x:0,y:0},j=c?{source:"e",target:"w"}:GN(S,k);return{id:v.id,source:v.src,target:v.dst,sourceHandle:`src-${j.source}`,targetHandle:`tgt-${j.target}`,sourcePosition:Za[j.source],targetPosition:Za[j.target],type:c?"loadstep":"default",animated:v.weight==="critical",data:{stepPosition:p.get(v.id)??.5},style:{stroke:g,strokeWidth:v.weight==="critical"?2.4:1.2,strokeDasharray:v.confidence<.8?"6 4":void 0},markerEnd:{type:cs.ArrowClosed,width:14,height:14,color:g},label:w?v.type.replaceAll("_"," "):void 0,labelStyle:w?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:w?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:w?[3,5]:void 0,labelBgBorderRadius:w?4:void 0}});return{rfNodes:y,rfEdges:x}}function tj({node:e,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:y}){const x=RN(e,r,o);return A.useEffect(()=>{const v=g=>{g.key==="Escape"&&s()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(v=>d.jsx("span",{className:"inspector-chip",children:v},v))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Dr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Dr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Dr(x.file)}),c&&e.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(e.file_path,e.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Dr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(v=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:v.label}),d.jsx("dd",{children:Dr(v.value)})]},v.key))}):null,d.jsx(Ip,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(Ip,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:y?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(e.id),children:"What if this changes"}):null,y?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>y(e.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:e.id),children:h?"Unpin":"Pin"}):null]})]})}function Ip({title:e,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[e,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Dr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Dr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function ic({nodes:e,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:y,repoPath:x,onOpenFile:v,pinnedId:g,onPin:w}){const[S,k]=A.useState(null),j=a!==void 0?a:S,E=ue=>{a===void 0&&k(ue),u==null||u(ue)},[I,_]=A.useState(null),[b,L]=A.useState(null),[$,F]=A.useState(()=>cN()),[Y,q]=A.useState(new Set(KN)),[te,J]=A.useState(!1),[ne,Q]=A.useState(""),[C,V]=A.useState(!1),W=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,U=I??oN(e.length),M=b??iN(e.length),D=te?j:null,H=A.useMemo(()=>p?uN(e,r,p):null,[e,r,p]),R=H?e.filter(ue=>H.nodeIds.has(ue.id)):e,z=H?r.filter(ue=>H.edgeIds.has(ue.id)):r,re=A.useMemo(()=>aN(R,z,{detail:M,families:Y,focusId:D,neighborhoodOnly:!!D}),[R,z,M,Y,D]),oe=A.useMemo(()=>`${$}|${re.nodes.map(ue=>ue.id).join("\0")}|${re.edges.map(ue=>ue.id).join("\0")}`,[$,re.nodes,re.edges]),fe=j?e.find(ue=>ue.id===j)??null:null,{rfNodes:he,rfEdges:pe}=A.useMemo(()=>{const ue=ej(re.nodes,re.edges,j,{roles:c,testOverlay:h,layout:$});return W&&(ue.rfEdges=ue.rfEdges.map(je=>({...je,animated:!1}))),ue},[re.nodes,re.edges,j,W,c,h,$]);A.useEffect(()=>{if(!s)return;const ue=e.find(je=>je.file_path===s);ue&&E(ue.id)},[s,e]);const Z=A.useMemo(()=>lN(e,ne),[e,ne]),se=(ue,je)=>{E(je.id)},me=()=>{E(null),J(!1)},Ne=fe?d.jsx(tj,{node:fe,nodes:e,edges:r,onClose:me,onWhatIf:o,onSelect:E,onOpenFile:v,pinned:g===fe.id,onPin:w,onIsolate:y?ue=>{y(p===ue?null:ue)}:void 0}):null,we=ue=>{q(je=>{const Le=new Set(je);if(Le.has(ue)){if(Le.size===1)return je;Le.delete(ue)}else Le.add(ue);return Le})},ve=A.useMemo(()=>{const ue=new Set;for(const je of e)ue.add(Pm(je.type));return ue},[e]),Pe=e.length-re.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:U==="2d"?"active":"","aria-pressed":U==="2d",onClick:()=>_("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:U==="3d"?"active":"","aria-pressed":U==="3d",onClick:()=>_("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:M==="overview"?"active":"","aria-pressed":M==="overview",onClick:()=>L("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:M==="full"?"active":"","aria-pressed":M==="full",onClick:()=>L("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(ue=>ve.has(ue)).map(ue=>d.jsx("button",{type:"button","data-testid":`graph-family-${ue}`,className:Y.has(ue)?"active":"","aria-pressed":Y.has(ue),onClick:()=>we(ue),children:ue},ue))}),U==="2d"?d.jsxs("label",{className:"graph-layout",children:["Layout",d.jsx("select",{id:"graph-layout","data-testid":"graph-layout",value:$,"aria-label":"2D layout algorithm",onChange:ue=>{var Le;const je=(Le=Sc.find(nt=>nt.id===ue.target.value))==null?void 0:Le.id;je&&(F(je),dN(je))},children:Sc.map(ue=>d.jsx("option",{value:ue.id,children:ue.label},ue.id))})]}):null,d.jsx("button",{type:"button",className:te?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!j,onClick:()=>J(ue=>!ue),children:te?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>y==null?void 0:y(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:ne,onChange:ue=>{Q(ue.target.value),V(!0)},onFocus:()=>V(!0),onBlur:()=>window.setTimeout(()=>V(!1),150)}),C&&ne.trim()&&Z.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:Z.map(ue=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:je=>je.preventDefault(),onClick:()=>{E(ue.id),Q(""),V(!1)},children:[ue.name,d.jsx("span",{className:"muted",children:ci(ue.type)})]})},ue.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[re.nodes.length," nodes · ",re.edges.length," edges",Pe?` · ${Pe} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:e.length===0?d.jsxs("div",{className:"empty graph-walk-empty","data-testid":"graph-walk-empty",children:[d.jsx("h2",{children:"No typed nodes on this walk"}),d.jsx("p",{children:"This range did not hit models, views, routes, or React pages Loadpath extracts. Open the architecture map for the indexed graph."})]}):U==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(A.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(UN,{nodes:re.nodes,edges:re.edges,selectedId:j,neighborIds:D?re.neighborIds:WN,onSelect:ue=>{E(ue),ue||J(!1)}})}),Ne]}):d.jsxs(Sm,{children:[d.jsxs(mk,{nodes:he,edges:pe,nodeTypes:qN,edgeTypes:ZN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:se,onPaneClick:me,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(JN,{topologyKey:oe}),d.jsx(_k,{}),d.jsx(Bk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(Ck,{})]}),Ne]})})]})}function Rm(){const e=localStorage.getItem("loadpath.editor")||"auto";return e==="cursor"||e==="vscode"||e==="system"?e:"auto"}function nj(e){localStorage.setItem("loadpath.editor",e)}async function rj(e,r,o,s=Rm()){try{const a=await Te.openEditor(e,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const Rp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],oj=["preset","branch","tag","commit"];function ij(e){var a;if(!(e!=null&&e.git))return[...Rp];const r=((a=e.presets)!=null&&a.length?e.presets:Rp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of e.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of e.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of e.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function sj(e,r){const o=r.trim().toLowerCase();return o?e.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):e}function aj(e){return oj.map(r=>({group:r,items:e.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function lj(e){return e==="preset"?"Common":e==="branch"?"Branches":e==="tag"?"Tags":"Recent commits"}function Tp({value:e,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=A.useId(),p=A.useRef(null),[y,x]=A.useState(!1),[v,g]=A.useState(null),[w,S]=A.useState(0),k=A.useMemo(()=>{const b=ij(u);return v===null?b:sj(b,v)},[u,v]),j=A.useMemo(()=>aj(k),[k]);A.useEffect(()=>{y&&c()},[y,c]),A.useEffect(()=>{S(0)},[v,y]);const E=()=>{x(!1),g(null)},I=b=>{r(b.value),E()},_=b=>{if(b.key==="ArrowDown"){if(b.preventDefault(),!y){x(!0);return}S(L=>Math.min(L+1,Math.max(k.length-1,0)))}else if(b.key==="ArrowUp"){if(b.preventDefault(),!y)return;S(L=>Math.max(L-1,0))}else if(b.key==="Enter"&&y){b.preventDefault();const L=k[w];L&&I(L)}else b.key==="Escape"&&y&&(b.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:b=>{b.currentTarget.contains(b.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:e,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":h,"aria-autocomplete":"list",onChange:b=>{r(b.target.value),y&&g(b.target.value)},onKeyDown:_}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:b=>b.preventDefault(),onClick:()=>y?E():x(!0),children:d.jsx(T0,{})})]}),y?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:j.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):j.map(b=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:lj(b.group)}),b.items.map(L=>{const $=k.indexOf(L);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===w,className:$===w?"combo-option active":"combo-option","data-testid":`ref-option-${L.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>S($),onClick:()=>I(L),children:[d.jsx("span",{className:"combo-label",children:L.label}),L.detail?d.jsx("span",{className:"combo-detail",children:L.detail}):null]},`${L.group}:${L.value}`)})]},b.group))}):null]})}function uj({initialPath:e,onSelect:r,onClose:o}){const[s,a]=A.useState(null),[u,c]=A.useState(e),[h,p]=A.useState(null),[y,x]=A.useState(""),[v,g]=A.useState(!1),w=A.useRef(null),S=A.useRef(0),k=async _=>{const b=S.current+1;S.current=b,g(!0);try{const L=await Te.browse(_);if(S.current!==b)return;a(L),c(L.path),p(L.is_git?L.path:null),x("")}catch(L){if(S.current!==b)return;x(L instanceof Error?L.message:String(L))}finally{S.current===b&&g(!1)}};A.useEffect(()=>{var _,b;k(e),(_=w.current)==null||_.focus(),(b=w.current)==null||b.select()},[e]);const j=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",I=_=>{_.key==="Escape"&&(_.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:I,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:_=>_.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:_=>{_.preventDefault(),k(u)},children:[d.jsx("input",{ref:w,"data-testid":"explorer-path",value:u,onChange:_=>c(_.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void k(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void k(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?d.jsx("div",{className:"error",role:"alert",children:y}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":v,children:s!=null&&s.entries.length?s.entries.map(_=>{const b=h===_.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":b,className:b?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":_.path,onClick:()=>p(_.path),onDoubleClick:()=>void k(_.path),children:[d.jsx(zp,{}),d.jsx("span",{className:"explorer-name",children:_.name}),_.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},_.path)}):d.jsx("div",{className:"muted explorer-empty",children:v?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:j,children:j}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!j,onClick:()=>j&&r(j),children:["Use ",E]})]})]})})}const cj={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},dj=new Set(["scan","extract","boot","stitch"]);function fj(e){const r=e.phase||"";if(!r||r==="idle")return null;const o=cj[r];if(!o)return null;if(o.start===o.end)return o.end;const s=e.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(e.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function hj(e){return!e.phase||e.phase==="idle"?null:typeof e.percent=="number"&&Number.isFinite(e.percent)?Math.max(0,Math.min(100,Math.round(e.percent))):fj(e)}const Ja=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],pj="obsidian",Tm="loadpath.theme";function gj(e){return Ja.some(r=>r.id===e)}function Lm(){try{const e=localStorage.getItem(Tm)||"";if(gj(e))return e}catch{}return pj}function mj(e){var r;return((r=Ja.find(o=>o.id===e))==null?void 0:r.group)==="light"?"light":"dark"}function Am(e){document.documentElement.dataset.theme=e,document.documentElement.style.colorScheme=mj(e);try{localStorage.setItem(Tm,e)}catch{}}const sc=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:C0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:M0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:P0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:I0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:R0}];function ac(e,r,o){let s;try{s=new URL(e)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function yj(){var yi,Mo,vi,xi,wi,Po,Qr,un,cn,dn;const[e,r]=A.useState("review"),[o,s]=A.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=A.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=A.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,y]=A.useState(null),[x,v]=A.useState(null),[g,w]=A.useState(null),[S,k]=A.useState([]),[j,E]=A.useState("review"),[I,_]=A.useState(""),[b,L]=A.useState(""),[$,F]=A.useState(null),[Y,q]=A.useState(!1),[te,J]=A.useState(!1),[ne,Q]=A.useState(""),[C,V]=A.useState({}),[W,U]=A.useState([]),[M,D]=A.useState([]),[H,R]=A.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,re]=A.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=A.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=A.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=A.useState(0),[me,Ne]=A.useState(""),[we,ve]=A.useState(Lm),[Pe,ue]=A.useState(!1),[je,Le]=A.useState(!1),[nt,lt]=A.useState(!1),[ut,Ge]=A.useState(null),[wt,Xt]=A.useState(null),[gt,mt]=A.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Mt,ct]=A.useState(null),[et,Bn]=A.useState(localStorage.getItem("loadpath.watch")==="1"),[Pt,bn]=A.useState([]),[di,Vn]=A.useState(null),[So,dr]=A.useState(null),[Br,Wn]=A.useState(null),[Vr,fr]=A.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[hr,Ht]=A.useState(null),[dt,Un]=A.useState(null),[Yn,En]=A.useState(!1),[Gn,Cn]=A.useState(!1),it=A.useRef(o);it.current=o;const pr=A.useRef(he);pr.current=he;const Mn=A.useRef(!1);Mn.current=je;const It=A.useRef(""),on=A.useRef(""),ko=P=>{ve(P),Am(P)},Ze=A.useRef(""),He=P=>{Ze.current=P,L(P)},Pn=P=>{let G=0,ce=!1;F(0);const Ce=()=>{Te.indexProgress(P).then(Re=>{if(!Ze.current)return;if(Re.phase&&Re.phase!=="idle"&&Re.message&&He(Re.message),dj.has(Re.phase))ce=!0;else if(!ce)return;const xr=hj(Re);xr!=null&&(Re.phase==="scan"&&!Re.done?G=xr:G=Math.max(G,xr),F(G))}).catch(()=>{})};Ce();const Ie=window.setInterval(Ce,250);return()=>{window.clearInterval(Ie),F(null)}};A.useEffect(()=>{Te.settings().then(V).catch(()=>{}).finally(()=>ue(!0)),Te.repos().then(P=>k(P.repos)).catch(()=>{})},[]);const Xn=()=>o.trim()?!0:(_("Point at a local repository path first."),!1);A.useEffect(()=>{if(e!=="architecture"||!o.trim())return;const P=o;let G=!1;return on.current!==P&&Kn(P),Te.config(P).then(ce=>{!G&&it.current===P&&dr(ce)}).catch(()=>{}),Te.architectureHealth(P).then(ce=>{!G&&it.current===P&&Wn(ce)}).catch(()=>{}),()=>{G=!0}},[e,o]);const sn=P=>{it.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==It.current&&(It.current="",Ht(null))},Wr=A.useCallback(P=>{const G=(P??it.current).trim();return!G||It.current===G?Promise.resolve():(It.current=G,Te.gitRefs(G).then(ce=>{it.current.trim()===G&&Ht(ce)}).catch(()=>{It.current===G&&(It.current="",Ht(null))}))},[]),an=(P,G)=>{u(P),h(G),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",G)},Rt=(P,G,ce)=>{re(P),R(G),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",G),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},qt=P=>{y(P),se(0),Ge(wt&&P.nodes.some(G=>G.id===wt)?wt:null),ct(null),Vn(null),P.what_if||(v(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},qn=async P=>{try{const G=await Te.reviews(P);bn(G.reviews)}catch{bn([])}},No=async P=>{try{Wn(await Te.architectureHealth(P))}catch{Wn(null)}},jo=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,Tt=A.useCallback(async(P=z)=>{var G;try{const ce=await Te.scmRepos(P);D(ce.repos),(G=ce.user)!=null&&G.login&&V(Ce=>({...Ce,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);A.useEffect(()=>{if(e!=="prs")return;let P=!1;return Tt(z).catch(()=>{P||D([])}),()=>{P=!0}},[e,z,Tt]),A.useEffect(()=>{if(!dt)return;let P=!1,G=0;const ce=async()=>{try{const Ce=await Te.githubOAuthPoll(dt.flow_id);if(P)return;if(Ce.status==="complete"){Un(null);const Ie=await Te.settings();V(Ie),Q(Ce.user?`Signed in to GitHub as ${Ce.user}`:"Signed in to GitHub"),Tt("github");return}if(Ce.status==="pending"||Ce.status==="slow_down"){G=window.setTimeout(ce,Math.max(Ce.interval||dt.interval,5)*1e3);return}Un(null),_(Ce.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Ce){if(P)return;Un(null),_(Ce instanceof Error?Ce.message:String(Ce))}};return G=window.setTimeout(ce,Math.max(dt.interval,5)*1e3),()=>{P=!0,window.clearTimeout(G)}},[dt,Tt]),A.useEffect(()=>{if(!Yn)return;let P=!1,G=0;const ce=Date.now(),Ce=async()=>{try{const Ie=await Te.oauthStatus();if(P)return;if(Ie.bitbucket.connected){En(!1);const Re=await Te.settings();V(Re),Q(Ie.bitbucket.user?`Signed in to Bitbucket as ${Ie.bitbucket.user}`:"Signed in to Bitbucket"),Tt("bitbucket");return}if(Date.now()-ce>18e4){En(!1),_("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Ce,1500)}catch(Ie){if(P)return;En(!1),_(Ie instanceof Error?Ie.message:String(Ie))}};return G=window.setTimeout(Ce,1500),()=>{P=!0,window.clearTimeout(G)}},[Yn,Tt]),A.useEffect(()=>{if(!Gn)return;let P=!1,G=0;const ce=Date.now(),Ce=async()=>{try{const Ie=await Te.oauthStatus();if(P)return;if(Ie.gitlab.connected){Cn(!1);const Re=await Te.settings();V(Re),Q(Ie.gitlab.user?`Signed in to GitLab as ${Ie.gitlab.user}`:"Signed in to GitLab"),Tt("gitlab");return}if(Date.now()-ce>18e4){Cn(!1),_("GitLab sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Ce,1500)}catch(Ie){if(P)return;Cn(!1),_(Ie instanceof Error?Ie.message:String(Ie))}};return G=window.setTimeout(Ce,1500),()=>{P=!0,window.clearTimeout(G)}},[Gn,Tt]);const Kn=async(P=o,G=!1)=>{if(!P.trim())return null;on.current=P,J(!0);try{const ce=await Te.architecture(P,!1);it.current===P&&w(ce);const Ce=Te.architectureGraph(P).then(Ie=>{it.current===P&&w(Re=>Re&&{...Re,nodes:Ie.nodes,edges:Ie.edges,graph_pending:!1})});return Ce.catch(()=>{w(Ie=>Ie&&it.current===P?{...Ie,graph_pending:!1}:Ie)}).finally(()=>{on.current===P&&J(!1)}),G&&await Ce,ce}catch(ce){throw it.current===P&&J(!1),ce}},Ur=async P=>{const G=P.trim();if(!(!G||G===it.current)){if(Ze.current){_("Wait for the current job to finish before switching workspace.");return}_(""),Q(""),y(null),v(null),w(null),E("architecture"),sn(G),q(!0),He(`Loading ${E0(G)}…`);try{await Promise.all([Kn(G),Wr(G)])}catch(ce){it.current===G&&_(ce instanceof Error?ce.message:String(ce))}finally{it.current===G&&(He(""),q(!1))}}},Qn=async()=>{if(Ze.current||!Xn())return;_(""),Q(""),He("Tracing load path…"),sn(o),an(a,c);const P=Pn(o);try{const G=await Te.review(o,a,c,!0,pr.current);qt(G),E("review"),r("review"),await Te.repos().then(ce=>k(ce.repos)).catch(()=>{}),await Promise.all([Kn(o),qn(o),No(o)])}catch(G){_(G instanceof Error?G.message:String(G))}finally{P(),He("")}},gr=async(P=!0)=>{if(Ze.current||!Xn())return;_(""),Q(""),He(P?"Indexing…":"Full reindex…"),sn(o);const G=Pn(o);try{await Te.index(o,P);const ce=await Kn(o);await Te.repos().then(Ce=>k(Ce.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){_(ce instanceof Error?ce.message:String(ce))}finally{G(),He("")}},Ve=async()=>{if(!Ze.current&&Xn()){_(""),Q(""),He("Detecting layout…"),sn(o);try{const P=await Te.init(o);Q(P.message),await Te.repos().then(G=>k(G.repos)).catch(()=>{})}catch(P){_(P instanceof Error?P.message:String(P))}finally{He("")}}},fi=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),Q("Copied markdown brief")}catch(P){_(P instanceof Error?P.message:String(P))}},Yr=async()=>{if(!Ze.current){if(p!=null&&p.what_if){_("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){_("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Te.postComment(z,H,Number(oe),p.markdown);Q(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){_(P instanceof Error?P.message:String(P))}finally{He("")}}},bo=async()=>{if(!Ze.current){_(""),He("Fetching pull requests…");try{const P=await Te.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const G=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());G!=null&&G.local_path&&sn(G.local_path)}catch(P){_(P instanceof Error?P.message:String(P))}finally{He("")}}},mr=async()=>{_("");try{const P=await Te.githubOAuthStart();Un(P),ac(P.verification_uri_complete,"github.com","/login/device")}catch(P){_(P instanceof Error?P.message:String(P))}},hi=async()=>{_("");try{const P=await Te.bitbucketOAuthStart();En(!0),ac(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){En(!1),_(P instanceof Error?P.message:String(P))}},Eo=async()=>{_("");try{const P=await Te.gitlabOAuthStart();Cn(!0),ac(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){Cn(!1),_(P instanceof Error?P.message:String(P))}},In=async P=>{if(!(Ze.current||!o.trim())){_(""),He("Walking what-if path…");try{const G=await Te.whatIf(o,P);Q(`${G.title} — ${G.confidence.level} · ${(G.sinks||[]).length} sinks`),qt({...G,markdown:G.markdown||"",index:G.index||(p==null?void 0:p.index),workspace:G.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(G){_(G instanceof Error?G.message:String(G))}finally{He("")}}},_t=()=>{if(x){qt(x),E("review"),r("review"),Q("Restored the last git-range walk");return}y(null),se(0),Ge(null),ct(null),Vn(null),E("architecture"),r("architecture"),Q("")},pi=async P=>{var Ie;if(Ze.current)return;Rt(P.provider,P.repo,String(P.number));const G=M.find(Re=>Re.slug.toLowerCase()===P.repo.toLowerCase());G!=null&&G.local_path&&sn(G.local_path),_(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(G==null?void 0:G.local_path)||o,Ce=ce?Pn(ce):()=>{};try{const Re=await Te.reviewPr(P.provider,P.repo,P.number,(G==null?void 0:G.local_path)||o||void 0);qt(Re),Re.pull_request&&typeof Re.pull_request.repo_path=="string"&&sn(Re.pull_request.repo_path),an(String(Re.base||P.target_branch),String(Re.head||P.source_branch)),E("review"),r("review"),typeof((Ie=Re.pull_request)==null?void 0:Ie.repo_path)=="string"&&qn(Re.pull_request.repo_path)}catch(Re){an(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),_(Re instanceof Error?Re.message:String(Re))}finally{Ce(),He("")}},yt=async P=>{_("");try{V(await Te.oauthDisconnect(P)),z===P&&D([]),Q(`Disconnected ${P}`)}catch(G){_(G instanceof Error?G.message:String(G))}},gi=async P=>{P.preventDefault();const G=new FormData(P.currentTarget),ce={github_token:String(G.get("github_token")||""),github_oauth_client_id:String(G.get("github_oauth_client_id")||""),github_host:String(G.get("github_host")||""),gitlab_token:String(G.get("gitlab_token")||""),gitlab_host:String(G.get("gitlab_host")||""),gitlab_oauth_client_id:String(G.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(G.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(G.get("bitbucket_token")||""),bitbucket_username:String(G.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(G.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(G.get("bitbucket_oauth_client_secret")||""),ai_provider:String(G.get("ai_provider")||"none"),ai_api_key:String(G.get("ai_api_key")||""),ai_model:String(G.get("ai_model")||""),ai_base_url:String(G.get("ai_base_url")||"")},Ce=S.length?{...ce,workspaces:S.map(Ie=>({path:Ie.path,name:Ie.name}))}:ce;try{V(await Te.saveSettings(Ce)),Q("Settings saved on this machine")}catch(Ie){_(Ie instanceof Error?Ie.message:String(Ie))}},mi=async()=>{if(!(!p||Ze.current)){He("Residual analysis…");try{const P=await Te.residual(p);Ne(P.note)}catch(P){_(P instanceof Error?P.message:String(P))}finally{He("")}}},Gr=A.useRef(Qn);Gr.current=Qn;const Rn=A.useRef(e);Rn.current=e;const Zn=A.useRef(!1);Zn.current=nt;const Tn=A.useRef(p);Tn.current=p;const Kt=A.useRef(Z);Kt.current=Z,A.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),G=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!G){fr(!1);return}let ce=!1;return Te.getReview(G,P).then(Ce=>{ce||(qt(Ce),an(Ce.base||localStorage.getItem("loadpath.base")||"HEAD~1",Ce.head||localStorage.getItem("loadpath.head")||"HEAD"),qn(G),No(G))}).catch(()=>{}).finally(()=>{ce||fr(!1)}),()=>{ce=!0}},[]);const Xr=A.useRef("");A.useEffect(()=>{if(!et||!o.trim())return;let P=!1;const G=async()=>{try{const Ce=await Te.workspaceStatus(o);if(P)return;Xr.current&&Ce.fingerprint!==Xr.current&&!Ze.current&&(pe(!0),pr.current=!0,localStorage.setItem("loadpath.dirty","1"),Gr.current()),Xr.current=Ce.fingerprint}catch{}};G();const ce=window.setInterval(G,2e3);return()=>{P=!0,window.clearInterval(ce)}},[et,o]),A.useEffect(()=>{const P=G=>{var Ie;if((G.metaKey||G.ctrlKey)&&G.key.toLowerCase()==="k"){G.preventDefault(),lt(Re=>!Re);return}if(Zn.current){G.key==="Escape"&&(G.preventDefault(),lt(!1));return}if(Mn.current){G.key==="Escape"&&(G.preventDefault(),Le(!1));return}const ce=G.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){G.key==="Escape"&&ce.blur();return}if(G.key==="Escape"){_(""),Q(""),Ge(wt),ct(null);return}if(G.key==="j"||G.key==="k"){const Re=((Ie=Tn.current)==null?void 0:Ie.read_order)||[];if(!Re.length)return;G.preventDefault();const _i=Kt.current,xr=G.key==="j"?Math.min(Re.length-1,_i+1):Math.max(0,_i-1);se(xr);return}const Ce=sc.find(Re=>Re.shortcut===G.key);if(Ce&&!G.metaKey&&!G.ctrlKey&&!G.altKey&&r(Ce.id),(G.metaKey||G.ctrlKey)&&G.key==="Enter"){if(Rn.current==="settings"||Rn.current==="prs"||Ze.current)return;G.preventDefault(),Gr.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const qr=async(P,G)=>{if(!o.trim())return;const ce=await rj(o,P,G);ce.ok?Q(ce.message):_(ce.message)},yr=async()=>{if(p)try{const P=await Te.exportHtml(p),G=URL.createObjectURL(P),ce=document.createElement("a");ce.href=G,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(G),Q("Saved HTML brief")}catch(P){_(P instanceof Error?P.message:String(P))}},Kr=async P=>{if(o.trim()){He("Loading stored review…");try{const G=await Te.getReview(o,P);qt(G),an(G.base||a,G.head||c),E("review"),r("review");const ce=Pt.findIndex(Ie=>Ie.id===P),Ce=ce>=0?Pt[ce+1]:void 0;if(Ce)try{Vn(await Te.reviewDiff(o,P,Ce.id))}catch{Vn(null)}}catch(G){_(G instanceof Error?G.message:String(G))}finally{He("")}}},ln={selectedId:ut,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Mt,onIsolate:ct,repoPath:o,onOpenFile:qr,pinnedId:wt,onPin:Xt},Jn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void Qn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:_t}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void gr(!0)},{id:"watch",group:"Run",label:et?"Stop watching working tree":"Watch working tree",run:()=>{const P=!et;Bn(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void yr()},...sc.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:ci(P.type),run:()=>{Ge(P.id),r("graph")}})),...Pt.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void Kr(P.id)}))],Co=A.useMemo(()=>j==="architecture"?(g==null?void 0:g.nodes)??[]:(p==null?void 0:p.nodes)??[],[j,g,p]),vr=A.useMemo(()=>j==="architecture"?(g==null?void 0:g.edges)??[]:(p==null?void 0:p.edges)??[],[j,g,p]),Fe=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:g!=null&&g.indexed?`${g.counts.nodes} nodes · ${g.counts.edges} edges`:"Not indexed",Ss=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),sc.map(P=>{const G=P.icon,ce=e===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(G,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:we,onChange:P=>ko(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Ja.filter(G=>G.group===P).map(G=>d.jsx("option",{value:G.id,children:G.label},G.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:b||Fe}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[b?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:$!=null?"progressbar":"status","aria-label":b,"aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:b})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[S.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:S.some(P=>P.path===o)?o:"",disabled:!!b,"aria-busy":Y,onChange:P=>{P.target.value&&Ur(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),S.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const G=P.target.value;s(G),G.trim()!==It.current&&(It.current="",Ht(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>Le(!0),children:d.jsx(zp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(Tp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>an(P,c),placeholder:"base",refs:hr,onNeedRefs:Wr})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(Tp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>an(a,P),placeholder:"head",refs:hr,onNeedRefs:Wr})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:et?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":et,onClick:()=>{const P=!et;Bn(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:et?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!b,onClick:Ve,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!b,onClick:()=>gr(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!b,onClick:Qn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[I?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:I}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>_(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>Q(""),"aria-label":"Dismiss",children:"×"})]}):null,((yi=p==null?void 0:p.index)!=null&&yi.stale||g!=null&&g.stale)&&(e==="review"||e==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((Mo=p==null?void 0:p.index)==null?void 0:Mo.django_boot)==="failed"||(g==null?void 0:g.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((vi=p==null?void 0:p.index)==null?void 0:vi.django_boot_detail)||(g==null?void 0:g.django_boot_detail)||"django.setup() failed"}):null,(xi=p==null?void 0:p.workspace)!=null&&xi.dirty_overlaps_review&&e==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((wi=p.node)==null?void 0:wi.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:_t,children:x?"Back to git range":"Back to architecture"})]}):null,Y?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:b||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":Y||te,children:[e==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(vj,{review:p,findings:Ss,aiNote:me,busy:!!b,tourIndex:Z,onTour:se,onAskAi:mi,onCopy:fi,onPost:Yr,onSelect:Ge,onOpenFile:qr,onExport:yr,history:Pt,diff:di,onReopen:Kr,onWaiver:(P,G)=>{o.trim()&&Te.addWaiver(o,P,G||void 0,"from review").then(ce=>{dr(ce),Q(`Waived ${P} in loadpath.yml`)})}}):Vr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(ic,{nodes:p.nodes,edges:p.edges,onWhatIf:In,focusPath:(Po=p.read_order[Z])==null?void 0:Po.path,...ln}):null})]}),e==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:g!=null&&g.indexed?d.jsx(xj,{architecture:g,busy:!!b,onReindex:()=>gr(!1),onReview:Qn,onSelect:Ge,config:So,health:Br,onSaveConfig:P=>{Te.saveConfig(o,P).then(G=>{dr(G),Q("Wrote loadpath.yml")})},onWaiver:(P,G,ce)=>{Te.addWaiver(o,P,G,ce).then(Ce=>{dr(Ce),Q(`Waived ${P}`)})}}):Y?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||g!=null&&g.graph_pending)&&!((g==null?void 0:g.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(Qr=g==null?void 0:g.counts)!=null&&Qr.nodes?`${g.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):g!=null&&g.indexed?d.jsx(ic,{nodes:g.nodes,edges:g.edges,onWhatIf:In,...ln,isolateSource:null,onIsolate:void 0}):null})]}),e==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":j==="review","data-testid":"graph-mode-review",className:j==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":j==="architecture","data-testid":"graph-mode-architecture",className:j==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),Co.length||j==="review"&&p||g!=null&&g.indexed&&!(te||g!=null&&g.graph_pending)?d.jsx(ic,{nodes:Co,edges:vr,onWhatIf:In,...ln,...j==="architecture"?{isolateSource:null,onIsolate:void 0,nodeRoles:void 0,testOverlay:!1}:{}}):te||g!=null&&g.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),e==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Rt(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Rt(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!b||!jo(z),onClick:()=>{Tt(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!b,onClick:bo,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var G;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((G=P.loadpath.level)==null?void 0:G.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void pi(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),e==="settings"&&Pe&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:gi,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ja.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:we===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>ko(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:Rm(),onChange:P=>nj(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void yt("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!dt||!C.github_oauth_ready,onClick:()=>void mr(),children:dt?"Waiting for GitHub…":"Sign in with GitHub"})})]}),dt?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:dt.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void yt("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Gn||!C.gitlab_oauth_ready,onClick:()=>void Eo(),children:Gn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void yt("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:Yn||!C.bitbucket_oauth_ready,onClick:()=>void hi(),children:Yn?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((un=C.ai)==null?void 0:un.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((cn=C.ai)==null?void 0:cn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((dn=C.ai)==null?void 0:dn.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(N0,{open:nt,actions:Jn,onClose:()=>lt(!1)}),je?d.jsx(uj,{initialPath:o,onClose:()=>Le(!1),onSelect:P=>{if(Ze.current){_("Wait for the current job to finish before switching workspace.");return}Le(!1),Ur(P)}}):null]})}function vj({review:e,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:y,onOpenFile:x,onExport:v,history:g,diff:w,onReopen:S,onWaiver:k}){var E,I,_,b,L,$,F,Y,q,te,J,ne,Q,C,V,W,U;const j=[...new Set(e.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${e.confidence.level}`,children:[d.jsxs("div",{className:`level ${e.confidence.level}`,children:[e.confidence.level.toUpperCase()," — ",e.title]}),j.length?d.jsx("ul",{className:"reasons",children:j.map(M=>d.jsx("li",{children:M},M))}):null,e.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,e.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,e.change_kinds.map(M=>d.jsx("span",{className:"chip",children:rs(M)},M)),(E=e.contract_break)!=null&&E.kind&&e.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${e.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",e.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[e.confidence.covered_sinks,"/",e.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:e.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:e.headline}),(e.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(e.checklist||[]).filter(M=>M.status==="todo").length})]}),(e.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>k(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,e.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:e.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",e.index.counts.nodes," nodes / ",e.index.counts.edges," edges",e.index.reindex_skipped?" from an unchanged index":e.index.reindexed?" after an incremental refresh":" from the existing index",e.index.django_boot&&e.index.django_boot!=="off"?` · Django boot ${e.index.django_boot}`:"",(I=e.workspace)!=null&&I.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:e.read_order.length})]}),e.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),e.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=e.read_order.length-1,onClick:()=>u(Math.min(e.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",e.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:e.clusters.length})]}),e.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:e.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx($m,{cards:e.deepening}),(b=(_=e.contract_break)==null?void 0:_.reasons)!=null&&b.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:e.contract_break.kind})]}),e.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(L=e.contract_break.sides)==null?void 0:L.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:e.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=e.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:e.auth.note}),(e.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(e.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(Y=e.suggested_tests)==null?void 0:Y.length})]}),(e.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=e.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:e.trend.note}),(e.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",lc(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:e.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),e.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),g.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:g.length})]}),w?d.jsx("div",{className:"muted",children:w.note}):null,g.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===e.id?"history-item current":"history-item",onClick:()=>S(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?lc(M.created_at):""})]},M.id))]}):null,(J=(te=e.evolution)==null?void 0:te.notes)!=null&&J.length||(Q=(ne=e.evolution)==null?void 0:ne.hotspots)!=null&&Q.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=e.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=e.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:v,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!e.what_if,title:e.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:e.suggested_reviewers.join(", ")||"—"}),(W=e.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",e.codeowners_reviewers.join(", ")]}):null,(U=e.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",e.knowledge_owners.join(", ")]}):null]})}function xj({architecture:e,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const y=e.findings.filter(v=>!v.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",e.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[e.indexed_at?`Last index ${lc(e.indexed_at)}`:"Indexed",e.incremental?" · incremental":" · full",e.stale?" · stale":"",e.django_boot&&e.django_boot!=="off"?` · Django boot ${e.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[e.counts.edges," edges"]}),e.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(e.contexts).map(v=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v.name})," — ",(v.django_apps||[]).join(", ")||"no apps"," ·"," ",(v.owners||[]).join(", ")||"unowned"]},v.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(e.rules||[]).length})]}),(e.rules||[]).map(v=>d.jsx("div",{className:"muted",children:v},v))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:y.length})]}),y.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):y.map(v=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>v.node_id&&a(v.node_id),children:[d.jsx("span",{className:`chip ${v.severity}`,children:v.severity}),v.message]})},v.rule+v.message))]}),d.jsx($m,{cards:e.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(v=>d.jsx("i",{className:v.level||"",title:`${v.level} · ${v.findings} findings`,style:{height:`${8+Math.min(24,(v.findings||0)*4)}px`}},v.id||v.created_at))}),Object.entries(c.contexts).map(([v,g])=>{var w;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v})," — last ",((w=g[g.length-1])==null?void 0:w.findings)??0," findings"]},v)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(j0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(e.type_counts||{}).sort((v,g)=>g[1]-v[1]).slice(0,12).map(([v,g])=>d.jsxs("tr",{children:[d.jsx("td",{children:ci(v)}),d.jsx("td",{children:g})]},v))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function $m({cards:e}){const r=e||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:b0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}Am(Lm());_0.createRoot(document.getElementById("root")).render(d.jsx(A.StrictMode,{children:d.jsx(yj,{})}));export{rN as L,Sj as a,wj as c,d as j,_j as l,A as r,ci as t}; diff --git a/src/loadpath/static/assets/index-CCz64vFJ.css b/src/loadpath/static/assets/index-Q9TpSg-b.css similarity index 71% rename from src/loadpath/static/assets/index-CCz64vFJ.css rename to src/loadpath/static/assets/index-Q9TpSg-b.css index d164dc1..3a56ef6 100644 --- a/src/loadpath/static/assets/index-CCz64vFJ.css +++ b/src/loadpath/static/assets/index-Q9TpSg-b.css @@ -1 +1 @@ -.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #555;--xy-background-pattern-lines-color-default: #333;--xy-background-pattern-cross-color-default: #333;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root,[data-theme=obsidian]{--bg: #070b10;--bg-2: #0d141c;--surface: #121a24;--line: #1e2c3c;--ink: #e7eef6;--muted: #8b9bb0;--high: #2a9d8f;--medium: #e9c46a;--low: #e76f51;--critical: #e85d04;--accent: #4cc9f0;--rail-from: #0b1219;--rail-to: #070b10;--rail-active: #15202c;--btn: #173044;--btn-line: #24506c;--btn-primary: #134e4a;--btn-primary-line: #2a9d8f;--node-bg: #101822;--node-line: #2a3d52;--graph-bg: #070b10;--graph-grid: rgba(42, 80, 120, .09);--edge-cheap: #4a5568;--edge-expensive: #f4a261;--edge-critical: #e85d04;--shadow: rgba(76, 201, 240, .08)}[data-theme=nord]{--bg: #2e3440;--bg-2: #3b4252;--surface: #434c5e;--line: #4c566a;--ink: #eceff4;--muted: #d8dee9;--high: #a3be8c;--medium: #ebcb8b;--low: #bf616a;--critical: #d08770;--accent: #88c0d0;--rail-from: #3b4252;--rail-to: #2e3440;--rail-active: #4c566a;--btn: #434c5e;--btn-line: #81a1c1;--btn-primary: #5e81ac;--btn-primary-line: #88c0d0;--node-bg: #3b4252;--node-line: #81a1c1;--graph-bg: #2e3440;--graph-grid: rgba(136, 192, 208, .12);--edge-cheap: #4c566a;--edge-expensive: #d08770;--edge-critical: #bf616a;--shadow: rgba(136, 192, 208, .12)}[data-theme=solarized-dark]{--bg: #002b36;--bg-2: #073642;--surface: #0a3944;--line: #16444f;--ink: #eee8d5;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #2aa198;--rail-from: #073642;--rail-to: #002b36;--rail-active: #16444f;--btn: #073642;--btn-line: #268bd2;--btn-primary: #0a4a42;--btn-primary-line: #2aa198;--node-bg: #073642;--node-line: #268bd2;--graph-bg: #002b36;--graph-grid: rgba(42, 161, 152, .12);--edge-cheap: #586e75;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(42, 161, 152, .12)}[data-theme=forest]{--bg: #0e1510;--bg-2: #152019;--surface: #1b2a20;--line: #2c4334;--ink: #e4f0e6;--muted: #8eaa96;--high: #6ab04c;--medium: #c8a951;--low: #e17055;--critical: #d35400;--accent: #7bed9f;--rail-from: #152019;--rail-to: #0e1510;--rail-active: #1f3326;--btn: #1f3326;--btn-line: #3d6b4f;--btn-primary: #1e4d32;--btn-primary-line: #6ab04c;--node-bg: #16241b;--node-line: #3d6b4f;--graph-bg: #0e1510;--graph-grid: rgba(123, 237, 159, .1);--edge-cheap: #3d6b4f;--edge-expensive: #c8a951;--edge-critical: #d35400;--shadow: rgba(123, 237, 159, .1)}[data-theme=rose]{--bg: #191724;--bg-2: #1f1d2e;--surface: #26233a;--line: #403d52;--ink: #e0def4;--muted: #908caa;--high: #9ccfd8;--medium: #f6c177;--low: #eb6f92;--critical: #eb6f92;--accent: #c4a7e7;--rail-from: #1f1d2e;--rail-to: #191724;--rail-active: #26233a;--btn: #26233a;--btn-line: #c4a7e7;--btn-primary: #3a2f4d;--btn-primary-line: #c4a7e7;--node-bg: #1f1d2e;--node-line: #524f67;--graph-bg: #191724;--graph-grid: rgba(196, 167, 231, .12);--edge-cheap: #524f67;--edge-expensive: #f6c177;--edge-critical: #eb6f92;--shadow: rgba(196, 167, 231, .12)}[data-theme=amber]{--bg: #120e0a;--bg-2: #1c1610;--surface: #261e16;--line: #3d2f22;--ink: #f4e6d0;--muted: #b59a78;--high: #c4d6a0;--medium: #e9b44c;--low: #d8572a;--critical: #c0392b;--accent: #f0a05a;--rail-from: #1c1610;--rail-to: #120e0a;--rail-active: #2b2218;--btn: #2b2218;--btn-line: #8a5a2b;--btn-primary: #4a3418;--btn-primary-line: #f0a05a;--node-bg: #1c1610;--node-line: #8a5a2b;--graph-bg: #120e0a;--graph-grid: rgba(240, 160, 90, .12);--edge-cheap: #5c4a38;--edge-expensive: #e9b44c;--edge-critical: #d8572a;--shadow: rgba(240, 160, 90, .12)}[data-theme=volcano]{--bg: #14090a;--bg-2: #1e0e10;--surface: #2a1416;--line: #4a2226;--ink: #fde8e4;--muted: #c48b86;--high: #7bed9f;--medium: #f6c90e;--low: #ff6b6b;--critical: #ff3b3b;--accent: #ff7b54;--rail-from: #1e0e10;--rail-to: #14090a;--rail-active: #32181b;--btn: #32181b;--btn-line: #ff7b54;--btn-primary: #5a1f18;--btn-primary-line: #ff7b54;--node-bg: #1e0e10;--node-line: #7a3330;--graph-bg: #14090a;--graph-grid: rgba(255, 123, 84, .12);--edge-cheap: #5a3330;--edge-expensive: #ff7b54;--edge-critical: #ff3b3b;--shadow: rgba(255, 123, 84, .14)}[data-theme=lavender]{--bg: #12101c;--bg-2: #1a1730;--surface: #221e3c;--line: #3b3560;--ink: #efeaff;--muted: #b3a7d6;--high: #80ffdb;--medium: #ffd166;--low: #ff6b9d;--critical: #ff4d6d;--accent: #c77dff;--rail-from: #1a1730;--rail-to: #12101c;--rail-active: #2a2550;--btn: #2a2550;--btn-line: #c77dff;--btn-primary: #3d2a66;--btn-primary-line: #c77dff;--node-bg: #1a1730;--node-line: #5a4d8a;--graph-bg: #12101c;--graph-grid: rgba(199, 125, 255, .12);--edge-cheap: #5a4d8a;--edge-expensive: #ffd166;--edge-critical: #ff4d6d;--shadow: rgba(199, 125, 255, .14)}[data-theme=neon-noir]{--bg: #05060a;--bg-2: #0a0c14;--surface: #10131c;--line: #1e2436;--ink: #f0f4ff;--muted: #8b93b0;--high: #39ff88;--medium: #ffe66d;--low: #ff2d95;--critical: #ff3d5a;--accent: #00f0ff;--rail-from: #0a0c14;--rail-to: #05060a;--rail-active: #151a2a;--btn: #151a2a;--btn-line: #00f0ff;--btn-primary: #063a40;--btn-primary-line: #00f0ff;--node-bg: #0a0c14;--node-line: #2a3550;--graph-bg: #05060a;--graph-grid: rgba(0, 240, 255, .12);--edge-cheap: #3a4560;--edge-expensive: #ff2d95;--edge-critical: #ff3d5a;--shadow: rgba(0, 240, 255, .22)}[data-theme=synthwave]{--bg: #1a0a2e;--bg-2: #240b3d;--surface: #2d1250;--line: #4a1d7a;--ink: #ffe6fb;--muted: #c49ad8;--high: #00f5d4;--medium: #ffd60a;--low: #ff6b9d;--critical: #ff006e;--accent: #ff2bd6;--rail-from: #240b3d;--rail-to: #1a0a2e;--rail-active: #3a1570;--btn: #3a1570;--btn-line: #ff2bd6;--btn-primary: #5a0a4a;--btn-primary-line: #ff2bd6;--node-bg: #240b3d;--node-line: #7b2cbf;--graph-bg: #1a0a2e;--graph-grid: rgba(255, 43, 214, .16);--edge-cheap: #5a3a80;--edge-expensive: #ff9e00;--edge-critical: #ff006e;--shadow: rgba(255, 43, 214, .24)}[data-theme=phosphor]{--bg: #020804;--bg-2: #061208;--surface: #0a1a0e;--line: #163c1e;--ink: #c8ffc8;--muted: #5aaa5a;--high: #39ff14;--medium: #c8f542;--low: #ffb000;--critical: #ff5e00;--accent: #00ff66;--rail-from: #061208;--rail-to: #020804;--rail-active: #0e2414;--btn: #0e2414;--btn-line: #00ff66;--btn-primary: #0a3a18;--btn-primary-line: #00ff66;--node-bg: #061208;--node-line: #1e6a32;--graph-bg: #020804;--graph-grid: rgba(0, 255, 102, .12);--edge-cheap: #1e5a2a;--edge-expensive: #c8f542;--edge-critical: #ff5e00;--shadow: rgba(0, 255, 102, .2)}[data-theme=aurora]{--bg: #071018;--bg-2: #0c1c28;--surface: #122636;--line: #1e3d52;--ink: #e8fff6;--muted: #7eb8a8;--high: #5fffcf;--medium: #ffe566;--low: #ff7eb6;--critical: #ff4d6d;--accent: #7cffb2;--rail-from: #0c1c28;--rail-to: #071018;--rail-active: #163044;--btn: #163044;--btn-line: #7cffb2;--btn-primary: #0e3d3a;--btn-primary-line: #7cffb2;--node-bg: #0c1c28;--node-line: #2a6a78;--graph-bg: #071018;--graph-grid: rgba(124, 255, 178, .12);--edge-cheap: #2a5a68;--edge-expensive: #c9a0ff;--edge-critical: #ff4d6d;--shadow: rgba(124, 255, 178, .18)}[data-theme=biolume]{--bg: #02141c;--bg-2: #042430;--surface: #073040;--line: #0a4a5c;--ink: #e6fffb;--muted: #6eb8b0;--high: #5dffb0;--medium: #ffe066;--low: #ff79c6;--critical: #ff4d6d;--accent: #18e7d4;--rail-from: #042430;--rail-to: #02141c;--rail-active: #0a3848;--btn: #0a3848;--btn-line: #18e7d4;--btn-primary: #0a4a48;--btn-primary-line: #18e7d4;--node-bg: #042430;--node-line: #1a7080;--graph-bg: #02141c;--graph-grid: rgba(24, 231, 212, .12);--edge-cheap: #1a5a68;--edge-expensive: #ff79c6;--edge-critical: #ff4d6d;--shadow: rgba(24, 231, 212, .2)}[data-theme=carbon]{--bg: #0d0d0f;--bg-2: #16161a;--surface: #1e1e24;--line: #33333c;--ink: #f2f2f4;--muted: #9a9aa8;--high: #3dd68c;--medium: #f0c040;--low: #ff5a5a;--critical: #ff2a2a;--accent: #ff2a2a;--rail-from: #16161a;--rail-to: #0d0d0f;--rail-active: #24242c;--btn: #24242c;--btn-line: #ff2a2a;--btn-primary: #4a1212;--btn-primary-line: #ff2a2a;--node-bg: #16161a;--node-line: #4a4a55;--graph-bg: #0d0d0f;--graph-grid: rgba(255, 42, 42, .1);--edge-cheap: #4a4a55;--edge-expensive: #ff8a3d;--edge-critical: #ff2a2a;--shadow: rgba(255, 42, 42, .18)}[data-theme=paper]{--bg: #f6f1e8;--bg-2: #efe6d6;--surface: #fffaf2;--line: #d9cbb6;--ink: #2b241c;--muted: #6f6456;--high: #2a7a4b;--medium: #b5811a;--low: #c0392b;--critical: #a93226;--accent: #1d6a7a;--rail-from: #efe6d6;--rail-to: #e7dcc8;--rail-active: #e2d3bb;--btn: #fffaf2;--btn-line: #c9b79a;--btn-primary: #d7eee0;--btn-primary-line: #2a7a4b;--node-bg: #fffaf2;--node-line: #c9b79a;--graph-bg: #f6f1e8;--graph-grid: rgba(29, 106, 122, .1);--edge-cheap: #b7a48c;--edge-expensive: #c0392b;--edge-critical: #a93226;--shadow: rgba(43, 36, 28, .08)}[data-theme=solarized-light]{--bg: #fdf6e3;--bg-2: #eee8d5;--surface: #f5efdc;--line: #d6cba9;--ink: #657b83;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #268bd2;--rail-from: #eee8d5;--rail-to: #e6dfc8;--rail-active: #e0d9c0;--btn: #fdf6e3;--btn-line: #93a1a1;--btn-primary: #e8efc8;--btn-primary-line: #859900;--node-bg: #fdf6e3;--node-line: #93a1a1;--graph-bg: #fdf6e3;--graph-grid: rgba(38, 139, 210, .12);--edge-cheap: #93a1a1;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(101, 123, 131, .1)}[data-theme=seafoam]{--bg: #eef7f4;--bg-2: #dff0ea;--surface: #ffffff;--line: #b7d5cc;--ink: #17332c;--muted: #4d7268;--high: #1b8a5a;--medium: #c48a14;--low: #c44536;--critical: #9b2d22;--accent: #1d9a8a;--rail-from: #dff0ea;--rail-to: #cfe6de;--rail-active: #c4ddd4;--btn: #ffffff;--btn-line: #8fbfb2;--btn-primary: #d4f0e4;--btn-primary-line: #1b8a5a;--node-bg: #ffffff;--node-line: #8fbfb2;--graph-bg: #eef7f4;--graph-grid: rgba(29, 154, 138, .12);--edge-cheap: #8fbfb2;--edge-expensive: #c48a14;--edge-critical: #c44536;--shadow: rgba(23, 51, 44, .08)}[data-theme=high-contrast]{--bg: #ffffff;--bg-2: #f2f2f2;--surface: #ffffff;--line: #111111;--ink: #000000;--muted: #222222;--high: #007a33;--medium: #8a5a00;--low: #b00000;--critical: #9b0000;--accent: #0033cc;--rail-from: #f2f2f2;--rail-to: #e6e6e6;--rail-active: #d9d9d9;--btn: #ffffff;--btn-line: #000000;--btn-primary: #d9f2e3;--btn-primary-line: #007a33;--node-bg: #ffffff;--node-line: #000000;--graph-bg: #ffffff;--graph-grid: rgba(0, 0, 0, .12);--edge-cheap: #444444;--edge-expensive: #8a5a00;--edge-critical: #b00000;--shadow: rgba(0, 0, 0, .12)}[data-theme=sakura]{--bg: #fff0f5;--bg-2: #ffe4ee;--surface: #fff7fa;--line: #f5b8cc;--ink: #4a1830;--muted: #a05a78;--high: #1a8a5c;--medium: #c48a14;--low: #d63d6e;--critical: #b01040;--accent: #e84a8a;--rail-from: #ffe4ee;--rail-to: #f8d4e0;--rail-active: #f5c8d8;--btn: #fff7fa;--btn-line: #e89ab0;--btn-primary: #ffd6e6;--btn-primary-line: #e84a8a;--node-bg: #fff7fa;--node-line: #e89ab0;--graph-bg: #fff0f5;--graph-grid: rgba(232, 74, 138, .12);--edge-cheap: #d4a0b0;--edge-expensive: #d63d6e;--edge-critical: #b01040;--shadow: rgba(74, 24, 48, .1)}[data-theme=citrus]{--bg: #fffce8;--bg-2: #fff3b0;--surface: #fffef5;--line: #e8d44a;--ink: #2a2a08;--muted: #6a6a20;--high: #2a8a20;--medium: #d4a000;--low: #e85d04;--critical: #c0392b;--accent: #5aad14;--rail-from: #fff3b0;--rail-to: #ffe98a;--rail-active: #ffe066;--btn: #fffef5;--btn-line: #d4c030;--btn-primary: #e8f5b8;--btn-primary-line: #5aad14;--node-bg: #fffef5;--node-line: #d4c030;--graph-bg: #fffce8;--graph-grid: rgba(90, 173, 20, .14);--edge-cheap: #c4b040;--edge-expensive: #e85d04;--edge-critical: #c0392b;--shadow: rgba(42, 42, 8, .1)}[data-theme=peach]{--bg: #fff3eb;--bg-2: #ffe0cc;--surface: #fffaf6;--line: #f0c4a8;--ink: #3a2218;--muted: #8a5a48;--high: #2a8a5c;--medium: #d48a14;--low: #e85d3a;--critical: #c0392b;--accent: #ff6b35;--rail-from: #ffe0cc;--rail-to: #ffd4b8;--rail-active: #ffc8a8;--btn: #fffaf6;--btn-line: #e8a888;--btn-primary: #ffe0cc;--btn-primary-line: #ff6b35;--node-bg: #fffaf6;--node-line: #e8a888;--graph-bg: #fff3eb;--graph-grid: rgba(255, 107, 53, .12);--edge-cheap: #d4a088;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(58, 34, 24, .1)}[data-theme=candy]{--bg: #f4f0ff;--bg-2: #e8dcff;--surface: #fbf8ff;--line: #d4c0f0;--ink: #2a1848;--muted: #6a5890;--high: #1a8a6a;--medium: #c48a14;--low: #e84a8a;--critical: #c01060;--accent: #ff5eb1;--rail-from: #e8dcff;--rail-to: #ddd0ff;--rail-active: #d4c4ff;--btn: #fbf8ff;--btn-line: #c4a8e8;--btn-primary: #ffd6ec;--btn-primary-line: #ff5eb1;--node-bg: #fbf8ff;--node-line: #c4a8e8;--graph-bg: #f4f0ff;--graph-grid: rgba(255, 94, 177, .14);--edge-cheap: #b0a0d0;--edge-expensive: #e84a8a;--edge-critical: #c01060;--shadow: rgba(42, 24, 72, .1)}[data-theme=sky]{--bg: #e8f4ff;--bg-2: #cfe8ff;--surface: #f5faff;--line: #90c8f0;--ink: #0a2848;--muted: #3a6080;--high: #0a8a4a;--medium: #c48a14;--low: #e85d3a;--critical: #c0392b;--accent: #0077ff;--rail-from: #cfe8ff;--rail-to: #b8dcff;--rail-active: #a8d4ff;--btn: #f5faff;--btn-line: #70b0e0;--btn-primary: #cfe8ff;--btn-primary-line: #0077ff;--node-bg: #f5faff;--node-line: #70b0e0;--graph-bg: #e8f4ff;--graph-grid: rgba(0, 119, 255, .12);--edge-cheap: #80b0d0;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(10, 40, 72, .1)}[data-theme=coral]{--bg: #fff1ee;--bg-2: #ffddd6;--surface: #fff8f6;--line: #f0b0a4;--ink: #3a1814;--muted: #8a5048;--high: #0d9488;--medium: #d48a14;--low: #e85d4a;--critical: #c0392b;--accent: #0d9488;--rail-from: #ffddd6;--rail-to: #ffd0c6;--rail-active: #ffc4b8;--btn: #fff8f6;--btn-line: #e89888;--btn-primary: #d4f4ee;--btn-primary-line: #0d9488;--node-bg: #fff8f6;--node-line: #e89888;--graph-bg: #fff1ee;--graph-grid: rgba(13, 148, 136, .14);--edge-cheap: #d4a098;--edge-expensive: #e85d4a;--edge-critical: #c0392b;--shadow: rgba(58, 24, 20, .1)}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}:root{--radius: 6px;--radius-lg: 10px;--control-h: 32px;--font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);--space: 8px}body{background:var(--bg);color:var(--ink);font-family:var(--font);font-size:13px;line-height:1.45;-webkit-font-smoothing:antialiased}button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:none;box-shadow:var(--focus-ring)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.skip{position:absolute;left:12px;top:-40px;z-index:50;background:var(--surface);color:var(--ink);border:1px solid var(--accent);border-radius:var(--radius);padding:8px 12px}.skip:focus{top:12px}.app{display:grid;grid-template-columns:232px 1fr;height:100%}.rail{border-right:1px solid var(--line);background:linear-gradient(180deg,var(--rail-from),var(--rail-to));padding:16px 12px;display:flex;flex-direction:column;gap:2px;min-width:0}.brand{display:flex;flex-direction:column;gap:2px;padding:4px 8px 16px}.brand-mark{font-family:var(--mono);letter-spacing:.16em;font-size:11px;text-transform:uppercase;color:var(--accent);font-weight:600}.brand-sub{font-size:11px;color:var(--muted)}.nav-item{display:flex;align-items:center;gap:10px;background:transparent;border:0;text-align:left;padding:8px 10px;border-radius:var(--radius);color:var(--muted);cursor:pointer;width:100%}.nav-item:hover{background:color-mix(in srgb,var(--rail-active) 70%,transparent);color:var(--ink)}.nav-item.active{background:var(--rail-active);color:var(--ink);font-weight:500}.nav-item svg{flex-shrink:0}.theme-pick{margin-top:14px;display:grid;gap:4px;padding:0 2px}.theme-pick label{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}.theme-pick select,.field select,.field input,.topbar input,.topbar select,.settings input,.settings select,.explorer-path input{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:0 10px;height:var(--control-h);width:100%}.rail-foot{margin-top:auto;padding:12px 8px 4px;border-top:1px solid var(--line);display:grid;gap:6px}.kbd-hint{font-size:11px;color:var(--muted)}kbd{font-family:var(--mono);font-size:10px;border:1px solid var(--line);border-radius:4px;padding:0 4px;background:var(--surface)}.main{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;background:var(--bg)}.progress{position:absolute;top:0;left:0;right:0;height:2px;overflow:hidden;z-index:30;background:color-mix(in srgb,var(--accent) 20%,transparent)}.progress i{display:block;height:100%;width:32%;background:var(--accent);animation:indeterminate 1.1s ease-in-out infinite}.progress.determinate i{width:0;animation:none;transform:none;transition:width .2s ease-out}@keyframes indeterminate{0%{transform:translate(-120%)}to{transform:translate(400%)}}.topbar{display:flex;gap:10px;align-items:flex-end;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg-2);flex-wrap:wrap}.field{display:grid;gap:4px;min-width:0}.field>span{font-size:11px;color:var(--muted);font-weight:500}.field.path{flex:1;min-width:180px}.field.ref{width:188px;flex:0 0 188px}.field.workspace{width:180px;flex:0 0 180px}.path-row,.combo-row{display:flex;min-width:0}.path-row input,.combo-row input{flex:1;min-width:0}.combo{position:relative;min-width:0}.combo-row input{border-top-right-radius:0;border-bottom-right-radius:0}.topbar .icon-btn{width:var(--control-h);padding:0;flex:0 0 var(--control-h)}.combo-toggle{border-top-left-radius:0;border-bottom-left-radius:0;border-left:0}.combo-menu{position:absolute;top:calc(100% + 4px);right:0;left:auto;min-width:340px;max-width:min(480px,70vw);max-height:360px;overflow:auto;z-index:40;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 12px 32px var(--shadow);padding:6px 0}.combo-heading{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:600;padding:8px 12px 4px}.combo-menu .combo-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;text-align:left;background:transparent;border:0;border-radius:0;height:auto;padding:6px 12px;color:var(--ink);cursor:pointer}.combo-menu .combo-option:hover,.combo-menu .combo-option.active{background:var(--rail-active)}.combo-label{font-family:var(--mono);font-size:12px}.combo-detail{color:var(--muted);font-size:12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.combo-empty{padding:10px 12px}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:50;background:color-mix(in srgb,var(--bg) 72%,transparent);display:grid;place-items:center;padding:24px}.modal{width:min(720px,100%);max-height:min(640px,90vh);background:var(--bg-2);border:1px solid var(--line);border-radius:var(--radius-lg);box-shadow:0 16px 48px var(--shadow);display:flex;flex-direction:column;overflow:hidden}.modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 16px 10px;border-bottom:1px solid var(--line)}.modal-head h2{font-size:15px}.modal-head .muted{margin:4px 0 0}.explorer-path{display:flex;gap:8px;padding:12px 16px;border-bottom:1px solid var(--line)}.explorer-path input{flex:1;min-width:0}.explorer-list{flex:1;overflow:auto;padding:8px;min-height:220px}.explorer-row{display:flex;align-items:center;gap:8px;width:100%;text-align:left;background:transparent;border:0;border-radius:var(--radius);padding:8px 10px;color:var(--ink);cursor:pointer;height:auto}.explorer-row:hover,.explorer-row.active{background:var(--rail-active)}.explorer-name{min-width:0;overflow:hidden;text-overflow:ellipsis}.git-badge{margin-left:auto;margin-bottom:0}.explorer-empty{padding:18px 10px}.modal-foot{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--line)}.explorer-current{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--mono);font-size:12px}.topbar input,.topbar select{min-width:0}.topbar-actions{display:flex;gap:8px;margin-left:auto;align-items:center;padding-bottom:0}.btn,.topbar button{background:var(--btn);border:1px solid var(--btn-line);border-radius:var(--radius);height:var(--control-h);padding:0 12px;cursor:pointer;font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap}.btn:hover,.topbar button:hover{filter:brightness(1.08)}.btn:disabled,.topbar button:disabled{opacity:.55;cursor:not-allowed;filter:none}.btn.primary{background:var(--btn-primary);border-color:var(--btn-primary-line)}.btn.ghost{background:transparent}.alerts{display:grid;gap:8px;padding:10px 16px 0}.alerts:empty{display:none;padding:0}.stage{flex:1;min-height:0;display:flex;flex-direction:column}.content{flex:1;min-height:0;display:grid;grid-template-columns:minmax(340px,420px) 1fr}.brief{overflow:auto;border-right:1px solid var(--line);padding:16px 18px 24px;background:radial-gradient(circle at 0 0,color-mix(in srgb,var(--accent) 8%,transparent),transparent 42%),var(--bg)}.graph-wrap{position:relative;min-height:0;display:flex;flex-direction:column}.impact-graph{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.graph-count{margin-left:auto;font-size:11px}.graph-layout{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--muted);letter-spacing:.04em}.graph-layout select{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:0 10px;height:26px;min-width:11.5rem;color:var(--ink);font:inherit;font-size:12px;letter-spacing:0;cursor:pointer}.chip-btn{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.chip-btn:hover{color:var(--ink)}.chip-btn.active{background:var(--rail-active);color:var(--ink)}.chip-btn:disabled{opacity:.45;cursor:not-allowed}.graph-stage{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-stage .react-flow,.graph-3d,.graph-3d-host,.graph-3d-canvas-host{flex:1;width:100%;height:100%;min-height:280px}.graph-3d{position:relative;background:var(--graph-bg);display:flex;flex-direction:column}.graph-3d-host{position:relative;min-height:0;display:flex;flex-direction:column}.graph-3d-canvas-host{position:relative;min-height:0;background:var(--graph-bg)}.graph-3d canvas{display:block;width:100%;height:100%}.graph-3d-tip{position:absolute;pointer-events:none;z-index:2;max-width:320px;padding:6px 8px;border-radius:var(--radius);background:var(--surface);border:1px solid var(--line);color:var(--ink);font-size:11px;line-height:1.35;box-shadow:0 8px 24px var(--shadow)}.graph-3d-tip .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.graph-3d-tip .n{font-weight:600}.graph-3d-hint{position:absolute;left:10px;bottom:10px;z-index:2;margin:0;font-size:11px;color:var(--muted);max-width:min(420px,calc(100% - 24px));pointer-events:none}.graph-wrap .react-flow{background-color:var(--graph-bg);background-image:linear-gradient(var(--graph-grid) 1px,transparent 1px),linear-gradient(90deg,var(--graph-grid) 1px,transparent 1px);background-size:24px 24px}.react-flow__minimap{background:var(--graph-bg)!important;border:1px solid var(--line)!important;border-radius:var(--radius);overflow:hidden;box-shadow:0 8px 24px var(--shadow)}.react-flow__minimap-node{fill:var(--muted);stroke:none}.react-flow__minimap-node.selected{fill:var(--accent)}.react-flow__minimap-mask{fill:#00000073!important;stroke:var(--accent)!important}.react-flow__controls{box-shadow:none!important}.react-flow__controls-button{background:var(--surface)!important;border-bottom:1px solid var(--line)!important;fill:var(--ink)!important}h1{font-size:18px;margin:0 0 6px;font-weight:600}h2{font-size:13px;margin:0;font-weight:600}.merge-box{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:12px 14px;margin-bottom:12px}.merge-box.high{border-color:color-mix(in srgb,var(--high) 55%,var(--line))}.merge-box.medium{border-color:color-mix(in srgb,var(--medium) 55%,var(--line))}.merge-box.low{border-color:color-mix(in srgb,var(--low) 55%,var(--line))}.level{font-family:var(--mono);font-weight:600;font-size:14px}.level.high{color:var(--high)}.level.medium{color:var(--medium)}.level.low{color:var(--low)}.merge-title{margin-top:4px;font-size:13px;color:var(--ink)}.reasons{margin:10px 0 0;padding:0 0 0 18px;color:var(--muted)}.reasons li{margin:0 0 4px}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:0 0 14px}.metric{border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:8px 10px}.metric .n{font-family:var(--mono);font-size:16px;font-weight:600;font-variant-numeric:tabular-nums}.metric .l{font-size:11px;color:var(--muted);margin-top:2px}.section{border-top:1px solid var(--line);padding:8px 0 4px}.section>summary{cursor:pointer;list-style:none;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600;padding:6px 0}.section>summary::-webkit-details-marker{display:none}.section>summary .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.kicker{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.08em;margin:16px 0 6px;font-weight:600}.chip{display:inline-flex;align-items:center;font-size:11px;padding:2px 8px;border-radius:999px;border:1px solid var(--line);margin:0 6px 6px 0;color:var(--muted);background:var(--surface)}.chip.blocker{color:var(--low);border-color:var(--low)}.chip.warning{color:var(--medium);border-color:var(--medium)}.chip.strong{color:var(--low);border-color:var(--low)}.chip.worth_exploring{color:var(--medium);border-color:var(--medium)}.chip.speculative{color:var(--muted);border-color:var(--line)}.chip.open{color:var(--high);border-color:color-mix(in srgb,var(--high) 50%,var(--line))}.file{font-family:var(--mono);font-size:12px;color:var(--accent)}.read-item,.finding,.residual{padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.read-item:last-child,.finding:last-child{border-bottom:0}.read-item.tour-current{background:color-mix(in srgb,var(--accent) 12%,var(--surface));border-color:var(--accent)}.tour-row{margin-top:8px;align-items:center}.field.dirty .chip-btn{height:32px}.muted{color:var(--muted);font-size:13px;line-height:1.45}.error{color:var(--low);padding:8px 12px;border:1px solid var(--low);background:color-mix(in srgb,var(--low) 10%,var(--surface));border-radius:var(--radius);display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner{padding:8px 12px;border-radius:var(--radius);border:1px solid var(--line);background:var(--surface);font-size:13px;line-height:1.45;display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner.warn{border-color:var(--medium);color:var(--medium)}.banner.stale{border-color:var(--low);color:var(--low)}.banner.whatif{border-color:var(--accent);align-items:center}.banner.whatif .btn{flex:0 0 auto;white-space:nowrap}.chip.whatif{color:var(--accent);border-color:color-mix(in srgb,var(--accent) 55%,var(--line))}.whatif-hint{margin:10px 0 0;font-size:12px;line-height:1.4;color:var(--muted)}.banner .dismiss{background:transparent;border:0;color:inherit;cursor:pointer;height:auto;padding:0 2px;opacity:.7}.empty{padding:24px 8px;color:var(--muted);font-size:13px;line-height:1.55}.workspace-loading{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;min-height:220px;padding:48px 16px}.graph-walk-empty{flex:1;display:flex;flex-direction:column;justify-content:center;max-width:36rem;margin:0 auto}.empty ol{margin:12px 0 0 18px;padding:0}.empty code,code{font-family:var(--mono);font-size:12px;color:var(--accent)}.btn-row{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.pr-list{padding:16px;overflow:auto}.pr-toolbar{display:flex;gap:8px;align-items:flex-end;margin-bottom:14px}.pr-toolbar .field{flex:1}.pr-toolbar .field.provider{flex:0 0 140px}.scm-count{margin:0 0 12px;font-size:12px}.scm-login{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px 0;border-top:1px solid var(--line)}.scm-login:first-of-type{border-top:0;padding-top:0}.scm-login .btn-row{margin-top:0}.scm-login p{margin:2px 0 0}.oauth-code{font-size:13px;margin:0}.oauth-code code{font-size:14px;letter-spacing:.08em}.pr{border:1px solid var(--line);background:var(--surface);padding:12px 14px;border-radius:var(--radius-lg);margin-bottom:10px}.pr h3{margin:0 0 4px;font-size:14px;font-weight:600}.pr-meta{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin:6px 0 10px}.pr-actions{display:flex;gap:8px;align-items:center}.settings{padding:24px;max-width:760px;overflow:auto;display:grid;gap:16px}.settings-card{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:16px;display:grid;gap:8px}.settings-card h2{font-size:14px;margin-bottom:2px}.settings label{font-size:12px;color:var(--muted);font-weight:500}.theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.theme-swatch{border:1px solid var(--line);background:var(--bg);color:var(--ink);border-radius:var(--radius);padding:10px;text-align:left;cursor:pointer;height:auto;box-shadow:0 1px 8px var(--shadow)}.theme-swatch.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent),0 1px 8px var(--shadow)}.theme-swatch .swatch-bar{height:6px;border-radius:3px;margin-bottom:8px;background:linear-gradient(90deg,var(--accent),var(--high),var(--medium),var(--low))}.theme-swatch .name{font-size:13px;font-weight:600}.theme-swatch .group{font-size:11px;color:var(--muted)}.headline{white-space:pre-wrap;font-family:var(--mono);font-size:12px;color:var(--muted);margin:8px 0 0}.graph-modes{display:flex;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:2px;background:var(--surface)}.seg button,.graph-modes button{background:transparent;border:0;border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.seg button.active,.graph-modes button.active{background:var(--rail-active);color:var(--ink)}.legend{margin-left:auto;display:flex;gap:12px;color:var(--muted);font-size:11px}.legend i{display:inline-block;width:14px;height:2px;margin-right:6px;vertical-align:middle;background:var(--edge-cheap)}.legend i.exp{background:var(--edge-expensive)}.legend i.crit{background:var(--edge-critical);height:3px}.legend i.dash{border-top:2px dashed var(--muted);background:none;height:0}.legend i.seed{height:10px;width:10px;border-radius:2px;background:color-mix(in srgb,var(--medium) 70%,var(--node-bg))}.legend i.down{height:10px;width:10px;border-radius:2px;border:1px solid color-mix(in srgb,var(--accent) 45%,var(--node-line));background:var(--node-bg)}.inspector{position:absolute;top:12px;right:12px;z-index:5;width:300px;max-width:calc(100% - 24px);max-height:calc(100% - 24px);overflow-x:hidden;overflow-y:auto;overflow-wrap:break-word;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:10px 12px;box-shadow:0 8px 24px var(--shadow);font-size:12px}.inspector .t{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.inspector .n,.inspector .file,.inspector .muted{overflow-wrap:break-word}.inspector .n{font-weight:600;margin:4px 0}.inspector-head{display:flex;align-items:flex-start;gap:8px}.inspector-roles{display:flex;flex-wrap:wrap;justify-content:flex-end;flex:1;gap:4px}.inspector-chip{font-size:10px;text-transform:uppercase;letter-spacing:.04em;padding:1px 6px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.inspector-close{flex:0 0 auto;width:24px;height:24px;padding:0;border:1px solid var(--line);border-radius:var(--radius);background:transparent;color:var(--muted);font-size:16px;line-height:1;cursor:pointer}.inspector-close:hover{color:var(--ink)}.inspector-purpose{margin:6px 0 8px;color:var(--ink);font-size:12px;line-height:1.4}.inspector-layer{margin-top:4px;font-size:11px}.inspector-degree{font-size:11px}.inspector-path{margin:6px 0 0;font-size:12px;line-height:1.4;color:var(--muted)}.inspector-facts{margin:10px 0 0;padding-top:8px;border-top:1px solid var(--line)}.inspector-fact{display:grid;grid-template-columns:minmax(64px,92px) minmax(0,1fr);gap:8px;padding:3px 0;align-items:start}.inspector-fact dt{color:var(--muted);font-size:11px;margin:0}.inspector-fact dd{margin:0;overflow-wrap:break-word}.inspector-section{margin-top:10px;padding-top:8px;border-top:1px solid var(--line)}.inspector-section h3{margin:0 0 6px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600}.inspector-section .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.inspector-section ul{list-style:none;margin:0;padding:0}.inspector-section li{padding:4px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.inspector-section li:last-child{border-bottom:0}.inspector-link-name{display:block;font-weight:600;overflow-wrap:break-word}.inspector-link-meta{display:block;color:var(--muted);font-size:11px}.lp-node{padding:8px 10px;border-radius:var(--radius);border:1px solid var(--node-line);background:var(--node-bg);width:208px;max-width:100%;height:64px;box-sizing:border-box;box-shadow:0 0 0 1px var(--shadow);overflow:visible;position:relative}.lp-node .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.lp-node .n{font-size:13px;font-weight:600;line-height:1.2;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow-wrap:anywhere}.lp-node.selected{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.lp-node.role-seed{border-color:var(--medium);background:color-mix(in srgb,var(--medium) 14%,var(--node-bg))}.lp-node.role-downstream{border-color:color-mix(in srgb,var(--accent) 45%,var(--node-line))}.lp-node.role-untested{box-shadow:inset 3px 0 0 var(--low)}.lp-node.role-tested{box-shadow:inset 3px 0 0 var(--high)}.lp-node.role-contract{outline:1px dashed color-mix(in srgb,var(--accent) 50%,transparent)}.lp-node.dim{opacity:.38}.merge-box.compact{padding:6px 10px;min-width:92px;margin:0}.merge-box.compact .level{font-size:12px}.palette-scrim{position:fixed;top:0;right:0;bottom:0;left:0;background:color-mix(in srgb,var(--bg) 55%,transparent);z-index:40;display:grid;place-items:start center;padding-top:12vh}.palette{width:min(640px,calc(100vw - 32px));background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:0 18px 60px var(--shadow);overflow:hidden}.palette input{width:100%;border:0;border-bottom:1px solid var(--line);background:transparent;color:var(--ink);padding:14px 16px;font:inherit}.palette ul{list-style:none;margin:0;padding:6px;max-height:360px;overflow:auto}.palette li button{width:100%;display:flex;justify-content:space-between;gap:12px;text-align:left;background:transparent;border:0;color:var(--ink);padding:8px 10px;border-radius:8px;cursor:pointer}.palette li button.active,.palette li button:hover{background:var(--rail-active)}.palette-foot{padding:8px 12px 10px}.graph-search{position:relative;min-width:140px}.graph-search input{width:100%;background:var(--bg-2);border:1px solid var(--line);color:var(--ink);border-radius:8px;padding:6px 8px;font:inherit}.graph-search-hits{position:absolute;z-index:5;left:0;right:0;top:calc(100% + 4px);background:var(--surface);border:1px solid var(--line);border-radius:8px;list-style:none;margin:0;padding:4px;max-height:240px;overflow:auto}.graph-search-hits button{width:100%;display:flex;justify-content:space-between;gap:8px;background:transparent;border:0;color:var(--ink);text-align:left;padding:6px 8px;cursor:pointer}.graph-search-hits button:hover{background:var(--rail-active)}.inspector-link{display:flex;flex-direction:column;width:100%;background:transparent;border:0;color:inherit;text-align:left;cursor:pointer;padding:0}.file-row{display:flex;flex-direction:column;gap:6px}.linkish{background:none;border:0;color:inherit;font:inherit;text-align:left;cursor:pointer;padding:0}.history-item,.check-item{display:flex;flex-wrap:wrap;gap:8px;align-items:baseline;width:100%;background:transparent;border:0;color:inherit;font:inherit;text-align:left;padding:6px 0;cursor:pointer}.history-item.current{color:var(--accent)}.check-row{display:flex;gap:8px;align-items:center;margin:4px 0}.sparkline{display:flex;align-items:flex-end;gap:3px;height:36px;margin:8px 0}.sparkline i{flex:1;background:var(--muted);border-radius:2px 2px 0 0;min-width:4px}.sparkline i.high{background:var(--high)}.sparkline i.medium{background:var(--medium)}.sparkline i.low{background:var(--low)}.config-editor .field{display:flex;flex-direction:column;gap:4px;margin:8px 0}.config-editor input,.config-editor select{background:var(--bg-2);border:1px solid var(--line);color:var(--ink);border-radius:8px;padding:6px 8px}.react-flow__node-load .react-flow__handle{width:8px;height:8px;border:none;background:transparent;opacity:0}.type-table{width:100%;border-collapse:collapse;font-size:12px}.type-table td{padding:3px 0}.type-table td:last-child{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--muted)}@media(prefers-reduced-motion:reduce){.progress i{animation:none;width:100%}.progress.determinate i{width:var(--progress, 100%)}*{scroll-behavior:auto!important}}@media(max-width:960px){.app{grid-template-columns:56px 1fr}.brand-sub,.nav-item span,.theme-pick,.kbd-hint,.rail-foot .muted{display:none}.nav-item{justify-content:center;padding:10px}.content{grid-template-columns:1fr}.brief{border-right:0;border-bottom:1px solid var(--line);max-height:42vh}} +.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #555;--xy-background-pattern-lines-color-default: #333;--xy-background-pattern-cross-color-default: #333;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root,[data-theme=obsidian]{--bg: #070b10;--bg-2: #0d141c;--surface: #121a24;--line: #1e2c3c;--ink: #e7eef6;--muted: #8b9bb0;--high: #2a9d8f;--medium: #e9c46a;--low: #e76f51;--critical: #e85d04;--accent: #4cc9f0;--rail-from: #0b1219;--rail-to: #070b10;--rail-active: #15202c;--btn: #173044;--btn-line: #24506c;--btn-primary: #134e4a;--btn-primary-line: #2a9d8f;--node-bg: #101822;--node-line: #2a3d52;--graph-bg: #070b10;--graph-grid: rgba(42, 80, 120, .09);--edge-cheap: #4a5568;--edge-expensive: #f4a261;--edge-critical: #e85d04;--shadow: rgba(76, 201, 240, .08)}[data-theme=nord]{--bg: #2e3440;--bg-2: #3b4252;--surface: #434c5e;--line: #4c566a;--ink: #eceff4;--muted: #d8dee9;--high: #a3be8c;--medium: #ebcb8b;--low: #bf616a;--critical: #d08770;--accent: #88c0d0;--rail-from: #3b4252;--rail-to: #2e3440;--rail-active: #4c566a;--btn: #434c5e;--btn-line: #81a1c1;--btn-primary: #5e81ac;--btn-primary-line: #88c0d0;--node-bg: #3b4252;--node-line: #81a1c1;--graph-bg: #2e3440;--graph-grid: rgba(136, 192, 208, .12);--edge-cheap: #4c566a;--edge-expensive: #d08770;--edge-critical: #bf616a;--shadow: rgba(136, 192, 208, .12)}[data-theme=solarized-dark]{--bg: #002b36;--bg-2: #073642;--surface: #0a3944;--line: #16444f;--ink: #eee8d5;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #2aa198;--rail-from: #073642;--rail-to: #002b36;--rail-active: #16444f;--btn: #073642;--btn-line: #268bd2;--btn-primary: #0a4a42;--btn-primary-line: #2aa198;--node-bg: #073642;--node-line: #268bd2;--graph-bg: #002b36;--graph-grid: rgba(42, 161, 152, .12);--edge-cheap: #586e75;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(42, 161, 152, .12)}[data-theme=forest]{--bg: #0e1510;--bg-2: #152019;--surface: #1b2a20;--line: #2c4334;--ink: #e4f0e6;--muted: #8eaa96;--high: #6ab04c;--medium: #c8a951;--low: #e17055;--critical: #d35400;--accent: #7bed9f;--rail-from: #152019;--rail-to: #0e1510;--rail-active: #1f3326;--btn: #1f3326;--btn-line: #3d6b4f;--btn-primary: #1e4d32;--btn-primary-line: #6ab04c;--node-bg: #16241b;--node-line: #3d6b4f;--graph-bg: #0e1510;--graph-grid: rgba(123, 237, 159, .1);--edge-cheap: #3d6b4f;--edge-expensive: #c8a951;--edge-critical: #d35400;--shadow: rgba(123, 237, 159, .1)}[data-theme=rose]{--bg: #191724;--bg-2: #1f1d2e;--surface: #26233a;--line: #403d52;--ink: #e0def4;--muted: #908caa;--high: #9ccfd8;--medium: #f6c177;--low: #eb6f92;--critical: #eb6f92;--accent: #c4a7e7;--rail-from: #1f1d2e;--rail-to: #191724;--rail-active: #26233a;--btn: #26233a;--btn-line: #c4a7e7;--btn-primary: #3a2f4d;--btn-primary-line: #c4a7e7;--node-bg: #1f1d2e;--node-line: #524f67;--graph-bg: #191724;--graph-grid: rgba(196, 167, 231, .12);--edge-cheap: #524f67;--edge-expensive: #f6c177;--edge-critical: #eb6f92;--shadow: rgba(196, 167, 231, .12)}[data-theme=amber]{--bg: #120e0a;--bg-2: #1c1610;--surface: #261e16;--line: #3d2f22;--ink: #f4e6d0;--muted: #b59a78;--high: #c4d6a0;--medium: #e9b44c;--low: #d8572a;--critical: #c0392b;--accent: #f0a05a;--rail-from: #1c1610;--rail-to: #120e0a;--rail-active: #2b2218;--btn: #2b2218;--btn-line: #8a5a2b;--btn-primary: #4a3418;--btn-primary-line: #f0a05a;--node-bg: #1c1610;--node-line: #8a5a2b;--graph-bg: #120e0a;--graph-grid: rgba(240, 160, 90, .12);--edge-cheap: #5c4a38;--edge-expensive: #e9b44c;--edge-critical: #d8572a;--shadow: rgba(240, 160, 90, .12)}[data-theme=volcano]{--bg: #14090a;--bg-2: #1e0e10;--surface: #2a1416;--line: #4a2226;--ink: #fde8e4;--muted: #c48b86;--high: #7bed9f;--medium: #f6c90e;--low: #ff6b6b;--critical: #ff3b3b;--accent: #ff7b54;--rail-from: #1e0e10;--rail-to: #14090a;--rail-active: #32181b;--btn: #32181b;--btn-line: #ff7b54;--btn-primary: #5a1f18;--btn-primary-line: #ff7b54;--node-bg: #1e0e10;--node-line: #7a3330;--graph-bg: #14090a;--graph-grid: rgba(255, 123, 84, .12);--edge-cheap: #5a3330;--edge-expensive: #ff7b54;--edge-critical: #ff3b3b;--shadow: rgba(255, 123, 84, .14)}[data-theme=lavender]{--bg: #12101c;--bg-2: #1a1730;--surface: #221e3c;--line: #3b3560;--ink: #efeaff;--muted: #b3a7d6;--high: #80ffdb;--medium: #ffd166;--low: #ff6b9d;--critical: #ff4d6d;--accent: #c77dff;--rail-from: #1a1730;--rail-to: #12101c;--rail-active: #2a2550;--btn: #2a2550;--btn-line: #c77dff;--btn-primary: #3d2a66;--btn-primary-line: #c77dff;--node-bg: #1a1730;--node-line: #5a4d8a;--graph-bg: #12101c;--graph-grid: rgba(199, 125, 255, .12);--edge-cheap: #5a4d8a;--edge-expensive: #ffd166;--edge-critical: #ff4d6d;--shadow: rgba(199, 125, 255, .14)}[data-theme=neon-noir]{--bg: #05060a;--bg-2: #0a0c14;--surface: #10131c;--line: #1e2436;--ink: #f0f4ff;--muted: #8b93b0;--high: #39ff88;--medium: #ffe66d;--low: #ff2d95;--critical: #ff3d5a;--accent: #00f0ff;--rail-from: #0a0c14;--rail-to: #05060a;--rail-active: #151a2a;--btn: #151a2a;--btn-line: #00f0ff;--btn-primary: #063a40;--btn-primary-line: #00f0ff;--node-bg: #0a0c14;--node-line: #2a3550;--graph-bg: #05060a;--graph-grid: rgba(0, 240, 255, .12);--edge-cheap: #3a4560;--edge-expensive: #ff2d95;--edge-critical: #ff3d5a;--shadow: rgba(0, 240, 255, .22)}[data-theme=synthwave]{--bg: #1a0a2e;--bg-2: #240b3d;--surface: #2d1250;--line: #4a1d7a;--ink: #ffe6fb;--muted: #c49ad8;--high: #00f5d4;--medium: #ffd60a;--low: #ff6b9d;--critical: #ff006e;--accent: #ff2bd6;--rail-from: #240b3d;--rail-to: #1a0a2e;--rail-active: #3a1570;--btn: #3a1570;--btn-line: #ff2bd6;--btn-primary: #5a0a4a;--btn-primary-line: #ff2bd6;--node-bg: #240b3d;--node-line: #7b2cbf;--graph-bg: #1a0a2e;--graph-grid: rgba(255, 43, 214, .16);--edge-cheap: #5a3a80;--edge-expensive: #ff9e00;--edge-critical: #ff006e;--shadow: rgba(255, 43, 214, .24)}[data-theme=phosphor]{--bg: #020804;--bg-2: #061208;--surface: #0a1a0e;--line: #163c1e;--ink: #c8ffc8;--muted: #5aaa5a;--high: #39ff14;--medium: #c8f542;--low: #ffb000;--critical: #ff5e00;--accent: #00ff66;--rail-from: #061208;--rail-to: #020804;--rail-active: #0e2414;--btn: #0e2414;--btn-line: #00ff66;--btn-primary: #0a3a18;--btn-primary-line: #00ff66;--node-bg: #061208;--node-line: #1e6a32;--graph-bg: #020804;--graph-grid: rgba(0, 255, 102, .12);--edge-cheap: #1e5a2a;--edge-expensive: #c8f542;--edge-critical: #ff5e00;--shadow: rgba(0, 255, 102, .2)}[data-theme=aurora]{--bg: #071018;--bg-2: #0c1c28;--surface: #122636;--line: #1e3d52;--ink: #e8fff6;--muted: #7eb8a8;--high: #5fffcf;--medium: #ffe566;--low: #ff7eb6;--critical: #ff4d6d;--accent: #7cffb2;--rail-from: #0c1c28;--rail-to: #071018;--rail-active: #163044;--btn: #163044;--btn-line: #7cffb2;--btn-primary: #0e3d3a;--btn-primary-line: #7cffb2;--node-bg: #0c1c28;--node-line: #2a6a78;--graph-bg: #071018;--graph-grid: rgba(124, 255, 178, .12);--edge-cheap: #2a5a68;--edge-expensive: #c9a0ff;--edge-critical: #ff4d6d;--shadow: rgba(124, 255, 178, .18)}[data-theme=biolume]{--bg: #02141c;--bg-2: #042430;--surface: #073040;--line: #0a4a5c;--ink: #e6fffb;--muted: #6eb8b0;--high: #5dffb0;--medium: #ffe066;--low: #ff79c6;--critical: #ff4d6d;--accent: #18e7d4;--rail-from: #042430;--rail-to: #02141c;--rail-active: #0a3848;--btn: #0a3848;--btn-line: #18e7d4;--btn-primary: #0a4a48;--btn-primary-line: #18e7d4;--node-bg: #042430;--node-line: #1a7080;--graph-bg: #02141c;--graph-grid: rgba(24, 231, 212, .12);--edge-cheap: #1a5a68;--edge-expensive: #ff79c6;--edge-critical: #ff4d6d;--shadow: rgba(24, 231, 212, .2)}[data-theme=carbon]{--bg: #0d0d0f;--bg-2: #16161a;--surface: #1e1e24;--line: #33333c;--ink: #f2f2f4;--muted: #9a9aa8;--high: #3dd68c;--medium: #f0c040;--low: #ff5a5a;--critical: #ff2a2a;--accent: #ff2a2a;--rail-from: #16161a;--rail-to: #0d0d0f;--rail-active: #24242c;--btn: #24242c;--btn-line: #ff2a2a;--btn-primary: #4a1212;--btn-primary-line: #ff2a2a;--node-bg: #16161a;--node-line: #4a4a55;--graph-bg: #0d0d0f;--graph-grid: rgba(255, 42, 42, .1);--edge-cheap: #4a4a55;--edge-expensive: #ff8a3d;--edge-critical: #ff2a2a;--shadow: rgba(255, 42, 42, .18)}[data-theme=paper]{--bg: #f6f1e8;--bg-2: #efe6d6;--surface: #fffaf2;--line: #d9cbb6;--ink: #2b241c;--muted: #6f6456;--high: #2a7a4b;--medium: #b5811a;--low: #c0392b;--critical: #a93226;--accent: #1d6a7a;--rail-from: #efe6d6;--rail-to: #e7dcc8;--rail-active: #e2d3bb;--btn: #fffaf2;--btn-line: #c9b79a;--btn-primary: #d7eee0;--btn-primary-line: #2a7a4b;--node-bg: #fffaf2;--node-line: #c9b79a;--graph-bg: #f6f1e8;--graph-grid: rgba(29, 106, 122, .1);--edge-cheap: #b7a48c;--edge-expensive: #c0392b;--edge-critical: #a93226;--shadow: rgba(43, 36, 28, .08)}[data-theme=solarized-light]{--bg: #fdf6e3;--bg-2: #eee8d5;--surface: #f5efdc;--line: #d6cba9;--ink: #657b83;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #268bd2;--rail-from: #eee8d5;--rail-to: #e6dfc8;--rail-active: #e0d9c0;--btn: #fdf6e3;--btn-line: #93a1a1;--btn-primary: #e8efc8;--btn-primary-line: #859900;--node-bg: #fdf6e3;--node-line: #93a1a1;--graph-bg: #fdf6e3;--graph-grid: rgba(38, 139, 210, .12);--edge-cheap: #93a1a1;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(101, 123, 131, .1)}[data-theme=seafoam]{--bg: #eef7f4;--bg-2: #dff0ea;--surface: #ffffff;--line: #b7d5cc;--ink: #17332c;--muted: #4d7268;--high: #1b8a5a;--medium: #c48a14;--low: #c44536;--critical: #9b2d22;--accent: #1d9a8a;--rail-from: #dff0ea;--rail-to: #cfe6de;--rail-active: #c4ddd4;--btn: #ffffff;--btn-line: #8fbfb2;--btn-primary: #d4f0e4;--btn-primary-line: #1b8a5a;--node-bg: #ffffff;--node-line: #8fbfb2;--graph-bg: #eef7f4;--graph-grid: rgba(29, 154, 138, .12);--edge-cheap: #8fbfb2;--edge-expensive: #c48a14;--edge-critical: #c44536;--shadow: rgba(23, 51, 44, .08)}[data-theme=high-contrast]{--bg: #ffffff;--bg-2: #f2f2f2;--surface: #ffffff;--line: #111111;--ink: #000000;--muted: #222222;--high: #007a33;--medium: #8a5a00;--low: #b00000;--critical: #9b0000;--accent: #0033cc;--rail-from: #f2f2f2;--rail-to: #e6e6e6;--rail-active: #d9d9d9;--btn: #ffffff;--btn-line: #000000;--btn-primary: #d9f2e3;--btn-primary-line: #007a33;--node-bg: #ffffff;--node-line: #000000;--graph-bg: #ffffff;--graph-grid: rgba(0, 0, 0, .12);--edge-cheap: #444444;--edge-expensive: #8a5a00;--edge-critical: #b00000;--shadow: rgba(0, 0, 0, .12)}[data-theme=sakura]{--bg: #fff0f5;--bg-2: #ffe4ee;--surface: #fff7fa;--line: #f5b8cc;--ink: #4a1830;--muted: #a05a78;--high: #1a8a5c;--medium: #c48a14;--low: #d63d6e;--critical: #b01040;--accent: #e84a8a;--rail-from: #ffe4ee;--rail-to: #f8d4e0;--rail-active: #f5c8d8;--btn: #fff7fa;--btn-line: #e89ab0;--btn-primary: #ffd6e6;--btn-primary-line: #e84a8a;--node-bg: #fff7fa;--node-line: #e89ab0;--graph-bg: #fff0f5;--graph-grid: rgba(232, 74, 138, .12);--edge-cheap: #d4a0b0;--edge-expensive: #d63d6e;--edge-critical: #b01040;--shadow: rgba(74, 24, 48, .1)}[data-theme=citrus]{--bg: #fffce8;--bg-2: #fff3b0;--surface: #fffef5;--line: #e8d44a;--ink: #2a2a08;--muted: #6a6a20;--high: #2a8a20;--medium: #d4a000;--low: #e85d04;--critical: #c0392b;--accent: #5aad14;--rail-from: #fff3b0;--rail-to: #ffe98a;--rail-active: #ffe066;--btn: #fffef5;--btn-line: #d4c030;--btn-primary: #e8f5b8;--btn-primary-line: #5aad14;--node-bg: #fffef5;--node-line: #d4c030;--graph-bg: #fffce8;--graph-grid: rgba(90, 173, 20, .14);--edge-cheap: #c4b040;--edge-expensive: #e85d04;--edge-critical: #c0392b;--shadow: rgba(42, 42, 8, .1)}[data-theme=peach]{--bg: #fff3eb;--bg-2: #ffe0cc;--surface: #fffaf6;--line: #f0c4a8;--ink: #3a2218;--muted: #8a5a48;--high: #2a8a5c;--medium: #d48a14;--low: #e85d3a;--critical: #c0392b;--accent: #ff6b35;--rail-from: #ffe0cc;--rail-to: #ffd4b8;--rail-active: #ffc8a8;--btn: #fffaf6;--btn-line: #e8a888;--btn-primary: #ffe0cc;--btn-primary-line: #ff6b35;--node-bg: #fffaf6;--node-line: #e8a888;--graph-bg: #fff3eb;--graph-grid: rgba(255, 107, 53, .12);--edge-cheap: #d4a088;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(58, 34, 24, .1)}[data-theme=candy]{--bg: #f4f0ff;--bg-2: #e8dcff;--surface: #fbf8ff;--line: #d4c0f0;--ink: #2a1848;--muted: #6a5890;--high: #1a8a6a;--medium: #c48a14;--low: #e84a8a;--critical: #c01060;--accent: #ff5eb1;--rail-from: #e8dcff;--rail-to: #ddd0ff;--rail-active: #d4c4ff;--btn: #fbf8ff;--btn-line: #c4a8e8;--btn-primary: #ffd6ec;--btn-primary-line: #ff5eb1;--node-bg: #fbf8ff;--node-line: #c4a8e8;--graph-bg: #f4f0ff;--graph-grid: rgba(255, 94, 177, .14);--edge-cheap: #b0a0d0;--edge-expensive: #e84a8a;--edge-critical: #c01060;--shadow: rgba(42, 24, 72, .1)}[data-theme=sky]{--bg: #e8f4ff;--bg-2: #cfe8ff;--surface: #f5faff;--line: #90c8f0;--ink: #0a2848;--muted: #3a6080;--high: #0a8a4a;--medium: #c48a14;--low: #e85d3a;--critical: #c0392b;--accent: #0077ff;--rail-from: #cfe8ff;--rail-to: #b8dcff;--rail-active: #a8d4ff;--btn: #f5faff;--btn-line: #70b0e0;--btn-primary: #cfe8ff;--btn-primary-line: #0077ff;--node-bg: #f5faff;--node-line: #70b0e0;--graph-bg: #e8f4ff;--graph-grid: rgba(0, 119, 255, .12);--edge-cheap: #80b0d0;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(10, 40, 72, .1)}[data-theme=coral]{--bg: #fff1ee;--bg-2: #ffddd6;--surface: #fff8f6;--line: #f0b0a4;--ink: #3a1814;--muted: #8a5048;--high: #0d9488;--medium: #d48a14;--low: #e85d4a;--critical: #c0392b;--accent: #0d9488;--rail-from: #ffddd6;--rail-to: #ffd0c6;--rail-active: #ffc4b8;--btn: #fff8f6;--btn-line: #e89888;--btn-primary: #d4f4ee;--btn-primary-line: #0d9488;--node-bg: #fff8f6;--node-line: #e89888;--graph-bg: #fff1ee;--graph-grid: rgba(13, 148, 136, .14);--edge-cheap: #d4a098;--edge-expensive: #e85d4a;--edge-critical: #c0392b;--shadow: rgba(58, 24, 20, .1)}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}:root{--radius: 6px;--radius-lg: 10px;--control-h: 32px;--font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);--space: 8px}body{background:var(--bg);color:var(--ink);font-family:var(--font);font-size:13px;line-height:1.45;-webkit-font-smoothing:antialiased}button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:none;box-shadow:var(--focus-ring)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.skip{position:absolute;left:12px;top:-40px;z-index:50;background:var(--surface);color:var(--ink);border:1px solid var(--accent);border-radius:var(--radius);padding:8px 12px}.skip:focus{top:12px}.app{display:grid;grid-template-columns:232px 1fr;height:100%}.rail{border-right:1px solid var(--line);background:linear-gradient(180deg,var(--rail-from),var(--rail-to));padding:16px 12px;display:flex;flex-direction:column;gap:2px;min-width:0}.brand{display:flex;flex-direction:column;gap:2px;padding:4px 8px 16px}.brand-mark{font-family:var(--mono);letter-spacing:.16em;font-size:11px;text-transform:uppercase;color:var(--accent);font-weight:600}.brand-sub{font-size:11px;color:var(--muted)}.nav-item{display:flex;align-items:center;gap:10px;background:transparent;border:0;text-align:left;padding:8px 10px;border-radius:var(--radius);color:var(--muted);cursor:pointer;width:100%}.nav-item:hover{background:color-mix(in srgb,var(--rail-active) 70%,transparent);color:var(--ink)}.nav-item.active{background:var(--rail-active);color:var(--ink);font-weight:500}.nav-item svg{flex-shrink:0}.theme-pick{margin-top:14px;display:grid;gap:4px;padding:0 2px}.theme-pick label{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}.theme-pick select,.field select,.field input,.topbar input,.topbar select,.settings input,.settings select,.explorer-path input{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:0 10px;height:var(--control-h);width:100%}.rail-foot{margin-top:auto;padding:12px 8px 4px;border-top:1px solid var(--line);display:grid;gap:6px}.kbd-hint{font-size:11px;color:var(--muted)}kbd{font-family:var(--mono);font-size:10px;border:1px solid var(--line);border-radius:4px;padding:0 4px;background:var(--surface)}.main{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;background:var(--bg)}.progress{position:absolute;top:0;left:0;right:0;height:2px;overflow:hidden;z-index:30;background:color-mix(in srgb,var(--accent) 20%,transparent)}.progress i{display:block;height:100%;width:32%;background:var(--accent);animation:indeterminate 1.1s ease-in-out infinite}.progress.determinate i{width:0;animation:none;transform:none;transition:width .2s ease-out}@keyframes indeterminate{0%{transform:translate(-120%)}to{transform:translate(400%)}}.topbar{display:flex;gap:10px;align-items:flex-end;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg-2);flex-wrap:wrap}.field{display:grid;gap:4px;min-width:0}.field>span{font-size:11px;color:var(--muted);font-weight:500}.field.path{flex:1;min-width:180px}.field.ref{width:188px;flex:0 0 188px}.field.workspace{width:180px;flex:0 0 180px}.path-row,.combo-row{display:flex;min-width:0}.path-row input,.combo-row input{flex:1;min-width:0}.combo{position:relative;min-width:0}.combo-row input{border-top-right-radius:0;border-bottom-right-radius:0}.topbar .icon-btn{width:var(--control-h);padding:0;flex:0 0 var(--control-h)}.combo-toggle{border-top-left-radius:0;border-bottom-left-radius:0;border-left:0}.combo-menu{position:absolute;top:calc(100% + 4px);right:0;left:auto;min-width:340px;max-width:min(480px,70vw);max-height:360px;overflow:auto;z-index:40;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 12px 32px var(--shadow);padding:6px 0}.combo-heading{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:600;padding:8px 12px 4px}.combo-menu .combo-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;text-align:left;background:transparent;border:0;border-radius:0;height:auto;padding:6px 12px;color:var(--ink);cursor:pointer}.combo-menu .combo-option:hover,.combo-menu .combo-option.active{background:var(--rail-active)}.combo-label{font-family:var(--mono);font-size:12px}.combo-detail{color:var(--muted);font-size:12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.combo-empty{padding:10px 12px}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:50;background:color-mix(in srgb,var(--bg) 72%,transparent);display:grid;place-items:center;padding:24px}.modal{width:min(720px,100%);max-height:min(640px,90vh);background:var(--bg-2);border:1px solid var(--line);border-radius:var(--radius-lg);box-shadow:0 16px 48px var(--shadow);display:flex;flex-direction:column;overflow:hidden}.modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 16px 10px;border-bottom:1px solid var(--line)}.modal-head h2{font-size:15px}.modal-head .muted{margin:4px 0 0}.explorer-path{display:flex;gap:8px;padding:12px 16px;border-bottom:1px solid var(--line)}.explorer-path input{flex:1;min-width:0}.explorer-list{flex:1;overflow:auto;padding:8px;min-height:220px}.explorer-row{display:flex;align-items:center;gap:8px;width:100%;text-align:left;background:transparent;border:0;border-radius:var(--radius);padding:8px 10px;color:var(--ink);cursor:pointer;height:auto}.explorer-row:hover,.explorer-row.active{background:var(--rail-active)}.explorer-name{min-width:0;overflow:hidden;text-overflow:ellipsis}.git-badge{margin-left:auto;margin-bottom:0}.explorer-empty{padding:18px 10px}.modal-foot{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--line)}.explorer-current{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--mono);font-size:12px}.topbar input,.topbar select{min-width:0}.topbar-actions{display:flex;gap:8px;margin-left:auto;align-items:center;padding-bottom:0}.btn,.topbar button{background:var(--btn);border:1px solid var(--btn-line);border-radius:var(--radius);height:var(--control-h);padding:0 12px;cursor:pointer;font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap}.btn:hover,.topbar button:hover{filter:brightness(1.08)}.btn:disabled,.topbar button:disabled{opacity:.55;cursor:not-allowed;filter:none}.btn.primary{background:var(--btn-primary);border-color:var(--btn-primary-line)}.btn.ghost{background:transparent}.alerts{display:grid;gap:8px;padding:10px 16px 0}.alerts:empty{display:none;padding:0}.stage{flex:1;min-height:0;display:flex;flex-direction:column}.content{flex:1;min-height:0;display:grid;grid-template-columns:minmax(340px,420px) 1fr}.brief{overflow:auto;border-right:1px solid var(--line);padding:16px 18px 24px;background:radial-gradient(circle at 0 0,color-mix(in srgb,var(--accent) 8%,transparent),transparent 42%),var(--bg)}.graph-wrap{position:relative;min-height:0;display:flex;flex-direction:column}.impact-graph{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.graph-count{margin-left:auto;font-size:11px}.graph-layout{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--muted);letter-spacing:.04em}.graph-layout select{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:0 10px;height:26px;min-width:11.5rem;color:var(--ink);font:inherit;font-size:12px;letter-spacing:0;cursor:pointer}.chip-btn{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.chip-btn:hover{color:var(--ink)}.chip-btn.active{background:var(--rail-active);color:var(--ink)}.chip-btn:disabled{opacity:.45;cursor:not-allowed}.graph-stage{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-stage .react-flow,.graph-3d,.graph-3d-host,.graph-3d-canvas-host{flex:1;width:100%;height:100%;min-height:280px}.graph-3d{position:relative;background:var(--graph-bg);display:flex;flex-direction:column}.graph-3d-host{position:relative;min-height:0;display:flex;flex-direction:column}.graph-3d-canvas-host{position:relative;min-height:0;background:var(--graph-bg)}.graph-3d canvas{display:block;width:100%;height:100%}.graph-3d-tip{position:absolute;pointer-events:none;z-index:2;max-width:320px;padding:6px 8px;border-radius:var(--radius);background:var(--surface);border:1px solid var(--line);color:var(--ink);font-size:11px;line-height:1.35;box-shadow:0 8px 24px var(--shadow)}.graph-3d-tip .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.graph-3d-tip .n{font-weight:600}.graph-3d-tip .f{color:var(--muted);font-size:10px;margin-top:2px;overflow-wrap:anywhere}.graph-3d-hint{position:absolute;left:10px;bottom:10px;z-index:2;margin:0;font-size:11px;color:var(--muted);max-width:min(420px,calc(100% - 24px));pointer-events:none}.graph-wrap .react-flow{background-color:var(--graph-bg);background-image:linear-gradient(var(--graph-grid) 1px,transparent 1px),linear-gradient(90deg,var(--graph-grid) 1px,transparent 1px);background-size:24px 24px}.react-flow__minimap{background:var(--graph-bg)!important;border:1px solid var(--line)!important;border-radius:var(--radius);overflow:hidden;box-shadow:0 8px 24px var(--shadow)}.react-flow__minimap-node{fill:var(--muted);stroke:none}.react-flow__minimap-node.selected{fill:var(--accent)}.react-flow__minimap-mask{fill:#00000073!important;stroke:var(--accent)!important}.react-flow__controls{box-shadow:none!important}.react-flow__controls-button{background:var(--surface)!important;border-bottom:1px solid var(--line)!important;fill:var(--ink)!important}h1{font-size:18px;margin:0 0 6px;font-weight:600}h2{font-size:13px;margin:0;font-weight:600}.merge-box{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:12px 14px;margin-bottom:12px}.merge-box.high{border-color:color-mix(in srgb,var(--high) 55%,var(--line))}.merge-box.medium{border-color:color-mix(in srgb,var(--medium) 55%,var(--line))}.merge-box.low{border-color:color-mix(in srgb,var(--low) 55%,var(--line))}.level{font-family:var(--mono);font-weight:600;font-size:14px}.level.high{color:var(--high)}.level.medium{color:var(--medium)}.level.low{color:var(--low)}.merge-title{margin-top:4px;font-size:13px;color:var(--ink)}.reasons{margin:10px 0 0;padding:0 0 0 18px;color:var(--muted)}.reasons li{margin:0 0 4px}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:0 0 14px}.metric{border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:8px 10px}.metric .n{font-family:var(--mono);font-size:16px;font-weight:600;font-variant-numeric:tabular-nums}.metric .l{font-size:11px;color:var(--muted);margin-top:2px}.section{border-top:1px solid var(--line);padding:8px 0 4px}.section>summary{cursor:pointer;list-style:none;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600;padding:6px 0}.section>summary::-webkit-details-marker{display:none}.section>summary .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.kicker{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.08em;margin:16px 0 6px;font-weight:600}.chip{display:inline-flex;align-items:center;font-size:11px;padding:2px 8px;border-radius:999px;border:1px solid var(--line);margin:0 6px 6px 0;color:var(--muted);background:var(--surface)}.chip.blocker{color:var(--low);border-color:var(--low)}.chip.warning{color:var(--medium);border-color:var(--medium)}.chip.strong{color:var(--low);border-color:var(--low)}.chip.worth_exploring{color:var(--medium);border-color:var(--medium)}.chip.speculative{color:var(--muted);border-color:var(--line)}.chip.open{color:var(--high);border-color:color-mix(in srgb,var(--high) 50%,var(--line))}.file{font-family:var(--mono);font-size:12px;color:var(--accent)}.read-item,.finding,.residual{padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.read-item:last-child,.finding:last-child{border-bottom:0}.read-item.tour-current{background:color-mix(in srgb,var(--accent) 12%,var(--surface));border-color:var(--accent)}.tour-row{margin-top:8px;align-items:center}.field.dirty .chip-btn{height:32px}.muted{color:var(--muted);font-size:13px;line-height:1.45}.error{color:var(--low);padding:8px 12px;border:1px solid var(--low);background:color-mix(in srgb,var(--low) 10%,var(--surface));border-radius:var(--radius);display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner{padding:8px 12px;border-radius:var(--radius);border:1px solid var(--line);background:var(--surface);font-size:13px;line-height:1.45;display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner.warn{border-color:var(--medium);color:var(--medium)}.banner.stale{border-color:var(--low);color:var(--low)}.banner.whatif{border-color:var(--accent);align-items:center}.banner.whatif .btn{flex:0 0 auto;white-space:nowrap}.chip.whatif{color:var(--accent);border-color:color-mix(in srgb,var(--accent) 55%,var(--line))}.whatif-hint{margin:10px 0 0;font-size:12px;line-height:1.4;color:var(--muted)}.banner .dismiss{background:transparent;border:0;color:inherit;cursor:pointer;height:auto;padding:0 2px;opacity:.7}.empty{padding:24px 8px;color:var(--muted);font-size:13px;line-height:1.55}.workspace-loading{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;min-height:220px;padding:48px 16px}.graph-walk-empty{flex:1;display:flex;flex-direction:column;justify-content:center;max-width:36rem;margin:0 auto}.empty ol{margin:12px 0 0 18px;padding:0}.empty code,code{font-family:var(--mono);font-size:12px;color:var(--accent)}.btn-row{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.pr-list{padding:16px;overflow:auto}.pr-toolbar{display:flex;gap:8px;align-items:flex-end;margin-bottom:14px}.pr-toolbar .field{flex:1}.pr-toolbar .field.provider{flex:0 0 140px}.scm-count{margin:0 0 12px;font-size:12px}.scm-login{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px 0;border-top:1px solid var(--line)}.scm-login:first-of-type{border-top:0;padding-top:0}.scm-login .btn-row{margin-top:0}.scm-login p{margin:2px 0 0}.oauth-code{font-size:13px;margin:0}.oauth-code code{font-size:14px;letter-spacing:.08em}.pr{border:1px solid var(--line);background:var(--surface);padding:12px 14px;border-radius:var(--radius-lg);margin-bottom:10px}.pr h3{margin:0 0 4px;font-size:14px;font-weight:600}.pr-meta{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin:6px 0 10px}.pr-actions{display:flex;gap:8px;align-items:center}.settings{padding:24px;max-width:760px;overflow:auto;display:grid;gap:16px}.settings-card{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:16px;display:grid;gap:8px}.settings-card h2{font-size:14px;margin-bottom:2px}.settings label{font-size:12px;color:var(--muted);font-weight:500}.theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.theme-swatch{border:1px solid var(--line);background:var(--bg);color:var(--ink);border-radius:var(--radius);padding:10px;text-align:left;cursor:pointer;height:auto;box-shadow:0 1px 8px var(--shadow)}.theme-swatch.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent),0 1px 8px var(--shadow)}.theme-swatch .swatch-bar{height:6px;border-radius:3px;margin-bottom:8px;background:linear-gradient(90deg,var(--accent),var(--high),var(--medium),var(--low))}.theme-swatch .name{font-size:13px;font-weight:600}.theme-swatch .group{font-size:11px;color:var(--muted)}.headline{white-space:pre-wrap;font-family:var(--mono);font-size:12px;color:var(--muted);margin:8px 0 0}.graph-modes{display:flex;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:2px;background:var(--surface)}.seg button,.graph-modes button{background:transparent;border:0;border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.seg button.active,.graph-modes button.active{background:var(--rail-active);color:var(--ink)}.legend{margin-left:auto;display:flex;gap:12px;color:var(--muted);font-size:11px}.legend i{display:inline-block;width:14px;height:2px;margin-right:6px;vertical-align:middle;background:var(--edge-cheap)}.legend i.exp{background:var(--edge-expensive)}.legend i.crit{background:var(--edge-critical);height:3px}.legend i.dash{border-top:2px dashed var(--muted);background:none;height:0}.legend i.seed{height:10px;width:10px;border-radius:2px;background:color-mix(in srgb,var(--medium) 70%,var(--node-bg))}.legend i.down{height:10px;width:10px;border-radius:2px;border:1px solid color-mix(in srgb,var(--accent) 45%,var(--node-line));background:var(--node-bg)}.inspector{position:absolute;top:12px;right:12px;z-index:5;width:300px;max-width:calc(100% - 24px);max-height:calc(100% - 24px);overflow-x:hidden;overflow-y:auto;overflow-wrap:break-word;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:10px 12px;box-shadow:0 8px 24px var(--shadow);font-size:12px}.inspector .t{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.inspector .n,.inspector .file,.inspector .muted{overflow-wrap:break-word}.inspector .n{font-weight:600;margin:4px 0}.inspector-head{display:flex;align-items:flex-start;gap:8px}.inspector-roles{display:flex;flex-wrap:wrap;justify-content:flex-end;flex:1;gap:4px}.inspector-chip{font-size:10px;text-transform:uppercase;letter-spacing:.04em;padding:1px 6px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.inspector-close{flex:0 0 auto;width:24px;height:24px;padding:0;border:1px solid var(--line);border-radius:var(--radius);background:transparent;color:var(--muted);font-size:16px;line-height:1;cursor:pointer}.inspector-close:hover{color:var(--ink)}.inspector-purpose{margin:6px 0 8px;color:var(--ink);font-size:12px;line-height:1.4}.inspector-layer{margin-top:4px;font-size:11px}.inspector-degree{font-size:11px}.inspector-path{margin:6px 0 0;font-size:12px;line-height:1.4;color:var(--muted)}.inspector-facts{margin:10px 0 0;padding-top:8px;border-top:1px solid var(--line)}.inspector-fact{display:grid;grid-template-columns:minmax(64px,92px) minmax(0,1fr);gap:8px;padding:3px 0;align-items:start}.inspector-fact dt{color:var(--muted);font-size:11px;margin:0}.inspector-fact dd{margin:0;overflow-wrap:break-word}.inspector-section{margin-top:10px;padding-top:8px;border-top:1px solid var(--line)}.inspector-section h3{margin:0 0 6px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600}.inspector-section .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.inspector-section ul{list-style:none;margin:0;padding:0}.inspector-section li{padding:4px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.inspector-section li:last-child{border-bottom:0}.inspector-link-name{display:block;font-weight:600;overflow-wrap:break-word}.inspector-link-meta{display:block;color:var(--muted);font-size:11px}.lp-node{padding:8px 10px;border-radius:var(--radius);border:1px solid var(--node-line);background:var(--node-bg);width:208px;max-width:100%;height:64px;box-sizing:border-box;box-shadow:0 0 0 1px var(--shadow);overflow:visible;position:relative}.lp-node .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.lp-node .n{font-size:13px;font-weight:600;line-height:1.2;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow-wrap:anywhere}.lp-node.selected{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.lp-node.role-seed{border-color:var(--medium);background:color-mix(in srgb,var(--medium) 14%,var(--node-bg))}.lp-node.role-downstream{border-color:color-mix(in srgb,var(--accent) 45%,var(--node-line))}.lp-node.role-untested{box-shadow:inset 3px 0 0 var(--low)}.lp-node.role-tested{box-shadow:inset 3px 0 0 var(--high)}.lp-node.role-contract{outline:1px dashed color-mix(in srgb,var(--accent) 50%,transparent)}.lp-node.dim{opacity:.38}.merge-box.compact{padding:6px 10px;min-width:92px;margin:0}.merge-box.compact .level{font-size:12px}.palette-scrim{position:fixed;top:0;right:0;bottom:0;left:0;background:color-mix(in srgb,var(--bg) 55%,transparent);z-index:40;display:grid;place-items:start center;padding-top:12vh}.palette{width:min(640px,calc(100vw - 32px));background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:0 18px 60px var(--shadow);overflow:hidden}.palette input{width:100%;border:0;border-bottom:1px solid var(--line);background:transparent;color:var(--ink);padding:14px 16px;font:inherit}.palette ul{list-style:none;margin:0;padding:6px;max-height:360px;overflow:auto}.palette li button{width:100%;display:flex;justify-content:space-between;gap:12px;text-align:left;background:transparent;border:0;color:var(--ink);padding:8px 10px;border-radius:8px;cursor:pointer}.palette li button.active,.palette li button:hover{background:var(--rail-active)}.palette-foot{padding:8px 12px 10px}.graph-search{position:relative;min-width:140px}.graph-search input{width:100%;background:var(--bg-2);border:1px solid var(--line);color:var(--ink);border-radius:8px;padding:6px 8px;font:inherit}.graph-search-hits{position:absolute;z-index:5;left:0;right:0;top:calc(100% + 4px);background:var(--surface);border:1px solid var(--line);border-radius:8px;list-style:none;margin:0;padding:4px;max-height:240px;overflow:auto}.graph-search-hits button{width:100%;display:flex;justify-content:space-between;gap:8px;background:transparent;border:0;color:var(--ink);text-align:left;padding:6px 8px;cursor:pointer}.graph-search-hits button:hover{background:var(--rail-active)}.inspector-link{display:flex;flex-direction:column;width:100%;background:transparent;border:0;color:inherit;text-align:left;cursor:pointer;padding:0}.file-row{display:flex;flex-direction:column;gap:6px}.linkish{background:none;border:0;color:inherit;font:inherit;text-align:left;cursor:pointer;padding:0}.history-item,.check-item{display:flex;flex-wrap:wrap;gap:8px;align-items:baseline;width:100%;background:transparent;border:0;color:inherit;font:inherit;text-align:left;padding:6px 0;cursor:pointer}.history-item.current{color:var(--accent)}.check-row{display:flex;gap:8px;align-items:center;margin:4px 0}.sparkline{display:flex;align-items:flex-end;gap:3px;height:36px;margin:8px 0}.sparkline i{flex:1;background:var(--muted);border-radius:2px 2px 0 0;min-width:4px}.sparkline i.high{background:var(--high)}.sparkline i.medium{background:var(--medium)}.sparkline i.low{background:var(--low)}.config-editor .field{display:flex;flex-direction:column;gap:4px;margin:8px 0}.config-editor input,.config-editor select{background:var(--bg-2);border:1px solid var(--line);color:var(--ink);border-radius:8px;padding:6px 8px}.react-flow__node-load .react-flow__handle{width:8px;height:8px;border:none;background:transparent;opacity:0}.type-table{width:100%;border-collapse:collapse;font-size:12px}.type-table td{padding:3px 0}.type-table td:last-child{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--muted)}@media(prefers-reduced-motion:reduce){.progress i{animation:none;width:100%}.progress.determinate i{width:var(--progress, 100%)}*{scroll-behavior:auto!important}}@media(max-width:960px){.app{grid-template-columns:56px 1fr}.brand-sub,.nav-item span,.theme-pick,.kbd-hint,.rail-foot .muted{display:none}.nav-item{justify-content:center;padding:10px}.content{grid-template-columns:1fr}.brief{border-right:0;border-bottom:1px solid var(--line);max-height:42vh}} diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index 49adf16..2a71cb3 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,8 +17,8 @@ - - + +
diff --git a/tests/e2e/test_ui_flows.py b/tests/e2e/test_ui_flows.py index eade99e..e2a1936 100644 --- a/tests/e2e/test_ui_flows.py +++ b/tests/e2e/test_ui_flows.py @@ -188,7 +188,7 @@ def test_ui_index_review_graph_copy_and_workspace(live_app, browser_page): page.get_by_test_id("graph-view-3d").click() assert page.get_by_test_id("graph-view-3d").get_attribute("aria-pressed") == "true" page.get_by_test_id("graph-3d").wait_for(timeout=15_000) - assert page.get_by_test_id("graph-layout").count() == 0 + page.get_by_test_id("graph-layout").wait_for() page.locator("[data-testid='graph-3d-canvas'], [data-testid='graph-3d-fallback']").first.wait_for(timeout=20_000) page.get_by_test_id("graph-view-2d").click() page.locator(".react-flow__node").first.wait_for(timeout=15_000) diff --git a/tests/e2e/test_ui_screenshots.py b/tests/e2e/test_ui_screenshots.py index dc89107..17853d8 100644 --- a/tests/e2e/test_ui_screenshots.py +++ b/tests/e2e/test_ui_screenshots.py @@ -102,6 +102,8 @@ def test_ui_review_graph_prs_settings(live_app, tmp_path: Path, browser_page): page.wait_for_timeout(800) _shot(page, dest, "architecture.png") + page.get_by_test_id("btn-review").wait_for(state="visible") + page.wait_for_function("() => !document.querySelector('[data-testid=\"btn-review\"]')?.disabled") with page.expect_response( lambda r: "/api/review" in r.url and r.request.method == "POST", timeout=60_000, @@ -113,8 +115,8 @@ def test_ui_review_graph_prs_settings(live_app, tmp_path: Path, browser_page): error = page.locator(".error") if error.count() and error.inner_text().strip(): pytest.fail(error.inner_text()) + page.get_by_test_id("brief").locator(".level").wait_for(timeout=30_000) page.get_by_test_id("merge-box").wait_for(timeout=15_000) - page.get_by_test_id("brief").locator(".level").wait_for(timeout=15_000) brief = page.get_by_test_id("brief").inner_text() assert "MEDIUM" in brief or "LOW" in brief or "HIGH" in brief _wait_graph(page) diff --git a/ui/src/ImpactGraph.tsx b/ui/src/ImpactGraph.tsx index 3f61d1d..b62fccb 100644 --- a/ui/src/ImpactGraph.tsx +++ b/ui/src/ImpactGraph.tsx @@ -1,4 +1,4 @@ -import { lazy, Suspense, useEffect, useMemo, useState } from "react"; +import { Component, lazy, Suspense, useEffect, useMemo, useState, type ReactNode } from "react"; import { Background, BaseEdge, @@ -22,6 +22,7 @@ import { GRAPH_LAYOUTS, defaultDetail, defaultProjection, + effectiveProjection, familyFor, isolatePathIds, layoutGraph, @@ -29,6 +30,7 @@ import { readGraphLayout, searchNodes, visibleGraph, + webglAvailable, writeGraphLayout, type GraphDetail, type GraphFamily, @@ -50,6 +52,22 @@ const LayeredGraph3D = lazy(() => import("./LayeredGraph3D").then((mod) => ({ default: mod.LayeredGraph3D })), ); +class GraphBoundary extends Component<{ children: ReactNode; fallback: ReactNode }, { failed: boolean }> { + state = { failed: false }; + static getDerivedStateFromError() { + return { failed: true }; + } + render() { + return this.state.failed ? this.props.fallback : this.props.children; + } +} + +const WEBGL_FALLBACK = ( +

+ WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map. +

+); + const WEIGHT_COLOR: Record = { cheap: "var(--edge-cheap)", expensive: "var(--edge-expensive)", @@ -455,7 +473,7 @@ function InspectorLinks({ ); } -export function ImpactGraph({ +function ImpactGraphView({ nodes, edges, onWhatIf, @@ -499,10 +517,22 @@ export function ImpactGraph({ const [neighborhoodOnly, setNeighborhoodOnly] = useState(false); const [query, setQuery] = useState(""); const [hitsOpen, setHitsOpen] = useState(false); + const [webgl, setWebgl] = useState(null); const reduceMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches; - const view = projection ?? defaultProjection(nodes.length); + useEffect(() => { + const probe = () => setWebgl(webglAvailable()); + if (typeof window.requestIdleCallback === "function") { + const idle = window.requestIdleCallback(probe); + return () => window.cancelIdleCallback(idle); + } + const timer = window.setTimeout(probe, 0); + return () => window.clearTimeout(timer); + }, []); + + const preferred = projection ?? defaultProjection(nodes.length); + const view = effectiveProjection(preferred, projection, webgl); const level = detail ?? defaultDetail(nodes.length); const neighborhoodFocus = neighborhoodOnly ? selectedId : null; const isolated = useMemo( @@ -656,29 +686,27 @@ export function ImpactGraph({ ))} - {view === "2d" ? ( - - ) : null} +