56243e1835
Obsidian-artige Visualisierung des Gedaechtnisses: Knoten = Fakten, Kanten = semantische Aehnlichkeit (Kosinus der gespeicherten Embeddings, kNN je Knoten), Farbe = Kategorie, Groesse = Vernetzung. Klick auf Knoten -> Detailpanel mit verwandten Fakten + vergessen. - mem0_service/app.py: /graph rechnet Aehnlichkeitskanten aus den Chroma-Embeddings. - backend: services.memory.graph() + /api/memory/graph (Passthrough). - frontend: GraphView (reagraph, WebGL), Graph/Liste-Umschalter in MemoryView, GraphErrorBoundary, lazy-load (three.js nur bei Bedarf -> Hauptbundle bleibt schlank). reagraph auf 4.22.0 gepinnt (4.23+ braucht @react-three/fiber v9 = React 19; Projekt ist React 18). Live gegen die Box verifiziert (Graph rendert, Kategorien-Farben, Kanten, dunkel). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
3957 lines
1.2 MiB
Plaintext
3957 lines
1.2 MiB
Plaintext
import{r as K,a as Hv,g as Hr,R as Um,c as q2,j as Ne,l as Z2,S as K2,b as Vx,T as $2}from"./index-DuvhfsJu.js";/**
|
|
* @license
|
|
* Copyright 2010-2023 Three.js Authors
|
|
* SPDX-License-Identifier: MIT
|
|
*/const Yd="154",ab={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},J2={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},lb=0,L0=1,cb=2,Q2=3,ub=0,qd=1,gu=2,Or=3,ls=0,yi=1,vn=2,eC=2,Fs=0,pa=1,I0=2,D0=3,U0=4,hb=5,aa=100,fb=101,db=102,O0=103,N0=104,pb=200,mb=201,gb=202,vb=203,Vv=204,Wv=205,yb=206,_b=207,xb=208,wb=209,Sb=210,Eb=0,bb=1,Mb=2,Ld=3,Tb=4,Ab=5,Cb=6,Rb=7,ih=0,Pb=1,Lb=2,zr=0,Ib=1,Db=2,Ub=3,Xv=4,Ob=5,Zd=300,xo=301,wo=302,Cu=303,Ru=304,Jl=306,Pu=1e3,vi=1001,Lu=1002,Dn=1003,Id=1004,tC=1004,vu=1005,nC=1005,fn=1006,jv=1007,iC=1007,So=1008,rC=1008,os=1009,Nb=1010,Fb=1011,Kd=1012,Yv=1013,Ns=1014,rs=1015,Vl=1016,qv=1017,Zv=1018,mo=1020,kb=1021,Bi=1023,zb=1024,Bb=1025,go=1026,xa=1027,Gb=1028,Kv=1029,Hb=1030,$v=1031,Jv=1033,vd=33776,yd=33777,_d=33778,xd=33779,F0=35840,k0=35841,z0=35842,B0=35843,Vb=36196,G0=37492,H0=37496,V0=37808,W0=37809,X0=37810,j0=37811,Y0=37812,q0=37813,Z0=37814,K0=37815,$0=37816,J0=37817,Q0=37818,ev=37819,tv=37820,nv=37821,wd=36492,Wb=36283,iv=36284,rv=36285,sv=36286,Xb=2200,jb=2201,Yb=2202,Iu=2300,Du=2301,Sd=2302,ua=2400,ha=2401,Uu=2402,$d=2500,Qv=2501,sC=0,oC=1,aC=2,ey=3e3,vo=3001,qb=3200,ty=3201,Mo=0,Zb=1,yo="",Mt="srgb",Br="srgb-linear",ny="display-p3",lC=0,Ed=7680,cC=7681,uC=7682,hC=7683,fC=34055,dC=34056,pC=5386,mC=512,gC=513,vC=514,yC=515,_C=516,xC=517,wC=518,Kb=519,$b=512,Jb=513,Qb=514,eM=515,tM=516,nM=517,iM=518,rM=519,Ou=35044,SC=35048,EC=35040,bC=35045,MC=35049,TC=35041,AC=35046,CC=35050,RC=35042,PC="100",ov="300 es",Dd=1035,ss=2e3,Nu=2001;let Hs=class{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){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}};const mi=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Wx=1234567;const ma=Math.PI/180,Wl=180/Math.PI;function er(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(mi[r&255]+mi[r>>8&255]+mi[r>>16&255]+mi[r>>24&255]+"-"+mi[e&255]+mi[e>>8&255]+"-"+mi[e>>16&15|64]+mi[e>>24&255]+"-"+mi[t&63|128]+mi[t>>8&255]+"-"+mi[t>>16&255]+mi[t>>24&255]+mi[n&255]+mi[n>>8&255]+mi[n>>16&255]+mi[n>>24&255]).toLowerCase()}function Tn(r,e,t){return Math.max(e,Math.min(t,r))}function iy(r,e){return(r%e+e)%e}function LC(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function IC(r,e,t){return r!==e?(t-r)/(e-r):0}function yu(r,e,t){return(1-t)*r+t*e}function DC(r,e,t,n){return yu(r,e,1-Math.exp(-t*n))}function UC(r,e=1){return e-Math.abs(iy(r,e*2)-e)}function OC(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function NC(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function FC(r,e){return r+Math.floor(Math.random()*(e-r+1))}function kC(r,e){return r+Math.random()*(e-r)}function zC(r){return r*(.5-Math.random())}function BC(r){r!==void 0&&(Wx=r);let e=Wx+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function GC(r){return r*ma}function HC(r){return r*Wl}function av(r){return(r&r-1)===0&&r!==0}function sM(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Ud(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function VC(r,e,t,n,i){const s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+n)/2),u=o((e+n)/2),h=s((e-n)/2),p=o((e-n)/2),m=s((n-e)/2),v=o((n-e)/2);switch(i){case"XYX":r.set(a*u,l*h,l*p,a*c);break;case"YZY":r.set(l*p,a*u,l*h,a*c);break;case"ZXZ":r.set(l*h,l*p,a*u,a*c);break;case"XZX":r.set(a*u,l*v,l*m,a*c);break;case"YXY":r.set(l*m,a*u,l*v,a*c);break;case"ZYZ":r.set(l*v,l*m,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Qi(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function Lt(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const Od={DEG2RAD:ma,RAD2DEG:Wl,generateUUID:er,clamp:Tn,euclideanModulo:iy,mapLinear:LC,inverseLerp:IC,lerp:yu,damp:DC,pingpong:UC,smoothstep:OC,smootherstep:NC,randInt:FC,randFloat:kC,randFloatSpread:zC,seededRandom:BC,degToRad:GC,radToDeg:HC,isPowerOfTwo:av,ceilPowerOfTwo:sM,floorPowerOfTwo:Ud,setQuaternionFromProperEuler:VC,normalize:Lt,denormalize:Qi};class De{constructor(e=0,t=0){De.prototype.isVector2=!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("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,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,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(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(Tn(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),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*i+e.x,this.y=s*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ct{constructor(e,t,n,i,s,o,a,l,c){Ct.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,o,a,l,c)}set(e,t,n,i,s,o,a,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=n,u[7]=o,u[8]=c,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,i=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],h=n[7],p=n[2],m=n[5],v=n[8],_=i[0],y=i[3],g=i[6],x=i[1],w=i[4],E=i[7],b=i[2],M=i[5],A=i[8];return s[0]=o*_+a*x+l*b,s[3]=o*y+a*w+l*M,s[6]=o*g+a*E+l*A,s[1]=c*_+u*x+h*b,s[4]=c*y+u*w+h*M,s[7]=c*g+u*E+h*A,s[2]=p*_+m*x+v*b,s[5]=p*y+m*w+v*M,s[8]=p*g+m*E+v*A,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],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-n*s*u+n*a*l+i*s*c-i*o*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*o-a*c,p=a*l-u*s,m=c*s-o*l,v=t*h+n*p+i*m;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/v;return e[0]=h*_,e[1]=(i*c-u*n)*_,e[2]=(a*n-i*o)*_,e[3]=p*_,e[4]=(u*t-i*l)*_,e[5]=(i*s-a*t)*_,e[6]=m*_,e[7]=(n*l-c*t)*_,e[8]=(o*t-n*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,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-i*c,i*l,-i*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Om.makeScale(e,t)),this}rotate(e){return this.premultiply(Om.makeRotation(-e)),this}translate(e,t){return this.premultiply(Om.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 i=0;i<9;i++)if(t[i]!==n[i])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)}}const Om=new Ct;function oM(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}const WC={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Dl(r,e){return new WC[r](e)}function Fu(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const Xx={};function _u(r){r in Xx||(Xx[r]=!0,console.warn(r))}function zl(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Nm(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}const XC=new Ct().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),jC=new Ct().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function YC(r){return r.convertSRGBToLinear().applyMatrix3(jC)}function qC(r){return r.applyMatrix3(XC).convertLinearToSRGB()}const ZC={[Br]:r=>r,[Mt]:r=>r.convertSRGBToLinear(),[ny]:YC},KC={[Br]:r=>r,[Mt]:r=>r.convertLinearToSRGB(),[ny]:qC},vr={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(r){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!r},get workingColorSpace(){return Br},set workingColorSpace(r){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(r,e,t){if(this.enabled===!1||e===t||!e||!t)return r;const n=ZC[e],i=KC[t];if(n===void 0||i===void 0)throw new Error(`Unsupported color space conversion, "${e}" to "${t}".`);return i(n(r))},fromWorkingColorSpace:function(r,e){return this.convert(r,this.workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this.workingColorSpace)}};let Ka;class ry{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Ka===void 0&&(Ka=Fu("canvas")),Ka.width=e.width,Ka.height=e.height;const n=Ka.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Ka}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Fu("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=zl(s[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(zl(t[n]/255)*255):t[n]=zl(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let $C=0;class fa{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:$C++}),this.uuid=er(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(Fm(i[o].image)):s.push(Fm(i[o]))}else s=Fm(i);n.url=s}return t||(e.images[this.uuid]=n),n}}function Fm(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?ry.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let JC=0;class Sn extends Hs{constructor(e=Sn.DEFAULT_IMAGE,t=Sn.DEFAULT_MAPPING,n=vi,i=vi,s=fn,o=So,a=Bi,l=os,c=Sn.DEFAULT_ANISOTROPY,u=yo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:JC++}),this.uuid=er(),this.name="",this.source=new fa(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new De(0,0),this.repeat=new De(1,1),this.center=new De(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ct,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof u=="string"?this.colorSpace=u:(_u("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=u===vo?Mt:yo),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}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.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Zd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Pu:e.x=e.x-Math.floor(e.x);break;case vi:e.x=e.x<0?0:1;break;case Lu: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 Pu:e.y=e.y-Math.floor(e.y);break;case vi:e.y=e.y<0?0:1;break;case Lu: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)}get encoding(){return _u("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Mt?vo:ey}set encoding(e){_u("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===vo?Mt:yo}}Sn.DEFAULT_IMAGE=null;Sn.DEFAULT_MAPPING=Zd;Sn.DEFAULT_ANISOTROPY=1;class Xt{constructor(e=0,t=0,n=0,i=1){Xt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}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,i){return this.x=e,this.y=t,this.z=n,this.w=i,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("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,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,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*s,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,i,s;const l=e.elements,c=l[0],u=l[4],h=l[8],p=l[1],m=l[5],v=l[9],_=l[2],y=l[6],g=l[10];if(Math.abs(u-p)<.01&&Math.abs(h-_)<.01&&Math.abs(v-y)<.01){if(Math.abs(u+p)<.1&&Math.abs(h+_)<.1&&Math.abs(v+y)<.1&&Math.abs(c+m+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(c+1)/2,E=(m+1)/2,b=(g+1)/2,M=(u+p)/4,A=(h+_)/4,P=(v+y)/4;return w>E&&w>b?w<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(w),i=M/n,s=A/n):E>b?E<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(E),n=M/i,s=P/i):b<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(b),n=A/s,i=P/s),this.set(n,i,s,t),this}let x=Math.sqrt((y-v)*(y-v)+(h-_)*(h-_)+(p-u)*(p-u));return Math.abs(x)<.001&&(x=1),this.x=(y-v)/x,this.y=(h-_)/x,this.z=(p-u)/x,this.w=Math.acos((c+m+g-1)/2),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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(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}}class Gr extends Hs{constructor(e=1,t=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Xt(0,0,e,t),this.scissorTest=!1,this.viewport=new Xt(0,0,e,t);const i={width:e,height:t,depth:1};n.encoding!==void 0&&(_u("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===vo?Mt:yo),this.texture=new Sn(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:fn,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,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.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new fa(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Jd extends Sn{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Dn,this.minFilter=Dn,this.wrapR=vi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class QC extends Gr{constructor(e=1,t=1,n=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Jd(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class sy extends Sn{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Dn,this.minFilter=Dn,this.wrapR=vi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class eR extends Gr{constructor(e=1,t=1,n=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new sy(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class tR extends Gr{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let o=0;o<n;o++)this.texture[o]=s.clone(),this.texture[o].isRenderTargetTexture=!0}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,s=this.texture.length;i<s;i++)this.texture[i].image.width=e,this.texture[i].image.height=t,this.texture[i].image.depth=n;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),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.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.texture.length=0;for(let t=0,n=e.texture.length;t<n;t++)this.texture[t]=e.texture[t].clone(),this.texture[t].isRenderTargetTexture=!0;return this}}class si{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,o,a){let l=n[i+0],c=n[i+1],u=n[i+2],h=n[i+3];const p=s[o+0],m=s[o+1],v=s[o+2],_=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=p,e[t+1]=m,e[t+2]=v,e[t+3]=_;return}if(h!==_||l!==p||c!==m||u!==v){let y=1-a;const g=l*p+c*m+u*v+h*_,x=g>=0?1:-1,w=1-g*g;if(w>Number.EPSILON){const b=Math.sqrt(w),M=Math.atan2(b,g*x);y=Math.sin(y*M)/b,a=Math.sin(a*M)/b}const E=a*x;if(l=l*y+p*E,c=c*y+m*E,u=u*y+v*E,h=h*y+_*E,y===1-a){const b=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=b,c*=b,u*=b,h*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,o){const a=n[i],l=n[i+1],c=n[i+2],u=n[i+3],h=s[o],p=s[o+1],m=s[o+2],v=s[o+3];return e[t]=a*v+u*h+l*m-c*p,e[t+1]=l*v+u*p+c*h-a*m,e[t+2]=c*v+u*m+a*p-l*h,e[t+3]=u*v-a*h-l*p-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,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){const n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(i/2),h=a(s/2),p=l(n/2),m=l(i/2),v=l(s/2);switch(o){case"XYZ":this._x=p*u*h+c*m*v,this._y=c*m*h-p*u*v,this._z=c*u*v+p*m*h,this._w=c*u*h-p*m*v;break;case"YXZ":this._x=p*u*h+c*m*v,this._y=c*m*h-p*u*v,this._z=c*u*v-p*m*h,this._w=c*u*h+p*m*v;break;case"ZXY":this._x=p*u*h-c*m*v,this._y=c*m*h+p*u*v,this._z=c*u*v+p*m*h,this._w=c*u*h-p*m*v;break;case"ZYX":this._x=p*u*h-c*m*v,this._y=c*m*h+p*u*v,this._z=c*u*v-p*m*h,this._w=c*u*h+p*m*v;break;case"YZX":this._x=p*u*h+c*m*v,this._y=c*m*h+p*u*v,this._z=c*u*v-p*m*h,this._w=c*u*h-p*m*v;break;case"XZY":this._x=p*u*h-c*m*v,this._y=c*m*h-p*u*v,this._z=c*u*v+p*m*h,this._w=c*u*h+p*m*v;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],h=t[10],p=n+a+h;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(u-l)*m,this._y=(s-c)*m,this._z=(o-i)*m}else if(n>a&&n>h){const m=2*Math.sqrt(1+n-a-h);this._w=(u-l)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(s+c)/m}else if(a>h){const m=2*Math.sqrt(1+a-n-h);this._w=(s-c)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(l+u)/m}else{const m=2*Math.sqrt(1+h-n-a);this._w=(o-i)/m,this._x=(s+c)/m,this._y=(l+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(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(Tn(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(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,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+o*a+i*c-s*l,this._y=i*u+o*l+s*a-n*c,this._z=s*u+o*c+n*l-i*a,this._w=o*u-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,o=this._w;let a=o*e._w+n*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const m=1-t;return this._w=m*o+t*this._w,this._x=m*n+t*this._x,this._y=m*i+t*this._y,this._z=m*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),u=Math.atan2(c,a),h=Math.sin((1-t)*u)/c,p=Math.sin(t*u)/c;return this._w=o*h+this._w*p,this._x=n*h+this._x*p,this._y=i*h+this._y*p,this._z=s*h+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}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}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Y{constructor(e=0,t=0,n=0){Y.prototype.isVector3=!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("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,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(jx.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(jx.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=l*t+o*i-a*n,u=l*n+a*t-s*i,h=l*i+s*n-o*t,p=-s*t-o*n-a*i;return this.x=c*l+p*-s+u*-a-h*-o,this.y=u*l+p*-o+h*-s-c*-a,this.z=h*l+p*-a+c*-o-u*-s,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,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(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,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,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 km.copy(this).projectOnVector(e),this.sub(km)}reflect(e){return this.sub(km.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(Tn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}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 i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*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(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const km=new Y,jx=new si;class ir{constructor(e=new Y(1/0,1/0,1/0),t=new Y(-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<n;t+=3)this.expandByPoint(Es.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Es.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Es.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){if(e.updateWorldMatrix(!1,!1),e.boundingBox!==void 0)e.boundingBox===null&&e.computeBoundingBox(),$a.copy(e.boundingBox),$a.applyMatrix4(e.matrixWorld),this.union($a);else{const i=e.geometry;if(i!==void 0)if(t&&i.attributes!==void 0&&i.attributes.position!==void 0){const s=i.attributes.position;for(let o=0,a=s.count;o<a;o++)Es.fromBufferAttribute(s,o).applyMatrix4(e.matrixWorld),this.expandByPoint(Es)}else i.boundingBox===null&&i.computeBoundingBox(),$a.copy(i.boundingBox),$a.applyMatrix4(e.matrixWorld),this.union($a)}const n=e.children;for(let i=0,s=n.length;i<s;i++)this.expandByObject(n[i],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,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,Es),Es.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(Rc),hf.subVectors(this.max,Rc),Ja.subVectors(e.a,Rc),Qa.subVectors(e.b,Rc),el.subVectors(e.c,Rc),io.subVectors(Qa,Ja),ro.subVectors(el,Qa),Xo.subVectors(Ja,el);let t=[0,-io.z,io.y,0,-ro.z,ro.y,0,-Xo.z,Xo.y,io.z,0,-io.x,ro.z,0,-ro.x,Xo.z,0,-Xo.x,-io.y,io.x,0,-ro.y,ro.x,0,-Xo.y,Xo.x,0];return!zm(t,Ja,Qa,el,hf)||(t=[1,0,0,0,1,0,0,0,1],!zm(t,Ja,Qa,el,hf))?!1:(ff.crossVectors(io,ro),t=[ff.x,ff.y,ff.z],zm(t,Ja,Qa,el,hf))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Es).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Es).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:(Ss[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ss[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ss[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ss[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ss[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ss[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ss[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ss[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ss),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Ss=[new Y,new Y,new Y,new Y,new Y,new Y,new Y,new Y],Es=new Y,$a=new ir,Ja=new Y,Qa=new Y,el=new Y,io=new Y,ro=new Y,Xo=new Y,Rc=new Y,hf=new Y,ff=new Y,jo=new Y;function zm(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){jo.fromArray(r,s);const a=i.x*Math.abs(jo.x)+i.y*Math.abs(jo.y)+i.z*Math.abs(jo.z),l=e.dot(jo),c=t.dot(jo),u=n.dot(jo);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}const nR=new ir,Pc=new Y,Bm=new Y;let rr=class{constructor(e=new Y,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):nR.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.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;Pc.subVectors(e,this.center);const t=Pc.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Pc,i/n),this.radius+=i}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):(Bm.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Pc.copy(e.center).add(Bm)),this.expandByPoint(Pc.copy(e.center).sub(Bm))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}};const bs=new Y,Gm=new Y,df=new Y,so=new Y,Hm=new Y,pf=new Y,Vm=new Y;class Ql{constructor(e=new Y,t=new Y(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,bs)),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=bs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(bs.copy(this.origin).addScaledVector(this.direction,t),bs.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Gm.copy(e).add(t).multiplyScalar(.5),df.copy(t).sub(e).normalize(),so.copy(this.origin).sub(Gm);const s=e.distanceTo(t)*.5,o=-this.direction.dot(df),a=so.dot(this.direction),l=-so.dot(df),c=so.lengthSq(),u=Math.abs(1-o*o);let h,p,m,v;if(u>0)if(h=o*l-a,p=o*a-l,v=s*u,h>=0)if(p>=-v)if(p<=v){const _=1/u;h*=_,p*=_,m=h*(h+o*p+2*a)+p*(o*h+p+2*l)+c}else p=s,h=Math.max(0,-(o*p+a)),m=-h*h+p*(p+2*l)+c;else p=-s,h=Math.max(0,-(o*p+a)),m=-h*h+p*(p+2*l)+c;else p<=-v?(h=Math.max(0,-(-o*s+a)),p=h>0?-s:Math.min(Math.max(-s,-l),s),m=-h*h+p*(p+2*l)+c):p<=v?(h=0,p=Math.min(Math.max(-s,-l),s),m=p*(p+2*l)+c):(h=Math.max(0,-(o*s+a)),p=h>0?s:Math.min(Math.max(-s,-l),s),m=-h*h+p*(p+2*l)+c);else p=o>0?-s:s,h=Math.max(0,-(o*p+a)),m=-h*h+p*(p+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Gm).addScaledVector(df,p),m}intersectSphere(e,t){bs.subVectors(e.center,this.origin);const n=bs.dot(this.direction),i=bs.dot(bs)-n*n,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return 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,i,s,o,a,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,p=this.origin;return c>=0?(n=(e.min.x-p.x)*c,i=(e.max.x-p.x)*c):(n=(e.max.x-p.x)*c,i=(e.min.x-p.x)*c),u>=0?(s=(e.min.y-p.y)*u,o=(e.max.y-p.y)*u):(s=(e.max.y-p.y)*u,o=(e.min.y-p.y)*u),n>o||s>i||((s>n||isNaN(n))&&(n=s),(o<i||isNaN(i))&&(i=o),h>=0?(a=(e.min.z-p.z)*h,l=(e.max.z-p.z)*h):(a=(e.max.z-p.z)*h,l=(e.min.z-p.z)*h),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,bs)!==null}intersectTriangle(e,t,n,i,s){Hm.subVectors(t,e),pf.subVectors(n,e),Vm.crossVectors(Hm,pf);let o=this.direction.dot(Vm),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;so.subVectors(this.origin,e);const l=a*this.direction.dot(pf.crossVectors(so,pf));if(l<0)return null;const c=a*this.direction.dot(Hm.cross(so));if(c<0||l+c>o)return null;const u=-a*so.dot(Vm);return u<0?null:this.at(u/o,s)}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 yt{constructor(e,t,n,i,s,o,a,l,c,u,h,p,m,v,_,y){yt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,o,a,l,c,u,h,p,m,v,_,y)}set(e,t,n,i,s,o,a,l,c,u,h,p,m,v,_,y){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=s,g[5]=o,g[9]=a,g[13]=l,g[2]=c,g[6]=u,g[10]=h,g[14]=p,g[3]=m,g[7]=v,g[11]=_,g[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new yt().fromArray(this.elements)}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],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/tl.setFromMatrixColumn(e,0).length(),s=1/tl.setFromMatrixColumn(e,1).length(),o=1/tl.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const p=o*u,m=o*h,v=a*u,_=a*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=m+v*c,t[5]=p-_*c,t[9]=-a*l,t[2]=_-p*c,t[6]=v+m*c,t[10]=o*l}else if(e.order==="YXZ"){const p=l*u,m=l*h,v=c*u,_=c*h;t[0]=p+_*a,t[4]=v*a-m,t[8]=o*c,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=m*a-v,t[6]=_+p*a,t[10]=o*l}else if(e.order==="ZXY"){const p=l*u,m=l*h,v=c*u,_=c*h;t[0]=p-_*a,t[4]=-o*h,t[8]=v+m*a,t[1]=m+v*a,t[5]=o*u,t[9]=_-p*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const p=o*u,m=o*h,v=a*u,_=a*h;t[0]=l*u,t[4]=v*c-m,t[8]=p*c+_,t[1]=l*h,t[5]=_*c+p,t[9]=m*c-v,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const p=o*l,m=o*c,v=a*l,_=a*c;t[0]=l*u,t[4]=_-p*h,t[8]=v*h+m,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=m*h+v,t[10]=p-_*h}else if(e.order==="XZY"){const p=o*l,m=o*c,v=a*l,_=a*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=p*h+_,t[5]=o*u,t[9]=m*h-v,t[2]=v*h-m,t[6]=a*u,t[10]=_*h+p}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(iR,e,rR)}lookAt(e,t,n){const i=this.elements;return $i.subVectors(e,t),$i.lengthSq()===0&&($i.z=1),$i.normalize(),oo.crossVectors(n,$i),oo.lengthSq()===0&&(Math.abs(n.z)===1?$i.x+=1e-4:$i.z+=1e-4,$i.normalize(),oo.crossVectors(n,$i)),oo.normalize(),mf.crossVectors($i,oo),i[0]=oo.x,i[4]=mf.x,i[8]=$i.x,i[1]=oo.y,i[5]=mf.y,i[9]=$i.y,i[2]=oo.z,i[6]=mf.z,i[10]=$i.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],u=n[1],h=n[5],p=n[9],m=n[13],v=n[2],_=n[6],y=n[10],g=n[14],x=n[3],w=n[7],E=n[11],b=n[15],M=i[0],A=i[4],P=i[8],C=i[12],L=i[1],F=i[5],N=i[9],I=i[13],X=i[2],q=i[6],W=i[10],O=i[14],k=i[3],G=i[7],B=i[11],D=i[15];return s[0]=o*M+a*L+l*X+c*k,s[4]=o*A+a*F+l*q+c*G,s[8]=o*P+a*N+l*W+c*B,s[12]=o*C+a*I+l*O+c*D,s[1]=u*M+h*L+p*X+m*k,s[5]=u*A+h*F+p*q+m*G,s[9]=u*P+h*N+p*W+m*B,s[13]=u*C+h*I+p*O+m*D,s[2]=v*M+_*L+y*X+g*k,s[6]=v*A+_*F+y*q+g*G,s[10]=v*P+_*N+y*W+g*B,s[14]=v*C+_*I+y*O+g*D,s[3]=x*M+w*L+E*X+b*k,s[7]=x*A+w*F+E*q+b*G,s[11]=x*P+w*N+E*W+b*B,s[15]=x*C+w*I+E*O+b*D,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],h=e[6],p=e[10],m=e[14],v=e[3],_=e[7],y=e[11],g=e[15];return v*(+s*l*h-i*c*h-s*a*p+n*c*p+i*a*m-n*l*m)+_*(+t*l*m-t*c*p+s*o*p-i*o*m+i*c*u-s*l*u)+y*(+t*c*h-t*a*m-s*o*h+n*o*m+s*a*u-n*c*u)+g*(-i*a*u-t*l*h+t*a*p+i*o*h-n*o*p+n*l*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],p=e[10],m=e[11],v=e[12],_=e[13],y=e[14],g=e[15],x=h*y*c-_*p*c+_*l*m-a*y*m-h*l*g+a*p*g,w=v*p*c-u*y*c-v*l*m+o*y*m+u*l*g-o*p*g,E=u*_*c-v*h*c+v*a*m-o*_*m-u*a*g+o*h*g,b=v*h*l-u*_*l-v*a*p+o*_*p+u*a*y-o*h*y,M=t*x+n*w+i*E+s*b;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/M;return e[0]=x*A,e[1]=(_*p*s-h*y*s-_*i*m+n*y*m+h*i*g-n*p*g)*A,e[2]=(a*y*s-_*l*s+_*i*c-n*y*c-a*i*g+n*l*g)*A,e[3]=(h*l*s-a*p*s-h*i*c+n*p*c+a*i*m-n*l*m)*A,e[4]=w*A,e[5]=(u*y*s-v*p*s+v*i*m-t*y*m-u*i*g+t*p*g)*A,e[6]=(v*l*s-o*y*s-v*i*c+t*y*c+o*i*g-t*l*g)*A,e[7]=(o*p*s-u*l*s+u*i*c-t*p*c-o*i*m+t*l*m)*A,e[8]=E*A,e[9]=(v*h*s-u*_*s-v*n*m+t*_*m+u*n*g-t*h*g)*A,e[10]=(o*_*s-v*a*s+v*n*c-t*_*c-o*n*g+t*a*g)*A,e[11]=(u*a*s-o*h*s-u*n*c+t*h*c+o*n*m-t*a*m)*A,e[12]=b*A,e[13]=(u*_*i-v*h*i+v*n*p-t*_*p-u*n*y+t*h*y)*A,e[14]=(v*a*i-o*_*i-v*n*l+t*_*l+o*n*y-t*a*y)*A,e[15]=(o*h*i-u*a*i+u*n*l-t*h*l-o*n*p+t*a*p)*A,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,c=s*o,u=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,u*a+n,u*l-i*o,0,c*l-i*a,u*l+i*o,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,o){return this.set(1,n,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,u=o+o,h=a+a,p=s*c,m=s*u,v=s*h,_=o*u,y=o*h,g=a*h,x=l*c,w=l*u,E=l*h,b=n.x,M=n.y,A=n.z;return i[0]=(1-(_+g))*b,i[1]=(m+E)*b,i[2]=(v-w)*b,i[3]=0,i[4]=(m-E)*M,i[5]=(1-(p+g))*M,i[6]=(y+x)*M,i[7]=0,i[8]=(v+w)*A,i[9]=(y-x)*A,i[10]=(1-(p+_))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=tl.set(i[0],i[1],i[2]).length();const o=tl.set(i[4],i[5],i[6]).length(),a=tl.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Cr.copy(this);const c=1/s,u=1/o,h=1/a;return Cr.elements[0]*=c,Cr.elements[1]*=c,Cr.elements[2]*=c,Cr.elements[4]*=u,Cr.elements[5]*=u,Cr.elements[6]*=u,Cr.elements[8]*=h,Cr.elements[9]*=h,Cr.elements[10]*=h,t.setFromRotationMatrix(Cr),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,s,o,a=ss){const l=this.elements,c=2*s/(t-e),u=2*s/(n-i),h=(t+e)/(t-e),p=(n+i)/(n-i);let m,v;if(a===ss)m=-(o+s)/(o-s),v=-2*o*s/(o-s);else if(a===Nu)m=-o/(o-s),v=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,o,a=ss){const l=this.elements,c=1/(t-e),u=1/(n-i),h=1/(o-s),p=(t+e)*c,m=(n+i)*u;let v,_;if(a===ss)v=(o+s)*h,_=-2*h;else if(a===Nu)v=s*h,_=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-p,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=_,l[14]=-v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;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[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const tl=new Y,Cr=new yt,iR=new Y(0,0,0),rR=new Y(1,1,1),oo=new Y,mf=new Y,$i=new Y,Yx=new yt,qx=new si;class Eo{constructor(e=0,t=0,n=0,i=Eo.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],u=i[9],h=i[2],p=i[6],m=i[10];switch(t){case"XYZ":this._y=Math.asin(Tn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Tn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Tn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Tn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Tn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,m));break;case"XZY":this._z=Math.asin(-Tn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Yx.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Yx,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return qx.setFromEuler(this),this.setFromQuaternion(qx,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Eo.DEFAULT_ORDER="XYZ";class ga{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let sR=0;const Zx=new Y,nl=new si,Ms=new yt,gf=new Y,Lc=new Y,oR=new Y,aR=new si,Kx=new Y(1,0,0),$x=new Y(0,1,0),Jx=new Y(0,0,1),lR={type:"added"},Qx={type:"removed"};class jt extends Hs{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:sR++}),this.uuid=er(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=jt.DEFAULT_UP.clone();const e=new Y,t=new Eo,n=new si,i=new Y(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new yt},normalMatrix:{value:new Ct}}),this.matrix=new yt,this.matrixWorld=new yt,this.matrixAutoUpdate=jt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=jt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new ga,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return nl.setFromAxisAngle(e,t),this.quaternion.multiply(nl),this}rotateOnWorldAxis(e,t){return nl.setFromAxisAngle(e,t),this.quaternion.premultiply(nl),this}rotateX(e){return this.rotateOnAxis(Kx,e)}rotateY(e){return this.rotateOnAxis($x,e)}rotateZ(e){return this.rotateOnAxis(Jx,e)}translateOnAxis(e,t){return Zx.copy(e).applyQuaternion(this.quaternion),this.position.add(Zx.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Kx,e)}translateY(e){return this.translateOnAxis($x,e)}translateZ(e){return this.translateOnAxis(Jx,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ms.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?gf.copy(e):gf.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Lc.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ms.lookAt(Lc,gf,this.up):Ms.lookAt(gf,Lc,this.up),this.quaternion.setFromRotationMatrix(Ms),i&&(Ms.extractRotation(i.matrixWorld),nl.setFromRotationMatrix(Ms),this.quaternion.premultiply(nl.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(lR)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Qx)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(Qx)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Ms.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ms.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ms),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t){let n=[];this[e]===t&&n.push(this);for(let i=0,s=this.children.length;i<s;i++){const o=this.children[i].getObjectsByProperty(e,t);o.length>0&&(n=n.concat(o))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Lc,e,oR),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Lc,aR,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++){const s=t[n];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++){const a=i[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(s(e.animations,l))}}if(t){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),u=o(e.images),h=o(e.shapes),p=o(e.skeletons),m=o(e.animations),v=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),p.length>0&&(n.skeletons=p),m.length>0&&(n.animations=m),v.length>0&&(n.nodes=v)}return n.object=i,n;function o(a){const l=[];for(const c in a){const u=a[c];delete u.metadata,l.push(u)}return l}}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.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}jt.DEFAULT_UP=new Y(0,1,0);jt.DEFAULT_MATRIX_AUTO_UPDATE=!0;jt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Rr=new Y,Ts=new Y,Wm=new Y,As=new Y,il=new Y,rl=new Y,e1=new Y,Xm=new Y,jm=new Y,Ym=new Y;let vf=!1;class zi{constructor(e=new Y,t=new Y,n=new Y){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Rr.subVectors(e,t),i.cross(Rr);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){Rr.subVectors(i,t),Ts.subVectors(n,t),Wm.subVectors(e,t);const o=Rr.dot(Rr),a=Rr.dot(Ts),l=Rr.dot(Wm),c=Ts.dot(Ts),u=Ts.dot(Wm),h=o*c-a*a;if(h===0)return s.set(-2,-1,-1);const p=1/h,m=(c*l-a*u)*p,v=(o*u-a*l)*p;return s.set(1-m-v,v,m)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,As),As.x>=0&&As.y>=0&&As.x+As.y<=1}static getUV(e,t,n,i,s,o,a,l){return vf===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),vf=!0),this.getInterpolation(e,t,n,i,s,o,a,l)}static getInterpolation(e,t,n,i,s,o,a,l){return this.getBarycoord(e,t,n,i,As),l.setScalar(0),l.addScaledVector(s,As.x),l.addScaledVector(o,As.y),l.addScaledVector(a,As.z),l}static isFrontFacing(e,t,n,i){return Rr.subVectors(n,t),Ts.subVectors(e,t),Rr.cross(Ts).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 Rr.subVectors(this.c,this.b),Ts.subVectors(this.a,this.b),Rr.cross(Ts).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return zi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return zi.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return vf===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),vf=!0),zi.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}getInterpolation(e,t,n,i,s){return zi.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return zi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let o,a;il.subVectors(i,n),rl.subVectors(s,n),Xm.subVectors(e,n);const l=il.dot(Xm),c=rl.dot(Xm);if(l<=0&&c<=0)return t.copy(n);jm.subVectors(e,i);const u=il.dot(jm),h=rl.dot(jm);if(u>=0&&h<=u)return t.copy(i);const p=l*h-u*c;if(p<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(n).addScaledVector(il,o);Ym.subVectors(e,s);const m=il.dot(Ym),v=rl.dot(Ym);if(v>=0&&m<=v)return t.copy(s);const _=m*c-l*v;if(_<=0&&c>=0&&v<=0)return a=c/(c-v),t.copy(n).addScaledVector(rl,a);const y=u*v-m*h;if(y<=0&&h-u>=0&&m-v>=0)return e1.subVectors(s,i),a=(h-u)/(h-u+(m-v)),t.copy(i).addScaledVector(e1,a);const g=1/(y+_+p);return o=_*g,a=p*g,t.copy(n).addScaledVector(il,o).addScaledVector(rl,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let cR=0;class oi extends Hs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:cR++}),this.uuid=er(),this.name="",this.type="Material",this.blending=pa,this.side=ls,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Vv,this.blendDst=Wv,this.blendEquation=aa,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Ld,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Kb,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ed,this.stencilZFail=Ed,this.stencilZPass=Ed,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}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){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,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&&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.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.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!==pa&&(n.blending=this.blending),this.side!==ls&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,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=this.alphaHash),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(n.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(n.wireframe=this.wireframe),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=this.flatShading),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 i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const s=i(e.textures),o=i(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}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.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 i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].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.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++}}const aM={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Pr={h:0,s:0,l:0},yf={h:0,s:0,l:0};function qm(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class Ke{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 i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Mt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,vr.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=vr.workingColorSpace){return this.r=e,this.g=t,this.b=n,vr.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=vr.workingColorSpace){if(e=iy(e,1),t=Tn(t,0,1),n=Tn(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=qm(o,s,e+1/3),this.g=qm(o,s,e),this.b=qm(o,s,e-1/3)}return vr.toWorkingColorSpace(this,i),this}setStyle(e,t=Mt){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Mt){const n=aM[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=zl(e.r),this.g=zl(e.g),this.b=zl(e.b),this}copyLinearToSRGB(e){return this.r=Nm(e.r),this.g=Nm(e.g),this.b=Nm(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Mt){return vr.fromWorkingColorSpace(gi.copy(this),e),Math.round(Tn(gi.r*255,0,255))*65536+Math.round(Tn(gi.g*255,0,255))*256+Math.round(Tn(gi.b*255,0,255))}getHexString(e=Mt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=vr.workingColorSpace){vr.fromWorkingColorSpace(gi.copy(this),t);const n=gi.r,i=gi.g,s=gi.b,o=Math.max(n,i,s),a=Math.min(n,i,s);let l,c;const u=(a+o)/2;if(a===o)l=0,c=0;else{const h=o-a;switch(c=u<=.5?h/(o+a):h/(2-o-a),o){case n:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-n)/h+2;break;case s:l=(n-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=vr.workingColorSpace){return vr.fromWorkingColorSpace(gi.copy(this),t),e.r=gi.r,e.g=gi.g,e.b=gi.b,e}getStyle(e=Mt){vr.fromWorkingColorSpace(gi.copy(this),e);const t=gi.r,n=gi.g,i=gi.b;return e!==Mt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Pr),Pr.h+=e,Pr.s+=t,Pr.l+=n,this.setHSL(Pr.h,Pr.s,Pr.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Pr),e.getHSL(yf);const n=yu(Pr.h,yf.h,t),i=yu(Pr.s,yf.s,t),s=yu(Pr.l,yf.l,t);return this.setHSL(n,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*i,this.g=s[1]*t+s[4]*n+s[7]*i,this.b=s[2]*t+s[5]*n+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const gi=new Ke;Ke.NAMES=aM;class Vs extends oi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ke(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.combine=ih,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.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 Os=uR();function uR(){const r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}function ki(r){Math.abs(r)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),r=Tn(r,-65504,65504),Os.floatView[0]=r;const e=Os.uint32View[0],t=e>>23&511;return Os.baseTable[t]+((e&8388607)>>Os.shiftTable[t])}function hu(r){const e=r>>10;return Os.uint32View[0]=Os.mantissaTable[Os.offsetTable[e]+(r&1023)]+Os.exponentTable[e],Os.floatView[0]}const hR={toHalfFloat:ki,fromHalfFloat:hu},Fn=new Y,_f=new De;class $t{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ou,this.updateRange={offset:0,count:-1},this.gpuType=rs,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}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 i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)_f.fromBufferAttribute(this,t),_f.applyMatrix3(e),this.setXY(t,_f.x,_f.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Fn.fromBufferAttribute(this,t),Fn.applyMatrix3(e),this.setXYZ(t,Fn.x,Fn.y,Fn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Fn.fromBufferAttribute(this,t),Fn.applyMatrix4(e),this.setXYZ(t,Fn.x,Fn.y,Fn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Fn.fromBufferAttribute(this,t),Fn.applyNormalMatrix(e),this.setXYZ(t,Fn.x,Fn.y,Fn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Fn.fromBufferAttribute(this,t),Fn.transformDirection(e),this.setXYZ(t,Fn.x,Fn.y,Fn.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Qi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Qi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Qi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Qi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Lt(t,this.array),n=Lt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=Lt(t,this.array),n=Lt(n,this.array),i=Lt(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=Lt(t,this.array),n=Lt(n,this.array),i=Lt(i,this.array),s=Lt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Ou&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}}class fR extends $t{constructor(e,t,n){super(new Int8Array(e),t,n)}}class dR extends $t{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class pR extends $t{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class mR extends $t{constructor(e,t,n){super(new Int16Array(e),t,n)}}class oy extends $t{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class gR extends $t{constructor(e,t,n){super(new Int32Array(e),t,n)}}class ay extends $t{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class vR extends $t{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=hu(this.array[e*this.itemSize]);return this.normalized&&(t=Qi(t,this.array)),t}setX(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize]=ki(t),this}getY(e){let t=hu(this.array[e*this.itemSize+1]);return this.normalized&&(t=Qi(t,this.array)),t}setY(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize+1]=ki(t),this}getZ(e){let t=hu(this.array[e*this.itemSize+2]);return this.normalized&&(t=Qi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize+2]=ki(t),this}getW(e){let t=hu(this.array[e*this.itemSize+3]);return this.normalized&&(t=Qi(t,this.array)),t}setW(e,t){return this.normalized&&(t=Lt(t,this.array)),this.array[e*this.itemSize+3]=ki(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Lt(t,this.array),n=Lt(n,this.array)),this.array[e+0]=ki(t),this.array[e+1]=ki(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=Lt(t,this.array),n=Lt(n,this.array),i=Lt(i,this.array)),this.array[e+0]=ki(t),this.array[e+1]=ki(n),this.array[e+2]=ki(i),this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=Lt(t,this.array),n=Lt(n,this.array),i=Lt(i,this.array),s=Lt(s,this.array)),this.array[e+0]=ki(t),this.array[e+1]=ki(n),this.array[e+2]=ki(i),this.array[e+3]=ki(s),this}}class st extends $t{constructor(e,t,n){super(new Float32Array(e),t,n)}}class yR extends $t{constructor(e,t,n){super(new Float64Array(e),t,n)}}let _R=0;const pr=new yt,Zm=new jt,sl=new Y,Ji=new ir,Ic=new ir,Jn=new Y;class Tt extends Hs{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:_R++}),this.uuid=er(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(oM(e)?ay:oy)(e,1):this.index=e,this}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 s=new Ct().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return pr.makeRotationFromQuaternion(e),this.applyMatrix4(pr),this}rotateX(e){return pr.makeRotationX(e),this.applyMatrix4(pr),this}rotateY(e){return pr.makeRotationY(e),this.applyMatrix4(pr),this}rotateZ(e){return pr.makeRotationZ(e),this.applyMatrix4(pr),this}translate(e,t,n){return pr.makeTranslation(e,t,n),this.applyMatrix4(pr),this}scale(e,t,n){return pr.makeScale(e,t,n),this.applyMatrix4(pr),this}lookAt(e){return Zm.lookAt(e),Zm.updateMatrix(),this.applyMatrix4(Zm.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(sl).negate(),this.translate(sl.x,sl.y,sl.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new st(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ir);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new Y(-1/0,-1/0,-1/0),new Y(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const s=t[n];Ji.setFromBufferAttribute(s),this.morphTargetsRelative?(Jn.addVectors(this.boundingBox.min,Ji.min),this.boundingBox.expandByPoint(Jn),Jn.addVectors(this.boundingBox.max,Ji.max),this.boundingBox.expandByPoint(Jn)):(this.boundingBox.expandByPoint(Ji.min),this.boundingBox.expandByPoint(Ji.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new rr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new Y,1/0);return}if(e){const n=this.boundingSphere.center;if(Ji.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){const a=t[s];Ic.setFromBufferAttribute(a),this.morphTargetsRelative?(Jn.addVectors(Ji.min,Ic.min),Ji.expandByPoint(Jn),Jn.addVectors(Ji.max,Ic.max),Ji.expandByPoint(Jn)):(Ji.expandByPoint(Ic.min),Ji.expandByPoint(Ic.max))}Ji.getCenter(n);let i=0;for(let s=0,o=e.count;s<o;s++)Jn.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Jn));if(t)for(let s=0,o=t.length;s<o;s++){const a=t[s],l=this.morphTargetsRelative;for(let c=0,u=a.count;c<u;c++)Jn.fromBufferAttribute(a,c),l&&(sl.fromBufferAttribute(e,c),Jn.add(sl)),i=Math.max(i,n.distanceToSquared(Jn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.array,i=t.position.array,s=t.normal.array,o=t.uv.array,a=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new $t(new Float32Array(4*a),4));const l=this.getAttribute("tangent").array,c=[],u=[];for(let L=0;L<a;L++)c[L]=new Y,u[L]=new Y;const h=new Y,p=new Y,m=new Y,v=new De,_=new De,y=new De,g=new Y,x=new Y;function w(L,F,N){h.fromArray(i,L*3),p.fromArray(i,F*3),m.fromArray(i,N*3),v.fromArray(o,L*2),_.fromArray(o,F*2),y.fromArray(o,N*2),p.sub(h),m.sub(h),_.sub(v),y.sub(v);const I=1/(_.x*y.y-y.x*_.y);isFinite(I)&&(g.copy(p).multiplyScalar(y.y).addScaledVector(m,-_.y).multiplyScalar(I),x.copy(m).multiplyScalar(_.x).addScaledVector(p,-y.x).multiplyScalar(I),c[L].add(g),c[F].add(g),c[N].add(g),u[L].add(x),u[F].add(x),u[N].add(x))}let E=this.groups;E.length===0&&(E=[{start:0,count:n.length}]);for(let L=0,F=E.length;L<F;++L){const N=E[L],I=N.start,X=N.count;for(let q=I,W=I+X;q<W;q+=3)w(n[q+0],n[q+1],n[q+2])}const b=new Y,M=new Y,A=new Y,P=new Y;function C(L){A.fromArray(s,L*3),P.copy(A);const F=c[L];b.copy(F),b.sub(A.multiplyScalar(A.dot(F))).normalize(),M.crossVectors(P,F);const I=M.dot(u[L])<0?-1:1;l[L*4]=b.x,l[L*4+1]=b.y,l[L*4+2]=b.z,l[L*4+3]=I}for(let L=0,F=E.length;L<F;++L){const N=E[L],I=N.start,X=N.count;for(let q=I,W=I+X;q<W;q+=3)C(n[q+0]),C(n[q+1]),C(n[q+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new $t(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let p=0,m=n.count;p<m;p++)n.setXYZ(p,0,0,0);const i=new Y,s=new Y,o=new Y,a=new Y,l=new Y,c=new Y,u=new Y,h=new Y;if(e)for(let p=0,m=e.count;p<m;p+=3){const v=e.getX(p+0),_=e.getX(p+1),y=e.getX(p+2);i.fromBufferAttribute(t,v),s.fromBufferAttribute(t,_),o.fromBufferAttribute(t,y),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),a.fromBufferAttribute(n,v),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,y),a.add(u),l.add(u),c.add(u),n.setXYZ(v,a.x,a.y,a.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(y,c.x,c.y,c.z)}else for(let p=0,m=t.count;p<m;p+=3)i.fromBufferAttribute(t,p+0),s.fromBufferAttribute(t,p+1),o.fromBufferAttribute(t,p+2),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),n.setXYZ(p+0,u.x,u.y,u.z),n.setXYZ(p+1,u.x,u.y,u.z),n.setXYZ(p+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Jn.fromBufferAttribute(e,t),Jn.normalize(),e.setXYZ(t,Jn.x,Jn.y,Jn.z)}toNonIndexed(){function e(a,l){const c=a.array,u=a.itemSize,h=a.normalized,p=new c.constructor(l.length*u);let m=0,v=0;for(let _=0,y=l.length;_<y;_++){a.isInterleavedBufferAttribute?m=l[_]*a.data.stride+a.offset:m=l[_]*u;for(let g=0;g<u;g++)p[v++]=c[m++]}return new $t(p,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Tt,n=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=e(l,n);t.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let u=0,h=c.length;u<h;u++){const p=c[u],m=e(p,n);l.push(m)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);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 l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,p=c.length;h<p;h++){const m=c[h];u.push(m.toJSON(e.data))}u.length>0&&(i[l]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),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(t));const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],h=s[c];for(let p=0,m=h.length;p<m;p++)u.push(h[p].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,u=o.length;c<u;c++){const h=o[c];this.addGroup(h.start,h.count,h.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const t1=new yt,Yo=new Ql,xf=new rr,n1=new Y,ol=new Y,al=new Y,ll=new Y,Km=new Y,wf=new Y,Sf=new De,Ef=new De,bf=new De,i1=new Y,r1=new Y,s1=new Y,Mf=new Y,Tf=new Y;class _n extends jt{constructor(e=new Tt,t=new Vs){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,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=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(s&&a){wf.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=a[l],h=s[l];u!==0&&(Km.fromBufferAttribute(h,e),o?wf.addScaledVector(Km,u):wf.addScaledVector(Km.sub(t),u))}t.add(wf)}return t}raycast(e,t){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),xf.copy(n.boundingSphere),xf.applyMatrix4(s),Yo.copy(e.ray).recast(e.near),!(xf.containsPoint(Yo.origin)===!1&&(Yo.intersectSphere(xf,n1)===null||Yo.origin.distanceToSquared(n1)>(e.far-e.near)**2))&&(t1.copy(s).invert(),Yo.copy(e.ray).applyMatrix4(t1),!(n.boundingBox!==null&&Yo.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Yo)))}_computeIntersections(e,t,n){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,p=s.groups,m=s.drawRange;if(a!==null)if(Array.isArray(o))for(let v=0,_=p.length;v<_;v++){const y=p[v],g=o[y.materialIndex],x=Math.max(y.start,m.start),w=Math.min(a.count,Math.min(y.start+y.count,m.start+m.count));for(let E=x,b=w;E<b;E+=3){const M=a.getX(E),A=a.getX(E+1),P=a.getX(E+2);i=Af(this,g,e,n,c,u,h,M,A,P),i&&(i.faceIndex=Math.floor(E/3),i.face.materialIndex=y.materialIndex,t.push(i))}}else{const v=Math.max(0,m.start),_=Math.min(a.count,m.start+m.count);for(let y=v,g=_;y<g;y+=3){const x=a.getX(y),w=a.getX(y+1),E=a.getX(y+2);i=Af(this,o,e,n,c,u,h,x,w,E),i&&(i.faceIndex=Math.floor(y/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let v=0,_=p.length;v<_;v++){const y=p[v],g=o[y.materialIndex],x=Math.max(y.start,m.start),w=Math.min(l.count,Math.min(y.start+y.count,m.start+m.count));for(let E=x,b=w;E<b;E+=3){const M=E,A=E+1,P=E+2;i=Af(this,g,e,n,c,u,h,M,A,P),i&&(i.faceIndex=Math.floor(E/3),i.face.materialIndex=y.materialIndex,t.push(i))}}else{const v=Math.max(0,m.start),_=Math.min(l.count,m.start+m.count);for(let y=v,g=_;y<g;y+=3){const x=y,w=y+1,E=y+2;i=Af(this,o,e,n,c,u,h,x,w,E),i&&(i.faceIndex=Math.floor(y/3),t.push(i))}}}}function xR(r,e,t,n,i,s,o,a){let l;if(e.side===yi?l=n.intersectTriangle(o,s,i,!0,a):l=n.intersectTriangle(i,s,o,e.side===ls,a),l===null)return null;Tf.copy(a),Tf.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(Tf);return c<t.near||c>t.far?null:{distance:c,point:Tf.clone(),object:r}}function Af(r,e,t,n,i,s,o,a,l,c){r.getVertexPosition(a,ol),r.getVertexPosition(l,al),r.getVertexPosition(c,ll);const u=xR(r,e,t,n,ol,al,ll,Mf);if(u){i&&(Sf.fromBufferAttribute(i,a),Ef.fromBufferAttribute(i,l),bf.fromBufferAttribute(i,c),u.uv=zi.getInterpolation(Mf,ol,al,ll,Sf,Ef,bf,new De)),s&&(Sf.fromBufferAttribute(s,a),Ef.fromBufferAttribute(s,l),bf.fromBufferAttribute(s,c),u.uv1=zi.getInterpolation(Mf,ol,al,ll,Sf,Ef,bf,new De),u.uv2=u.uv1),o&&(i1.fromBufferAttribute(o,a),r1.fromBufferAttribute(o,l),s1.fromBufferAttribute(o,c),u.normal=zi.getInterpolation(Mf,ol,al,ll,i1,r1,s1,new Y),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const h={a,b:l,c,normal:new Y,materialIndex:0};zi.getNormal(ol,al,ll,h.normal),u.face=h}return u}class Ws extends Tt{constructor(e=1,t=1,n=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],u=[],h=[];let p=0,m=0;v("z","y","x",-1,-1,n,t,e,o,s,0),v("z","y","x",1,-1,n,t,-e,o,s,1),v("x","z","y",1,1,e,n,t,i,o,2),v("x","z","y",1,-1,e,n,-t,i,o,3),v("x","y","z",1,-1,e,t,n,i,s,4),v("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new st(c,3)),this.setAttribute("normal",new st(u,3)),this.setAttribute("uv",new st(h,2));function v(_,y,g,x,w,E,b,M,A,P,C){const L=E/A,F=b/P,N=E/2,I=b/2,X=M/2,q=A+1,W=P+1;let O=0,k=0;const G=new Y;for(let B=0;B<W;B++){const D=B*F-I;for(let V=0;V<q;V++){const Z=V*L-N;G[_]=Z*x,G[y]=D*w,G[g]=X,c.push(G.x,G.y,G.z),G[_]=0,G[y]=0,G[g]=M>0?1:-1,u.push(G.x,G.y,G.z),h.push(V/A),h.push(1-B/P),O+=1}}for(let B=0;B<P;B++)for(let D=0;D<A;D++){const V=p+D+q*B,Z=p+D+q*(B+1),ee=p+(D+1)+q*(B+1),ie=p+(D+1)+q*B;l.push(V,Z,ie),l.push(Z,ee,ie),k+=6}a.addGroup(m,k,C),m+=k,p+=O}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ws(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Xl(r){const e={};for(const t in r){e[t]={};for(const n in r[t]){const i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function Ci(r){const e={};for(let t=0;t<r.length;t++){const n=Xl(r[t]);for(const i in n)e[i]=n[i]}return e}function wR(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function lM(r){return r.getRenderTarget()===null?r.outputColorSpace:Br}const ly={clone:Xl,merge:Ci};var SR=`void main() {
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
}`,ER=`void main() {
|
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
}`;class cs extends oi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=SR,this.fragmentShader=ER,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Xl(e.uniforms),this.uniformsGroups=wR(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?t.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[i]={type:"m4",value:o.toArray()}:t.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class rh extends jt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new yt,this.projectionMatrix=new yt,this.projectionMatrixInverse=new yt,this.coordinateSystem=ss}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){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class zn extends rh{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=Wl*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ma*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Wl*2*Math.atan(Math.tan(ma*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,o){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=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(ma*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,t-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far,this.coordinateSystem),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}}const cl=-90,ul=1;class cM extends jt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;const i=new zn(cl,ul,e,t);i.layers=this.layers,this.add(i);const s=new zn(cl,ul,e,t);s.layers=this.layers,this.add(s);const o=new zn(cl,ul,e,t);o.layers=this.layers,this.add(o);const a=new zn(cl,ul,e,t);a.layers=this.layers,this.add(a);const l=new zn(cl,ul,e,t);l.layers=this.layers,this.add(l);const c=new zn(cl,ul,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,s,o,a,l]=t;for(const c of t)this.remove(c);if(e===ss)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Nu)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[i,s,o,a,l,c]=this.children,u=e.getRenderTarget(),h=e.toneMapping,p=e.xr.enabled;e.toneMapping=zr,e.xr.enabled=!1;const m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,s),e.setRenderTarget(n,2),e.render(t,o),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,l),n.texture.generateMipmaps=m,e.setRenderTarget(n,5),e.render(t,c),e.setRenderTarget(u),e.toneMapping=h,e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class sh extends Sn{constructor(e,t,n,i,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:xo,super(e,t,n,i,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class uM extends Gr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];t.encoding!==void 0&&(_u("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===vo?Mt:yo),this.texture=new sh(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:fn}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 <begin_vertex>
|
|
#include <project_vertex>
|
|
|
|
}
|
|
`,fragmentShader:`
|
|
|
|
uniform sampler2D tEquirect;
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 direction = normalize( vWorldDirection );
|
|
|
|
vec2 sampleUV = equirectUv( direction );
|
|
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
|
|
}
|
|
`},i=new Ws(5,5,5),s=new cs({name:"CubemapFromEquirect",uniforms:Xl(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:yi,blending:Fs});s.uniforms.tEquirect.value=t;const o=new _n(i,s),a=t.minFilter;return t.minFilter===So&&(t.minFilter=fn),new cM(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(s)}}const $m=new Y,bR=new Y,MR=new Ct;class Us{constructor(e=new Y(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,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=$m.subVectors(n,t).cross(bR.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta($m),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||MR.getNormalMatrix(e),i=this.coplanarPoint($m).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const qo=new rr,Cf=new Y;class oh{constructor(e=new Us,t=new Us,n=new Us,i=new Us,s=new Us,o=new Us){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),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=ss){const n=this.planes,i=e.elements,s=i[0],o=i[1],a=i[2],l=i[3],c=i[4],u=i[5],h=i[6],p=i[7],m=i[8],v=i[9],_=i[10],y=i[11],g=i[12],x=i[13],w=i[14],E=i[15];if(n[0].setComponents(l-s,p-c,y-m,E-g).normalize(),n[1].setComponents(l+s,p+c,y+m,E+g).normalize(),n[2].setComponents(l+o,p+u,y+v,E+x).normalize(),n[3].setComponents(l-o,p-u,y-v,E-x).normalize(),n[4].setComponents(l-a,p-h,y-_,E-w).normalize(),t===ss)n[5].setComponents(l+a,p+h,y+_,E+w).normalize();else if(t===Nu)n[5].setComponents(a,h,_,w).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(),qo.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),qo.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(qo)}intersectsSprite(e){return qo.center.set(0,0,0),qo.radius=.7071067811865476,qo.applyMatrix4(e.matrixWorld),this.intersectsSphere(qo)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(Cf.x=i.normal.x>0?e.max.x:e.min.x,Cf.y=i.normal.y>0?e.max.y:e.min.y,Cf.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Cf)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function hM(){let r=null,e=!1,t=null,n=null;function i(s,o){t(s,o),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function TR(r,e){const t=e.isWebGL2,n=new WeakMap;function i(c,u){const h=c.array,p=c.usage,m=r.createBuffer();r.bindBuffer(u,m),r.bufferData(u,h,p),c.onUploadCallback();let v;if(h instanceof Float32Array)v=r.FLOAT;else if(h instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(t)v=r.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else v=r.UNSIGNED_SHORT;else if(h instanceof Int16Array)v=r.SHORT;else if(h instanceof Uint32Array)v=r.UNSIGNED_INT;else if(h instanceof Int32Array)v=r.INT;else if(h instanceof Int8Array)v=r.BYTE;else if(h instanceof Uint8Array)v=r.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)v=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:m,type:v,bytesPerElement:h.BYTES_PER_ELEMENT,version:c.version}}function s(c,u,h){const p=u.array,m=u.updateRange;r.bindBuffer(h,c),m.count===-1?r.bufferSubData(h,0,p):(t?r.bufferSubData(h,m.offset*p.BYTES_PER_ELEMENT,p,m.offset,m.count):r.bufferSubData(h,m.offset*p.BYTES_PER_ELEMENT,p.subarray(m.offset,m.offset+m.count)),m.count=-1),u.onUploadCallback()}function o(c){return c.isInterleavedBufferAttribute&&(c=c.data),n.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);const u=n.get(c);u&&(r.deleteBuffer(u.buffer),n.delete(c))}function l(c,u){if(c.isGLBufferAttribute){const p=n.get(c);(!p||p.version<c.version)&&n.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);const h=n.get(c);h===void 0?n.set(c,i(c,u)):h.version<c.version&&(s(h.buffer,c,u),h.version=c.version)}return{get:o,remove:a,update:l}}class To extends Tt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const s=e/2,o=t/2,a=Math.floor(n),l=Math.floor(i),c=a+1,u=l+1,h=e/a,p=t/l,m=[],v=[],_=[],y=[];for(let g=0;g<u;g++){const x=g*p-o;for(let w=0;w<c;w++){const E=w*h-s;v.push(E,-x,0),_.push(0,0,1),y.push(w/a),y.push(1-g/l)}}for(let g=0;g<l;g++)for(let x=0;x<a;x++){const w=x+c*g,E=x+c*(g+1),b=x+1+c*(g+1),M=x+1+c*g;m.push(w,E,M),m.push(E,b,M)}this.setIndex(m),this.setAttribute("position",new st(v,3)),this.setAttribute("normal",new st(_,3)),this.setAttribute("uv",new st(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new To(e.width,e.height,e.widthSegments,e.heightSegments)}}var AR=`#ifdef USE_ALPHAHASH
|
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
#endif`,CR=`#ifdef USE_ALPHAHASH
|
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
float hash2D( vec2 value ) {
|
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
}
|
|
float hash3D( vec3 value ) {
|
|
return hash2D( vec2( hash2D( value.xy ), value.z ) );
|
|
}
|
|
float getAlphaHashThreshold( vec3 position ) {
|
|
float maxDeriv = max(
|
|
length( dFdx( position.xyz ) ),
|
|
length( dFdy( position.xyz ) )
|
|
);
|
|
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
|
|
vec2 pixScales = vec2(
|
|
exp2( floor( log2( pixScale ) ) ),
|
|
exp2( ceil( log2( pixScale ) ) )
|
|
);
|
|
vec2 alpha = vec2(
|
|
hash3D( floor( pixScales.x * position.xyz ) ),
|
|
hash3D( floor( pixScales.y * position.xyz ) )
|
|
);
|
|
float lerpFactor = fract( log2( pixScale ) );
|
|
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
|
|
float a = min( lerpFactor, 1.0 - lerpFactor );
|
|
vec3 cases = vec3(
|
|
x * x / ( 2.0 * a * ( 1.0 - a ) ),
|
|
( x - 0.5 * a ) / ( 1.0 - a ),
|
|
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
|
|
);
|
|
float threshold = ( x < ( 1.0 - a ) )
|
|
? ( ( x < a ) ? cases.x : cases.y )
|
|
: cases.z;
|
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
}
|
|
#endif`,RR=`#ifdef USE_ALPHAMAP
|
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
#endif`,PR=`#ifdef USE_ALPHAMAP
|
|
uniform sampler2D alphaMap;
|
|
#endif`,LR=`#ifdef USE_ALPHATEST
|
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
#endif`,IR=`#ifdef USE_ALPHATEST
|
|
uniform float alphaTest;
|
|
#endif`,DR=`#ifdef USE_AOMAP
|
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
|
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
#endif
|
|
#endif`,UR=`#ifdef USE_AOMAP
|
|
uniform sampler2D aoMap;
|
|
uniform float aoMapIntensity;
|
|
#endif`,OR=`vec3 transformed = vec3( position );
|
|
#ifdef USE_ALPHAHASH
|
|
vPosition = vec3( position );
|
|
#endif`,NR=`vec3 objectNormal = vec3( normal );
|
|
#ifdef USE_TANGENT
|
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
#endif`,FR=`float G_BlinnPhong_Implicit( ) {
|
|
return 0.25;
|
|
}
|
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
|
}
|
|
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
|
|
float G = G_BlinnPhong_Implicit( );
|
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
return F * ( G * D );
|
|
} // validated`,kR=`#ifdef USE_IRIDESCENCE
|
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
3.2404542, -0.9692660, 0.0556434,
|
|
-1.5371385, 1.8760108, -0.2040259,
|
|
-0.4985314, 0.0415560, 1.0572252
|
|
);
|
|
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
|
|
vec3 sqrtF0 = sqrt( fresnel0 );
|
|
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
|
|
}
|
|
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
|
|
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
|
|
}
|
|
float IorToFresnel0( float transmittedIor, float incidentIor ) {
|
|
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
|
|
}
|
|
vec3 evalSensitivity( float OPD, vec3 shift ) {
|
|
float phase = 2.0 * PI * OPD * 1.0e-9;
|
|
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
|
|
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
|
|
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
|
|
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
|
|
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
|
|
xyz /= 1.0685e-7;
|
|
vec3 rgb = XYZ_TO_REC709 * xyz;
|
|
return rgb;
|
|
}
|
|
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
|
|
vec3 I;
|
|
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
|
|
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
|
|
float cosTheta2Sq = 1.0 - sinTheta2Sq;
|
|
if ( cosTheta2Sq < 0.0 ) {
|
|
return vec3( 1.0 );
|
|
}
|
|
float cosTheta2 = sqrt( cosTheta2Sq );
|
|
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
|
|
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
|
|
float R21 = R12;
|
|
float T121 = 1.0 - R12;
|
|
float phi12 = 0.0;
|
|
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
|
|
float phi21 = PI - phi12;
|
|
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
|
|
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
|
|
vec3 phi23 = vec3( 0.0 );
|
|
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
|
|
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
|
|
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
|
|
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
|
|
vec3 phi = vec3( phi21 ) + phi23;
|
|
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
|
|
vec3 r123 = sqrt( R123 );
|
|
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
|
|
vec3 C0 = R12 + Rs;
|
|
I = C0;
|
|
vec3 Cm = Rs - T121;
|
|
for ( int m = 1; m <= 2; ++ m ) {
|
|
Cm *= r123;
|
|
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
|
|
I += Cm * Sm;
|
|
}
|
|
return max( I, vec3( 0.0 ) );
|
|
}
|
|
#endif`,zR=`#ifdef USE_BUMPMAP
|
|
uniform sampler2D bumpMap;
|
|
uniform float bumpScale;
|
|
vec2 dHdxy_fwd() {
|
|
vec2 dSTdx = dFdx( vBumpMapUv );
|
|
vec2 dSTdy = dFdy( vBumpMapUv );
|
|
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
|
|
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
|
|
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
|
|
return vec2( dBx, dBy );
|
|
}
|
|
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|
vec3 vSigmaX = dFdx( surf_pos.xyz );
|
|
vec3 vSigmaY = dFdy( surf_pos.xyz );
|
|
vec3 vN = surf_norm;
|
|
vec3 R1 = cross( vSigmaY, vN );
|
|
vec3 R2 = cross( vN, vSigmaX );
|
|
float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
}
|
|
#endif`,BR=`#if NUM_CLIPPING_PLANES > 0
|
|
vec4 plane;
|
|
#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`,GR=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
#endif`,HR=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
#endif`,VR=`#if NUM_CLIPPING_PLANES > 0
|
|
vClipPosition = - mvPosition.xyz;
|
|
#endif`,WR=`#if defined( USE_COLOR_ALPHA )
|
|
diffuseColor *= vColor;
|
|
#elif defined( USE_COLOR )
|
|
diffuseColor.rgb *= vColor;
|
|
#endif`,XR=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,jR=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,YR=`#if defined( USE_COLOR_ALPHA )
|
|
vColor = vec4( 1.0 );
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
|
vColor = vec3( 1.0 );
|
|
#endif
|
|
#ifdef USE_COLOR
|
|
vColor *= color;
|
|
#endif
|
|
#ifdef USE_INSTANCING_COLOR
|
|
vColor.xyz *= instanceColor.xyz;
|
|
#endif`,qR=`#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;
|
|
};
|
|
struct GeometricContext {
|
|
vec3 position;
|
|
vec3 normal;
|
|
vec3 viewDir;
|
|
#ifdef USE_CLEARCOAT
|
|
vec3 clearcoatNormal;
|
|
#endif
|
|
};
|
|
#ifdef USE_ALPHAHASH
|
|
varying vec3 vPosition;
|
|
#endif
|
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
}
|
|
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
|
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
|
}
|
|
mat3 transposeMat3( const in mat3 m ) {
|
|
mat3 tmp;
|
|
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
|
|
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
|
|
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
|
|
return tmp;
|
|
}
|
|
float luminance( const in vec3 rgb ) {
|
|
const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
|
|
return dot( weights, rgb );
|
|
}
|
|
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`,ZR=`#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_v0 0.339
|
|
#define cubeUV_m0 - 2.0
|
|
#define cubeUV_r1 0.8
|
|
#define cubeUV_v1 0.276
|
|
#define cubeUV_m1 - 1.0
|
|
#define cubeUV_r4 0.4
|
|
#define cubeUV_v4 0.046
|
|
#define cubeUV_m4 2.0
|
|
#define cubeUV_r5 0.305
|
|
#define cubeUV_v5 0.016
|
|
#define cubeUV_m5 3.0
|
|
#define cubeUV_r6 0.21
|
|
#define cubeUV_v6 0.0038
|
|
#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`,KR=`vec3 transformedNormal = objectNormal;
|
|
#ifdef USE_INSTANCING
|
|
mat3 m = mat3( instanceMatrix );
|
|
transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
|
|
transformedNormal = m * transformedNormal;
|
|
#endif
|
|
transformedNormal = normalMatrix * transformedNormal;
|
|
#ifdef FLIP_SIDED
|
|
transformedNormal = - transformedNormal;
|
|
#endif
|
|
#ifdef USE_TANGENT
|
|
vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
#ifdef FLIP_SIDED
|
|
transformedTangent = - transformedTangent;
|
|
#endif
|
|
#endif`,$R=`#ifdef USE_DISPLACEMENTMAP
|
|
uniform sampler2D displacementMap;
|
|
uniform float displacementScale;
|
|
uniform float displacementBias;
|
|
#endif`,JR=`#ifdef USE_DISPLACEMENTMAP
|
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
#endif`,QR=`#ifdef USE_EMISSIVEMAP
|
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
#endif`,eP=`#ifdef USE_EMISSIVEMAP
|
|
uniform sampler2D emissiveMap;
|
|
#endif`,tP="gl_FragColor = linearToOutputTexel( gl_FragColor );",nP=`vec4 LinearToLinear( in vec4 value ) {
|
|
return value;
|
|
}
|
|
vec4 LinearTosRGB( 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 );
|
|
}`,iP=`#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 = inverseTransformDirection( 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, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
|
#else
|
|
vec4 envColor = vec4( 0.0 );
|
|
#endif
|
|
#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`,rP=`#ifdef USE_ENVMAP
|
|
uniform float envMapIntensity;
|
|
uniform float flipEnvMap;
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
uniform samplerCube envMap;
|
|
#else
|
|
uniform sampler2D envMap;
|
|
#endif
|
|
|
|
#endif`,sP=`#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`,oP=`#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`,aP=`#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 = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
#ifdef ENVMAP_MODE_REFLECTION
|
|
vReflect = reflect( cameraToVertex, worldNormal );
|
|
#else
|
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
#endif
|
|
#endif
|
|
#endif`,lP=`#ifdef USE_FOG
|
|
vFogDepth = - mvPosition.z;
|
|
#endif`,cP=`#ifdef USE_FOG
|
|
varying float vFogDepth;
|
|
#endif`,uP=`#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`,hP=`#ifdef USE_FOG
|
|
uniform vec3 fogColor;
|
|
varying float vFogDepth;
|
|
#ifdef FOG_EXP2
|
|
uniform float fogDensity;
|
|
#else
|
|
uniform float fogNear;
|
|
uniform float fogFar;
|
|
#endif
|
|
#endif`,fP=`#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
|
|
}`,dP=`#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
reflectedLight.indirectDiffuse += lightMapIrradiance;
|
|
#endif`,pP=`#ifdef USE_LIGHTMAP
|
|
uniform sampler2D lightMap;
|
|
uniform float lightMapIntensity;
|
|
#endif`,mP=`LambertMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.specularStrength = specularStrength;`,gP=`varying vec3 vViewPosition;
|
|
struct LambertMaterial {
|
|
vec3 diffuseColor;
|
|
float specularStrength;
|
|
};
|
|
void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, 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`,vP=`uniform bool receiveShadow;
|
|
uniform vec3 ambientLightColor;
|
|
uniform vec3 lightProbe[ 9 ];
|
|
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 = inverseTransformDirection( 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 ) {
|
|
#if defined ( LEGACY_LIGHTS )
|
|
if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
|
|
return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
|
|
}
|
|
return 1.0;
|
|
#else
|
|
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
|
if ( cutoffDistance > 0.0 ) {
|
|
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
|
}
|
|
return distanceFalloff;
|
|
#endif
|
|
}
|
|
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, const in GeometricContext geometry, 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 GeometricContext geometry, out IncidentLight light ) {
|
|
vec3 lVector = pointLight.position - geometry.position;
|
|
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 GeometricContext geometry, out IncidentLight light ) {
|
|
vec3 lVector = spotLight.position - geometry.position;
|
|
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`,yP=`#ifdef USE_ENVMAP
|
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
vec4 envMapColor = textureCubeUV( envMap, 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, roughness * roughness) );
|
|
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
|
vec4 envMapColor = textureCubeUV( envMap, 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`,_P=`ToonMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;`,xP=`varying vec3 vViewPosition;
|
|
struct ToonMaterial {
|
|
vec3 diffuseColor;
|
|
};
|
|
void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, 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`,wP=`BlinnPhongMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.specularColor = specular;
|
|
material.specularShininess = shininess;
|
|
material.specularStrength = specularStrength;`,SP=`varying vec3 vViewPosition;
|
|
struct BlinnPhongMaterial {
|
|
vec3 diffuseColor;
|
|
vec3 specularColor;
|
|
float specularShininess;
|
|
float specularStrength;
|
|
};
|
|
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
|
}
|
|
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, 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`,EP=`PhysicalMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
|
|
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 = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
|
#else
|
|
material.specularColor = mix( vec3( 0.04 ), 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_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.07, 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 );
|
|
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`,bP=`struct PhysicalMaterial {
|
|
vec3 diffuseColor;
|
|
float roughness;
|
|
vec3 specularColor;
|
|
float specularF90;
|
|
#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;
|
|
#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 clearcoatSpecular = vec3( 0.0 );
|
|
vec3 sheenSpecular = 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 ) );
|
|
float v = 0.5 / ( gv + gl );
|
|
return saturate(v);
|
|
}
|
|
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.specularColor;
|
|
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 * transposeMat3( 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 a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
|
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
|
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
|
return saturate( DG * RECIPROCAL_PI );
|
|
}
|
|
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
|
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
|
vec4 r = roughness * c0 + c1;
|
|
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
|
|
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
|
|
return fab;
|
|
}
|
|
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
|
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
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
|
|
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
#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;
|
|
}
|
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 normal = geometry.normal;
|
|
vec3 viewDir = geometry.viewDir;
|
|
vec3 position = geometry.position;
|
|
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.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
|
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
|
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
|
}
|
|
#endif
|
|
void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
|
|
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
clearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
|
|
#endif
|
|
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
|
#ifdef USE_CLEARCOAT
|
|
clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
|
|
#endif
|
|
vec3 singleScattering = vec3( 0.0 );
|
|
vec3 multiScattering = vec3( 0.0 );
|
|
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
|
#ifdef USE_IRIDESCENCE
|
|
computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
|
#else
|
|
computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
|
#endif
|
|
vec3 totalScattering = singleScattering + multiScattering;
|
|
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
|
|
reflectedLight.indirectSpecular += radiance * singleScattering;
|
|
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
|
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
|
}
|
|
#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 );
|
|
}`,MP=`
|
|
GeometricContext geometry;
|
|
geometry.position = - vViewPosition;
|
|
geometry.normal = normal;
|
|
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
#ifdef USE_CLEARCOAT
|
|
geometry.clearcoatNormal = clearcoatNormal;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
float dotNVi = saturate( dot( normal, geometry.viewDir ) );
|
|
if ( material.iridescenceThickness == 0.0 ) {
|
|
material.iridescence = 0.0;
|
|
} else {
|
|
material.iridescence = saturate( material.iridescence );
|
|
}
|
|
if ( material.iridescence > 0.0 ) {
|
|
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
|
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, geometry, directLight );
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
|
pointLightShadow = pointLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometry, 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, geometry, 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.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometry, 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, geometry, 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.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometry, 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, geometry, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if defined( RE_IndirectDiffuse )
|
|
vec3 iblIrradiance = vec3( 0.0 );
|
|
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
|
irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
#if ( NUM_HEMI_LIGHTS > 0 )
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
#if defined( RE_IndirectSpecular )
|
|
vec3 radiance = vec3( 0.0 );
|
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
#endif`,TP=`#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( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
|
iblIrradiance += getIBLIrradiance( geometry.normal );
|
|
#endif
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
|
#ifdef USE_ANISOTROPY
|
|
radiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );
|
|
#else
|
|
radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
|
|
#endif
|
|
#endif`,AP=`#if defined( RE_IndirectDiffuse )
|
|
RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
|
|
#endif
|
|
#if defined( RE_IndirectSpecular )
|
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
|
|
#endif`,CP=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
|
gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
#endif`,RP=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
|
uniform float logDepthBufFC;
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#endif`,PP=`#ifdef USE_LOGDEPTHBUF
|
|
#ifdef USE_LOGDEPTHBUF_EXT
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#else
|
|
uniform float logDepthBufFC;
|
|
#endif
|
|
#endif`,LP=`#ifdef USE_LOGDEPTHBUF
|
|
#ifdef USE_LOGDEPTHBUF_EXT
|
|
vFragDepth = 1.0 + gl_Position.w;
|
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
#else
|
|
if ( isPerspectiveMatrix( projectionMatrix ) ) {
|
|
gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
|
|
gl_Position.z *= gl_Position.w;
|
|
}
|
|
#endif
|
|
#endif`,IP=`#ifdef USE_MAP
|
|
diffuseColor *= texture2D( map, vMapUv );
|
|
#endif`,DP=`#ifdef USE_MAP
|
|
uniform sampler2D map;
|
|
#endif`,UP=`#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`,OP=`#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`,NP=`float metalnessFactor = metalness;
|
|
#ifdef USE_METALNESSMAP
|
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
metalnessFactor *= texelMetalness.b;
|
|
#endif`,FP=`#ifdef USE_METALNESSMAP
|
|
uniform sampler2D metalnessMap;
|
|
#endif`,kP=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
|
|
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`,zP=`#ifdef USE_MORPHNORMALS
|
|
objectNormal *= morphTargetBaseInfluence;
|
|
#ifdef MORPHTARGETS_TEXTURE
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
}
|
|
#else
|
|
objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
|
|
objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
|
|
objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
|
|
objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
|
|
#endif
|
|
#endif`,BP=`#ifdef USE_MORPHTARGETS
|
|
uniform float morphTargetBaseInfluence;
|
|
#ifdef MORPHTARGETS_TEXTURE
|
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
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 );
|
|
}
|
|
#else
|
|
#ifndef USE_MORPHNORMALS
|
|
uniform float morphTargetInfluences[ 8 ];
|
|
#else
|
|
uniform float morphTargetInfluences[ 4 ];
|
|
#endif
|
|
#endif
|
|
#endif`,GP=`#ifdef USE_MORPHTARGETS
|
|
transformed *= morphTargetBaseInfluence;
|
|
#ifdef MORPHTARGETS_TEXTURE
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
}
|
|
#else
|
|
transformed += morphTarget0 * morphTargetInfluences[ 0 ];
|
|
transformed += morphTarget1 * morphTargetInfluences[ 1 ];
|
|
transformed += morphTarget2 * morphTargetInfluences[ 2 ];
|
|
transformed += morphTarget3 * morphTargetInfluences[ 3 ];
|
|
#ifndef USE_MORPHNORMALS
|
|
transformed += morphTarget4 * morphTargetInfluences[ 4 ];
|
|
transformed += morphTarget5 * morphTargetInfluences[ 5 ];
|
|
transformed += morphTarget6 * morphTargetInfluences[ 6 ];
|
|
transformed += morphTarget7 * morphTargetInfluences[ 7 ];
|
|
#endif
|
|
#endif
|
|
#endif`,HP=`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
|
|
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
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
|
|
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
tbn2[0] *= faceDirection;
|
|
tbn2[1] *= faceDirection;
|
|
#endif
|
|
#endif
|
|
vec3 geometryNormal = normal;`,VP=`#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;
|
|
mapN.xy *= normalScale;
|
|
normal = normalize( tbn * mapN );
|
|
#elif defined( USE_BUMPMAP )
|
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
#endif`,WP=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,XP=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,jP=`#ifndef FLAT_SHADED
|
|
vNormal = normalize( transformedNormal );
|
|
#ifdef USE_TANGENT
|
|
vTangent = normalize( transformedTangent );
|
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|
#endif
|
|
#endif`,YP=`#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`,qP=`#ifdef USE_CLEARCOAT
|
|
vec3 clearcoatNormal = geometryNormal;
|
|
#endif`,ZP=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
#endif`,KP=`#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`,$P=`#ifdef USE_IRIDESCENCEMAP
|
|
uniform sampler2D iridescenceMap;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
uniform sampler2D iridescenceThicknessMap;
|
|
#endif`,JP=`#ifdef OPAQUE
|
|
diffuseColor.a = 1.0;
|
|
#endif
|
|
#ifdef USE_TRANSMISSION
|
|
diffuseColor.a *= material.transmissionAlpha;
|
|
#endif
|
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,QP=`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 vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
|
|
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
|
|
const float ShiftRight8 = 1. / 256.;
|
|
vec4 packDepthToRGBA( const in float v ) {
|
|
vec4 r = vec4( fract( v * PackFactors ), v );
|
|
r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
|
|
}
|
|
float unpackRGBAToDepth( const in vec4 v ) {
|
|
return dot( v, UnpackFactors );
|
|
}
|
|
vec2 packDepthToRG( in highp float v ) {
|
|
return packDepthToRGBA( v ).yx;
|
|
}
|
|
float unpackRGToDepth( const in highp vec2 v ) {
|
|
return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
|
|
}
|
|
vec4 pack2HalfToRGBA( 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( 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 ) {
|
|
return depth * ( near - far ) - near;
|
|
}
|
|
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 ) {
|
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
}`,eL=`#ifdef PREMULTIPLIED_ALPHA
|
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
#endif`,tL=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
#ifdef USE_INSTANCING
|
|
mvPosition = instanceMatrix * mvPosition;
|
|
#endif
|
|
mvPosition = modelViewMatrix * mvPosition;
|
|
gl_Position = projectionMatrix * mvPosition;`,nL=`#ifdef DITHERING
|
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
#endif`,iL=`#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`,rL=`float roughnessFactor = roughness;
|
|
#ifdef USE_ROUGHNESSMAP
|
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
roughnessFactor *= texelRoughness.g;
|
|
#endif`,sL=`#ifdef USE_ROUGHNESSMAP
|
|
uniform sampler2D roughnessMap;
|
|
#endif`,oL=`#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
|
|
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
struct DirectionalLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
struct SpotLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
struct PointLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
float shadowCameraNear;
|
|
float shadowCameraFar;
|
|
};
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
#endif
|
|
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
|
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
|
|
}
|
|
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
|
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
|
}
|
|
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
|
|
float occlusion = 1.0;
|
|
vec2 distribution = texture2DDistribution( shadow, uv );
|
|
float hard_shadow = step( compare , distribution.x );
|
|
if (hard_shadow != 1.0 ) {
|
|
float distance = compare - distribution.x ;
|
|
float variance = max( 0.00000, distribution.y * distribution.y );
|
|
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
|
}
|
|
return occlusion;
|
|
}
|
|
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, 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 ) {
|
|
#if defined( SHADOWMAP_TYPE_PCF )
|
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
float dx0 = - texelSize.x * shadowRadius;
|
|
float dy0 = - texelSize.y * shadowRadius;
|
|
float dx1 = + texelSize.x * shadowRadius;
|
|
float dy1 = + texelSize.y * shadowRadius;
|
|
float dx2 = dx0 / 2.0;
|
|
float dy2 = dy0 / 2.0;
|
|
float dx3 = dx1 / 2.0;
|
|
float dy3 = dy1 / 2.0;
|
|
shadow = (
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
|
) * ( 1.0 / 17.0 );
|
|
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
float dx = texelSize.x;
|
|
float dy = texelSize.y;
|
|
vec2 uv = shadowCoord.xy;
|
|
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
|
uv -= f * texelSize;
|
|
shadow = (
|
|
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
|
f.x ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
|
f.x ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
|
f.y ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
|
f.y ) +
|
|
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
|
f.x ),
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
|
f.x ),
|
|
f.y )
|
|
) * ( 1.0 / 9.0 );
|
|
#elif defined( SHADOWMAP_TYPE_VSM )
|
|
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
#else
|
|
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
#endif
|
|
}
|
|
return shadow;
|
|
}
|
|
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
|
vec3 absV = abs( v );
|
|
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
|
absV *= scaleToCube;
|
|
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
|
vec2 planar = v.xy;
|
|
float almostATexel = 1.5 * texelSizeY;
|
|
float almostOne = 1.0 - almostATexel;
|
|
if ( absV.z >= almostOne ) {
|
|
if ( v.z > 0.0 )
|
|
planar.x = 4.0 - v.x;
|
|
} else if ( absV.x >= almostOne ) {
|
|
float signX = sign( v.x );
|
|
planar.x = v.z * signX + 2.0 * signX;
|
|
} else if ( absV.y >= almostOne ) {
|
|
float signY = sign( v.y );
|
|
planar.x = v.x + 2.0 * signY + 2.0;
|
|
planar.y = v.z * signY - 2.0;
|
|
}
|
|
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
|
}
|
|
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|
vec3 lightToPosition = shadowCoord.xyz;
|
|
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
|
vec3 bd3D = normalize( lightToPosition );
|
|
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
|
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
|
return (
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|
) * ( 1.0 / 9.0 );
|
|
#else
|
|
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
|
#endif
|
|
}
|
|
#endif`,aL=`#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 shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
struct SpotLightShadow {
|
|
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 shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
float shadowCameraNear;
|
|
float shadowCameraFar;
|
|
};
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#endif`,lL=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
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`,cL=`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.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.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
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.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
return shadow;
|
|
}`,uL=`#ifdef USE_SKINNING
|
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
#endif`,hL=`#ifdef USE_SKINNING
|
|
uniform mat4 bindMatrix;
|
|
uniform mat4 bindMatrixInverse;
|
|
uniform highp sampler2D boneTexture;
|
|
uniform int boneTextureSize;
|
|
mat4 getBoneMatrix( const in float i ) {
|
|
float j = i * 4.0;
|
|
float x = mod( j, float( boneTextureSize ) );
|
|
float y = floor( j / float( boneTextureSize ) );
|
|
float dx = 1.0 / float( boneTextureSize );
|
|
float dy = 1.0 / float( boneTextureSize );
|
|
y = dy * ( y + 0.5 );
|
|
vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
|
|
vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
|
|
vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
|
|
vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
|
|
mat4 bone = mat4( v1, v2, v3, v4 );
|
|
return bone;
|
|
}
|
|
#endif`,fL=`#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`,dL=`#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`,pL=`float specularStrength;
|
|
#ifdef USE_SPECULARMAP
|
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
specularStrength = texelSpecular.r;
|
|
#else
|
|
specularStrength = 1.0;
|
|
#endif`,mL=`#ifdef USE_SPECULARMAP
|
|
uniform sampler2D specularMap;
|
|
#endif`,gL=`#if defined( TONE_MAPPING )
|
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
#endif`,vL=`#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 OptimizedCineonToneMapping( 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 );
|
|
}
|
|
vec3 CustomToneMapping( vec3 color ) { return color; }`,yL=`#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 = inverseTransformDirection( normal, viewMatrix );
|
|
vec4 transmitted = getIBLVolumeRefraction(
|
|
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
|
pos, modelMatrix, viewMatrix, projectionMatrix, 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`,_L=`#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 ior, const in float thickness,
|
|
const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
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;
|
|
vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
|
vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
|
|
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`,xL=`#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`,wL=`#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`,SL=`#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`,EL=`#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_INSTANCING
|
|
worldPosition = instanceMatrix * worldPosition;
|
|
#endif
|
|
worldPosition = modelMatrix * worldPosition;
|
|
#endif`;const bL=`varying vec2 vUv;
|
|
uniform mat3 uvTransform;
|
|
void main() {
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
}`,ML=`uniform sampler2D t2D;
|
|
uniform float backgroundIntensity;
|
|
varying vec2 vUv;
|
|
void main() {
|
|
vec4 texColor = texture2D( t2D, vUv );
|
|
texColor.rgb *= backgroundIntensity;
|
|
gl_FragColor = texColor;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,TL=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
gl_Position.z = gl_Position.w;
|
|
}`,AL=`#ifdef ENVMAP_TYPE_CUBE
|
|
uniform samplerCube envMap;
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
uniform sampler2D envMap;
|
|
#endif
|
|
uniform float flipEnvMap;
|
|
uniform float backgroundBlurriness;
|
|
uniform float backgroundIntensity;
|
|
varying vec3 vWorldDirection;
|
|
#include <cube_uv_reflection_fragment>
|
|
void main() {
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
|
|
#else
|
|
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
#endif
|
|
texColor.rgb *= backgroundIntensity;
|
|
gl_FragColor = texColor;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,CL=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
gl_Position.z = gl_Position.w;
|
|
}`,RL=`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 <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,PL=`#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <skinbase_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vHighPrecisionZW = gl_Position.zw;
|
|
}`,LL=`#if DEPTH_PACKING == 3200
|
|
uniform float opacity;
|
|
#endif
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#if DEPTH_PACKING == 3200
|
|
diffuseColor.a = opacity;
|
|
#endif
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
|
|
#if DEPTH_PACKING == 3200
|
|
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
|
#elif DEPTH_PACKING == 3201
|
|
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
#endif
|
|
}`,IL=`#define DISTANCE
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <skinbase_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vWorldPosition = worldPosition.xyz;
|
|
}`,DL=`#define DISTANCE
|
|
uniform vec3 referencePosition;
|
|
uniform float nearDistance;
|
|
uniform float farDistance;
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main () {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
float dist = length( vWorldPosition - referencePosition );
|
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
dist = saturate( dist );
|
|
gl_FragColor = packDepthToRGBA( dist );
|
|
}`,UL=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
}`,OL=`uniform sampler2D tEquirect;
|
|
varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vec3 direction = normalize( vWorldDirection );
|
|
vec2 sampleUV = equirectUv( direction );
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,NL=`uniform float scale;
|
|
attribute float lineDistance;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
vLineDistance = scale * lineDistance;
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,FL=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform float dashSize;
|
|
uniform float totalSize;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
|
discard;
|
|
}
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,kL=`#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,zL=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#endif
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
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 <aomap_fragment>
|
|
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
|
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,BL=`#define LAMBERT
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,GL=`#define LAMBERT
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_lambert_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_lambert_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,HL=`#define MATCAP
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
}`,VL=`#define MATCAP
|
|
uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform sampler2D matcap;
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
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 <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,WL=`#define NORMAL
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
vViewPosition = - mvPosition.xyz;
|
|
#endif
|
|
}`,XL=`#define NORMAL
|
|
uniform float opacity;
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
|
|
#ifdef OPAQUE
|
|
gl_FragColor.a = 1.0;
|
|
#endif
|
|
}`,jL=`#define PHONG
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,YL=`#define PHONG
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform vec3 specular;
|
|
uniform float shininess;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_phong_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_phong_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,qL=`#define STANDARD
|
|
varying vec3 vViewPosition;
|
|
#ifdef USE_TRANSMISSION
|
|
varying vec3 vWorldPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
#ifdef USE_TRANSMISSION
|
|
vWorldPosition = worldPosition.xyz;
|
|
#endif
|
|
}`,ZL=`#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_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 <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <iridescence_fragment>
|
|
#include <cube_uv_reflection_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_physical_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_physical_pars_fragment>
|
|
#include <transmission_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <clearcoat_pars_fragment>
|
|
#include <iridescence_pars_fragment>
|
|
#include <roughnessmap_pars_fragment>
|
|
#include <metalnessmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <roughnessmap_fragment>
|
|
#include <metalnessmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <clearcoat_normal_fragment_begin>
|
|
#include <clearcoat_normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_physical_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
#include <transmission_fragment>
|
|
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
#ifdef USE_SHEEN
|
|
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
|
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
|
|
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;
|
|
#endif
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,KL=`#define TOON
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,$L=`#define TOON
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <gradientmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_toon_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_toon_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,JL=`uniform float size;
|
|
uniform float scale;
|
|
#include <common>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
#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 <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
gl_PointSize = size;
|
|
#ifdef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
|
#endif
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <fog_vertex>
|
|
}`,QL=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <map_particle_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_particle_fragment>
|
|
#include <color_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,eI=`#include <common>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
void main() {
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,tI=`uniform vec3 color;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <shadowmask_pars_fragment>
|
|
void main() {
|
|
#include <logdepthbuf_fragment>
|
|
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
}`,nI=`uniform float rotation;
|
|
uniform vec2 center;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
vec2 scale;
|
|
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
|
|
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
|
|
#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 <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,iI=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
}`,bt={alphahash_fragment:AR,alphahash_pars_fragment:CR,alphamap_fragment:RR,alphamap_pars_fragment:PR,alphatest_fragment:LR,alphatest_pars_fragment:IR,aomap_fragment:DR,aomap_pars_fragment:UR,begin_vertex:OR,beginnormal_vertex:NR,bsdfs:FR,iridescence_fragment:kR,bumpmap_pars_fragment:zR,clipping_planes_fragment:BR,clipping_planes_pars_fragment:GR,clipping_planes_pars_vertex:HR,clipping_planes_vertex:VR,color_fragment:WR,color_pars_fragment:XR,color_pars_vertex:jR,color_vertex:YR,common:qR,cube_uv_reflection_fragment:ZR,defaultnormal_vertex:KR,displacementmap_pars_vertex:$R,displacementmap_vertex:JR,emissivemap_fragment:QR,emissivemap_pars_fragment:eP,colorspace_fragment:tP,colorspace_pars_fragment:nP,envmap_fragment:iP,envmap_common_pars_fragment:rP,envmap_pars_fragment:sP,envmap_pars_vertex:oP,envmap_physical_pars_fragment:yP,envmap_vertex:aP,fog_vertex:lP,fog_pars_vertex:cP,fog_fragment:uP,fog_pars_fragment:hP,gradientmap_pars_fragment:fP,lightmap_fragment:dP,lightmap_pars_fragment:pP,lights_lambert_fragment:mP,lights_lambert_pars_fragment:gP,lights_pars_begin:vP,lights_toon_fragment:_P,lights_toon_pars_fragment:xP,lights_phong_fragment:wP,lights_phong_pars_fragment:SP,lights_physical_fragment:EP,lights_physical_pars_fragment:bP,lights_fragment_begin:MP,lights_fragment_maps:TP,lights_fragment_end:AP,logdepthbuf_fragment:CP,logdepthbuf_pars_fragment:RP,logdepthbuf_pars_vertex:PP,logdepthbuf_vertex:LP,map_fragment:IP,map_pars_fragment:DP,map_particle_fragment:UP,map_particle_pars_fragment:OP,metalnessmap_fragment:NP,metalnessmap_pars_fragment:FP,morphcolor_vertex:kP,morphnormal_vertex:zP,morphtarget_pars_vertex:BP,morphtarget_vertex:GP,normal_fragment_begin:HP,normal_fragment_maps:VP,normal_pars_fragment:WP,normal_pars_vertex:XP,normal_vertex:jP,normalmap_pars_fragment:YP,clearcoat_normal_fragment_begin:qP,clearcoat_normal_fragment_maps:ZP,clearcoat_pars_fragment:KP,iridescence_pars_fragment:$P,opaque_fragment:JP,packing:QP,premultiplied_alpha_fragment:eL,project_vertex:tL,dithering_fragment:nL,dithering_pars_fragment:iL,roughnessmap_fragment:rL,roughnessmap_pars_fragment:sL,shadowmap_pars_fragment:oL,shadowmap_pars_vertex:aL,shadowmap_vertex:lL,shadowmask_pars_fragment:cL,skinbase_vertex:uL,skinning_pars_vertex:hL,skinning_vertex:fL,skinnormal_vertex:dL,specularmap_fragment:pL,specularmap_pars_fragment:mL,tonemapping_fragment:gL,tonemapping_pars_fragment:vL,transmission_fragment:yL,transmission_pars_fragment:_L,uv_pars_fragment:xL,uv_pars_vertex:wL,uv_vertex:SL,worldpos_vertex:EL,background_vert:bL,background_frag:ML,backgroundCube_vert:TL,backgroundCube_frag:AL,cube_vert:CL,cube_frag:RL,depth_vert:PL,depth_frag:LL,distanceRGBA_vert:IL,distanceRGBA_frag:DL,equirect_vert:UL,equirect_frag:OL,linedashed_vert:NL,linedashed_frag:FL,meshbasic_vert:kL,meshbasic_frag:zL,meshlambert_vert:BL,meshlambert_frag:GL,meshmatcap_vert:HL,meshmatcap_frag:VL,meshnormal_vert:WL,meshnormal_frag:XL,meshphong_vert:jL,meshphong_frag:YL,meshphysical_vert:qL,meshphysical_frag:ZL,meshtoon_vert:KL,meshtoon_frag:$L,points_vert:JL,points_frag:QL,shadow_vert:eI,shadow_frag:tI,sprite_vert:nI,sprite_frag:iI},Je={common:{diffuse:{value:new Ke(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ct}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ct}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ct}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ct},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ct},normalScale:{value:new De(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ct},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ct}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ct}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ct}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ke(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ke(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0},uvTransform:{value:new Ct}},sprite:{diffuse:{value:new Ke(16777215)},opacity:{value:1},center:{value:new De(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}}},Nr={basic:{uniforms:Ci([Je.common,Je.specularmap,Je.envmap,Je.aomap,Je.lightmap,Je.fog]),vertexShader:bt.meshbasic_vert,fragmentShader:bt.meshbasic_frag},lambert:{uniforms:Ci([Je.common,Je.specularmap,Je.envmap,Je.aomap,Je.lightmap,Je.emissivemap,Je.bumpmap,Je.normalmap,Je.displacementmap,Je.fog,Je.lights,{emissive:{value:new Ke(0)}}]),vertexShader:bt.meshlambert_vert,fragmentShader:bt.meshlambert_frag},phong:{uniforms:Ci([Je.common,Je.specularmap,Je.envmap,Je.aomap,Je.lightmap,Je.emissivemap,Je.bumpmap,Je.normalmap,Je.displacementmap,Je.fog,Je.lights,{emissive:{value:new Ke(0)},specular:{value:new Ke(1118481)},shininess:{value:30}}]),vertexShader:bt.meshphong_vert,fragmentShader:bt.meshphong_frag},standard:{uniforms:Ci([Je.common,Je.envmap,Je.aomap,Je.lightmap,Je.emissivemap,Je.bumpmap,Je.normalmap,Je.displacementmap,Je.roughnessmap,Je.metalnessmap,Je.fog,Je.lights,{emissive:{value:new Ke(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:bt.meshphysical_vert,fragmentShader:bt.meshphysical_frag},toon:{uniforms:Ci([Je.common,Je.aomap,Je.lightmap,Je.emissivemap,Je.bumpmap,Je.normalmap,Je.displacementmap,Je.gradientmap,Je.fog,Je.lights,{emissive:{value:new Ke(0)}}]),vertexShader:bt.meshtoon_vert,fragmentShader:bt.meshtoon_frag},matcap:{uniforms:Ci([Je.common,Je.bumpmap,Je.normalmap,Je.displacementmap,Je.fog,{matcap:{value:null}}]),vertexShader:bt.meshmatcap_vert,fragmentShader:bt.meshmatcap_frag},points:{uniforms:Ci([Je.points,Je.fog]),vertexShader:bt.points_vert,fragmentShader:bt.points_frag},dashed:{uniforms:Ci([Je.common,Je.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:bt.linedashed_vert,fragmentShader:bt.linedashed_frag},depth:{uniforms:Ci([Je.common,Je.displacementmap]),vertexShader:bt.depth_vert,fragmentShader:bt.depth_frag},normal:{uniforms:Ci([Je.common,Je.bumpmap,Je.normalmap,Je.displacementmap,{opacity:{value:1}}]),vertexShader:bt.meshnormal_vert,fragmentShader:bt.meshnormal_frag},sprite:{uniforms:Ci([Je.sprite,Je.fog]),vertexShader:bt.sprite_vert,fragmentShader:bt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ct},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:bt.background_vert,fragmentShader:bt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:bt.backgroundCube_vert,fragmentShader:bt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:bt.cube_vert,fragmentShader:bt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:bt.equirect_vert,fragmentShader:bt.equirect_frag},distanceRGBA:{uniforms:Ci([Je.common,Je.displacementmap,{referencePosition:{value:new Y},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:bt.distanceRGBA_vert,fragmentShader:bt.distanceRGBA_frag},shadow:{uniforms:Ci([Je.lights,Je.fog,{color:{value:new Ke(0)},opacity:{value:1}}]),vertexShader:bt.shadow_vert,fragmentShader:bt.shadow_frag}};Nr.physical={uniforms:Ci([Nr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ct},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ct},clearcoatNormalScale:{value:new De(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ct},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ct},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ct},sheen:{value:0},sheenColor:{value:new Ke(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ct},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ct},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ct},transmissionSamplerSize:{value:new De},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ct},attenuationDistance:{value:0},attenuationColor:{value:new Ke(0)},specularColor:{value:new Ke(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ct},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ct},anisotropyVector:{value:new De},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ct}}]),vertexShader:bt.meshphysical_vert,fragmentShader:bt.meshphysical_frag};const Rf={r:0,b:0,g:0};function rI(r,e,t,n,i,s,o){const a=new Ke(0);let l=s===!0?0:1,c,u,h=null,p=0,m=null;function v(y,g){let x=!1,w=g.isScene===!0?g.background:null;switch(w&&w.isTexture&&(w=(g.backgroundBlurriness>0?t:e).get(w)),w===null?_(a,l):w&&w.isColor&&(_(w,1),x=!0),r.xr.getEnvironmentBlendMode()){case"opaque":x=!0;break;case"additive":n.buffers.color.setClear(0,0,0,1,o),x=!0;break;case"alpha-blend":n.buffers.color.setClear(0,0,0,0,o),x=!0;break}(r.autoClear||x)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),w&&(w.isCubeTexture||w.mapping===Jl)?(u===void 0&&(u=new _n(new Ws(1,1,1),new cs({name:"BackgroundCubeMaterial",uniforms:Xl(Nr.backgroundCube.uniforms),vertexShader:Nr.backgroundCube.vertexShader,fragmentShader:Nr.backgroundCube.fragmentShader,side:yi,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(M,A,P){this.matrixWorld.copyPosition(P.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=w,u.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=g.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,u.material.toneMapped=w.colorSpace!==Mt,(h!==w||p!==w.version||m!==r.toneMapping)&&(u.material.needsUpdate=!0,h=w,p=w.version,m=r.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null)):w&&w.isTexture&&(c===void 0&&(c=new _n(new To(2,2),new cs({name:"BackgroundMaterial",uniforms:Xl(Nr.background.uniforms),vertexShader:Nr.background.vertexShader,fragmentShader:Nr.background.fragmentShader,side:ls,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=w,c.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,c.material.toneMapped=w.colorSpace!==Mt,w.matrixAutoUpdate===!0&&w.updateMatrix(),c.material.uniforms.uvTransform.value.copy(w.matrix),(h!==w||p!==w.version||m!==r.toneMapping)&&(c.material.needsUpdate=!0,h=w,p=w.version,m=r.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function _(y,g){y.getRGB(Rf,lM(r)),n.buffers.color.setClear(Rf.r,Rf.g,Rf.b,g,o)}return{getClearColor:function(){return a},setClearColor:function(y,g=1){a.set(y),l=g,_(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,_(a,l)},render:v}}function sI(r,e,t,n){const i=r.getParameter(r.MAX_VERTEX_ATTRIBS),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||s!==null,a={},l=y(null);let c=l,u=!1;function h(X,q,W,O,k){let G=!1;if(o){const B=_(O,W,q);c!==B&&(c=B,m(c.object)),G=g(X,O,W,k),G&&x(X,O,W,k)}else{const B=q.wireframe===!0;(c.geometry!==O.id||c.program!==W.id||c.wireframe!==B)&&(c.geometry=O.id,c.program=W.id,c.wireframe=B,G=!0)}k!==null&&t.update(k,r.ELEMENT_ARRAY_BUFFER),(G||u)&&(u=!1,P(X,q,W,O),k!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(k).buffer))}function p(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function m(X){return n.isWebGL2?r.bindVertexArray(X):s.bindVertexArrayOES(X)}function v(X){return n.isWebGL2?r.deleteVertexArray(X):s.deleteVertexArrayOES(X)}function _(X,q,W){const O=W.wireframe===!0;let k=a[X.id];k===void 0&&(k={},a[X.id]=k);let G=k[q.id];G===void 0&&(G={},k[q.id]=G);let B=G[O];return B===void 0&&(B=y(p()),G[O]=B),B}function y(X){const q=[],W=[],O=[];for(let k=0;k<i;k++)q[k]=0,W[k]=0,O[k]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:q,enabledAttributes:W,attributeDivisors:O,object:X,attributes:{},index:null}}function g(X,q,W,O){const k=c.attributes,G=q.attributes;let B=0;const D=W.getAttributes();for(const V in D)if(D[V].location>=0){const ee=k[V];let ie=G[V];if(ie===void 0&&(V==="instanceMatrix"&&X.instanceMatrix&&(ie=X.instanceMatrix),V==="instanceColor"&&X.instanceColor&&(ie=X.instanceColor)),ee===void 0||ee.attribute!==ie||ie&&ee.data!==ie.data)return!0;B++}return c.attributesNum!==B||c.index!==O}function x(X,q,W,O){const k={},G=q.attributes;let B=0;const D=W.getAttributes();for(const V in D)if(D[V].location>=0){let ee=G[V];ee===void 0&&(V==="instanceMatrix"&&X.instanceMatrix&&(ee=X.instanceMatrix),V==="instanceColor"&&X.instanceColor&&(ee=X.instanceColor));const ie={};ie.attribute=ee,ee&&ee.data&&(ie.data=ee.data),k[V]=ie,B++}c.attributes=k,c.attributesNum=B,c.index=O}function w(){const X=c.newAttributes;for(let q=0,W=X.length;q<W;q++)X[q]=0}function E(X){b(X,0)}function b(X,q){const W=c.newAttributes,O=c.enabledAttributes,k=c.attributeDivisors;W[X]=1,O[X]===0&&(r.enableVertexAttribArray(X),O[X]=1),k[X]!==q&&((n.isWebGL2?r:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](X,q),k[X]=q)}function M(){const X=c.newAttributes,q=c.enabledAttributes;for(let W=0,O=q.length;W<O;W++)q[W]!==X[W]&&(r.disableVertexAttribArray(W),q[W]=0)}function A(X,q,W,O,k,G,B){B===!0?r.vertexAttribIPointer(X,q,W,k,G):r.vertexAttribPointer(X,q,W,O,k,G)}function P(X,q,W,O){if(n.isWebGL2===!1&&(X.isInstancedMesh||O.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const k=O.attributes,G=W.getAttributes(),B=q.defaultAttributeValues;for(const D in G){const V=G[D];if(V.location>=0){let Z=k[D];if(Z===void 0&&(D==="instanceMatrix"&&X.instanceMatrix&&(Z=X.instanceMatrix),D==="instanceColor"&&X.instanceColor&&(Z=X.instanceColor)),Z!==void 0){const ee=Z.normalized,ie=Z.itemSize,ue=t.get(Z);if(ue===void 0)continue;const ce=ue.buffer,le=ue.type,Ae=ue.bytesPerElement,Ee=n.isWebGL2===!0&&(le===r.INT||le===r.UNSIGNED_INT||Z.gpuType===Yv);if(Z.isInterleavedBufferAttribute){const ae=Z.data,z=ae.stride,oe=Z.offset;if(ae.isInstancedInterleavedBuffer){for(let te=0;te<V.locationSize;te++)b(V.location+te,ae.meshPerAttribute);X.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let te=0;te<V.locationSize;te++)E(V.location+te);r.bindBuffer(r.ARRAY_BUFFER,ce);for(let te=0;te<V.locationSize;te++)A(V.location+te,ie/V.locationSize,le,ee,z*Ae,(oe+ie/V.locationSize*te)*Ae,Ee)}else{if(Z.isInstancedBufferAttribute){for(let ae=0;ae<V.locationSize;ae++)b(V.location+ae,Z.meshPerAttribute);X.isInstancedMesh!==!0&&O._maxInstanceCount===void 0&&(O._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let ae=0;ae<V.locationSize;ae++)E(V.location+ae);r.bindBuffer(r.ARRAY_BUFFER,ce);for(let ae=0;ae<V.locationSize;ae++)A(V.location+ae,ie/V.locationSize,le,ee,ie*Ae,ie/V.locationSize*ae*Ae,Ee)}}else if(B!==void 0){const ee=B[D];if(ee!==void 0)switch(ee.length){case 2:r.vertexAttrib2fv(V.location,ee);break;case 3:r.vertexAttrib3fv(V.location,ee);break;case 4:r.vertexAttrib4fv(V.location,ee);break;default:r.vertexAttrib1fv(V.location,ee)}}}}M()}function C(){N();for(const X in a){const q=a[X];for(const W in q){const O=q[W];for(const k in O)v(O[k].object),delete O[k];delete q[W]}delete a[X]}}function L(X){if(a[X.id]===void 0)return;const q=a[X.id];for(const W in q){const O=q[W];for(const k in O)v(O[k].object),delete O[k];delete q[W]}delete a[X.id]}function F(X){for(const q in a){const W=a[q];if(W[X.id]===void 0)continue;const O=W[X.id];for(const k in O)v(O[k].object),delete O[k];delete W[X.id]}}function N(){I(),u=!0,c!==l&&(c=l,m(c.object))}function I(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:h,reset:N,resetDefaultState:I,dispose:C,releaseStatesOfGeometry:L,releaseStatesOfProgram:F,initAttributes:w,enableAttribute:E,disableUnusedAttributes:M}}function oI(r,e,t,n){const i=n.isWebGL2;let s;function o(c){s=c}function a(c,u){r.drawArrays(s,c,u),t.update(u,s,1)}function l(c,u,h){if(h===0)return;let p,m;if(i)p=r,m="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),m="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[m](s,c,u,h),t.update(u,s,h)}this.setMode=o,this.render=a,this.renderInstances=l}function aI(r,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(A){if(A==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&r.constructor.name==="WebGL2RenderingContext";let a=t.precision!==void 0?t.precision:"highp";const l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,h=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),p=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=r.getParameter(r.MAX_TEXTURE_SIZE),v=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),_=r.getParameter(r.MAX_VERTEX_ATTRIBS),y=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),g=r.getParameter(r.MAX_VARYING_VECTORS),x=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),w=p>0,E=o||e.has("OES_texture_float"),b=w&&E,M=o?r.getParameter(r.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:p,maxTextureSize:m,maxCubemapSize:v,maxAttributes:_,maxVertexUniforms:y,maxVaryings:g,maxFragmentUniforms:x,vertexTextures:w,floatFragmentTextures:E,floatVertexTextures:b,maxSamples:M}}function lI(r){const e=this;let t=null,n=0,i=!1,s=!1;const o=new Us,a=new Ct,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,p){const m=h.length!==0||p||n!==0||i;return i=p,n=h.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,p){t=u(h,p,0)},this.setState=function(h,p,m){const v=h.clippingPlanes,_=h.clipIntersection,y=h.clipShadows,g=r.get(h);if(!i||v===null||v.length===0||s&&!y)s?u(null):c();else{const x=s?0:n,w=x*4;let E=g.clippingState||null;l.value=E,E=u(v,p,w,m);for(let b=0;b!==w;++b)E[b]=t[b];g.clippingState=E,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,p,m,v){const _=h!==null?h.length:0;let y=null;if(_!==0){if(y=l.value,v!==!0||y===null){const g=m+_*4,x=p.matrixWorldInverse;a.getNormalMatrix(x),(y===null||y.length<g)&&(y=new Float32Array(g));for(let w=0,E=m;w!==_;++w,E+=4)o.copy(h[w]).applyMatrix4(x,a),o.normal.toArray(y,E),y[E+3]=o.constant}l.value=y,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,y}}function cI(r){let e=new WeakMap;function t(o,a){return a===Cu?o.mapping=xo:a===Ru&&(o.mapping=wo),o}function n(o){if(o&&o.isTexture&&o.isRenderTargetTexture===!1){const a=o.mapping;if(a===Cu||a===Ru)if(e.has(o)){const l=e.get(o).texture;return t(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new uM(l.height/2);return c.fromEquirectangularTexture(r,o),e.set(o,c),o.addEventListener("dispose",i),t(c.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class Pa extends rh{constructor(e=-1,t=1,n=1,i=-1,s=.1,o=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=i,this.near=s,this.far=o,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,i,s,o){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=i,this.view.width=s,this.view.height=o,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,i=(this.top+this.bottom)/2;let s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Ul=4,o1=[.125,.215,.35,.446,.526,.582],la=20,Jm=new Pa,a1=new Ke;let Qm=null;const sa=(1+Math.sqrt(5))/2,hl=1/sa,l1=[new Y(1,1,1),new Y(-1,1,1),new Y(1,1,-1),new Y(-1,1,-1),new Y(0,sa,hl),new Y(0,sa,-hl),new Y(hl,0,sa),new Y(-hl,0,sa),new Y(sa,hl,0),new Y(-sa,hl,0)];class lv{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Qm=this._renderer.getRenderTarget(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=h1(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=u1(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Qm),e.scissorTest=!1,Pf(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===xo||e.mapping===wo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Qm=this._renderer.getRenderTarget();const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:fn,minFilter:fn,generateMipmaps:!1,type:Vl,format:Bi,colorSpace:Br,depthBuffer:!1},i=c1(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=c1(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=uI(s)),this._blurMaterial=hI(s,e,t)}return i}_compileMaterial(e){const t=new _n(this._lodPlanes[0],e);this._renderer.compile(t,Jm)}_sceneToCubeUV(e,t,n,i){const a=new zn(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,p=u.toneMapping;u.getClearColor(a1),u.toneMapping=zr,u.autoClear=!1;const m=new Vs({name:"PMREM.Background",side:yi,depthWrite:!1,depthTest:!1}),v=new _n(new Ws,m);let _=!1;const y=e.background;y?y.isColor&&(m.color.copy(y),e.background=null,_=!0):(m.color.copy(a1),_=!0);for(let g=0;g<6;g++){const x=g%3;x===0?(a.up.set(0,l[g],0),a.lookAt(c[g],0,0)):x===1?(a.up.set(0,0,l[g]),a.lookAt(0,c[g],0)):(a.up.set(0,l[g],0),a.lookAt(0,0,c[g]));const w=this._cubeSize;Pf(i,x*w,g>2?w:0,w,w),u.setRenderTarget(i),_&&u.render(v,a),u.render(e,a)}v.geometry.dispose(),v.material.dispose(),u.toneMapping=p,u.autoClear=h,e.background=y}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===xo||e.mapping===wo;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=h1()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=u1());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new _n(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;Pf(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Jm)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=l1[(i-1)%l1.length];this._blur(e,i-1,i,s,o)}t.autoClear=n}_blur(e,t,n,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",s),this._halfBlur(o,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new _n(this._lodPlanes[i],c),p=c.uniforms,m=this._sizeLods[n]-1,v=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*la-1),_=s/v,y=isFinite(s)?1+Math.floor(u*_):la;y>la&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${la}`);const g=[];let x=0;for(let A=0;A<la;++A){const P=A/_,C=Math.exp(-P*P/2);g.push(C),A===0?x+=C:A<y&&(x+=2*C)}for(let A=0;A<g.length;A++)g[A]=g[A]/x;p.envMap.value=e.texture,p.samples.value=y,p.weights.value=g,p.latitudinal.value=o==="latitudinal",a&&(p.poleAxis.value=a);const{_lodMax:w}=this;p.dTheta.value=v,p.mipInt.value=w-n;const E=this._sizeLods[i],b=3*E*(i>w-Ul?i-w+Ul:0),M=4*(this._cubeSize-E);Pf(t,b,M,3*E,2*E),l.setRenderTarget(t),l.render(h,Jm)}}function uI(r){const e=[],t=[],n=[];let i=r;const s=r-Ul+1+o1.length;for(let o=0;o<s;o++){const a=Math.pow(2,i);t.push(a);let l=1/a;o>r-Ul?l=o1[o-r+Ul-1]:o===0&&(l=0),n.push(l);const c=1/(a-2),u=-c,h=1+c,p=[u,u,h,u,h,h,u,u,h,h,u,h],m=6,v=6,_=3,y=2,g=1,x=new Float32Array(_*v*m),w=new Float32Array(y*v*m),E=new Float32Array(g*v*m);for(let M=0;M<m;M++){const A=M%3*2/3-1,P=M>2?0:-1,C=[A,P,0,A+2/3,P,0,A+2/3,P+1,0,A,P,0,A+2/3,P+1,0,A,P+1,0];x.set(C,_*v*M),w.set(p,y*v*M);const L=[M,M,M,M,M,M];E.set(L,g*v*M)}const b=new Tt;b.setAttribute("position",new $t(x,_)),b.setAttribute("uv",new $t(w,y)),b.setAttribute("faceIndex",new $t(E,g)),e.push(b),i>Ul&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function c1(r,e,t){const n=new Gr(r,e,t);return n.texture.mapping=Jl,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Pf(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function hI(r,e,t){const n=new Float32Array(la),i=new Y(0,1,0);return new cs({name:"SphericalGaussianBlur",defines:{n:la,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:cy(),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 <cube_uv_reflection_fragment>
|
|
|
|
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:Fs,depthTest:!1,depthWrite:!1})}function u1(){return new cs({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:cy(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 outputDirection = normalize( vOutputDirection );
|
|
vec2 uv = equirectUv( outputDirection );
|
|
|
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
|
|
}
|
|
`,blending:Fs,depthTest:!1,depthWrite:!1})}function h1(){return new cs({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:cy(),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:Fs,depthTest:!1,depthWrite:!1})}function cy(){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 );
|
|
|
|
}
|
|
`}function fI(r){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){const l=a.mapping,c=l===Cu||l===Ru,u=l===xo||l===wo;if(c||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=e.get(a);return t===null&&(t=new lv(r)),h=c?t.fromEquirectangular(a,h):t.fromCubemap(a,h),e.set(a,h),h.texture}else{if(e.has(a))return e.get(a).texture;{const h=a.image;if(c&&h&&h.height>0||u&&h&&i(h)){t===null&&(t=new lv(r));const p=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,p),a.addEventListener("dispose",s),p.texture}else return null}}}return a}function i(a){let l=0;const c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function s(a){const l=a.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function dI(r){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?t("EXT_color_buffer_float"):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(n){const i=t(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function pI(r,e,t,n){const i={},s=new WeakMap;function o(h){const p=h.target;p.index!==null&&e.remove(p.index);for(const v in p.attributes)e.remove(p.attributes[v]);for(const v in p.morphAttributes){const _=p.morphAttributes[v];for(let y=0,g=_.length;y<g;y++)e.remove(_[y])}p.removeEventListener("dispose",o),delete i[p.id];const m=s.get(p);m&&(e.remove(m),s.delete(p)),n.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,t.memory.geometries--}function a(h,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,t.memory.geometries++),p}function l(h){const p=h.attributes;for(const v in p)e.update(p[v],r.ARRAY_BUFFER);const m=h.morphAttributes;for(const v in m){const _=m[v];for(let y=0,g=_.length;y<g;y++)e.update(_[y],r.ARRAY_BUFFER)}}function c(h){const p=[],m=h.index,v=h.attributes.position;let _=0;if(m!==null){const x=m.array;_=m.version;for(let w=0,E=x.length;w<E;w+=3){const b=x[w+0],M=x[w+1],A=x[w+2];p.push(b,M,M,A,A,b)}}else{const x=v.array;_=v.version;for(let w=0,E=x.length/3-1;w<E;w+=3){const b=w+0,M=w+1,A=w+2;p.push(b,M,M,A,A,b)}}const y=new(oM(p)?ay:oy)(p,1);y.version=_;const g=s.get(h);g&&e.remove(g),s.set(h,y)}function u(h){const p=s.get(h);if(p){const m=h.index;m!==null&&p.version<m.version&&c(h)}else c(h);return s.get(h)}return{get:a,update:l,getWireframeAttribute:u}}function mI(r,e,t,n){const i=n.isWebGL2;let s;function o(p){s=p}let a,l;function c(p){a=p.type,l=p.bytesPerElement}function u(p,m){r.drawElements(s,m,a,p*l),t.update(m,s,1)}function h(p,m,v){if(v===0)return;let _,y;if(i)_=r,y="drawElementsInstanced";else if(_=e.get("ANGLE_instanced_arrays"),y="drawElementsInstancedANGLE",_===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}_[y](s,m,a,p*l,v),t.update(m,s,v)}this.setMode=o,this.setIndex=c,this.render=u,this.renderInstances=h}function gI(r){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(t.calls++,o){case r.TRIANGLES:t.triangles+=a*(s/3);break;case r.LINES:t.lines+=a*(s/2);break;case r.LINE_STRIP:t.lines+=a*(s-1);break;case r.LINE_LOOP:t.lines+=a*s;break;case r.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function vI(r,e){return r[0]-e[0]}function yI(r,e){return Math.abs(e[1])-Math.abs(r[1])}function _I(r,e,t){const n={},i=new Float32Array(8),s=new WeakMap,o=new Xt,a=[];for(let c=0;c<8;c++)a[c]=[c,0];function l(c,u,h){const p=c.morphTargetInfluences;if(e.isWebGL2===!0){const m=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,v=m!==void 0?m.length:0;let _=s.get(u);if(_===void 0||_.count!==v){let X=function(){N.dispose(),s.delete(u),u.removeEventListener("dispose",X)};_!==void 0&&_.texture.dispose();const x=u.morphAttributes.position!==void 0,w=u.morphAttributes.normal!==void 0,E=u.morphAttributes.color!==void 0,b=u.morphAttributes.position||[],M=u.morphAttributes.normal||[],A=u.morphAttributes.color||[];let P=0;x===!0&&(P=1),w===!0&&(P=2),E===!0&&(P=3);let C=u.attributes.position.count*P,L=1;C>e.maxTextureSize&&(L=Math.ceil(C/e.maxTextureSize),C=e.maxTextureSize);const F=new Float32Array(C*L*4*v),N=new Jd(F,C,L,v);N.type=rs,N.needsUpdate=!0;const I=P*4;for(let q=0;q<v;q++){const W=b[q],O=M[q],k=A[q],G=C*L*4*q;for(let B=0;B<W.count;B++){const D=B*I;x===!0&&(o.fromBufferAttribute(W,B),F[G+D+0]=o.x,F[G+D+1]=o.y,F[G+D+2]=o.z,F[G+D+3]=0),w===!0&&(o.fromBufferAttribute(O,B),F[G+D+4]=o.x,F[G+D+5]=o.y,F[G+D+6]=o.z,F[G+D+7]=0),E===!0&&(o.fromBufferAttribute(k,B),F[G+D+8]=o.x,F[G+D+9]=o.y,F[G+D+10]=o.z,F[G+D+11]=k.itemSize===4?o.w:1)}}_={count:v,texture:N,size:new De(C,L)},s.set(u,_),u.addEventListener("dispose",X)}let y=0;for(let x=0;x<p.length;x++)y+=p[x];const g=u.morphTargetsRelative?1:1-y;h.getUniforms().setValue(r,"morphTargetBaseInfluence",g),h.getUniforms().setValue(r,"morphTargetInfluences",p),h.getUniforms().setValue(r,"morphTargetsTexture",_.texture,t),h.getUniforms().setValue(r,"morphTargetsTextureSize",_.size)}else{const m=p===void 0?0:p.length;let v=n[u.id];if(v===void 0||v.length!==m){v=[];for(let w=0;w<m;w++)v[w]=[w,0];n[u.id]=v}for(let w=0;w<m;w++){const E=v[w];E[0]=w,E[1]=p[w]}v.sort(yI);for(let w=0;w<8;w++)w<m&&v[w][1]?(a[w][0]=v[w][0],a[w][1]=v[w][1]):(a[w][0]=Number.MAX_SAFE_INTEGER,a[w][1]=0);a.sort(vI);const _=u.morphAttributes.position,y=u.morphAttributes.normal;let g=0;for(let w=0;w<8;w++){const E=a[w],b=E[0],M=E[1];b!==Number.MAX_SAFE_INTEGER&&M?(_&&u.getAttribute("morphTarget"+w)!==_[b]&&u.setAttribute("morphTarget"+w,_[b]),y&&u.getAttribute("morphNormal"+w)!==y[b]&&u.setAttribute("morphNormal"+w,y[b]),i[w]=M,g+=M):(_&&u.hasAttribute("morphTarget"+w)===!0&&u.deleteAttribute("morphTarget"+w),y&&u.hasAttribute("morphNormal"+w)===!0&&u.deleteAttribute("morphNormal"+w),i[w]=0)}const x=u.morphTargetsRelative?1:1-g;h.getUniforms().setValue(r,"morphTargetBaseInfluence",x),h.getUniforms().setValue(r,"morphTargetInfluences",i)}}return{update:l}}function xI(r,e,t,n){let i=new WeakMap;function s(l){const c=n.render.frame,u=l.geometry,h=e.get(l,u);if(i.get(h)!==c&&(e.update(h),i.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),i.get(l)!==c&&(t.update(l.instanceMatrix,r.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,r.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const p=l.skeleton;i.get(p)!==c&&(p.update(),i.set(p,c))}return h}function o(){i=new WeakMap}function a(l){const c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:o}}const fM=new Sn,dM=new Jd,pM=new sy,mM=new sh,f1=[],d1=[],p1=new Float32Array(16),m1=new Float32Array(9),g1=new Float32Array(4);function ec(r,e,t){const n=r[0];if(n<=0||n>0)return r;const i=e*t;let s=f1[i];if(s===void 0&&(s=new Float32Array(i),f1[i]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function Wn(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function Xn(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function Qd(r,e){let t=d1[e];t===void 0&&(t=new Int32Array(e),d1[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function wI(r,e){const t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function SI(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Wn(t,e))return;r.uniform2fv(this.addr,e),Xn(t,e)}}function EI(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Wn(t,e))return;r.uniform3fv(this.addr,e),Xn(t,e)}}function bI(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Wn(t,e))return;r.uniform4fv(this.addr,e),Xn(t,e)}}function MI(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Wn(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),Xn(t,e)}else{if(Wn(t,n))return;g1.set(n),r.uniformMatrix2fv(this.addr,!1,g1),Xn(t,n)}}function TI(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Wn(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),Xn(t,e)}else{if(Wn(t,n))return;m1.set(n),r.uniformMatrix3fv(this.addr,!1,m1),Xn(t,n)}}function AI(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Wn(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),Xn(t,e)}else{if(Wn(t,n))return;p1.set(n),r.uniformMatrix4fv(this.addr,!1,p1),Xn(t,n)}}function CI(r,e){const t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function RI(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Wn(t,e))return;r.uniform2iv(this.addr,e),Xn(t,e)}}function PI(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Wn(t,e))return;r.uniform3iv(this.addr,e),Xn(t,e)}}function LI(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Wn(t,e))return;r.uniform4iv(this.addr,e),Xn(t,e)}}function II(r,e){const t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function DI(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Wn(t,e))return;r.uniform2uiv(this.addr,e),Xn(t,e)}}function UI(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Wn(t,e))return;r.uniform3uiv(this.addr,e),Xn(t,e)}}function OI(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Wn(t,e))return;r.uniform4uiv(this.addr,e),Xn(t,e)}}function NI(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2D(e||fM,i)}function FI(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||pM,i)}function kI(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||mM,i)}function zI(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||dM,i)}function BI(r){switch(r){case 5126:return wI;case 35664:return SI;case 35665:return EI;case 35666:return bI;case 35674:return MI;case 35675:return TI;case 35676:return AI;case 5124:case 35670:return CI;case 35667:case 35671:return RI;case 35668:case 35672:return PI;case 35669:case 35673:return LI;case 5125:return II;case 36294:return DI;case 36295:return UI;case 36296:return OI;case 35678:case 36198:case 36298:case 36306:case 35682:return NI;case 35679:case 36299:case 36307:return FI;case 35680:case 36300:case 36308:case 36293:return kI;case 36289:case 36303:case 36311:case 36292:return zI}}function GI(r,e){r.uniform1fv(this.addr,e)}function HI(r,e){const t=ec(e,this.size,2);r.uniform2fv(this.addr,t)}function VI(r,e){const t=ec(e,this.size,3);r.uniform3fv(this.addr,t)}function WI(r,e){const t=ec(e,this.size,4);r.uniform4fv(this.addr,t)}function XI(r,e){const t=ec(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function jI(r,e){const t=ec(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function YI(r,e){const t=ec(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function qI(r,e){r.uniform1iv(this.addr,e)}function ZI(r,e){r.uniform2iv(this.addr,e)}function KI(r,e){r.uniform3iv(this.addr,e)}function $I(r,e){r.uniform4iv(this.addr,e)}function JI(r,e){r.uniform1uiv(this.addr,e)}function QI(r,e){r.uniform2uiv(this.addr,e)}function eD(r,e){r.uniform3uiv(this.addr,e)}function tD(r,e){r.uniform4uiv(this.addr,e)}function nD(r,e,t){const n=this.cache,i=e.length,s=Qd(t,i);Wn(n,s)||(r.uniform1iv(this.addr,s),Xn(n,s));for(let o=0;o!==i;++o)t.setTexture2D(e[o]||fM,s[o])}function iD(r,e,t){const n=this.cache,i=e.length,s=Qd(t,i);Wn(n,s)||(r.uniform1iv(this.addr,s),Xn(n,s));for(let o=0;o!==i;++o)t.setTexture3D(e[o]||pM,s[o])}function rD(r,e,t){const n=this.cache,i=e.length,s=Qd(t,i);Wn(n,s)||(r.uniform1iv(this.addr,s),Xn(n,s));for(let o=0;o!==i;++o)t.setTextureCube(e[o]||mM,s[o])}function sD(r,e,t){const n=this.cache,i=e.length,s=Qd(t,i);Wn(n,s)||(r.uniform1iv(this.addr,s),Xn(n,s));for(let o=0;o!==i;++o)t.setTexture2DArray(e[o]||dM,s[o])}function oD(r){switch(r){case 5126:return GI;case 35664:return HI;case 35665:return VI;case 35666:return WI;case 35674:return XI;case 35675:return jI;case 35676:return YI;case 5124:case 35670:return qI;case 35667:case 35671:return ZI;case 35668:case 35672:return KI;case 35669:case 35673:return $I;case 5125:return JI;case 36294:return QI;case 36295:return eD;case 36296:return tD;case 35678:case 36198:case 36298:case 36306:case 35682:return nD;case 35679:case 36299:case 36307:return iD;case 35680:case 36300:case 36308:case 36293:return rD;case 36289:case 36303:case 36311:case 36292:return sD}}class aD{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=BI(t.type)}}class lD{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=oD(t.type)}}class cD{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let s=0,o=i.length;s!==o;++s){const a=i[s];a.setValue(e,t[a.id],n)}}}const eg=/(\w+)(\])?(\[|\.)?/g;function v1(r,e){r.seq.push(e),r.map[e.id]=e}function uD(r,e,t){const n=r.name,i=n.length;for(eg.lastIndex=0;;){const s=eg.exec(n),o=eg.lastIndex;let a=s[1];const l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===i){v1(t,c===void 0?new aD(a,r,e):new lD(a,r,e));break}else{let h=t.map[a];h===void 0&&(h=new cD(a),v1(t,h)),t=h}}}class bd{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const s=e.getActiveUniform(t,i),o=e.getUniformLocation(t,s.name);uD(s,o,this)}}setValue(e,t,n,i){const s=this.map[t];s!==void 0&&s.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,o=t.length;s!==o;++s){const a=t[s],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,s=e.length;i!==s;++i){const o=e[i];o.id in t&&n.push(o)}return n}}function y1(r,e,t){const n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}let hD=0;function fD(r,e){const t=r.split(`
|
|
`),n=[],i=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=i;o<s;o++){const a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
|
|
`)}function dD(r){switch(r){case Br:return["Linear","( value )"];case Mt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",r),["Linear","( value )"]}}function _1(r,e,t){const n=r.getShaderParameter(e,r.COMPILE_STATUS),i=r.getShaderInfoLog(e).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const o=parseInt(s[1]);return t.toUpperCase()+`
|
|
|
|
`+i+`
|
|
|
|
`+fD(r.getShaderSource(e),o)}else return i}function pD(r,e){const t=dD(e);return"vec4 "+r+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function mD(r,e){let t;switch(e){case Ib:t="Linear";break;case Db:t="Reinhard";break;case Ub:t="OptimizedCineon";break;case Xv:t="ACESFilmic";break;case Ob:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function gD(r){return[r.extensionDerivatives||r.envMapCubeUVHeight||r.bumpMap||r.normalMapTangentSpace||r.clearcoatNormalMap||r.flatShading||r.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(r.extensionFragDepth||r.logarithmicDepthBuffer)&&r.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",r.extensionDrawBuffers&&r.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(r.extensionShaderTextureLOD||r.envMap||r.transmission)&&r.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(fu).join(`
|
|
`)}function vD(r){const e=[];for(const t in r){const n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
`)}function yD(r,e){const t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const s=r.getActiveAttrib(e,i),o=s.name;let a=1;s.type===r.FLOAT_MAT2&&(a=2),s.type===r.FLOAT_MAT3&&(a=3),s.type===r.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:r.getAttribLocation(e,o),locationSize:a}}return t}function fu(r){return r!==""}function x1(r,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return r.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function w1(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const _D=/^[ \t]*#include +<([\w\d./]+)>/gm;function cv(r){return r.replace(_D,wD)}const xD=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function wD(r,e){let t=bt[e];if(t===void 0){const n=xD.get(e);if(n!==void 0)t=bt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return cv(t)}const SD=/#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 S1(r){return r.replace(SD,ED)}function ED(r,e,t,n){let i="";for(let s=parseInt(e);s<parseInt(t);s++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function E1(r){let e="precision "+r.precision+` float;
|
|
precision `+r.precision+" int;";return r.precision==="highp"?e+=`
|
|
#define HIGH_PRECISION`:r.precision==="mediump"?e+=`
|
|
#define MEDIUM_PRECISION`:r.precision==="lowp"&&(e+=`
|
|
#define LOW_PRECISION`),e}function bD(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===qd?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===gu?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===Or&&(e="SHADOWMAP_TYPE_VSM"),e}function MD(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case xo:case wo:e="ENVMAP_TYPE_CUBE";break;case Jl:e="ENVMAP_TYPE_CUBE_UV";break}return e}function TD(r){let e="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case wo:e="ENVMAP_MODE_REFRACTION";break}return e}function AD(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case ih:e="ENVMAP_BLENDING_MULTIPLY";break;case Pb:e="ENVMAP_BLENDING_MIX";break;case Lb:e="ENVMAP_BLENDING_ADD";break}return e}function CD(r){const e=r.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function RD(r,e,t,n){const i=r.getContext(),s=t.defines;let o=t.vertexShader,a=t.fragmentShader;const l=bD(t),c=MD(t),u=TD(t),h=AD(t),p=CD(t),m=t.isWebGL2?"":gD(t),v=vD(s),_=i.createProgram();let y,g,x=t.glslVersion?"#version "+t.glslVersion+`
|
|
`:"";t.isRawShaderMaterial?(y=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(fu).join(`
|
|
`),y.length>0&&(y+=`
|
|
`),g=[m,"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(fu).join(`
|
|
`),g.length>0&&(g+=`
|
|
`)):(y=[E1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",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 "+u:"",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.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.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&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","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","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","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
`].filter(fu).join(`
|
|
`),g=[m,E1(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.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.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.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.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?"#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 "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==zr?"#define TONE_MAPPING":"",t.toneMapping!==zr?bt.tonemapping_pars_fragment:"",t.toneMapping!==zr?mD("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",bt.colorspace_pars_fragment,pD("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
`].filter(fu).join(`
|
|
`)),o=cv(o),o=x1(o,t),o=w1(o,t),a=cv(a),a=x1(a,t),a=w1(a,t),o=S1(o),a=S1(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(x=`#version 300 es
|
|
`,y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
`)+`
|
|
`+y,g=["#define varying in",t.glslVersion===ov?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ov?"":"#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(`
|
|
`)+`
|
|
`+g);const w=x+y+o,E=x+g+a,b=y1(i,i.VERTEX_SHADER,w),M=y1(i,i.FRAGMENT_SHADER,E);if(i.attachShader(_,b),i.attachShader(_,M),t.index0AttributeName!==void 0?i.bindAttribLocation(_,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_),r.debug.checkShaderErrors){const C=i.getProgramInfoLog(_).trim(),L=i.getShaderInfoLog(b).trim(),F=i.getShaderInfoLog(M).trim();let N=!0,I=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(N=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(i,_,b,M);else{const X=_1(i,b,"vertex"),q=_1(i,M,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+`
|
|
|
|
Program Info Log: `+C+`
|
|
`+X+`
|
|
`+q)}else C!==""?console.warn("THREE.WebGLProgram: Program Info Log:",C):(L===""||F==="")&&(I=!1);I&&(this.diagnostics={runnable:N,programLog:C,vertexShader:{log:L,prefix:y},fragmentShader:{log:F,prefix:g}})}i.deleteShader(b),i.deleteShader(M);let A;this.getUniforms=function(){return A===void 0&&(A=new bd(i,_)),A};let P;return this.getAttributes=function(){return P===void 0&&(P=yD(i,_)),P},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=hD++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=b,this.fragmentShader=M,this}let PD=0;class LD{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.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}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}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 ID(e),t.set(e,n)),n}}class ID{constructor(e){this.id=PD++,this.code=e,this.usedTimes=0}}function DD(r,e,t,n,i,s,o){const a=new ga,l=new LD,c=[],u=i.isWebGL2,h=i.logarithmicDepthBuffer,p=i.vertexTextures;let m=i.precision;const v={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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 _(C){return C===0?"uv":`uv${C}`}function y(C,L,F,N,I){const X=N.fog,q=I.geometry,W=C.isMeshStandardMaterial?N.environment:null,O=(C.isMeshStandardMaterial?t:e).get(C.envMap||W),k=O&&O.mapping===Jl?O.image.height:null,G=v[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const B=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,D=B!==void 0?B.length:0;let V=0;q.morphAttributes.position!==void 0&&(V=1),q.morphAttributes.normal!==void 0&&(V=2),q.morphAttributes.color!==void 0&&(V=3);let Z,ee,ie,ue;if(G){const Ot=Nr[G];Z=Ot.vertexShader,ee=Ot.fragmentShader}else Z=C.vertexShader,ee=C.fragmentShader,l.update(C),ie=l.getVertexShaderID(C),ue=l.getFragmentShaderID(C);const ce=r.getRenderTarget(),le=I.isInstancedMesh===!0,Ae=!!C.map,Ee=!!C.matcap,ae=!!O,z=!!C.aoMap,oe=!!C.lightMap,te=!!C.bumpMap,se=!!C.normalMap,$=!!C.displacementMap,Ie=!!C.emissiveMap,de=!!C.metalnessMap,Se=!!C.roughnessMap,Le=C.anisotropy>0,ge=C.clearcoat>0,He=C.iridescence>0,j=C.sheen>0,H=C.transmission>0,ne=Le&&!!C.anisotropyMap,we=ge&&!!C.clearcoatMap,be=ge&&!!C.clearcoatNormalMap,Me=ge&&!!C.clearcoatRoughnessMap,Fe=He&&!!C.iridescenceMap,Ue=He&&!!C.iridescenceThicknessMap,xe=j&&!!C.sheenColorMap,Be=j&&!!C.sheenRoughnessMap,$e=!!C.specularMap,Ve=!!C.specularColorMap,Oe=!!C.specularIntensityMap,We=H&&!!C.transmissionMap,nt=H&&!!C.thicknessMap,pt=!!C.gradientMap,re=!!C.alphaMap,ze=C.alphaTest>0,ve=!!C.alphaHash,Ge=!!C.extensions,Ye=!!q.attributes.uv1,_t=!!q.attributes.uv2,It=!!q.attributes.uv3;return{isWebGL2:u,shaderID:G,shaderType:C.type,shaderName:C.name,vertexShader:Z,fragmentShader:ee,defines:C.defines,customVertexShaderID:ie,customFragmentShaderID:ue,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,instancing:le,instancingColor:le&&I.instanceColor!==null,supportsVertexTextures:p,outputColorSpace:ce===null?r.outputColorSpace:ce.isXRRenderTarget===!0?ce.texture.colorSpace:Br,map:Ae,matcap:Ee,envMap:ae,envMapMode:ae&&O.mapping,envMapCubeUVHeight:k,aoMap:z,lightMap:oe,bumpMap:te,normalMap:se,displacementMap:p&&$,emissiveMap:Ie,normalMapObjectSpace:se&&C.normalMapType===Zb,normalMapTangentSpace:se&&C.normalMapType===Mo,metalnessMap:de,roughnessMap:Se,anisotropy:Le,anisotropyMap:ne,clearcoat:ge,clearcoatMap:we,clearcoatNormalMap:be,clearcoatRoughnessMap:Me,iridescence:He,iridescenceMap:Fe,iridescenceThicknessMap:Ue,sheen:j,sheenColorMap:xe,sheenRoughnessMap:Be,specularMap:$e,specularColorMap:Ve,specularIntensityMap:Oe,transmission:H,transmissionMap:We,thicknessMap:nt,gradientMap:pt,opaque:C.transparent===!1&&C.blending===pa,alphaMap:re,alphaTest:ze,alphaHash:ve,combine:C.combine,mapUv:Ae&&_(C.map.channel),aoMapUv:z&&_(C.aoMap.channel),lightMapUv:oe&&_(C.lightMap.channel),bumpMapUv:te&&_(C.bumpMap.channel),normalMapUv:se&&_(C.normalMap.channel),displacementMapUv:$&&_(C.displacementMap.channel),emissiveMapUv:Ie&&_(C.emissiveMap.channel),metalnessMapUv:de&&_(C.metalnessMap.channel),roughnessMapUv:Se&&_(C.roughnessMap.channel),anisotropyMapUv:ne&&_(C.anisotropyMap.channel),clearcoatMapUv:we&&_(C.clearcoatMap.channel),clearcoatNormalMapUv:be&&_(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Me&&_(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Fe&&_(C.iridescenceMap.channel),iridescenceThicknessMapUv:Ue&&_(C.iridescenceThicknessMap.channel),sheenColorMapUv:xe&&_(C.sheenColorMap.channel),sheenRoughnessMapUv:Be&&_(C.sheenRoughnessMap.channel),specularMapUv:$e&&_(C.specularMap.channel),specularColorMapUv:Ve&&_(C.specularColorMap.channel),specularIntensityMapUv:Oe&&_(C.specularIntensityMap.channel),transmissionMapUv:We&&_(C.transmissionMap.channel),thicknessMapUv:nt&&_(C.thicknessMap.channel),alphaMapUv:re&&_(C.alphaMap.channel),vertexTangents:!!q.attributes.tangent&&(se||Le),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,vertexUv1s:Ye,vertexUv2s:_t,vertexUv3s:It,pointsUvs:I.isPoints===!0&&!!q.attributes.uv&&(Ae||re),fog:!!X,useFog:C.fog===!0,fogExp2:X&&X.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:I.isSkinnedMesh===!0,morphTargets:q.morphAttributes.position!==void 0,morphNormals:q.morphAttributes.normal!==void 0,morphColors:q.morphAttributes.color!==void 0,morphTargetsCount:D,morphTextureStride:V,numDirLights:L.directional.length,numPointLights:L.point.length,numSpotLights:L.spot.length,numSpotLightMaps:L.spotLightMap.length,numRectAreaLights:L.rectArea.length,numHemiLights:L.hemi.length,numDirLightShadows:L.directionalShadowMap.length,numPointLightShadows:L.pointShadowMap.length,numSpotLightShadows:L.spotShadowMap.length,numSpotLightShadowsWithMaps:L.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:C.dithering,shadowMapEnabled:r.shadowMap.enabled&&F.length>0,shadowMapType:r.shadowMap.type,toneMapping:C.toneMapped?r.toneMapping:zr,useLegacyLights:r.useLegacyLights,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===vn,flipSided:C.side===yi,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionDerivatives:Ge&&C.extensions.derivatives===!0,extensionFragDepth:Ge&&C.extensions.fragDepth===!0,extensionDrawBuffers:Ge&&C.extensions.drawBuffers===!0,extensionShaderTextureLOD:Ge&&C.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),customProgramCacheKey:C.customProgramCacheKey()}}function g(C){const L=[];if(C.shaderID?L.push(C.shaderID):(L.push(C.customVertexShaderID),L.push(C.customFragmentShaderID)),C.defines!==void 0)for(const F in C.defines)L.push(F),L.push(C.defines[F]);return C.isRawShaderMaterial===!1&&(x(L,C),w(L,C),L.push(r.outputColorSpace)),L.push(C.customProgramCacheKey),L.join()}function x(C,L){C.push(L.precision),C.push(L.outputColorSpace),C.push(L.envMapMode),C.push(L.envMapCubeUVHeight),C.push(L.mapUv),C.push(L.alphaMapUv),C.push(L.lightMapUv),C.push(L.aoMapUv),C.push(L.bumpMapUv),C.push(L.normalMapUv),C.push(L.displacementMapUv),C.push(L.emissiveMapUv),C.push(L.metalnessMapUv),C.push(L.roughnessMapUv),C.push(L.anisotropyMapUv),C.push(L.clearcoatMapUv),C.push(L.clearcoatNormalMapUv),C.push(L.clearcoatRoughnessMapUv),C.push(L.iridescenceMapUv),C.push(L.iridescenceThicknessMapUv),C.push(L.sheenColorMapUv),C.push(L.sheenRoughnessMapUv),C.push(L.specularMapUv),C.push(L.specularColorMapUv),C.push(L.specularIntensityMapUv),C.push(L.transmissionMapUv),C.push(L.thicknessMapUv),C.push(L.combine),C.push(L.fogExp2),C.push(L.sizeAttenuation),C.push(L.morphTargetsCount),C.push(L.morphAttributeCount),C.push(L.numDirLights),C.push(L.numPointLights),C.push(L.numSpotLights),C.push(L.numSpotLightMaps),C.push(L.numHemiLights),C.push(L.numRectAreaLights),C.push(L.numDirLightShadows),C.push(L.numPointLightShadows),C.push(L.numSpotLightShadows),C.push(L.numSpotLightShadowsWithMaps),C.push(L.shadowMapType),C.push(L.toneMapping),C.push(L.numClippingPlanes),C.push(L.numClipIntersection),C.push(L.depthPacking)}function w(C,L){a.disableAll(),L.isWebGL2&&a.enable(0),L.supportsVertexTextures&&a.enable(1),L.instancing&&a.enable(2),L.instancingColor&&a.enable(3),L.matcap&&a.enable(4),L.envMap&&a.enable(5),L.normalMapObjectSpace&&a.enable(6),L.normalMapTangentSpace&&a.enable(7),L.clearcoat&&a.enable(8),L.iridescence&&a.enable(9),L.alphaTest&&a.enable(10),L.vertexColors&&a.enable(11),L.vertexAlphas&&a.enable(12),L.vertexUv1s&&a.enable(13),L.vertexUv2s&&a.enable(14),L.vertexUv3s&&a.enable(15),L.vertexTangents&&a.enable(16),L.anisotropy&&a.enable(17),C.push(a.mask),a.disableAll(),L.fog&&a.enable(0),L.useFog&&a.enable(1),L.flatShading&&a.enable(2),L.logarithmicDepthBuffer&&a.enable(3),L.skinning&&a.enable(4),L.morphTargets&&a.enable(5),L.morphNormals&&a.enable(6),L.morphColors&&a.enable(7),L.premultipliedAlpha&&a.enable(8),L.shadowMapEnabled&&a.enable(9),L.useLegacyLights&&a.enable(10),L.doubleSided&&a.enable(11),L.flipSided&&a.enable(12),L.useDepthPacking&&a.enable(13),L.dithering&&a.enable(14),L.transmission&&a.enable(15),L.sheen&&a.enable(16),L.opaque&&a.enable(17),L.pointsUvs&&a.enable(18),C.push(a.mask)}function E(C){const L=v[C.type];let F;if(L){const N=Nr[L];F=ly.clone(N.uniforms)}else F=C.uniforms;return F}function b(C,L){let F;for(let N=0,I=c.length;N<I;N++){const X=c[N];if(X.cacheKey===L){F=X,++F.usedTimes;break}}return F===void 0&&(F=new RD(r,L,C,s),c.push(F)),F}function M(C){if(--C.usedTimes===0){const L=c.indexOf(C);c[L]=c[c.length-1],c.pop(),C.destroy()}}function A(C){l.remove(C)}function P(){l.dispose()}return{getParameters:y,getProgramCacheKey:g,getUniforms:E,acquireProgram:b,releaseProgram:M,releaseShaderCache:A,programs:c,dispose:P}}function UD(){let r=new WeakMap;function e(s){let o=r.get(s);return o===void 0&&(o={},r.set(s,o)),o}function t(s){r.delete(s)}function n(s,o,a){r.get(s)[o]=a}function i(){r=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function OD(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function b1(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function M1(){const r=[];let e=0;const t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function o(h,p,m,v,_,y){let g=r[e];return g===void 0?(g={id:h.id,object:h,geometry:p,material:m,groupOrder:v,renderOrder:h.renderOrder,z:_,group:y},r[e]=g):(g.id=h.id,g.object=h,g.geometry=p,g.material=m,g.groupOrder=v,g.renderOrder=h.renderOrder,g.z=_,g.group=y),e++,g}function a(h,p,m,v,_,y){const g=o(h,p,m,v,_,y);m.transmission>0?n.push(g):m.transparent===!0?i.push(g):t.push(g)}function l(h,p,m,v,_,y){const g=o(h,p,m,v,_,y);m.transmission>0?n.unshift(g):m.transparent===!0?i.unshift(g):t.unshift(g)}function c(h,p){t.length>1&&t.sort(h||OD),n.length>1&&n.sort(p||b1),i.length>1&&i.sort(p||b1)}function u(){for(let h=e,p=r.length;h<p;h++){const m=r[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:a,unshift:l,finish:u,sort:c}}function ND(){let r=new WeakMap;function e(n,i){const s=r.get(n);let o;return s===void 0?(o=new M1,r.set(n,[o])):i>=s.length?(o=new M1,s.push(o)):o=s[i],o}function t(){r=new WeakMap}return{get:e,dispose:t}}function FD(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new Y,color:new Ke};break;case"SpotLight":t={position:new Y,direction:new Y,color:new Ke,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new Y,color:new Ke,distance:0,decay:0};break;case"HemisphereLight":t={direction:new Y,skyColor:new Ke,groundColor:new Ke};break;case"RectAreaLight":t={color:new Ke,position:new Y,halfWidth:new Y,halfHeight:new Y};break}return r[e.id]=t,t}}}function kD(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new De};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new De};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new De,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let zD=0;function BD(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function GD(r,e){const t=new FD,n=kD(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-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};for(let u=0;u<9;u++)i.probe.push(new Y);const s=new Y,o=new yt,a=new yt;function l(u,h){let p=0,m=0,v=0;for(let F=0;F<9;F++)i.probe[F].set(0,0,0);let _=0,y=0,g=0,x=0,w=0,E=0,b=0,M=0,A=0,P=0;u.sort(BD);const C=h===!0?Math.PI:1;for(let F=0,N=u.length;F<N;F++){const I=u[F],X=I.color,q=I.intensity,W=I.distance,O=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)p+=X.r*q*C,m+=X.g*q*C,v+=X.b*q*C;else if(I.isLightProbe)for(let k=0;k<9;k++)i.probe[k].addScaledVector(I.sh.coefficients[k],q);else if(I.isDirectionalLight){const k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity*C),I.castShadow){const G=I.shadow,B=n.get(I);B.shadowBias=G.bias,B.shadowNormalBias=G.normalBias,B.shadowRadius=G.radius,B.shadowMapSize=G.mapSize,i.directionalShadow[_]=B,i.directionalShadowMap[_]=O,i.directionalShadowMatrix[_]=I.shadow.matrix,E++}i.directional[_]=k,_++}else if(I.isSpotLight){const k=t.get(I);k.position.setFromMatrixPosition(I.matrixWorld),k.color.copy(X).multiplyScalar(q*C),k.distance=W,k.coneCos=Math.cos(I.angle),k.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),k.decay=I.decay,i.spot[g]=k;const G=I.shadow;if(I.map&&(i.spotLightMap[A]=I.map,A++,G.updateMatrices(I),I.castShadow&&P++),i.spotLightMatrix[g]=G.matrix,I.castShadow){const B=n.get(I);B.shadowBias=G.bias,B.shadowNormalBias=G.normalBias,B.shadowRadius=G.radius,B.shadowMapSize=G.mapSize,i.spotShadow[g]=B,i.spotShadowMap[g]=O,M++}g++}else if(I.isRectAreaLight){const k=t.get(I);k.color.copy(X).multiplyScalar(q),k.halfWidth.set(I.width*.5,0,0),k.halfHeight.set(0,I.height*.5,0),i.rectArea[x]=k,x++}else if(I.isPointLight){const k=t.get(I);if(k.color.copy(I.color).multiplyScalar(I.intensity*C),k.distance=I.distance,k.decay=I.decay,I.castShadow){const G=I.shadow,B=n.get(I);B.shadowBias=G.bias,B.shadowNormalBias=G.normalBias,B.shadowRadius=G.radius,B.shadowMapSize=G.mapSize,B.shadowCameraNear=G.camera.near,B.shadowCameraFar=G.camera.far,i.pointShadow[y]=B,i.pointShadowMap[y]=O,i.pointShadowMatrix[y]=I.shadow.matrix,b++}i.point[y]=k,y++}else if(I.isHemisphereLight){const k=t.get(I);k.skyColor.copy(I.color).multiplyScalar(q*C),k.groundColor.copy(I.groundColor).multiplyScalar(q*C),i.hemi[w]=k,w++}}x>0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Je.LTC_FLOAT_1,i.rectAreaLTC2=Je.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Je.LTC_HALF_1,i.rectAreaLTC2=Je.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=p,i.ambient[1]=m,i.ambient[2]=v;const L=i.hash;(L.directionalLength!==_||L.pointLength!==y||L.spotLength!==g||L.rectAreaLength!==x||L.hemiLength!==w||L.numDirectionalShadows!==E||L.numPointShadows!==b||L.numSpotShadows!==M||L.numSpotMaps!==A)&&(i.directional.length=_,i.spot.length=g,i.rectArea.length=x,i.point.length=y,i.hemi.length=w,i.directionalShadow.length=E,i.directionalShadowMap.length=E,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=E,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=M+A-P,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=P,L.directionalLength=_,L.pointLength=y,L.spotLength=g,L.rectAreaLength=x,L.hemiLength=w,L.numDirectionalShadows=E,L.numPointShadows=b,L.numSpotShadows=M,L.numSpotMaps=A,i.version=zD++)}function c(u,h){let p=0,m=0,v=0,_=0,y=0;const g=h.matrixWorldInverse;for(let x=0,w=u.length;x<w;x++){const E=u[x];if(E.isDirectionalLight){const b=i.directional[p];b.direction.setFromMatrixPosition(E.matrixWorld),s.setFromMatrixPosition(E.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(g),p++}else if(E.isSpotLight){const b=i.spot[v];b.position.setFromMatrixPosition(E.matrixWorld),b.position.applyMatrix4(g),b.direction.setFromMatrixPosition(E.matrixWorld),s.setFromMatrixPosition(E.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(g),v++}else if(E.isRectAreaLight){const b=i.rectArea[_];b.position.setFromMatrixPosition(E.matrixWorld),b.position.applyMatrix4(g),a.identity(),o.copy(E.matrixWorld),o.premultiply(g),a.extractRotation(o),b.halfWidth.set(E.width*.5,0,0),b.halfHeight.set(0,E.height*.5,0),b.halfWidth.applyMatrix4(a),b.halfHeight.applyMatrix4(a),_++}else if(E.isPointLight){const b=i.point[m];b.position.setFromMatrixPosition(E.matrixWorld),b.position.applyMatrix4(g),m++}else if(E.isHemisphereLight){const b=i.hemi[y];b.direction.setFromMatrixPosition(E.matrixWorld),b.direction.transformDirection(g),y++}}}return{setup:l,setupView:c,state:i}}function T1(r,e){const t=new GD(r,e),n=[],i=[];function s(){n.length=0,i.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function l(h){t.setup(n,h)}function c(h){t.setupView(n,h)}return{init:s,state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:l,setupLightsView:c,pushLight:o,pushShadow:a}}function HD(r,e){let t=new WeakMap;function n(s,o=0){const a=t.get(s);let l;return a===void 0?(l=new T1(r,e),t.set(s,[l])):o>=a.length?(l=new T1(r,e),a.push(l)):l=a[o],l}function i(){t=new WeakMap}return{get:n,dispose:i}}class ep extends oi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=qb,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 tp extends oi{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}}const VD=`void main() {
|
|
gl_Position = vec4( position, 1.0 );
|
|
}`,WD=`uniform sampler2D shadow_pass;
|
|
uniform vec2 resolution;
|
|
uniform float radius;
|
|
#include <packing>
|
|
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 = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
|
|
mean += distribution.x;
|
|
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
|
#else
|
|
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
|
|
mean += depth;
|
|
squared_mean += depth * depth;
|
|
#endif
|
|
}
|
|
mean = mean / samples;
|
|
squared_mean = squared_mean / samples;
|
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
}`;function XD(r,e,t){let n=new oh;const i=new De,s=new De,o=new Xt,a=new ep({depthPacking:ty}),l=new tp,c={},u=t.maxTextureSize,h={[ls]:yi,[yi]:ls,[vn]:vn},p=new cs({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new De},radius:{value:4}},vertexShader:VD,fragmentShader:WD}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const v=new Tt;v.setAttribute("position",new $t(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new _n(v,p),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=qd;let g=this.type;this.render=function(b,M,A){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||b.length===0)return;const P=r.getRenderTarget(),C=r.getActiveCubeFace(),L=r.getActiveMipmapLevel(),F=r.state;F.setBlending(Fs),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const N=g!==Or&&this.type===Or,I=g===Or&&this.type!==Or;for(let X=0,q=b.length;X<q;X++){const W=b[X],O=W.shadow;if(O===void 0){console.warn("THREE.WebGLShadowMap:",W,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;i.copy(O.mapSize);const k=O.getFrameExtents();if(i.multiply(k),s.copy(O.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/k.x),i.x=s.x*k.x,O.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/k.y),i.y=s.y*k.y,O.mapSize.y=s.y)),O.map===null||N===!0||I===!0){const B=this.type!==Or?{minFilter:Dn,magFilter:Dn}:{};O.map!==null&&O.map.dispose(),O.map=new Gr(i.x,i.y,B),O.map.texture.name=W.name+".shadowMap",O.camera.updateProjectionMatrix()}r.setRenderTarget(O.map),r.clear();const G=O.getViewportCount();for(let B=0;B<G;B++){const D=O.getViewport(B);o.set(s.x*D.x,s.y*D.y,s.x*D.z,s.y*D.w),F.viewport(o),O.updateMatrices(W,B),n=O.getFrustum(),E(M,A,O.camera,W,this.type)}O.isPointLightShadow!==!0&&this.type===Or&&x(O,A),O.needsUpdate=!1}g=this.type,y.needsUpdate=!1,r.setRenderTarget(P,C,L)};function x(b,M){const A=e.update(_);p.defines.VSM_SAMPLES!==b.blurSamples&&(p.defines.VSM_SAMPLES=b.blurSamples,m.defines.VSM_SAMPLES=b.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Gr(i.x,i.y)),p.uniforms.shadow_pass.value=b.map.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,r.setRenderTarget(b.mapPass),r.clear(),r.renderBufferDirect(M,null,A,p,_,null),m.uniforms.shadow_pass.value=b.mapPass.texture,m.uniforms.resolution.value=b.mapSize,m.uniforms.radius.value=b.radius,r.setRenderTarget(b.map),r.clear(),r.renderBufferDirect(M,null,A,m,_,null)}function w(b,M,A,P){let C=null;const L=A.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(L!==void 0)C=L;else if(C=A.isPointLight===!0?l:a,r.localClippingEnabled&&M.clipShadows===!0&&Array.isArray(M.clippingPlanes)&&M.clippingPlanes.length!==0||M.displacementMap&&M.displacementScale!==0||M.alphaMap&&M.alphaTest>0||M.map&&M.alphaTest>0){const F=C.uuid,N=M.uuid;let I=c[F];I===void 0&&(I={},c[F]=I);let X=I[N];X===void 0&&(X=C.clone(),I[N]=X),C=X}if(C.visible=M.visible,C.wireframe=M.wireframe,P===Or?C.side=M.shadowSide!==null?M.shadowSide:M.side:C.side=M.shadowSide!==null?M.shadowSide:h[M.side],C.alphaMap=M.alphaMap,C.alphaTest=M.alphaTest,C.map=M.map,C.clipShadows=M.clipShadows,C.clippingPlanes=M.clippingPlanes,C.clipIntersection=M.clipIntersection,C.displacementMap=M.displacementMap,C.displacementScale=M.displacementScale,C.displacementBias=M.displacementBias,C.wireframeLinewidth=M.wireframeLinewidth,C.linewidth=M.linewidth,A.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const F=r.properties.get(C);F.light=A}return C}function E(b,M,A,P,C){if(b.visible===!1)return;if(b.layers.test(M.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&C===Or)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);const N=e.update(b),I=b.material;if(Array.isArray(I)){const X=N.groups;for(let q=0,W=X.length;q<W;q++){const O=X[q],k=I[O.materialIndex];if(k&&k.visible){const G=w(b,k,P,C);r.renderBufferDirect(A,null,N,G,b,O)}}}else if(I.visible){const X=w(b,I,P,C);r.renderBufferDirect(A,null,N,X,b,null)}}const F=b.children;for(let N=0,I=F.length;N<I;N++)E(F[N],M,A,P,C)}}function jD(r,e,t){const n=t.isWebGL2;function i(){let re=!1;const ze=new Xt;let ve=null;const Ge=new Xt(0,0,0,0);return{setMask:function(Ye){ve!==Ye&&!re&&(r.colorMask(Ye,Ye,Ye,Ye),ve=Ye)},setLocked:function(Ye){re=Ye},setClear:function(Ye,_t,It,Ft,Ot){Ot===!0&&(Ye*=Ft,_t*=Ft,It*=Ft),ze.set(Ye,_t,It,Ft),Ge.equals(ze)===!1&&(r.clearColor(Ye,_t,It,Ft),Ge.copy(ze))},reset:function(){re=!1,ve=null,Ge.set(-1,0,0,0)}}}function s(){let re=!1,ze=null,ve=null,Ge=null;return{setTest:function(Ye){Ye?ce(r.DEPTH_TEST):le(r.DEPTH_TEST)},setMask:function(Ye){ze!==Ye&&!re&&(r.depthMask(Ye),ze=Ye)},setFunc:function(Ye){if(ve!==Ye){switch(Ye){case Eb:r.depthFunc(r.NEVER);break;case bb:r.depthFunc(r.ALWAYS);break;case Mb:r.depthFunc(r.LESS);break;case Ld:r.depthFunc(r.LEQUAL);break;case Tb:r.depthFunc(r.EQUAL);break;case Ab:r.depthFunc(r.GEQUAL);break;case Cb:r.depthFunc(r.GREATER);break;case Rb:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}ve=Ye}},setLocked:function(Ye){re=Ye},setClear:function(Ye){Ge!==Ye&&(r.clearDepth(Ye),Ge=Ye)},reset:function(){re=!1,ze=null,ve=null,Ge=null}}}function o(){let re=!1,ze=null,ve=null,Ge=null,Ye=null,_t=null,It=null,Ft=null,Ot=null;return{setTest:function(Yt){re||(Yt?ce(r.STENCIL_TEST):le(r.STENCIL_TEST))},setMask:function(Yt){ze!==Yt&&!re&&(r.stencilMask(Yt),ze=Yt)},setFunc:function(Yt,Nt,Rt){(ve!==Yt||Ge!==Nt||Ye!==Rt)&&(r.stencilFunc(Yt,Nt,Rt),ve=Yt,Ge=Nt,Ye=Rt)},setOp:function(Yt,Nt,Rt){(_t!==Yt||It!==Nt||Ft!==Rt)&&(r.stencilOp(Yt,Nt,Rt),_t=Yt,It=Nt,Ft=Rt)},setLocked:function(Yt){re=Yt},setClear:function(Yt){Ot!==Yt&&(r.clearStencil(Yt),Ot=Yt)},reset:function(){re=!1,ze=null,ve=null,Ge=null,Ye=null,_t=null,It=null,Ft=null,Ot=null}}}const a=new i,l=new s,c=new o,u=new WeakMap,h=new WeakMap;let p={},m={},v=new WeakMap,_=[],y=null,g=!1,x=null,w=null,E=null,b=null,M=null,A=null,P=null,C=!1,L=null,F=null,N=null,I=null,X=null;const q=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,O=0;const k=r.getParameter(r.VERSION);k.indexOf("WebGL")!==-1?(O=parseFloat(/^WebGL (\d)/.exec(k)[1]),W=O>=1):k.indexOf("OpenGL ES")!==-1&&(O=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),W=O>=2);let G=null,B={};const D=r.getParameter(r.SCISSOR_BOX),V=r.getParameter(r.VIEWPORT),Z=new Xt().fromArray(D),ee=new Xt().fromArray(V);function ie(re,ze,ve,Ge){const Ye=new Uint8Array(4),_t=r.createTexture();r.bindTexture(re,_t),r.texParameteri(re,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(re,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let It=0;It<ve;It++)n&&(re===r.TEXTURE_3D||re===r.TEXTURE_2D_ARRAY)?r.texImage3D(ze,0,r.RGBA,1,1,Ge,0,r.RGBA,r.UNSIGNED_BYTE,Ye):r.texImage2D(ze+It,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,Ye);return _t}const ue={};ue[r.TEXTURE_2D]=ie(r.TEXTURE_2D,r.TEXTURE_2D,1),ue[r.TEXTURE_CUBE_MAP]=ie(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(ue[r.TEXTURE_2D_ARRAY]=ie(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),ue[r.TEXTURE_3D]=ie(r.TEXTURE_3D,r.TEXTURE_3D,1,1)),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),ce(r.DEPTH_TEST),l.setFunc(Ld),$(!1),Ie(L0),ce(r.CULL_FACE),te(Fs);function ce(re){p[re]!==!0&&(r.enable(re),p[re]=!0)}function le(re){p[re]!==!1&&(r.disable(re),p[re]=!1)}function Ae(re,ze){return m[re]!==ze?(r.bindFramebuffer(re,ze),m[re]=ze,n&&(re===r.DRAW_FRAMEBUFFER&&(m[r.FRAMEBUFFER]=ze),re===r.FRAMEBUFFER&&(m[r.DRAW_FRAMEBUFFER]=ze)),!0):!1}function Ee(re,ze){let ve=_,Ge=!1;if(re)if(ve=v.get(ze),ve===void 0&&(ve=[],v.set(ze,ve)),re.isWebGLMultipleRenderTargets){const Ye=re.texture;if(ve.length!==Ye.length||ve[0]!==r.COLOR_ATTACHMENT0){for(let _t=0,It=Ye.length;_t<It;_t++)ve[_t]=r.COLOR_ATTACHMENT0+_t;ve.length=Ye.length,Ge=!0}}else ve[0]!==r.COLOR_ATTACHMENT0&&(ve[0]=r.COLOR_ATTACHMENT0,Ge=!0);else ve[0]!==r.BACK&&(ve[0]=r.BACK,Ge=!0);Ge&&(t.isWebGL2?r.drawBuffers(ve):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(ve))}function ae(re){return y!==re?(r.useProgram(re),y=re,!0):!1}const z={[aa]:r.FUNC_ADD,[fb]:r.FUNC_SUBTRACT,[db]:r.FUNC_REVERSE_SUBTRACT};if(n)z[O0]=r.MIN,z[N0]=r.MAX;else{const re=e.get("EXT_blend_minmax");re!==null&&(z[O0]=re.MIN_EXT,z[N0]=re.MAX_EXT)}const oe={[pb]:r.ZERO,[mb]:r.ONE,[gb]:r.SRC_COLOR,[Vv]:r.SRC_ALPHA,[Sb]:r.SRC_ALPHA_SATURATE,[xb]:r.DST_COLOR,[yb]:r.DST_ALPHA,[vb]:r.ONE_MINUS_SRC_COLOR,[Wv]:r.ONE_MINUS_SRC_ALPHA,[wb]:r.ONE_MINUS_DST_COLOR,[_b]:r.ONE_MINUS_DST_ALPHA};function te(re,ze,ve,Ge,Ye,_t,It,Ft){if(re===Fs){g===!0&&(le(r.BLEND),g=!1);return}if(g===!1&&(ce(r.BLEND),g=!0),re!==hb){if(re!==x||Ft!==C){if((w!==aa||M!==aa)&&(r.blendEquation(r.FUNC_ADD),w=aa,M=aa),Ft)switch(re){case pa:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case I0:r.blendFunc(r.ONE,r.ONE);break;case D0:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case U0:r.blendFuncSeparate(r.ZERO,r.SRC_COLOR,r.ZERO,r.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",re);break}else switch(re){case pa:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case I0:r.blendFunc(r.SRC_ALPHA,r.ONE);break;case D0:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case U0:r.blendFunc(r.ZERO,r.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",re);break}E=null,b=null,A=null,P=null,x=re,C=Ft}return}Ye=Ye||ze,_t=_t||ve,It=It||Ge,(ze!==w||Ye!==M)&&(r.blendEquationSeparate(z[ze],z[Ye]),w=ze,M=Ye),(ve!==E||Ge!==b||_t!==A||It!==P)&&(r.blendFuncSeparate(oe[ve],oe[Ge],oe[_t],oe[It]),E=ve,b=Ge,A=_t,P=It),x=re,C=!1}function se(re,ze){re.side===vn?le(r.CULL_FACE):ce(r.CULL_FACE);let ve=re.side===yi;ze&&(ve=!ve),$(ve),re.blending===pa&&re.transparent===!1?te(Fs):te(re.blending,re.blendEquation,re.blendSrc,re.blendDst,re.blendEquationAlpha,re.blendSrcAlpha,re.blendDstAlpha,re.premultipliedAlpha),l.setFunc(re.depthFunc),l.setTest(re.depthTest),l.setMask(re.depthWrite),a.setMask(re.colorWrite);const Ge=re.stencilWrite;c.setTest(Ge),Ge&&(c.setMask(re.stencilWriteMask),c.setFunc(re.stencilFunc,re.stencilRef,re.stencilFuncMask),c.setOp(re.stencilFail,re.stencilZFail,re.stencilZPass)),Se(re.polygonOffset,re.polygonOffsetFactor,re.polygonOffsetUnits),re.alphaToCoverage===!0?ce(r.SAMPLE_ALPHA_TO_COVERAGE):le(r.SAMPLE_ALPHA_TO_COVERAGE)}function $(re){L!==re&&(re?r.frontFace(r.CW):r.frontFace(r.CCW),L=re)}function Ie(re){re!==lb?(ce(r.CULL_FACE),re!==F&&(re===L0?r.cullFace(r.BACK):re===cb?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):le(r.CULL_FACE),F=re}function de(re){re!==N&&(W&&r.lineWidth(re),N=re)}function Se(re,ze,ve){re?(ce(r.POLYGON_OFFSET_FILL),(I!==ze||X!==ve)&&(r.polygonOffset(ze,ve),I=ze,X=ve)):le(r.POLYGON_OFFSET_FILL)}function Le(re){re?ce(r.SCISSOR_TEST):le(r.SCISSOR_TEST)}function ge(re){re===void 0&&(re=r.TEXTURE0+q-1),G!==re&&(r.activeTexture(re),G=re)}function He(re,ze,ve){ve===void 0&&(G===null?ve=r.TEXTURE0+q-1:ve=G);let Ge=B[ve];Ge===void 0&&(Ge={type:void 0,texture:void 0},B[ve]=Ge),(Ge.type!==re||Ge.texture!==ze)&&(G!==ve&&(r.activeTexture(ve),G=ve),r.bindTexture(re,ze||ue[re]),Ge.type=re,Ge.texture=ze)}function j(){const re=B[G];re!==void 0&&re.type!==void 0&&(r.bindTexture(re.type,null),re.type=void 0,re.texture=void 0)}function H(){try{r.compressedTexImage2D.apply(r,arguments)}catch(re){console.error("THREE.WebGLState:",re)}}function ne(){try{r.compressedTexImage3D.apply(r,arguments)}catch(re){console.error("THREE.WebGLState:",re)}}function we(){try{r.texSubImage2D.apply(r,arguments)}catch(re){console.error("THREE.WebGLState:",re)}}function be(){try{r.texSubImage3D.apply(r,arguments)}catch(re){console.error("THREE.WebGLState:",re)}}function Me(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(re){console.error("THREE.WebGLState:",re)}}function Fe(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(re){console.error("THREE.WebGLState:",re)}}function Ue(){try{r.texStorage2D.apply(r,arguments)}catch(re){console.error("THREE.WebGLState:",re)}}function xe(){try{r.texStorage3D.apply(r,arguments)}catch(re){console.error("THREE.WebGLState:",re)}}function Be(){try{r.texImage2D.apply(r,arguments)}catch(re){console.error("THREE.WebGLState:",re)}}function $e(){try{r.texImage3D.apply(r,arguments)}catch(re){console.error("THREE.WebGLState:",re)}}function Ve(re){Z.equals(re)===!1&&(r.scissor(re.x,re.y,re.z,re.w),Z.copy(re))}function Oe(re){ee.equals(re)===!1&&(r.viewport(re.x,re.y,re.z,re.w),ee.copy(re))}function We(re,ze){let ve=h.get(ze);ve===void 0&&(ve=new WeakMap,h.set(ze,ve));let Ge=ve.get(re);Ge===void 0&&(Ge=r.getUniformBlockIndex(ze,re.name),ve.set(re,Ge))}function nt(re,ze){const Ge=h.get(ze).get(re);u.get(ze)!==Ge&&(r.uniformBlockBinding(ze,Ge,re.__bindingPointIndex),u.set(ze,Ge))}function pt(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),n===!0&&(r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),p={},G=null,B={},m={},v=new WeakMap,_=[],y=null,g=!1,x=null,w=null,E=null,b=null,M=null,A=null,P=null,C=!1,L=null,F=null,N=null,I=null,X=null,Z.set(0,0,r.canvas.width,r.canvas.height),ee.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),c.reset()}return{buffers:{color:a,depth:l,stencil:c},enable:ce,disable:le,bindFramebuffer:Ae,drawBuffers:Ee,useProgram:ae,setBlending:te,setMaterial:se,setFlipSided:$,setCullFace:Ie,setLineWidth:de,setPolygonOffset:Se,setScissorTest:Le,activeTexture:ge,bindTexture:He,unbindTexture:j,compressedTexImage2D:H,compressedTexImage3D:ne,texImage2D:Be,texImage3D:$e,updateUBOMapping:We,uniformBlockBinding:nt,texStorage2D:Ue,texStorage3D:xe,texSubImage2D:we,texSubImage3D:be,compressedTexSubImage2D:Me,compressedTexSubImage3D:Fe,scissor:Ve,viewport:Oe,reset:pt}}function YD(r,e,t,n,i,s,o){const a=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,u=i.maxTextureSize,h=i.maxSamples,p=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),v=new WeakMap;let _;const y=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(j,H){return g?new OffscreenCanvas(j,H):Fu("canvas")}function w(j,H,ne,we){let be=1;if((j.width>we||j.height>we)&&(be=we/Math.max(j.width,j.height)),be<1||H===!0)if(typeof HTMLImageElement<"u"&&j instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&j instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&j instanceof ImageBitmap){const Me=H?Ud:Math.floor,Fe=Me(be*j.width),Ue=Me(be*j.height);_===void 0&&(_=x(Fe,Ue));const xe=ne?x(Fe,Ue):_;return xe.width=Fe,xe.height=Ue,xe.getContext("2d").drawImage(j,0,0,Fe,Ue),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+j.width+"x"+j.height+") to ("+Fe+"x"+Ue+")."),xe}else return"data"in j&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+j.width+"x"+j.height+")."),j;return j}function E(j){return av(j.width)&&av(j.height)}function b(j){return a?!1:j.wrapS!==vi||j.wrapT!==vi||j.minFilter!==Dn&&j.minFilter!==fn}function M(j,H){return j.generateMipmaps&&H&&j.minFilter!==Dn&&j.minFilter!==fn}function A(j){r.generateMipmap(j)}function P(j,H,ne,we,be=!1){if(a===!1)return H;if(j!==null){if(r[j]!==void 0)return r[j];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+j+"'")}let Me=H;return H===r.RED&&(ne===r.FLOAT&&(Me=r.R32F),ne===r.HALF_FLOAT&&(Me=r.R16F),ne===r.UNSIGNED_BYTE&&(Me=r.R8)),H===r.RG&&(ne===r.FLOAT&&(Me=r.RG32F),ne===r.HALF_FLOAT&&(Me=r.RG16F),ne===r.UNSIGNED_BYTE&&(Me=r.RG8)),H===r.RGBA&&(ne===r.FLOAT&&(Me=r.RGBA32F),ne===r.HALF_FLOAT&&(Me=r.RGBA16F),ne===r.UNSIGNED_BYTE&&(Me=we===Mt&&be===!1?r.SRGB8_ALPHA8:r.RGBA8),ne===r.UNSIGNED_SHORT_4_4_4_4&&(Me=r.RGBA4),ne===r.UNSIGNED_SHORT_5_5_5_1&&(Me=r.RGB5_A1)),(Me===r.R16F||Me===r.R32F||Me===r.RG16F||Me===r.RG32F||Me===r.RGBA16F||Me===r.RGBA32F)&&e.get("EXT_color_buffer_float"),Me}function C(j,H,ne){return M(j,ne)===!0||j.isFramebufferTexture&&j.minFilter!==Dn&&j.minFilter!==fn?Math.log2(Math.max(H.width,H.height))+1:j.mipmaps!==void 0&&j.mipmaps.length>0?j.mipmaps.length:j.isCompressedTexture&&Array.isArray(j.image)?H.mipmaps.length:1}function L(j){return j===Dn||j===Id||j===vu?r.NEAREST:r.LINEAR}function F(j){const H=j.target;H.removeEventListener("dispose",F),I(H),H.isVideoTexture&&v.delete(H)}function N(j){const H=j.target;H.removeEventListener("dispose",N),q(H)}function I(j){const H=n.get(j);if(H.__webglInit===void 0)return;const ne=j.source,we=y.get(ne);if(we){const be=we[H.__cacheKey];be.usedTimes--,be.usedTimes===0&&X(j),Object.keys(we).length===0&&y.delete(ne)}n.remove(j)}function X(j){const H=n.get(j);r.deleteTexture(H.__webglTexture);const ne=j.source,we=y.get(ne);delete we[H.__cacheKey],o.memory.textures--}function q(j){const H=j.texture,ne=n.get(j),we=n.get(H);if(we.__webglTexture!==void 0&&(r.deleteTexture(we.__webglTexture),o.memory.textures--),j.depthTexture&&j.depthTexture.dispose(),j.isWebGLCubeRenderTarget)for(let be=0;be<6;be++)r.deleteFramebuffer(ne.__webglFramebuffer[be]),ne.__webglDepthbuffer&&r.deleteRenderbuffer(ne.__webglDepthbuffer[be]);else{if(r.deleteFramebuffer(ne.__webglFramebuffer),ne.__webglDepthbuffer&&r.deleteRenderbuffer(ne.__webglDepthbuffer),ne.__webglMultisampledFramebuffer&&r.deleteFramebuffer(ne.__webglMultisampledFramebuffer),ne.__webglColorRenderbuffer)for(let be=0;be<ne.__webglColorRenderbuffer.length;be++)ne.__webglColorRenderbuffer[be]&&r.deleteRenderbuffer(ne.__webglColorRenderbuffer[be]);ne.__webglDepthRenderbuffer&&r.deleteRenderbuffer(ne.__webglDepthRenderbuffer)}if(j.isWebGLMultipleRenderTargets)for(let be=0,Me=H.length;be<Me;be++){const Fe=n.get(H[be]);Fe.__webglTexture&&(r.deleteTexture(Fe.__webglTexture),o.memory.textures--),n.remove(H[be])}n.remove(H),n.remove(j)}let W=0;function O(){W=0}function k(){const j=W;return j>=l&&console.warn("THREE.WebGLTextures: Trying to use "+j+" texture units while this GPU supports only "+l),W+=1,j}function G(j){const H=[];return H.push(j.wrapS),H.push(j.wrapT),H.push(j.wrapR||0),H.push(j.magFilter),H.push(j.minFilter),H.push(j.anisotropy),H.push(j.internalFormat),H.push(j.format),H.push(j.type),H.push(j.generateMipmaps),H.push(j.premultiplyAlpha),H.push(j.flipY),H.push(j.unpackAlignment),H.push(j.colorSpace),H.join()}function B(j,H){const ne=n.get(j);if(j.isVideoTexture&&ge(j),j.isRenderTargetTexture===!1&&j.version>0&&ne.__version!==j.version){const we=j.image;if(we===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(we.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ae(ne,j,H);return}}t.bindTexture(r.TEXTURE_2D,ne.__webglTexture,r.TEXTURE0+H)}function D(j,H){const ne=n.get(j);if(j.version>0&&ne.__version!==j.version){Ae(ne,j,H);return}t.bindTexture(r.TEXTURE_2D_ARRAY,ne.__webglTexture,r.TEXTURE0+H)}function V(j,H){const ne=n.get(j);if(j.version>0&&ne.__version!==j.version){Ae(ne,j,H);return}t.bindTexture(r.TEXTURE_3D,ne.__webglTexture,r.TEXTURE0+H)}function Z(j,H){const ne=n.get(j);if(j.version>0&&ne.__version!==j.version){Ee(ne,j,H);return}t.bindTexture(r.TEXTURE_CUBE_MAP,ne.__webglTexture,r.TEXTURE0+H)}const ee={[Pu]:r.REPEAT,[vi]:r.CLAMP_TO_EDGE,[Lu]:r.MIRRORED_REPEAT},ie={[Dn]:r.NEAREST,[Id]:r.NEAREST_MIPMAP_NEAREST,[vu]:r.NEAREST_MIPMAP_LINEAR,[fn]:r.LINEAR,[jv]:r.LINEAR_MIPMAP_NEAREST,[So]:r.LINEAR_MIPMAP_LINEAR},ue={[$b]:r.NEVER,[rM]:r.ALWAYS,[Jb]:r.LESS,[eM]:r.LEQUAL,[Qb]:r.EQUAL,[iM]:r.GEQUAL,[tM]:r.GREATER,[nM]:r.NOTEQUAL};function ce(j,H,ne){if(ne?(r.texParameteri(j,r.TEXTURE_WRAP_S,ee[H.wrapS]),r.texParameteri(j,r.TEXTURE_WRAP_T,ee[H.wrapT]),(j===r.TEXTURE_3D||j===r.TEXTURE_2D_ARRAY)&&r.texParameteri(j,r.TEXTURE_WRAP_R,ee[H.wrapR]),r.texParameteri(j,r.TEXTURE_MAG_FILTER,ie[H.magFilter]),r.texParameteri(j,r.TEXTURE_MIN_FILTER,ie[H.minFilter])):(r.texParameteri(j,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(j,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),(j===r.TEXTURE_3D||j===r.TEXTURE_2D_ARRAY)&&r.texParameteri(j,r.TEXTURE_WRAP_R,r.CLAMP_TO_EDGE),(H.wrapS!==vi||H.wrapT!==vi)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(j,r.TEXTURE_MAG_FILTER,L(H.magFilter)),r.texParameteri(j,r.TEXTURE_MIN_FILTER,L(H.minFilter)),H.minFilter!==Dn&&H.minFilter!==fn&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),H.compareFunction&&(r.texParameteri(j,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(j,r.TEXTURE_COMPARE_FUNC,ue[H.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const we=e.get("EXT_texture_filter_anisotropic");if(H.magFilter===Dn||H.minFilter!==vu&&H.minFilter!==So||H.type===rs&&e.has("OES_texture_float_linear")===!1||a===!1&&H.type===Vl&&e.has("OES_texture_half_float_linear")===!1)return;(H.anisotropy>1||n.get(H).__currentAnisotropy)&&(r.texParameterf(j,we.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(H.anisotropy,i.getMaxAnisotropy())),n.get(H).__currentAnisotropy=H.anisotropy)}}function le(j,H){let ne=!1;j.__webglInit===void 0&&(j.__webglInit=!0,H.addEventListener("dispose",F));const we=H.source;let be=y.get(we);be===void 0&&(be={},y.set(we,be));const Me=G(H);if(Me!==j.__cacheKey){be[Me]===void 0&&(be[Me]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,ne=!0),be[Me].usedTimes++;const Fe=be[j.__cacheKey];Fe!==void 0&&(be[j.__cacheKey].usedTimes--,Fe.usedTimes===0&&X(H)),j.__cacheKey=Me,j.__webglTexture=be[Me].texture}return ne}function Ae(j,H,ne){let we=r.TEXTURE_2D;(H.isDataArrayTexture||H.isCompressedArrayTexture)&&(we=r.TEXTURE_2D_ARRAY),H.isData3DTexture&&(we=r.TEXTURE_3D);const be=le(j,H),Me=H.source;t.bindTexture(we,j.__webglTexture,r.TEXTURE0+ne);const Fe=n.get(Me);if(Me.version!==Fe.__version||be===!0){t.activeTexture(r.TEXTURE0+ne),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,H.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,H.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE);const Ue=b(H)&&E(H.image)===!1;let xe=w(H.image,Ue,!1,u);xe=He(H,xe);const Be=E(xe)||a,$e=s.convert(H.format,H.colorSpace);let Ve=s.convert(H.type),Oe=P(H.internalFormat,$e,Ve,H.colorSpace);ce(we,H,Be);let We;const nt=H.mipmaps,pt=a&&H.isVideoTexture!==!0,re=Fe.__version===void 0||be===!0,ze=C(H,xe,Be);if(H.isDepthTexture)Oe=r.DEPTH_COMPONENT,a?H.type===rs?Oe=r.DEPTH_COMPONENT32F:H.type===Ns?Oe=r.DEPTH_COMPONENT24:H.type===mo?Oe=r.DEPTH24_STENCIL8:Oe=r.DEPTH_COMPONENT16:H.type===rs&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),H.format===go&&Oe===r.DEPTH_COMPONENT&&H.type!==Kd&&H.type!==Ns&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),H.type=Ns,Ve=s.convert(H.type)),H.format===xa&&Oe===r.DEPTH_COMPONENT&&(Oe=r.DEPTH_STENCIL,H.type!==mo&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),H.type=mo,Ve=s.convert(H.type))),re&&(pt?t.texStorage2D(r.TEXTURE_2D,1,Oe,xe.width,xe.height):t.texImage2D(r.TEXTURE_2D,0,Oe,xe.width,xe.height,0,$e,Ve,null));else if(H.isDataTexture)if(nt.length>0&&Be){pt&&re&&t.texStorage2D(r.TEXTURE_2D,ze,Oe,nt[0].width,nt[0].height);for(let ve=0,Ge=nt.length;ve<Ge;ve++)We=nt[ve],pt?t.texSubImage2D(r.TEXTURE_2D,ve,0,0,We.width,We.height,$e,Ve,We.data):t.texImage2D(r.TEXTURE_2D,ve,Oe,We.width,We.height,0,$e,Ve,We.data);H.generateMipmaps=!1}else pt?(re&&t.texStorage2D(r.TEXTURE_2D,ze,Oe,xe.width,xe.height),t.texSubImage2D(r.TEXTURE_2D,0,0,0,xe.width,xe.height,$e,Ve,xe.data)):t.texImage2D(r.TEXTURE_2D,0,Oe,xe.width,xe.height,0,$e,Ve,xe.data);else if(H.isCompressedTexture)if(H.isCompressedArrayTexture){pt&&re&&t.texStorage3D(r.TEXTURE_2D_ARRAY,ze,Oe,nt[0].width,nt[0].height,xe.depth);for(let ve=0,Ge=nt.length;ve<Ge;ve++)We=nt[ve],H.format!==Bi?$e!==null?pt?t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,ve,0,0,0,We.width,We.height,xe.depth,$e,We.data,0,0):t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,ve,Oe,We.width,We.height,xe.depth,0,We.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pt?t.texSubImage3D(r.TEXTURE_2D_ARRAY,ve,0,0,0,We.width,We.height,xe.depth,$e,Ve,We.data):t.texImage3D(r.TEXTURE_2D_ARRAY,ve,Oe,We.width,We.height,xe.depth,0,$e,Ve,We.data)}else{pt&&re&&t.texStorage2D(r.TEXTURE_2D,ze,Oe,nt[0].width,nt[0].height);for(let ve=0,Ge=nt.length;ve<Ge;ve++)We=nt[ve],H.format!==Bi?$e!==null?pt?t.compressedTexSubImage2D(r.TEXTURE_2D,ve,0,0,We.width,We.height,$e,We.data):t.compressedTexImage2D(r.TEXTURE_2D,ve,Oe,We.width,We.height,0,We.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pt?t.texSubImage2D(r.TEXTURE_2D,ve,0,0,We.width,We.height,$e,Ve,We.data):t.texImage2D(r.TEXTURE_2D,ve,Oe,We.width,We.height,0,$e,Ve,We.data)}else if(H.isDataArrayTexture)pt?(re&&t.texStorage3D(r.TEXTURE_2D_ARRAY,ze,Oe,xe.width,xe.height,xe.depth),t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,xe.width,xe.height,xe.depth,$e,Ve,xe.data)):t.texImage3D(r.TEXTURE_2D_ARRAY,0,Oe,xe.width,xe.height,xe.depth,0,$e,Ve,xe.data);else if(H.isData3DTexture)pt?(re&&t.texStorage3D(r.TEXTURE_3D,ze,Oe,xe.width,xe.height,xe.depth),t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,xe.width,xe.height,xe.depth,$e,Ve,xe.data)):t.texImage3D(r.TEXTURE_3D,0,Oe,xe.width,xe.height,xe.depth,0,$e,Ve,xe.data);else if(H.isFramebufferTexture){if(re)if(pt)t.texStorage2D(r.TEXTURE_2D,ze,Oe,xe.width,xe.height);else{let ve=xe.width,Ge=xe.height;for(let Ye=0;Ye<ze;Ye++)t.texImage2D(r.TEXTURE_2D,Ye,Oe,ve,Ge,0,$e,Ve,null),ve>>=1,Ge>>=1}}else if(nt.length>0&&Be){pt&&re&&t.texStorage2D(r.TEXTURE_2D,ze,Oe,nt[0].width,nt[0].height);for(let ve=0,Ge=nt.length;ve<Ge;ve++)We=nt[ve],pt?t.texSubImage2D(r.TEXTURE_2D,ve,0,0,$e,Ve,We):t.texImage2D(r.TEXTURE_2D,ve,Oe,$e,Ve,We);H.generateMipmaps=!1}else pt?(re&&t.texStorage2D(r.TEXTURE_2D,ze,Oe,xe.width,xe.height),t.texSubImage2D(r.TEXTURE_2D,0,0,0,$e,Ve,xe)):t.texImage2D(r.TEXTURE_2D,0,Oe,$e,Ve,xe);M(H,Be)&&A(we),Fe.__version=Me.version,H.onUpdate&&H.onUpdate(H)}j.__version=H.version}function Ee(j,H,ne){if(H.image.length!==6)return;const we=le(j,H),be=H.source;t.bindTexture(r.TEXTURE_CUBE_MAP,j.__webglTexture,r.TEXTURE0+ne);const Me=n.get(be);if(be.version!==Me.__version||we===!0){t.activeTexture(r.TEXTURE0+ne),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,H.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,H.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE);const Fe=H.isCompressedTexture||H.image[0].isCompressedTexture,Ue=H.image[0]&&H.image[0].isDataTexture,xe=[];for(let ve=0;ve<6;ve++)!Fe&&!Ue?xe[ve]=w(H.image[ve],!1,!0,c):xe[ve]=Ue?H.image[ve].image:H.image[ve],xe[ve]=He(H,xe[ve]);const Be=xe[0],$e=E(Be)||a,Ve=s.convert(H.format,H.colorSpace),Oe=s.convert(H.type),We=P(H.internalFormat,Ve,Oe,H.colorSpace),nt=a&&H.isVideoTexture!==!0,pt=Me.__version===void 0||we===!0;let re=C(H,Be,$e);ce(r.TEXTURE_CUBE_MAP,H,$e);let ze;if(Fe){nt&&pt&&t.texStorage2D(r.TEXTURE_CUBE_MAP,re,We,Be.width,Be.height);for(let ve=0;ve<6;ve++){ze=xe[ve].mipmaps;for(let Ge=0;Ge<ze.length;Ge++){const Ye=ze[Ge];H.format!==Bi?Ve!==null?nt?t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Ge,0,0,Ye.width,Ye.height,Ve,Ye.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Ge,We,Ye.width,Ye.height,0,Ye.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):nt?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Ge,0,0,Ye.width,Ye.height,Ve,Oe,Ye.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Ge,We,Ye.width,Ye.height,0,Ve,Oe,Ye.data)}}}else{ze=H.mipmaps,nt&&pt&&(ze.length>0&&re++,t.texStorage2D(r.TEXTURE_CUBE_MAP,re,We,xe[0].width,xe[0].height));for(let ve=0;ve<6;ve++)if(Ue){nt?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,xe[ve].width,xe[ve].height,Ve,Oe,xe[ve].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,We,xe[ve].width,xe[ve].height,0,Ve,Oe,xe[ve].data);for(let Ge=0;Ge<ze.length;Ge++){const _t=ze[Ge].image[ve].image;nt?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Ge+1,0,0,_t.width,_t.height,Ve,Oe,_t.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Ge+1,We,_t.width,_t.height,0,Ve,Oe,_t.data)}}else{nt?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,Ve,Oe,xe[ve]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,We,Ve,Oe,xe[ve]);for(let Ge=0;Ge<ze.length;Ge++){const Ye=ze[Ge];nt?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Ge+1,0,0,Ve,Oe,Ye.image[ve]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Ge+1,We,Ve,Oe,Ye.image[ve])}}}M(H,$e)&&A(r.TEXTURE_CUBE_MAP),Me.__version=be.version,H.onUpdate&&H.onUpdate(H)}j.__version=H.version}function ae(j,H,ne,we,be){const Me=s.convert(ne.format,ne.colorSpace),Fe=s.convert(ne.type),Ue=P(ne.internalFormat,Me,Fe,ne.colorSpace);n.get(H).__hasExternalTextures||(be===r.TEXTURE_3D||be===r.TEXTURE_2D_ARRAY?t.texImage3D(be,0,Ue,H.width,H.height,H.depth,0,Me,Fe,null):t.texImage2D(be,0,Ue,H.width,H.height,0,Me,Fe,null)),t.bindFramebuffer(r.FRAMEBUFFER,j),Le(H)?p.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,we,be,n.get(ne).__webglTexture,0,Se(H)):(be===r.TEXTURE_2D||be>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&be<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,we,be,n.get(ne).__webglTexture,0),t.bindFramebuffer(r.FRAMEBUFFER,null)}function z(j,H,ne){if(r.bindRenderbuffer(r.RENDERBUFFER,j),H.depthBuffer&&!H.stencilBuffer){let we=r.DEPTH_COMPONENT16;if(ne||Le(H)){const be=H.depthTexture;be&&be.isDepthTexture&&(be.type===rs?we=r.DEPTH_COMPONENT32F:be.type===Ns&&(we=r.DEPTH_COMPONENT24));const Me=Se(H);Le(H)?p.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Me,we,H.width,H.height):r.renderbufferStorageMultisample(r.RENDERBUFFER,Me,we,H.width,H.height)}else r.renderbufferStorage(r.RENDERBUFFER,we,H.width,H.height);r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,j)}else if(H.depthBuffer&&H.stencilBuffer){const we=Se(H);ne&&Le(H)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,we,r.DEPTH24_STENCIL8,H.width,H.height):Le(H)?p.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,we,r.DEPTH24_STENCIL8,H.width,H.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,H.width,H.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,j)}else{const we=H.isWebGLMultipleRenderTargets===!0?H.texture:[H.texture];for(let be=0;be<we.length;be++){const Me=we[be],Fe=s.convert(Me.format,Me.colorSpace),Ue=s.convert(Me.type),xe=P(Me.internalFormat,Fe,Ue,Me.colorSpace),Be=Se(H);ne&&Le(H)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,Be,xe,H.width,H.height):Le(H)?p.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Be,xe,H.width,H.height):r.renderbufferStorage(r.RENDERBUFFER,xe,H.width,H.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function oe(j,H){if(H&&H.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(r.FRAMEBUFFER,j),!(H.depthTexture&&H.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(H.depthTexture).__webglTexture||H.depthTexture.image.width!==H.width||H.depthTexture.image.height!==H.height)&&(H.depthTexture.image.width=H.width,H.depthTexture.image.height=H.height,H.depthTexture.needsUpdate=!0),B(H.depthTexture,0);const we=n.get(H.depthTexture).__webglTexture,be=Se(H);if(H.depthTexture.format===go)Le(H)?p.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,we,0,be):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,we,0);else if(H.depthTexture.format===xa)Le(H)?p.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,we,0,be):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,we,0);else throw new Error("Unknown depthTexture format")}function te(j){const H=n.get(j),ne=j.isWebGLCubeRenderTarget===!0;if(j.depthTexture&&!H.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");oe(H.__webglFramebuffer,j)}else if(ne){H.__webglDepthbuffer=[];for(let we=0;we<6;we++)t.bindFramebuffer(r.FRAMEBUFFER,H.__webglFramebuffer[we]),H.__webglDepthbuffer[we]=r.createRenderbuffer(),z(H.__webglDepthbuffer[we],j,!1)}else t.bindFramebuffer(r.FRAMEBUFFER,H.__webglFramebuffer),H.__webglDepthbuffer=r.createRenderbuffer(),z(H.__webglDepthbuffer,j,!1);t.bindFramebuffer(r.FRAMEBUFFER,null)}function se(j,H,ne){const we=n.get(j);H!==void 0&&ae(we.__webglFramebuffer,j,j.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D),ne!==void 0&&te(j)}function $(j){const H=j.texture,ne=n.get(j),we=n.get(H);j.addEventListener("dispose",N),j.isWebGLMultipleRenderTargets!==!0&&(we.__webglTexture===void 0&&(we.__webglTexture=r.createTexture()),we.__version=H.version,o.memory.textures++);const be=j.isWebGLCubeRenderTarget===!0,Me=j.isWebGLMultipleRenderTargets===!0,Fe=E(j)||a;if(be){ne.__webglFramebuffer=[];for(let Ue=0;Ue<6;Ue++)ne.__webglFramebuffer[Ue]=r.createFramebuffer()}else{if(ne.__webglFramebuffer=r.createFramebuffer(),Me)if(i.drawBuffers){const Ue=j.texture;for(let xe=0,Be=Ue.length;xe<Be;xe++){const $e=n.get(Ue[xe]);$e.__webglTexture===void 0&&($e.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&j.samples>0&&Le(j)===!1){const Ue=Me?H:[H];ne.__webglMultisampledFramebuffer=r.createFramebuffer(),ne.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let xe=0;xe<Ue.length;xe++){const Be=Ue[xe];ne.__webglColorRenderbuffer[xe]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,ne.__webglColorRenderbuffer[xe]);const $e=s.convert(Be.format,Be.colorSpace),Ve=s.convert(Be.type),Oe=P(Be.internalFormat,$e,Ve,Be.colorSpace,j.isXRRenderTarget===!0),We=Se(j);r.renderbufferStorageMultisample(r.RENDERBUFFER,We,Oe,j.width,j.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+xe,r.RENDERBUFFER,ne.__webglColorRenderbuffer[xe])}r.bindRenderbuffer(r.RENDERBUFFER,null),j.depthBuffer&&(ne.__webglDepthRenderbuffer=r.createRenderbuffer(),z(ne.__webglDepthRenderbuffer,j,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(be){t.bindTexture(r.TEXTURE_CUBE_MAP,we.__webglTexture),ce(r.TEXTURE_CUBE_MAP,H,Fe);for(let Ue=0;Ue<6;Ue++)ae(ne.__webglFramebuffer[Ue],j,H,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+Ue);M(H,Fe)&&A(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Me){const Ue=j.texture;for(let xe=0,Be=Ue.length;xe<Be;xe++){const $e=Ue[xe],Ve=n.get($e);t.bindTexture(r.TEXTURE_2D,Ve.__webglTexture),ce(r.TEXTURE_2D,$e,Fe),ae(ne.__webglFramebuffer,j,$e,r.COLOR_ATTACHMENT0+xe,r.TEXTURE_2D),M($e,Fe)&&A(r.TEXTURE_2D)}t.unbindTexture()}else{let Ue=r.TEXTURE_2D;(j.isWebGL3DRenderTarget||j.isWebGLArrayRenderTarget)&&(a?Ue=j.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(Ue,we.__webglTexture),ce(Ue,H,Fe),ae(ne.__webglFramebuffer,j,H,r.COLOR_ATTACHMENT0,Ue),M(H,Fe)&&A(Ue),t.unbindTexture()}j.depthBuffer&&te(j)}function Ie(j){const H=E(j)||a,ne=j.isWebGLMultipleRenderTargets===!0?j.texture:[j.texture];for(let we=0,be=ne.length;we<be;we++){const Me=ne[we];if(M(Me,H)){const Fe=j.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D,Ue=n.get(Me).__webglTexture;t.bindTexture(Fe,Ue),A(Fe),t.unbindTexture()}}}function de(j){if(a&&j.samples>0&&Le(j)===!1){const H=j.isWebGLMultipleRenderTargets?j.texture:[j.texture],ne=j.width,we=j.height;let be=r.COLOR_BUFFER_BIT;const Me=[],Fe=j.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Ue=n.get(j),xe=j.isWebGLMultipleRenderTargets===!0;if(xe)for(let Be=0;Be<H.length;Be++)t.bindFramebuffer(r.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Be,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,Ue.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Be,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Ue.__webglFramebuffer);for(let Be=0;Be<H.length;Be++){Me.push(r.COLOR_ATTACHMENT0+Be),j.depthBuffer&&Me.push(Fe);const $e=Ue.__ignoreDepthValues!==void 0?Ue.__ignoreDepthValues:!1;if($e===!1&&(j.depthBuffer&&(be|=r.DEPTH_BUFFER_BIT),j.stencilBuffer&&(be|=r.STENCIL_BUFFER_BIT)),xe&&r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,Ue.__webglColorRenderbuffer[Be]),$e===!0&&(r.invalidateFramebuffer(r.READ_FRAMEBUFFER,[Fe]),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[Fe])),xe){const Ve=n.get(H[Be]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,Ve,0)}r.blitFramebuffer(0,0,ne,we,0,0,ne,we,be,r.NEAREST),m&&r.invalidateFramebuffer(r.READ_FRAMEBUFFER,Me)}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),xe)for(let Be=0;Be<H.length;Be++){t.bindFramebuffer(r.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Be,r.RENDERBUFFER,Ue.__webglColorRenderbuffer[Be]);const $e=n.get(H[Be]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,Ue.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Be,r.TEXTURE_2D,$e,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer)}}function Se(j){return Math.min(h,j.samples)}function Le(j){const H=n.get(j);return a&&j.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&H.__useRenderToTexture!==!1}function ge(j){const H=o.render.frame;v.get(j)!==H&&(v.set(j,H),j.update())}function He(j,H){const ne=j.colorSpace,we=j.format,be=j.type;return j.isCompressedTexture===!0||j.format===Dd||ne!==Br&&ne!==yo&&(ne===Mt?a===!1?e.has("EXT_sRGB")===!0&&we===Bi?(j.format=Dd,j.minFilter=fn,j.generateMipmaps=!1):H=ry.sRGBToLinear(H):(we!==Bi||be!==os)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ne)),H}this.allocateTextureUnit=k,this.resetTextureUnits=O,this.setTexture2D=B,this.setTexture2DArray=D,this.setTexture3D=V,this.setTextureCube=Z,this.rebindTextures=se,this.setupRenderTarget=$,this.updateRenderTargetMipmap=Ie,this.updateMultisampleRenderTarget=de,this.setupDepthRenderbuffer=te,this.setupFrameBufferTexture=ae,this.useMultisampledRTT=Le}function gM(r,e,t){const n=t.isWebGL2;function i(s,o=yo){let a;if(s===os)return r.UNSIGNED_BYTE;if(s===qv)return r.UNSIGNED_SHORT_4_4_4_4;if(s===Zv)return r.UNSIGNED_SHORT_5_5_5_1;if(s===Nb)return r.BYTE;if(s===Fb)return r.SHORT;if(s===Kd)return r.UNSIGNED_SHORT;if(s===Yv)return r.INT;if(s===Ns)return r.UNSIGNED_INT;if(s===rs)return r.FLOAT;if(s===Vl)return n?r.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===kb)return r.ALPHA;if(s===Bi)return r.RGBA;if(s===zb)return r.LUMINANCE;if(s===Bb)return r.LUMINANCE_ALPHA;if(s===go)return r.DEPTH_COMPONENT;if(s===xa)return r.DEPTH_STENCIL;if(s===Dd)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===Gb)return r.RED;if(s===Kv)return r.RED_INTEGER;if(s===Hb)return r.RG;if(s===$v)return r.RG_INTEGER;if(s===Jv)return r.RGBA_INTEGER;if(s===vd||s===yd||s===_d||s===xd)if(o===Mt)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===vd)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===yd)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===_d)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===xd)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===vd)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===yd)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===_d)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===xd)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===F0||s===k0||s===z0||s===B0)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===F0)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===k0)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===z0)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===B0)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Vb)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===G0||s===H0)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===G0)return o===Mt?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===H0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===V0||s===W0||s===X0||s===j0||s===Y0||s===q0||s===Z0||s===K0||s===$0||s===J0||s===Q0||s===ev||s===tv||s===nv)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===V0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===W0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===X0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===j0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Y0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===q0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Z0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===K0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===$0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===J0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Q0)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===ev)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===tv)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===nv)return o===Mt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===wd)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===wd)return o===Mt?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===Wb||s===iv||s===rv||s===sv)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===wd)return a.COMPRESSED_RED_RGTC1_EXT;if(s===iv)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===rv)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===sv)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===mo?n?r.UNSIGNED_INT_24_8:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}class vM extends zn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Ol extends jt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const qD={type:"move"};class tg{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ol,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ol,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Y,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Y),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ol,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Y,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Y),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const _ of e.hand.values()){const y=t.getJointPose(_,n),g=this._getHandJoint(c,_);y!==null&&(g.matrix.fromArray(y.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=y.radius),g.visible=y!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],p=u.position.distanceTo(h.position),m=.02,v=.005;c.inputState.pinching&&p>m+v?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=m-v&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(qD)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Ol;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class yM extends Sn{constructor(e,t,n,i,s,o,a,l,c,u){if(u=u!==void 0?u:go,u!==go&&u!==xa)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===go&&(n=Ns),n===void 0&&u===xa&&(n=mo),super(null,i,s,o,a,l,u,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Dn,this.minFilter=l!==void 0?l:Dn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class ZD extends Hs{constructor(e,t){super();const n=this;let i=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,p=null,m=null,v=null;const _=t.getContextAttributes();let y=null,g=null;const x=[],w=[],E=new zn;E.layers.enable(1),E.viewport=new Xt;const b=new zn;b.layers.enable(2),b.viewport=new Xt;const M=[E,b],A=new vM;A.layers.enable(1),A.layers.enable(2);let P=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(D){let V=x[D];return V===void 0&&(V=new tg,x[D]=V),V.getTargetRaySpace()},this.getControllerGrip=function(D){let V=x[D];return V===void 0&&(V=new tg,x[D]=V),V.getGripSpace()},this.getHand=function(D){let V=x[D];return V===void 0&&(V=new tg,x[D]=V),V.getHandSpace()};function L(D){const V=w.indexOf(D.inputSource);if(V===-1)return;const Z=x[V];Z!==void 0&&(Z.update(D.inputSource,D.frame,c||o),Z.dispatchEvent({type:D.type,data:D.inputSource}))}function F(){i.removeEventListener("select",L),i.removeEventListener("selectstart",L),i.removeEventListener("selectend",L),i.removeEventListener("squeeze",L),i.removeEventListener("squeezestart",L),i.removeEventListener("squeezeend",L),i.removeEventListener("end",F),i.removeEventListener("inputsourceschange",N);for(let D=0;D<x.length;D++){const V=w[D];V!==null&&(w[D]=null,x[D].disconnect(V))}P=null,C=null,e.setRenderTarget(y),m=null,p=null,h=null,i=null,g=null,B.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(D){s=D,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(D){a=D,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(D){c=D},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return h},this.getFrame=function(){return v},this.getSession=function(){return i},this.setSession=async function(D){if(i=D,i!==null){if(y=e.getRenderTarget(),i.addEventListener("select",L),i.addEventListener("selectstart",L),i.addEventListener("selectend",L),i.addEventListener("squeeze",L),i.addEventListener("squeezestart",L),i.addEventListener("squeezeend",L),i.addEventListener("end",F),i.addEventListener("inputsourceschange",N),_.xrCompatible!==!0&&await t.makeXRCompatible(),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const V={antialias:i.renderState.layers===void 0?_.antialias:!0,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,t,V),i.updateRenderState({baseLayer:m}),g=new Gr(m.framebufferWidth,m.framebufferHeight,{format:Bi,type:os,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil})}else{let V=null,Z=null,ee=null;_.depth&&(ee=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,V=_.stencil?xa:go,Z=_.stencil?mo:Ns);const ie={colorFormat:t.RGBA8,depthFormat:ee,scaleFactor:s};h=new XRWebGLBinding(i,t),p=h.createProjectionLayer(ie),i.updateRenderState({layers:[p]}),g=new Gr(p.textureWidth,p.textureHeight,{format:Bi,type:os,depthTexture:new yM(p.textureWidth,p.textureHeight,Z,void 0,void 0,void 0,void 0,void 0,void 0,V),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0});const ue=e.properties.get(g);ue.__ignoreDepthValues=p.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await i.requestReferenceSpace(a),B.setContext(i),B.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function N(D){for(let V=0;V<D.removed.length;V++){const Z=D.removed[V],ee=w.indexOf(Z);ee>=0&&(w[ee]=null,x[ee].disconnect(Z))}for(let V=0;V<D.added.length;V++){const Z=D.added[V];let ee=w.indexOf(Z);if(ee===-1){for(let ue=0;ue<x.length;ue++)if(ue>=w.length){w.push(Z),ee=ue;break}else if(w[ue]===null){w[ue]=Z,ee=ue;break}if(ee===-1)break}const ie=x[ee];ie&&ie.connect(Z)}}const I=new Y,X=new Y;function q(D,V,Z){I.setFromMatrixPosition(V.matrixWorld),X.setFromMatrixPosition(Z.matrixWorld);const ee=I.distanceTo(X),ie=V.projectionMatrix.elements,ue=Z.projectionMatrix.elements,ce=ie[14]/(ie[10]-1),le=ie[14]/(ie[10]+1),Ae=(ie[9]+1)/ie[5],Ee=(ie[9]-1)/ie[5],ae=(ie[8]-1)/ie[0],z=(ue[8]+1)/ue[0],oe=ce*ae,te=ce*z,se=ee/(-ae+z),$=se*-ae;V.matrixWorld.decompose(D.position,D.quaternion,D.scale),D.translateX($),D.translateZ(se),D.matrixWorld.compose(D.position,D.quaternion,D.scale),D.matrixWorldInverse.copy(D.matrixWorld).invert();const Ie=ce+se,de=le+se,Se=oe-$,Le=te+(ee-$),ge=Ae*le/de*Ie,He=Ee*le/de*Ie;D.projectionMatrix.makePerspective(Se,Le,ge,He,Ie,de),D.projectionMatrixInverse.copy(D.projectionMatrix).invert()}function W(D,V){V===null?D.matrixWorld.copy(D.matrix):D.matrixWorld.multiplyMatrices(V.matrixWorld,D.matrix),D.matrixWorldInverse.copy(D.matrixWorld).invert()}this.updateCamera=function(D){if(i===null)return;A.near=b.near=E.near=D.near,A.far=b.far=E.far=D.far,(P!==A.near||C!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),P=A.near,C=A.far);const V=D.parent,Z=A.cameras;W(A,V);for(let ee=0;ee<Z.length;ee++)W(Z[ee],V);Z.length===2?q(A,E,b):A.projectionMatrix.copy(E.projectionMatrix),O(D,A,V)};function O(D,V,Z){Z===null?D.matrix.copy(V.matrixWorld):(D.matrix.copy(Z.matrixWorld),D.matrix.invert(),D.matrix.multiply(V.matrixWorld)),D.matrix.decompose(D.position,D.quaternion,D.scale),D.updateMatrixWorld(!0);const ee=D.children;for(let ie=0,ue=ee.length;ie<ue;ie++)ee[ie].updateMatrixWorld(!0);D.projectionMatrix.copy(V.projectionMatrix),D.projectionMatrixInverse.copy(V.projectionMatrixInverse),D.isPerspectiveCamera&&(D.fov=Wl*2*Math.atan(1/D.projectionMatrix.elements[5]),D.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(p===null&&m===null))return l},this.setFoveation=function(D){l=D,p!==null&&(p.fixedFoveation=D),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=D)};let k=null;function G(D,V){if(u=V.getViewerPose(c||o),v=V,u!==null){const Z=u.views;m!==null&&(e.setRenderTargetFramebuffer(g,m.framebuffer),e.setRenderTarget(g));let ee=!1;Z.length!==A.cameras.length&&(A.cameras.length=0,ee=!0);for(let ie=0;ie<Z.length;ie++){const ue=Z[ie];let ce=null;if(m!==null)ce=m.getViewport(ue);else{const Ae=h.getViewSubImage(p,ue);ce=Ae.viewport,ie===0&&(e.setRenderTargetTextures(g,Ae.colorTexture,p.ignoreDepthValues?void 0:Ae.depthStencilTexture),e.setRenderTarget(g))}let le=M[ie];le===void 0&&(le=new zn,le.layers.enable(ie),le.viewport=new Xt,M[ie]=le),le.matrix.fromArray(ue.transform.matrix),le.matrix.decompose(le.position,le.quaternion,le.scale),le.projectionMatrix.fromArray(ue.projectionMatrix),le.projectionMatrixInverse.copy(le.projectionMatrix).invert(),le.viewport.set(ce.x,ce.y,ce.width,ce.height),ie===0&&(A.matrix.copy(le.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),ee===!0&&A.cameras.push(le)}}for(let Z=0;Z<x.length;Z++){const ee=w[Z],ie=x[Z];ee!==null&&ie!==void 0&&ie.update(ee,V,c||o)}k&&k(D,V),V.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:V}),v=null}const B=new hM;B.setAnimationLoop(G),this.setAnimationLoop=function(D){k=D},this.dispose=function(){}}}function KD(r,e){function t(y,g){y.matrixAutoUpdate===!0&&y.updateMatrix(),g.value.copy(y.matrix)}function n(y,g){g.color.getRGB(y.fogColor.value,lM(r)),g.isFog?(y.fogNear.value=g.near,y.fogFar.value=g.far):g.isFogExp2&&(y.fogDensity.value=g.density)}function i(y,g,x,w,E){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(y,g):g.isMeshToonMaterial?(s(y,g),h(y,g)):g.isMeshPhongMaterial?(s(y,g),u(y,g)):g.isMeshStandardMaterial?(s(y,g),p(y,g),g.isMeshPhysicalMaterial&&m(y,g,E)):g.isMeshMatcapMaterial?(s(y,g),v(y,g)):g.isMeshDepthMaterial?s(y,g):g.isMeshDistanceMaterial?(s(y,g),_(y,g)):g.isMeshNormalMaterial?s(y,g):g.isLineBasicMaterial?(o(y,g),g.isLineDashedMaterial&&a(y,g)):g.isPointsMaterial?l(y,g,x,w):g.isSpriteMaterial?c(y,g):g.isShadowMaterial?(y.color.value.copy(g.color),y.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(y,g){y.opacity.value=g.opacity,g.color&&y.diffuse.value.copy(g.color),g.emissive&&y.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(y.map.value=g.map,t(g.map,y.mapTransform)),g.alphaMap&&(y.alphaMap.value=g.alphaMap,t(g.alphaMap,y.alphaMapTransform)),g.bumpMap&&(y.bumpMap.value=g.bumpMap,t(g.bumpMap,y.bumpMapTransform),y.bumpScale.value=g.bumpScale,g.side===yi&&(y.bumpScale.value*=-1)),g.normalMap&&(y.normalMap.value=g.normalMap,t(g.normalMap,y.normalMapTransform),y.normalScale.value.copy(g.normalScale),g.side===yi&&y.normalScale.value.negate()),g.displacementMap&&(y.displacementMap.value=g.displacementMap,t(g.displacementMap,y.displacementMapTransform),y.displacementScale.value=g.displacementScale,y.displacementBias.value=g.displacementBias),g.emissiveMap&&(y.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,y.emissiveMapTransform)),g.specularMap&&(y.specularMap.value=g.specularMap,t(g.specularMap,y.specularMapTransform)),g.alphaTest>0&&(y.alphaTest.value=g.alphaTest);const x=e.get(g).envMap;if(x&&(y.envMap.value=x,y.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=g.reflectivity,y.ior.value=g.ior,y.refractionRatio.value=g.refractionRatio),g.lightMap){y.lightMap.value=g.lightMap;const w=r.useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=g.lightMapIntensity*w,t(g.lightMap,y.lightMapTransform)}g.aoMap&&(y.aoMap.value=g.aoMap,y.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,y.aoMapTransform))}function o(y,g){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity,g.map&&(y.map.value=g.map,t(g.map,y.mapTransform))}function a(y,g){y.dashSize.value=g.dashSize,y.totalSize.value=g.dashSize+g.gapSize,y.scale.value=g.scale}function l(y,g,x,w){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity,y.size.value=g.size*x,y.scale.value=w*.5,g.map&&(y.map.value=g.map,t(g.map,y.uvTransform)),g.alphaMap&&(y.alphaMap.value=g.alphaMap,t(g.alphaMap,y.alphaMapTransform)),g.alphaTest>0&&(y.alphaTest.value=g.alphaTest)}function c(y,g){y.diffuse.value.copy(g.color),y.opacity.value=g.opacity,y.rotation.value=g.rotation,g.map&&(y.map.value=g.map,t(g.map,y.mapTransform)),g.alphaMap&&(y.alphaMap.value=g.alphaMap,t(g.alphaMap,y.alphaMapTransform)),g.alphaTest>0&&(y.alphaTest.value=g.alphaTest)}function u(y,g){y.specular.value.copy(g.specular),y.shininess.value=Math.max(g.shininess,1e-4)}function h(y,g){g.gradientMap&&(y.gradientMap.value=g.gradientMap)}function p(y,g){y.metalness.value=g.metalness,g.metalnessMap&&(y.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,y.metalnessMapTransform)),y.roughness.value=g.roughness,g.roughnessMap&&(y.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,y.roughnessMapTransform)),e.get(g).envMap&&(y.envMapIntensity.value=g.envMapIntensity)}function m(y,g,x){y.ior.value=g.ior,g.sheen>0&&(y.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),y.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(y.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,y.sheenColorMapTransform)),g.sheenRoughnessMap&&(y.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,y.sheenRoughnessMapTransform))),g.clearcoat>0&&(y.clearcoat.value=g.clearcoat,y.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(y.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,y.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(y.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===yi&&y.clearcoatNormalScale.value.negate())),g.iridescence>0&&(y.iridescence.value=g.iridescence,y.iridescenceIOR.value=g.iridescenceIOR,y.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(y.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,y.iridescenceMapTransform)),g.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),g.transmission>0&&(y.transmission.value=g.transmission,y.transmissionSamplerMap.value=x.texture,y.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(y.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,y.transmissionMapTransform)),y.thickness.value=g.thickness,g.thicknessMap&&(y.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=g.attenuationDistance,y.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(y.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(y.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=g.specularIntensity,y.specularColor.value.copy(g.specularColor),g.specularColorMap&&(y.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,y.specularColorMapTransform)),g.specularIntensityMap&&(y.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,y.specularIntensityMapTransform))}function v(y,g){g.matcap&&(y.matcap.value=g.matcap)}function _(y,g){const x=e.get(g).light;y.referencePosition.value.setFromMatrixPosition(x.matrixWorld),y.nearDistance.value=x.shadow.camera.near,y.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function $D(r,e,t,n){let i={},s={},o=[];const a=t.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(x,w){const E=w.program;n.uniformBlockBinding(x,E)}function c(x,w){let E=i[x.id];E===void 0&&(v(x),E=u(x),i[x.id]=E,x.addEventListener("dispose",y));const b=w.program;n.updateUBOMapping(x,b);const M=e.render.frame;s[x.id]!==M&&(p(x),s[x.id]=M)}function u(x){const w=h();x.__bindingPointIndex=w;const E=r.createBuffer(),b=x.__size,M=x.usage;return r.bindBuffer(r.UNIFORM_BUFFER,E),r.bufferData(r.UNIFORM_BUFFER,b,M),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,w,E),E}function h(){for(let x=0;x<a;x++)if(o.indexOf(x)===-1)return o.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(x){const w=i[x.id],E=x.uniforms,b=x.__cache;r.bindBuffer(r.UNIFORM_BUFFER,w);for(let M=0,A=E.length;M<A;M++){const P=E[M];if(m(P,M,b)===!0){const C=P.__offset,L=Array.isArray(P.value)?P.value:[P.value];let F=0;for(let N=0;N<L.length;N++){const I=L[N],X=_(I);typeof I=="number"?(P.__data[0]=I,r.bufferSubData(r.UNIFORM_BUFFER,C+F,P.__data)):I.isMatrix3?(P.__data[0]=I.elements[0],P.__data[1]=I.elements[1],P.__data[2]=I.elements[2],P.__data[3]=I.elements[0],P.__data[4]=I.elements[3],P.__data[5]=I.elements[4],P.__data[6]=I.elements[5],P.__data[7]=I.elements[0],P.__data[8]=I.elements[6],P.__data[9]=I.elements[7],P.__data[10]=I.elements[8],P.__data[11]=I.elements[0]):(I.toArray(P.__data,F),F+=X.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,C,P.__data)}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function m(x,w,E){const b=x.value;if(E[w]===void 0){if(typeof b=="number")E[w]=b;else{const M=Array.isArray(b)?b:[b],A=[];for(let P=0;P<M.length;P++)A.push(M[P].clone());E[w]=A}return!0}else if(typeof b=="number"){if(E[w]!==b)return E[w]=b,!0}else{const M=Array.isArray(E[w])?E[w]:[E[w]],A=Array.isArray(b)?b:[b];for(let P=0;P<M.length;P++){const C=M[P];if(C.equals(A[P])===!1)return C.copy(A[P]),!0}}return!1}function v(x){const w=x.uniforms;let E=0;const b=16;let M=0;for(let A=0,P=w.length;A<P;A++){const C=w[A],L={boundary:0,storage:0},F=Array.isArray(C.value)?C.value:[C.value];for(let N=0,I=F.length;N<I;N++){const X=F[N],q=_(X);L.boundary+=q.boundary,L.storage+=q.storage}if(C.__data=new Float32Array(L.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=E,A>0){M=E%b;const N=b-M;M!==0&&N-L.boundary<0&&(E+=b-M,C.__offset=E)}E+=L.storage}return M=E%b,M>0&&(E+=b-M),x.__size=E,x.__cache={},this}function _(x){const w={boundary:0,storage:0};return typeof x=="number"?(w.boundary=4,w.storage=4):x.isVector2?(w.boundary=8,w.storage=8):x.isVector3||x.isColor?(w.boundary=16,w.storage=12):x.isVector4?(w.boundary=16,w.storage=16):x.isMatrix3?(w.boundary=48,w.storage=48):x.isMatrix4?(w.boundary=64,w.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),w}function y(x){const w=x.target;w.removeEventListener("dispose",y);const E=o.indexOf(w.__bindingPointIndex);o.splice(E,1),r.deleteBuffer(i[w.id]),delete i[w.id],delete s[w.id]}function g(){for(const x in i)r.deleteBuffer(i[x]);o=[],i={},s={}}return{bind:l,update:c,dispose:g}}function JD(){const r=Fu("canvas");return r.style.display="block",r}class uy{constructor(e={}){const{canvas:t=JD(),context:n=null,depth:i=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let p;n!==null?p=n.getContextAttributes().alpha:p=o;const m=new Uint32Array(4),v=new Int32Array(4);let _=null,y=null;const g=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=Mt,this.useLegacyLights=!0,this.toneMapping=zr,this.toneMappingExposure=1;const w=this;let E=!1,b=0,M=0,A=null,P=-1,C=null;const L=new Xt,F=new Xt;let N=null;const I=new Ke(0);let X=0,q=t.width,W=t.height,O=1,k=null,G=null;const B=new Xt(0,0,q,W),D=new Xt(0,0,q,W);let V=!1;const Z=new oh;let ee=!1,ie=!1,ue=null;const ce=new yt,le=new De,Ae=new Y,Ee={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ae(){return A===null?O:1}let z=n;function oe(J,me){for(let Re=0;Re<J.length;Re++){const pe=J[Re],Pe=t.getContext(pe,me);if(Pe!==null)return Pe}return null}try{const J={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Yd}`),t.addEventListener("webglcontextlost",ze,!1),t.addEventListener("webglcontextrestored",ve,!1),t.addEventListener("webglcontextcreationerror",Ge,!1),z===null){const me=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&me.shift(),z=oe(me,J),z===null)throw oe(me)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&z instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),z.getShaderPrecisionFormat===void 0&&(z.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(J){throw console.error("THREE.WebGLRenderer: "+J.message),J}let te,se,$,Ie,de,Se,Le,ge,He,j,H,ne,we,be,Me,Fe,Ue,xe,Be,$e,Ve,Oe,We,nt;function pt(){te=new dI(z),se=new aI(z,te,e),te.init(se),Oe=new gM(z,te,se),$=new jD(z,te,se),Ie=new gI(z),de=new UD,Se=new YD(z,te,$,de,se,Oe,Ie),Le=new cI(w),ge=new fI(w),He=new TR(z,se),We=new sI(z,te,He,se),j=new pI(z,He,Ie,We),H=new xI(z,j,He,Ie),Be=new _I(z,se,Se),Fe=new lI(de),ne=new DD(w,Le,ge,te,se,We,Fe),we=new KD(w,de),be=new ND,Me=new HD(te,se),xe=new rI(w,Le,ge,$,H,p,l),Ue=new XD(w,H,se),nt=new $D(z,Ie,se,$),$e=new oI(z,te,Ie,se),Ve=new mI(z,te,Ie,se),Ie.programs=ne.programs,w.capabilities=se,w.extensions=te,w.properties=de,w.renderLists=be,w.shadowMap=Ue,w.state=$,w.info=Ie}pt();const re=new ZD(w,z);this.xr=re,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){const J=te.get("WEBGL_lose_context");J&&J.loseContext()},this.forceContextRestore=function(){const J=te.get("WEBGL_lose_context");J&&J.restoreContext()},this.getPixelRatio=function(){return O},this.setPixelRatio=function(J){J!==void 0&&(O=J,this.setSize(q,W,!1))},this.getSize=function(J){return J.set(q,W)},this.setSize=function(J,me,Re=!0){if(re.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}q=J,W=me,t.width=Math.floor(J*O),t.height=Math.floor(me*O),Re===!0&&(t.style.width=J+"px",t.style.height=me+"px"),this.setViewport(0,0,J,me)},this.getDrawingBufferSize=function(J){return J.set(q*O,W*O).floor()},this.setDrawingBufferSize=function(J,me,Re){q=J,W=me,O=Re,t.width=Math.floor(J*Re),t.height=Math.floor(me*Re),this.setViewport(0,0,J,me)},this.getCurrentViewport=function(J){return J.copy(L)},this.getViewport=function(J){return J.copy(B)},this.setViewport=function(J,me,Re,pe){J.isVector4?B.set(J.x,J.y,J.z,J.w):B.set(J,me,Re,pe),$.viewport(L.copy(B).multiplyScalar(O).floor())},this.getScissor=function(J){return J.copy(D)},this.setScissor=function(J,me,Re,pe){J.isVector4?D.set(J.x,J.y,J.z,J.w):D.set(J,me,Re,pe),$.scissor(F.copy(D).multiplyScalar(O).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(J){$.setScissorTest(V=J)},this.setOpaqueSort=function(J){k=J},this.setTransparentSort=function(J){G=J},this.getClearColor=function(J){return J.copy(xe.getClearColor())},this.setClearColor=function(){xe.setClearColor.apply(xe,arguments)},this.getClearAlpha=function(){return xe.getClearAlpha()},this.setClearAlpha=function(){xe.setClearAlpha.apply(xe,arguments)},this.clear=function(J=!0,me=!0,Re=!0){let pe=0;if(J){let Pe=!1;if(A!==null){const it=A.texture.format;Pe=it===Jv||it===$v||it===Kv}if(Pe){const it=A.texture.type,lt=it===os||it===Ns||it===Kd||it===mo||it===qv||it===Zv,ct=xe.getClearColor(),dt=xe.getClearAlpha(),wt=ct.r,ke=ct.g,ut=ct.b;lt?(m[0]=wt,m[1]=ke,m[2]=ut,m[3]=dt,z.clearBufferuiv(z.COLOR,0,m)):(v[0]=wt,v[1]=ke,v[2]=ut,v[3]=dt,z.clearBufferiv(z.COLOR,0,v))}else pe|=z.COLOR_BUFFER_BIT}me&&(pe|=z.DEPTH_BUFFER_BIT),Re&&(pe|=z.STENCIL_BUFFER_BIT),z.clear(pe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",ze,!1),t.removeEventListener("webglcontextrestored",ve,!1),t.removeEventListener("webglcontextcreationerror",Ge,!1),be.dispose(),Me.dispose(),de.dispose(),Le.dispose(),ge.dispose(),H.dispose(),We.dispose(),nt.dispose(),ne.dispose(),re.dispose(),re.removeEventListener("sessionstart",Yt),re.removeEventListener("sessionend",Nt),ue&&(ue.dispose(),ue=null),Rt.stop()};function ze(J){J.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),E=!0}function ve(){console.log("THREE.WebGLRenderer: Context Restored."),E=!1;const J=Ie.autoReset,me=Ue.enabled,Re=Ue.autoUpdate,pe=Ue.needsUpdate,Pe=Ue.type;pt(),Ie.autoReset=J,Ue.enabled=me,Ue.autoUpdate=Re,Ue.needsUpdate=pe,Ue.type=Pe}function Ge(J){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",J.statusMessage)}function Ye(J){const me=J.target;me.removeEventListener("dispose",Ye),_t(me)}function _t(J){It(J),de.remove(J)}function It(J){const me=de.get(J).programs;me!==void 0&&(me.forEach(function(Re){ne.releaseProgram(Re)}),J.isShaderMaterial&&ne.releaseShaderCache(J))}this.renderBufferDirect=function(J,me,Re,pe,Pe,it){me===null&&(me=Ee);const lt=Pe.isMesh&&Pe.matrixWorld.determinant()<0,ct=Gn(J,me,Re,pe,Pe);$.setMaterial(pe,lt);let dt=Re.index,wt=1;pe.wireframe===!0&&(dt=j.getWireframeAttribute(Re),wt=2);const ke=Re.drawRange,ut=Re.attributes.position;let Jt=ke.start*wt,Gt=(ke.start+ke.count)*wt;it!==null&&(Jt=Math.max(Jt,it.start*wt),Gt=Math.min(Gt,(it.start+it.count)*wt)),dt!==null?(Jt=Math.max(Jt,0),Gt=Math.min(Gt,dt.count)):ut!=null&&(Jt=Math.max(Jt,0),Gt=Math.min(Gt,ut.count));const Yn=Gt-Jt;if(Yn<0||Yn===1/0)return;We.setup(Pe,pe,ct,Re,dt);let ci,qt=$e;if(dt!==null&&(ci=He.get(dt),qt=Ve,qt.setIndex(ci)),Pe.isMesh)pe.wireframe===!0?($.setLineWidth(pe.wireframeLinewidth*ae()),qt.setMode(z.LINES)):qt.setMode(z.TRIANGLES);else if(Pe.isLine){let mt=pe.linewidth;mt===void 0&&(mt=1),$.setLineWidth(mt*ae()),Pe.isLineSegments?qt.setMode(z.LINES):Pe.isLineLoop?qt.setMode(z.LINE_LOOP):qt.setMode(z.LINE_STRIP)}else Pe.isPoints?qt.setMode(z.POINTS):Pe.isSprite&&qt.setMode(z.TRIANGLES);if(Pe.isInstancedMesh)qt.renderInstances(Jt,Yn,Pe.count);else if(Re.isInstancedBufferGeometry){const mt=Re._maxInstanceCount!==void 0?Re._maxInstanceCount:1/0,kt=Math.min(Re.instanceCount,mt);qt.renderInstances(Jt,Yn,kt)}else qt.render(Jt,Yn)},this.compile=function(J,me){function Re(pe,Pe,it){pe.transparent===!0&&pe.side===vn&&pe.forceSinglePass===!1?(pe.side=yi,pe.needsUpdate=!0,tn(pe,Pe,it),pe.side=ls,pe.needsUpdate=!0,tn(pe,Pe,it),pe.side=vn):tn(pe,Pe,it)}y=Me.get(J),y.init(),x.push(y),J.traverseVisible(function(pe){pe.isLight&&pe.layers.test(me.layers)&&(y.pushLight(pe),pe.castShadow&&y.pushShadow(pe))}),y.setupLights(w.useLegacyLights),J.traverse(function(pe){const Pe=pe.material;if(Pe)if(Array.isArray(Pe))for(let it=0;it<Pe.length;it++){const lt=Pe[it];Re(lt,J,pe)}else Re(Pe,J,pe)}),x.pop(),y=null};let Ft=null;function Ot(J){Ft&&Ft(J)}function Yt(){Rt.stop()}function Nt(){Rt.start()}const Rt=new hM;Rt.setAnimationLoop(Ot),typeof self<"u"&&Rt.setContext(self),this.setAnimationLoop=function(J){Ft=J,re.setAnimationLoop(J),J===null?Rt.stop():Rt.start()},re.addEventListener("sessionstart",Yt),re.addEventListener("sessionend",Nt),this.render=function(J,me){if(me!==void 0&&me.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(E===!0)return;J.matrixWorldAutoUpdate===!0&&J.updateMatrixWorld(),me.parent===null&&me.matrixWorldAutoUpdate===!0&&me.updateMatrixWorld(),re.enabled===!0&&re.isPresenting===!0&&(re.cameraAutoUpdate===!0&&re.updateCamera(me),me=re.getCamera()),J.isScene===!0&&J.onBeforeRender(w,J,me,A),y=Me.get(J,x.length),y.init(),x.push(y),ce.multiplyMatrices(me.projectionMatrix,me.matrixWorldInverse),Z.setFromProjectionMatrix(ce),ie=this.localClippingEnabled,ee=Fe.init(this.clippingPlanes,ie),_=be.get(J,g.length),_.init(),g.push(_),li(J,me,0,w.sortObjects),_.finish(),w.sortObjects===!0&&_.sort(k,G),this.info.render.frame++,ee===!0&&Fe.beginShadows();const Re=y.state.shadowsArray;if(Ue.render(Re,J,me),ee===!0&&Fe.endShadows(),this.info.autoReset===!0&&this.info.reset(),xe.render(_,J),y.setupLights(w.useLegacyLights),me.isArrayCamera){const pe=me.cameras;for(let Pe=0,it=pe.length;Pe<it;Pe++){const lt=pe[Pe];jn(_,J,lt,lt.viewport)}}else jn(_,J,me);A!==null&&(Se.updateMultisampleRenderTarget(A),Se.updateRenderTargetMipmap(A)),J.isScene===!0&&J.onAfterRender(w,J,me),We.resetDefaultState(),P=-1,C=null,x.pop(),x.length>0?y=x[x.length-1]:y=null,g.pop(),g.length>0?_=g[g.length-1]:_=null};function li(J,me,Re,pe){if(J.visible===!1)return;if(J.layers.test(me.layers)){if(J.isGroup)Re=J.renderOrder;else if(J.isLOD)J.autoUpdate===!0&&J.update(me);else if(J.isLight)y.pushLight(J),J.castShadow&&y.pushShadow(J);else if(J.isSprite){if(!J.frustumCulled||Z.intersectsSprite(J)){pe&&Ae.setFromMatrixPosition(J.matrixWorld).applyMatrix4(ce);const lt=H.update(J),ct=J.material;ct.visible&&_.push(J,lt,ct,Re,Ae.z,null)}}else if((J.isMesh||J.isLine||J.isPoints)&&(!J.frustumCulled||Z.intersectsObject(J))){const lt=H.update(J),ct=J.material;if(pe&&(J.boundingSphere!==void 0?(J.boundingSphere===null&&J.computeBoundingSphere(),Ae.copy(J.boundingSphere.center)):(lt.boundingSphere===null&<.computeBoundingSphere(),Ae.copy(lt.boundingSphere.center)),Ae.applyMatrix4(J.matrixWorld).applyMatrix4(ce)),Array.isArray(ct)){const dt=lt.groups;for(let wt=0,ke=dt.length;wt<ke;wt++){const ut=dt[wt],Jt=ct[ut.materialIndex];Jt&&Jt.visible&&_.push(J,lt,Jt,Re,Ae.z,ut)}}else ct.visible&&_.push(J,lt,ct,Re,Ae.z,null)}}const it=J.children;for(let lt=0,ct=it.length;lt<ct;lt++)li(it[lt],me,Re,pe)}function jn(J,me,Re,pe){const Pe=J.opaque,it=J.transmissive,lt=J.transparent;y.setupLightsView(Re),ee===!0&&Fe.setGlobalState(w.clippingPlanes,Re),it.length>0&&Bt(Pe,it,me,Re),pe&&$.viewport(L.copy(pe)),Pe.length>0&&sn(Pe,me,Re),it.length>0&&sn(it,me,Re),lt.length>0&&sn(lt,me,Re),$.buffers.depth.setTest(!0),$.buffers.depth.setMask(!0),$.buffers.color.setMask(!0),$.setPolygonOffset(!1)}function Bt(J,me,Re,pe){const Pe=se.isWebGL2;ue===null&&(ue=new Gr(1,1,{generateMipmaps:!0,type:te.has("EXT_color_buffer_half_float")?Vl:os,minFilter:So,samples:Pe?4:0})),w.getDrawingBufferSize(le),Pe?ue.setSize(le.x,le.y):ue.setSize(Ud(le.x),Ud(le.y));const it=w.getRenderTarget();w.setRenderTarget(ue),w.getClearColor(I),X=w.getClearAlpha(),X<1&&w.setClearColor(16777215,.5),w.clear();const lt=w.toneMapping;w.toneMapping=zr,sn(J,Re,pe),Se.updateMultisampleRenderTarget(ue),Se.updateRenderTargetMipmap(ue);let ct=!1;for(let dt=0,wt=me.length;dt<wt;dt++){const ke=me[dt],ut=ke.object,Jt=ke.geometry,Gt=ke.material,Yn=ke.group;if(Gt.side===vn&&ut.layers.test(pe.layers)){const ci=Gt.side;Gt.side=yi,Gt.needsUpdate=!0,ti(ut,Re,pe,Jt,Gt,Yn),Gt.side=ci,Gt.needsUpdate=!0,ct=!0}}ct===!0&&(Se.updateMultisampleRenderTarget(ue),Se.updateRenderTargetMipmap(ue)),w.setRenderTarget(it),w.setClearColor(I,X),w.toneMapping=lt}function sn(J,me,Re){const pe=me.isScene===!0?me.overrideMaterial:null;for(let Pe=0,it=J.length;Pe<it;Pe++){const lt=J[Pe],ct=lt.object,dt=lt.geometry,wt=pe===null?lt.material:pe,ke=lt.group;ct.layers.test(Re.layers)&&ti(ct,me,Re,dt,wt,ke)}}function ti(J,me,Re,pe,Pe,it){J.onBeforeRender(w,me,Re,pe,Pe,it),J.modelViewMatrix.multiplyMatrices(Re.matrixWorldInverse,J.matrixWorld),J.normalMatrix.getNormalMatrix(J.modelViewMatrix),Pe.onBeforeRender(w,me,Re,pe,J,it),Pe.transparent===!0&&Pe.side===vn&&Pe.forceSinglePass===!1?(Pe.side=yi,Pe.needsUpdate=!0,w.renderBufferDirect(Re,me,pe,Pe,J,it),Pe.side=ls,Pe.needsUpdate=!0,w.renderBufferDirect(Re,me,pe,Pe,J,it),Pe.side=vn):w.renderBufferDirect(Re,me,pe,Pe,J,it),J.onAfterRender(w,me,Re,pe,Pe,it)}function tn(J,me,Re){me.isScene!==!0&&(me=Ee);const pe=de.get(J),Pe=y.state.lights,it=y.state.shadowsArray,lt=Pe.state.version,ct=ne.getParameters(J,Pe.state,it,me,Re),dt=ne.getProgramCacheKey(ct);let wt=pe.programs;pe.environment=J.isMeshStandardMaterial?me.environment:null,pe.fog=me.fog,pe.envMap=(J.isMeshStandardMaterial?ge:Le).get(J.envMap||pe.environment),wt===void 0&&(J.addEventListener("dispose",Ye),wt=new Map,pe.programs=wt);let ke=wt.get(dt);if(ke!==void 0){if(pe.currentProgram===ke&&pe.lightsStateVersion===lt)return dn(J,ct),ke}else ct.uniforms=ne.getUniforms(J),J.onBuild(Re,ct,w),J.onBeforeCompile(ct,w),ke=ne.acquireProgram(ct,dt),wt.set(dt,ke),pe.uniforms=ct.uniforms;const ut=pe.uniforms;(!J.isShaderMaterial&&!J.isRawShaderMaterial||J.clipping===!0)&&(ut.clippingPlanes=Fe.uniform),dn(J,ct),pe.needsLights=_i(J),pe.lightsStateVersion=lt,pe.needsLights&&(ut.ambientLightColor.value=Pe.state.ambient,ut.lightProbe.value=Pe.state.probe,ut.directionalLights.value=Pe.state.directional,ut.directionalLightShadows.value=Pe.state.directionalShadow,ut.spotLights.value=Pe.state.spot,ut.spotLightShadows.value=Pe.state.spotShadow,ut.rectAreaLights.value=Pe.state.rectArea,ut.ltc_1.value=Pe.state.rectAreaLTC1,ut.ltc_2.value=Pe.state.rectAreaLTC2,ut.pointLights.value=Pe.state.point,ut.pointLightShadows.value=Pe.state.pointShadow,ut.hemisphereLights.value=Pe.state.hemi,ut.directionalShadowMap.value=Pe.state.directionalShadowMap,ut.directionalShadowMatrix.value=Pe.state.directionalShadowMatrix,ut.spotShadowMap.value=Pe.state.spotShadowMap,ut.spotLightMatrix.value=Pe.state.spotLightMatrix,ut.spotLightMap.value=Pe.state.spotLightMap,ut.pointShadowMap.value=Pe.state.pointShadowMap,ut.pointShadowMatrix.value=Pe.state.pointShadowMatrix);const Jt=ke.getUniforms(),Gt=bd.seqWithValue(Jt.seq,ut);return pe.currentProgram=ke,pe.uniformsList=Gt,ke}function dn(J,me){const Re=de.get(J);Re.outputColorSpace=me.outputColorSpace,Re.instancing=me.instancing,Re.skinning=me.skinning,Re.morphTargets=me.morphTargets,Re.morphNormals=me.morphNormals,Re.morphColors=me.morphColors,Re.morphTargetsCount=me.morphTargetsCount,Re.numClippingPlanes=me.numClippingPlanes,Re.numIntersection=me.numClipIntersection,Re.vertexAlphas=me.vertexAlphas,Re.vertexTangents=me.vertexTangents,Re.toneMapping=me.toneMapping}function Gn(J,me,Re,pe,Pe){me.isScene!==!0&&(me=Ee),Se.resetTextureUnits();const it=me.fog,lt=pe.isMeshStandardMaterial?me.environment:null,ct=A===null?w.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:Br,dt=(pe.isMeshStandardMaterial?ge:Le).get(pe.envMap||lt),wt=pe.vertexColors===!0&&!!Re.attributes.color&&Re.attributes.color.itemSize===4,ke=!!Re.attributes.tangent&&(!!pe.normalMap||pe.anisotropy>0),ut=!!Re.morphAttributes.position,Jt=!!Re.morphAttributes.normal,Gt=!!Re.morphAttributes.color,Yn=pe.toneMapped?w.toneMapping:zr,ci=Re.morphAttributes.position||Re.morphAttributes.normal||Re.morphAttributes.color,qt=ci!==void 0?ci.length:0,mt=de.get(pe),kt=y.state.lights;if(ee===!0&&(ie===!0||J!==C)){const Un=J===C&&pe.id===P;Fe.setState(pe,J,Un)}let gt=!1;pe.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==kt.state.version||mt.outputColorSpace!==ct||Pe.isInstancedMesh&&mt.instancing===!1||!Pe.isInstancedMesh&&mt.instancing===!0||Pe.isSkinnedMesh&&mt.skinning===!1||!Pe.isSkinnedMesh&&mt.skinning===!0||mt.envMap!==dt||pe.fog===!0&&mt.fog!==it||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==Fe.numPlanes||mt.numIntersection!==Fe.numIntersection)||mt.vertexAlphas!==wt||mt.vertexTangents!==ke||mt.morphTargets!==ut||mt.morphNormals!==Jt||mt.morphColors!==Gt||mt.toneMapping!==Yn||se.isWebGL2===!0&&mt.morphTargetsCount!==qt)&&(gt=!0):(gt=!0,mt.__version=pe.version);let Cn=mt.currentProgram;gt===!0&&(Cn=tn(pe,me,Pe));let En=!1,cn=!1,Ii=!1;const Qt=Cn.getUniforms(),on=mt.uniforms;if($.useProgram(Cn.program)&&(En=!0,cn=!0,Ii=!0),pe.id!==P&&(P=pe.id,cn=!0),En||C!==J){if(Qt.setValue(z,"projectionMatrix",J.projectionMatrix),se.logarithmicDepthBuffer&&Qt.setValue(z,"logDepthBufFC",2/(Math.log(J.far+1)/Math.LN2)),C!==J&&(C=J,cn=!0,Ii=!0),pe.isShaderMaterial||pe.isMeshPhongMaterial||pe.isMeshToonMaterial||pe.isMeshStandardMaterial||pe.envMap){const Un=Qt.map.cameraPosition;Un!==void 0&&Un.setValue(z,Ae.setFromMatrixPosition(J.matrixWorld))}(pe.isMeshPhongMaterial||pe.isMeshToonMaterial||pe.isMeshLambertMaterial||pe.isMeshBasicMaterial||pe.isMeshStandardMaterial||pe.isShaderMaterial)&&Qt.setValue(z,"isOrthographic",J.isOrthographicCamera===!0),(pe.isMeshPhongMaterial||pe.isMeshToonMaterial||pe.isMeshLambertMaterial||pe.isMeshBasicMaterial||pe.isMeshStandardMaterial||pe.isShaderMaterial||pe.isShadowMaterial||Pe.isSkinnedMesh)&&Qt.setValue(z,"viewMatrix",J.matrixWorldInverse)}if(Pe.isSkinnedMesh){Qt.setOptional(z,Pe,"bindMatrix"),Qt.setOptional(z,Pe,"bindMatrixInverse");const Un=Pe.skeleton;Un&&(se.floatVertexTextures?(Un.boneTexture===null&&Un.computeBoneTexture(),Qt.setValue(z,"boneTexture",Un.boneTexture,Se),Qt.setValue(z,"boneTextureSize",Un.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const xi=Re.morphAttributes;if((xi.position!==void 0||xi.normal!==void 0||xi.color!==void 0&&se.isWebGL2===!0)&&Be.update(Pe,Re,Cn),(cn||mt.receiveShadow!==Pe.receiveShadow)&&(mt.receiveShadow=Pe.receiveShadow,Qt.setValue(z,"receiveShadow",Pe.receiveShadow)),pe.isMeshGouraudMaterial&&pe.envMap!==null&&(on.envMap.value=dt,on.flipEnvMap.value=dt.isCubeTexture&&dt.isRenderTargetTexture===!1?-1:1),cn&&(Qt.setValue(z,"toneMappingExposure",w.toneMappingExposure),mt.needsLights&&sr(on,Ii),it&&pe.fog===!0&&we.refreshFogUniforms(on,it),we.refreshMaterialUniforms(on,pe,O,W,ue),bd.upload(z,mt.uniformsList,on,Se)),pe.isShaderMaterial&&pe.uniformsNeedUpdate===!0&&(bd.upload(z,mt.uniformsList,on,Se),pe.uniformsNeedUpdate=!1),pe.isSpriteMaterial&&Qt.setValue(z,"center",Pe.center),Qt.setValue(z,"modelViewMatrix",Pe.modelViewMatrix),Qt.setValue(z,"normalMatrix",Pe.normalMatrix),Qt.setValue(z,"modelMatrix",Pe.matrixWorld),pe.isShaderMaterial||pe.isRawShaderMaterial){const Un=pe.uniformsGroups;for(let Xr=0,jr=Un.length;Xr<jr;Xr++)if(se.isWebGL2){const ui=Un[Xr];nt.update(ui,Cn),nt.bind(ui,Cn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Cn}function sr(J,me){J.ambientLightColor.needsUpdate=me,J.lightProbe.needsUpdate=me,J.directionalLights.needsUpdate=me,J.directionalLightShadows.needsUpdate=me,J.pointLights.needsUpdate=me,J.pointLightShadows.needsUpdate=me,J.spotLights.needsUpdate=me,J.spotLightShadows.needsUpdate=me,J.rectAreaLights.needsUpdate=me,J.hemisphereLights.needsUpdate=me}function _i(J){return J.isMeshLambertMaterial||J.isMeshToonMaterial||J.isMeshPhongMaterial||J.isMeshStandardMaterial||J.isShadowMaterial||J.isShaderMaterial&&J.lights===!0}this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(J,me,Re){de.get(J.texture).__webglTexture=me,de.get(J.depthTexture).__webglTexture=Re;const pe=de.get(J);pe.__hasExternalTextures=!0,pe.__hasExternalTextures&&(pe.__autoAllocateDepthBuffer=Re===void 0,pe.__autoAllocateDepthBuffer||te.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),pe.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(J,me){const Re=de.get(J);Re.__webglFramebuffer=me,Re.__useDefaultFramebuffer=me===void 0},this.setRenderTarget=function(J,me=0,Re=0){A=J,b=me,M=Re;let pe=!0,Pe=null,it=!1,lt=!1;if(J){const dt=de.get(J);dt.__useDefaultFramebuffer!==void 0?($.bindFramebuffer(z.FRAMEBUFFER,null),pe=!1):dt.__webglFramebuffer===void 0?Se.setupRenderTarget(J):dt.__hasExternalTextures&&Se.rebindTextures(J,de.get(J.texture).__webglTexture,de.get(J.depthTexture).__webglTexture);const wt=J.texture;(wt.isData3DTexture||wt.isDataArrayTexture||wt.isCompressedArrayTexture)&&(lt=!0);const ke=de.get(J).__webglFramebuffer;J.isWebGLCubeRenderTarget?(Pe=ke[me],it=!0):se.isWebGL2&&J.samples>0&&Se.useMultisampledRTT(J)===!1?Pe=de.get(J).__webglMultisampledFramebuffer:Pe=ke,L.copy(J.viewport),F.copy(J.scissor),N=J.scissorTest}else L.copy(B).multiplyScalar(O).floor(),F.copy(D).multiplyScalar(O).floor(),N=V;if($.bindFramebuffer(z.FRAMEBUFFER,Pe)&&se.drawBuffers&&pe&&$.drawBuffers(J,Pe),$.viewport(L),$.scissor(F),$.setScissorTest(N),it){const dt=de.get(J.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+me,dt.__webglTexture,Re)}else if(lt){const dt=de.get(J.texture),wt=me||0;z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,dt.__webglTexture,Re||0,wt)}P=-1},this.readRenderTargetPixels=function(J,me,Re,pe,Pe,it,lt){if(!(J&&J.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ct=de.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&<!==void 0&&(ct=ct[lt]),ct){$.bindFramebuffer(z.FRAMEBUFFER,ct);try{const dt=J.texture,wt=dt.format,ke=dt.type;if(wt!==Bi&&Oe.convert(wt)!==z.getParameter(z.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ut=ke===Vl&&(te.has("EXT_color_buffer_half_float")||se.isWebGL2&&te.has("EXT_color_buffer_float"));if(ke!==os&&Oe.convert(ke)!==z.getParameter(z.IMPLEMENTATION_COLOR_READ_TYPE)&&!(ke===rs&&(se.isWebGL2||te.has("OES_texture_float")||te.has("WEBGL_color_buffer_float")))&&!ut){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}me>=0&&me<=J.width-pe&&Re>=0&&Re<=J.height-Pe&&z.readPixels(me,Re,pe,Pe,Oe.convert(wt),Oe.convert(ke),it)}finally{const dt=A!==null?de.get(A).__webglFramebuffer:null;$.bindFramebuffer(z.FRAMEBUFFER,dt)}}},this.copyFramebufferToTexture=function(J,me,Re=0){const pe=Math.pow(2,-Re),Pe=Math.floor(me.image.width*pe),it=Math.floor(me.image.height*pe);Se.setTexture2D(me,0),z.copyTexSubImage2D(z.TEXTURE_2D,Re,0,0,J.x,J.y,Pe,it),$.unbindTexture()},this.copyTextureToTexture=function(J,me,Re,pe=0){const Pe=me.image.width,it=me.image.height,lt=Oe.convert(Re.format),ct=Oe.convert(Re.type);Se.setTexture2D(Re,0),z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,Re.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Re.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,Re.unpackAlignment),me.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,pe,J.x,J.y,Pe,it,lt,ct,me.image.data):me.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,pe,J.x,J.y,me.mipmaps[0].width,me.mipmaps[0].height,lt,me.mipmaps[0].data):z.texSubImage2D(z.TEXTURE_2D,pe,J.x,J.y,lt,ct,me.image),pe===0&&Re.generateMipmaps&&z.generateMipmap(z.TEXTURE_2D),$.unbindTexture()},this.copyTextureToTexture3D=function(J,me,Re,pe,Pe=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const it=J.max.x-J.min.x+1,lt=J.max.y-J.min.y+1,ct=J.max.z-J.min.z+1,dt=Oe.convert(pe.format),wt=Oe.convert(pe.type);let ke;if(pe.isData3DTexture)Se.setTexture3D(pe,0),ke=z.TEXTURE_3D;else if(pe.isDataArrayTexture)Se.setTexture2DArray(pe,0),ke=z.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,pe.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,pe.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,pe.unpackAlignment);const ut=z.getParameter(z.UNPACK_ROW_LENGTH),Jt=z.getParameter(z.UNPACK_IMAGE_HEIGHT),Gt=z.getParameter(z.UNPACK_SKIP_PIXELS),Yn=z.getParameter(z.UNPACK_SKIP_ROWS),ci=z.getParameter(z.UNPACK_SKIP_IMAGES),qt=Re.isCompressedTexture?Re.mipmaps[0]:Re.image;z.pixelStorei(z.UNPACK_ROW_LENGTH,qt.width),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,qt.height),z.pixelStorei(z.UNPACK_SKIP_PIXELS,J.min.x),z.pixelStorei(z.UNPACK_SKIP_ROWS,J.min.y),z.pixelStorei(z.UNPACK_SKIP_IMAGES,J.min.z),Re.isDataTexture||Re.isData3DTexture?z.texSubImage3D(ke,Pe,me.x,me.y,me.z,it,lt,ct,dt,wt,qt.data):Re.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),z.compressedTexSubImage3D(ke,Pe,me.x,me.y,me.z,it,lt,ct,dt,qt.data)):z.texSubImage3D(ke,Pe,me.x,me.y,me.z,it,lt,ct,dt,wt,qt),z.pixelStorei(z.UNPACK_ROW_LENGTH,ut),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,Jt),z.pixelStorei(z.UNPACK_SKIP_PIXELS,Gt),z.pixelStorei(z.UNPACK_SKIP_ROWS,Yn),z.pixelStorei(z.UNPACK_SKIP_IMAGES,ci),Pe===0&&pe.generateMipmaps&&z.generateMipmap(ke),$.unbindTexture()},this.initTexture=function(J){J.isCubeTexture?Se.setTextureCube(J,0):J.isData3DTexture?Se.setTexture3D(J,0):J.isDataArrayTexture||J.isCompressedArrayTexture?Se.setTexture2DArray(J,0):Se.setTexture2D(J,0),$.unbindTexture()},this.resetState=function(){b=0,M=0,A=null,$.reset(),We.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ss}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Mt?vo:ey}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===vo?Mt:Br}}class _M extends uy{}_M.prototype.isWebGL1Renderer=!0;class np{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ke(e),this.density=t}clone(){return new np(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class ip{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ke(e),this.near=t,this.far=n}clone(){return new ip(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class ku extends jt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class rp{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ou,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=er()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=er()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=er()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Ai=new Y;class wa{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Ai.fromBufferAttribute(this,t),Ai.applyMatrix4(e),this.setXYZ(t,Ai.x,Ai.y,Ai.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ai.fromBufferAttribute(this,t),Ai.applyNormalMatrix(e),this.setXYZ(t,Ai.x,Ai.y,Ai.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ai.fromBufferAttribute(this,t),Ai.transformDirection(e),this.setXYZ(t,Ai.x,Ai.y,Ai.z);return this}setX(e,t){return this.normalized&&(t=Lt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Lt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Lt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Lt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Qi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Qi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Qi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Qi(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Lt(t,this.array),n=Lt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Lt(t,this.array),n=Lt(n,this.array),i=Lt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Lt(t,this.array),n=Lt(n,this.array),i=Lt(i,this.array),s=Lt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new $t(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new wa(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class hy extends oi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ke(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 fl;const Dc=new Y,dl=new Y,pl=new Y,ml=new De,Uc=new De,xM=new yt,Lf=new Y,Oc=new Y,If=new Y,A1=new De,ng=new De,C1=new De;class wM extends jt{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",fl===void 0){fl=new Tt;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 rp(t,5);fl.setIndex([0,1,2,0,2,3]),fl.setAttribute("position",new wa(n,3,0,!1)),fl.setAttribute("uv",new wa(n,2,3,!1))}this.geometry=fl,this.material=e!==void 0?e:new hy,this.center=new De(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),dl.setFromMatrixScale(this.matrixWorld),xM.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),pl.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&dl.multiplyScalar(-pl.z);const n=this.material.rotation;let i,s;n!==0&&(s=Math.cos(n),i=Math.sin(n));const o=this.center;Df(Lf.set(-.5,-.5,0),pl,o,dl,i,s),Df(Oc.set(.5,-.5,0),pl,o,dl,i,s),Df(If.set(.5,.5,0),pl,o,dl,i,s),A1.set(0,0),ng.set(1,0),C1.set(1,1);let a=e.ray.intersectTriangle(Lf,Oc,If,!1,Dc);if(a===null&&(Df(Oc.set(-.5,.5,0),pl,o,dl,i,s),ng.set(0,1),a=e.ray.intersectTriangle(Lf,If,Oc,!1,Dc),a===null))return;const l=e.ray.origin.distanceTo(Dc);l<e.near||l>e.far||t.push({distance:l,point:Dc.clone(),uv:zi.getInterpolation(Dc,Lf,Oc,If,A1,ng,C1,new De),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 Df(r,e,t,n,i,s){ml.subVectors(r,t).addScalar(.5).multiply(n),i!==void 0?(Uc.x=s*ml.x-i*ml.y,Uc.y=i*ml.x+s*ml.y):Uc.copy(ml),r.copy(e),r.x+=Uc.x,r.y+=Uc.y,r.applyMatrix4(xM)}const Uf=new Y,R1=new Y;class SM extends jt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n<i;n++){const s=t[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let s;for(s=0;s<i.length&&!(t<i[s].distance);s++);return i.splice(s,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let s=t[n].distance;if(t[n].object.visible&&(s-=s*t[n].hysteresis),e<s)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Uf.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Uf);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Uf.setFromMatrixPosition(e.matrixWorld),R1.setFromMatrixPosition(this.matrixWorld);const n=Uf.distanceTo(R1)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i<s;i++){let o=t[i].distance;if(t[i].object.visible&&(o-=o*t[i].hysteresis),n>=o)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<s;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let i=0,s=n.length;i<s;i++){const o=n[i];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}}const P1=new Y,L1=new Xt,I1=new Xt,QD=new Y,D1=new yt,gl=new Y,ig=new rr,U1=new yt,rg=new Ql;class EM extends _n{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new yt,this.bindMatrixInverse=new yt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ir),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)gl.fromBufferAttribute(t,n),this.applyBoneTransform(n,gl),this.boundingBox.expandByPoint(gl)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new rr),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)gl.fromBufferAttribute(t,n),this.applyBoneTransform(n,gl),this.boundingSphere.expandByPoint(gl)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ig.copy(this.boundingSphere),ig.applyMatrix4(i),e.ray.intersectsSphere(ig)!==!1&&(U1.copy(i).invert(),rg.copy(e.ray).applyMatrix4(U1),!(this.boundingBox!==null&&rg.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,rg)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Xt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;L1.fromBufferAttribute(i.attributes.skinIndex,e),I1.fromBufferAttribute(i.attributes.skinWeight,e),P1.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const o=I1.getComponent(s);if(o!==0){const a=L1.getComponent(s);D1.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(QD.copy(P1).applyMatrix4(D1),o)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}}class fy extends jt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Bl extends Sn{constructor(e=null,t=1,n=1,i,s,o,a,l,c=Dn,u=Dn,h,p){super(null,o,a,l,c,u,i,s,h,p),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const O1=new yt,eU=new yt;class sp{constructor(e=[],t=[]){this.uuid=er(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new yt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new yt;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,o=e.length;s<o;s++){const a=e[s]?e[s].matrixWorld:eU;O1.multiplyMatrices(a,t[s]),O1.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new sp(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=sM(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Bl(t,e,e,Bi,rs);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const s=e.bones[n];let o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new fy),this.bones.push(o),this.boneInverses.push(new yt().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,s=t.length;i<s;i++){const o=t[i];e.bones.push(o.uuid);const a=n[i];e.boneInverses.push(a.toArray())}return e}}class Sa extends $t{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const vl=new yt,N1=new yt,Of=[],F1=new ir,tU=new yt,Nc=new _n,Fc=new rr;class bM extends _n{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Sa(new Float32Array(n*16),16),this.instanceColor=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,tU)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ir),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,vl),F1.copy(e.boundingBox).applyMatrix4(vl),this.boundingBox.union(F1)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new rr),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,vl),Fc.copy(e.boundingSphere).applyMatrix4(vl),this.boundingSphere.union(Fc)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){const n=this.matrixWorld,i=this.count;if(Nc.geometry=this.geometry,Nc.material=this.material,Nc.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Fc.copy(this.boundingSphere),Fc.applyMatrix4(n),e.ray.intersectsSphere(Fc)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,vl),N1.multiplyMatrices(n,vl),Nc.matrixWorld=N1,Nc.raycast(e,Of);for(let o=0,a=Of.length;o<a;o++){const l=Of[o];l.instanceId=s,l.object=this,t.push(l)}Of.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Sa(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class Pi extends oi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ke(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 k1=new Y,z1=new Y,B1=new yt,sg=new Ql,Nf=new rr;let bo=class extends jt{constructor(e=new Tt,t=new Pi){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=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 i=1,s=t.count;i<s;i++)k1.fromBufferAttribute(t,i-1),z1.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=k1.distanceTo(z1);e.setAttribute("lineDistance",new st(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Nf.copy(n.boundingSphere),Nf.applyMatrix4(i),Nf.radius+=s,e.ray.intersectsSphere(Nf)===!1)return;B1.copy(i).invert(),sg.copy(e.ray).applyMatrix4(B1);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new Y,u=new Y,h=new Y,p=new Y,m=this.isLineSegments?2:1,v=n.index,y=n.attributes.position;if(v!==null){const g=Math.max(0,o.start),x=Math.min(v.count,o.start+o.count);for(let w=g,E=x-1;w<E;w+=m){const b=v.getX(w),M=v.getX(w+1);if(c.fromBufferAttribute(y,b),u.fromBufferAttribute(y,M),sg.distanceSqToSegment(c,u,p,h)>l)continue;p.applyMatrix4(this.matrixWorld);const P=e.ray.origin.distanceTo(p);P<e.near||P>e.far||t.push({distance:P,point:h.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const g=Math.max(0,o.start),x=Math.min(y.count,o.start+o.count);for(let w=g,E=x-1;w<E;w+=m){if(c.fromBufferAttribute(y,w),u.fromBufferAttribute(y,w+1),sg.distanceSqToSegment(c,u,p,h)>l)continue;p.applyMatrix4(this.matrixWorld);const M=e.ray.origin.distanceTo(p);M<e.near||M>e.far||t.push({distance:M,point:h.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};const G1=new Y,H1=new Y;class hs extends bo{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 i=0,s=t.count;i<s;i+=2)G1.fromBufferAttribute(t,i),H1.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+G1.distanceTo(H1);e.setAttribute("lineDistance",new st(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class MM extends bo{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class dy extends oi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ke(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const V1=new yt,uv=new Ql,Ff=new rr,kf=new Y;class TM extends jt{constructor(e=new Tt,t=new dy){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ff.copy(n.boundingSphere),Ff.applyMatrix4(i),Ff.radius+=s,e.ray.intersectsSphere(Ff)===!1)return;V1.copy(i).invert(),uv.copy(e.ray).applyMatrix4(V1);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=n.index,h=n.attributes.position;if(c!==null){const p=Math.max(0,o.start),m=Math.min(c.count,o.start+o.count);for(let v=p,_=m;v<_;v++){const y=c.getX(v);kf.fromBufferAttribute(h,y),W1(kf,y,l,i,e,t,this)}}else{const p=Math.max(0,o.start),m=Math.min(h.count,o.start+o.count);for(let v=p,_=m;v<_;v++)kf.fromBufferAttribute(h,v),W1(kf,v,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function W1(r,e,t,n,i,s,o){const a=uv.distanceSqToPoint(r);if(a<t){const l=new Y;uv.closestPointToPoint(r,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class nU extends Sn{constructor(e,t,n,i,s,o,a,l,c){super(e,t,n,i,s,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:fn,this.magFilter=s!==void 0?s:fn,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class iU extends Sn{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Dn,this.minFilter=Dn,this.generateMipmaps=!1,this.needsUpdate=!0}}class py extends Sn{constructor(e,t,n,i,s,o,a,l,c,u,h,p){super(null,o,a,l,c,u,i,s,h,p),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class rU extends py{constructor(e,t,n,i,s,o){super(e,t,n,s,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=vi}}class sU extends Sn{constructor(e,t,n,i,s,o,a,l,c){super(e,t,n,i,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Vr{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const s=n.length;let o;t?o=t:o=e*n[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=n[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);const u=n[i],p=n[i+1]-u,m=(o-u)/p;return(i+m)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new De:new Y);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Y,i=[],s=[],o=[],a=new Y,l=new yt;for(let m=0;m<=e;m++){const v=m/e;i[m]=this.getTangentAt(v,new Y)}s[0]=new Y,o[0]=new Y;let c=Number.MAX_VALUE;const u=Math.abs(i[0].x),h=Math.abs(i[0].y),p=Math.abs(i[0].z);u<=c&&(c=u,n.set(1,0,0)),h<=c&&(c=h,n.set(0,1,0)),p<=c&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let m=1;m<=e;m++){if(s[m]=s[m-1].clone(),o[m]=o[m-1].clone(),a.crossVectors(i[m-1],i[m]),a.length()>Number.EPSILON){a.normalize();const v=Math.acos(Tn(i[m-1].dot(i[m]),-1,1));s[m].applyMatrix4(l.makeRotationAxis(a,v))}o[m].crossVectors(i[m],s[m])}if(t===!0){let m=Math.acos(Tn(s[0].dot(s[e]),-1,1));m/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(m=-m);for(let v=1;v<=e;v++)s[v].applyMatrix4(l.makeRotationAxis(i[v],m*v)),o[v].crossVectors(i[v],s[v])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class op extends Vr{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){const n=t||new De,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const a=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),p=l-this.aX,m=c-this.aY;l=p*u-m*h+this.aX,c=p*h+m*u+this.aY}return n.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class AM extends op{constructor(e,t,n,i,s,o){super(e,t,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function my(){let r=0,e=0,t=0,n=0;function i(s,o,a,l){r=s,e=a,t=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,u,h){let p=(o-s)/c-(a-s)/(c+u)+(a-o)/u,m=(a-o)/u-(l-o)/(u+h)+(l-a)/h;p*=u,m*=u,i(o,a,p,m)},calc:function(s){const o=s*s,a=o*s;return r+e*s+t*o+n*a}}}const zf=new Y,og=new my,ag=new my,lg=new my;class CM extends Vr{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new Y){const n=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=i[(a-1)%s]:(zf.subVectors(i[0],i[1]).add(i[0]),c=zf);const h=i[a%s],p=i[(a+1)%s];if(this.closed||a+2<s?u=i[(a+2)%s]:(zf.subVectors(i[s-1],i[s-2]).add(i[s-1]),u=zf),this.curveType==="centripetal"||this.curveType==="chordal"){const m=this.curveType==="chordal"?.5:.25;let v=Math.pow(c.distanceToSquared(h),m),_=Math.pow(h.distanceToSquared(p),m),y=Math.pow(p.distanceToSquared(u),m);_<1e-4&&(_=1),v<1e-4&&(v=_),y<1e-4&&(y=_),og.initNonuniformCatmullRom(c.x,h.x,p.x,u.x,v,_,y),ag.initNonuniformCatmullRom(c.y,h.y,p.y,u.y,v,_,y),lg.initNonuniformCatmullRom(c.z,h.z,p.z,u.z,v,_,y)}else this.curveType==="catmullrom"&&(og.initCatmullRom(c.x,h.x,p.x,u.x,this.tension),ag.initCatmullRom(c.y,h.y,p.y,u.y,this.tension),lg.initCatmullRom(c.z,h.z,p.z,u.z,this.tension));return n.set(og.calc(l),ag.calc(l),lg.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new Y().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function X1(r,e,t,n,i){const s=(n-e)*.5,o=(i-t)*.5,a=r*r,l=r*a;return(2*t-2*n+s+o)*l+(-3*t+3*n-2*s-o)*a+s*r+t}function oU(r,e){const t=1-r;return t*t*e}function aU(r,e){return 2*(1-r)*r*e}function lU(r,e){return r*r*e}function xu(r,e,t,n){return oU(r,e)+aU(r,t)+lU(r,n)}function cU(r,e){const t=1-r;return t*t*t*e}function uU(r,e){const t=1-r;return 3*t*t*r*e}function hU(r,e){return 3*(1-r)*r*r*e}function fU(r,e){return r*r*r*e}function wu(r,e,t,n,i){return cU(r,e)+uU(r,t)+hU(r,n)+fU(r,i)}class gy extends Vr{constructor(e=new De,t=new De,n=new De,i=new De){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new De){const n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(wu(e,i.x,s.x,o.x,a.x),wu(e,i.y,s.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class RM extends Vr{constructor(e=new Y,t=new Y,n=new Y,i=new Y){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new Y){const n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(wu(e,i.x,s.x,o.x,a.x),wu(e,i.y,s.y,o.y,a.y),wu(e,i.z,s.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class ap extends Vr{constructor(e=new De,t=new De){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new De){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new De){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class vy extends Vr{constructor(e=new Y,t=new Y){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new Y){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Y){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class yy extends Vr{constructor(e=new De,t=new De,n=new De){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new De){const n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(xu(e,i.x,s.x,o.x),xu(e,i.y,s.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class lp extends Vr{constructor(e=new Y,t=new Y,n=new Y){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Y){const n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(xu(e,i.x,s.x,o.x),xu(e,i.y,s.y,o.y),xu(e,i.z,s.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class _y extends Vr{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new De){const n=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],u=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(X1(a,l.x,c.x,u.x,h.x),X1(a,l.y,c.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new De().fromArray(i))}return this}}var xy=Object.freeze({__proto__:null,ArcCurve:AM,CatmullRomCurve3:CM,CubicBezierCurve:gy,CubicBezierCurve3:RM,EllipseCurve:op,LineCurve:ap,LineCurve3:vy,QuadraticBezierCurve:yy,QuadraticBezierCurve3:lp,SplineCurve:_y});class PM extends Vr{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new ap(t,e))}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const o=i[s]-n,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){const u=l[c];n&&n.equals(u)||(t.push(u),n=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new xy[i.type]().fromJSON(i))}return this}}class zu extends PM{constructor(e){super(),this.type="Path",this.currentPoint=new De,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new ap(this.currentPoint.clone(),new De(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const s=new yy(this.currentPoint.clone(),new De(e,t),new De(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,o){const a=new gy(this.currentPoint.clone(),new De(e,t),new De(n,i),new De(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new _y(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,n,i,s,o),this}absarc(e,t,n,i,s,o){return this.absellipse(e,t,n,n,i,s,o),this}ellipse(e,t,n,i,s,o,a,l){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,n,i,s,o,a,l),this}absellipse(e,t,n,i,s,o,a,l){const c=new op(e,t,n,i,s,o,a,l);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class ah extends Tt{constructor(e=[new De(0,-.5),new De(.5,0),new De(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=Tn(i,0,Math.PI*2);const s=[],o=[],a=[],l=[],c=[],u=1/t,h=new Y,p=new De,m=new Y,v=new Y,_=new Y;let y=0,g=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:y=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,m.x=g*1,m.y=-y,m.z=g*0,_.copy(m),m.normalize(),l.push(m.x,m.y,m.z);break;case e.length-1:l.push(_.x,_.y,_.z);break;default:y=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,m.x=g*1,m.y=-y,m.z=g*0,v.copy(m),m.x+=_.x,m.y+=_.y,m.z+=_.z,m.normalize(),l.push(m.x,m.y,m.z),_.copy(v)}for(let x=0;x<=t;x++){const w=n+x*u*i,E=Math.sin(w),b=Math.cos(w);for(let M=0;M<=e.length-1;M++){h.x=e[M].x*E,h.y=e[M].y,h.z=e[M].x*b,o.push(h.x,h.y,h.z),p.x=x/t,p.y=M/(e.length-1),a.push(p.x,p.y);const A=l[3*M+0]*E,P=l[3*M+1],C=l[3*M+0]*b;c.push(A,P,C)}}for(let x=0;x<t;x++)for(let w=0;w<e.length-1;w++){const E=w+x*e.length,b=E,M=E+e.length,A=E+e.length+1,P=E+1;s.push(b,M,P),s.push(A,P,M)}this.setIndex(s),this.setAttribute("position",new st(o,3)),this.setAttribute("uv",new st(a,2)),this.setAttribute("normal",new st(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ah(e.points,e.segments,e.phiStart,e.phiLength)}}class cp extends ah{constructor(e=1,t=1,n=4,i=8){const s=new zu;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new cp(e.radius,e.length,e.capSegments,e.radialSegments)}}class up extends Tt{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const s=[],o=[],a=[],l=[],c=new Y,u=new De;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let h=0,p=3;h<=t;h++,p+=3){const m=n+h/t*i;c.x=e*Math.cos(m),c.y=e*Math.sin(m),o.push(c.x,c.y,c.z),a.push(0,0,1),u.x=(o[p]/e+1)/2,u.y=(o[p+1]/e+1)/2,l.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new st(o,3)),this.setAttribute("normal",new st(a,3)),this.setAttribute("uv",new st(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new up(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class La extends Tt{constructor(e=1,t=1,n=1,i=32,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};const c=this;i=Math.floor(i),s=Math.floor(s);const u=[],h=[],p=[],m=[];let v=0;const _=[],y=n/2;let g=0;x(),o===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(u),this.setAttribute("position",new st(h,3)),this.setAttribute("normal",new st(p,3)),this.setAttribute("uv",new st(m,2));function x(){const E=new Y,b=new Y;let M=0;const A=(t-e)/n;for(let P=0;P<=s;P++){const C=[],L=P/s,F=L*(t-e)+e;for(let N=0;N<=i;N++){const I=N/i,X=I*l+a,q=Math.sin(X),W=Math.cos(X);b.x=F*q,b.y=-L*n+y,b.z=F*W,h.push(b.x,b.y,b.z),E.set(q,A,W).normalize(),p.push(E.x,E.y,E.z),m.push(I,1-L),C.push(v++)}_.push(C)}for(let P=0;P<i;P++)for(let C=0;C<s;C++){const L=_[C][P],F=_[C+1][P],N=_[C+1][P+1],I=_[C][P+1];u.push(L,F,I),u.push(F,N,I),M+=6}c.addGroup(g,M,0),g+=M}function w(E){const b=v,M=new De,A=new Y;let P=0;const C=E===!0?e:t,L=E===!0?1:-1;for(let N=1;N<=i;N++)h.push(0,y*L,0),p.push(0,L,0),m.push(.5,.5),v++;const F=v;for(let N=0;N<=i;N++){const X=N/i*l+a,q=Math.cos(X),W=Math.sin(X);A.x=C*W,A.y=y*L,A.z=C*q,h.push(A.x,A.y,A.z),p.push(0,L,0),M.x=q*.5+.5,M.y=W*.5*L+.5,m.push(M.x,M.y),v++}for(let N=0;N<i;N++){const I=b+N,X=F+N;E===!0?u.push(X,X+1,I):u.push(X+1,X,I),P+=3}c.addGroup(g,P,E===!0?1:2),g+=P}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new La(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class hp extends La{constructor(e=1,t=1,n=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new hp(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ao extends Tt{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const s=[],o=[];a(i),c(n),u(),this.setAttribute("position",new st(s,3)),this.setAttribute("normal",new st(s.slice(),3)),this.setAttribute("uv",new st(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(x){const w=new Y,E=new Y,b=new Y;for(let M=0;M<t.length;M+=3)m(t[M+0],w),m(t[M+1],E),m(t[M+2],b),l(w,E,b,x)}function l(x,w,E,b){const M=b+1,A=[];for(let P=0;P<=M;P++){A[P]=[];const C=x.clone().lerp(E,P/M),L=w.clone().lerp(E,P/M),F=M-P;for(let N=0;N<=F;N++)N===0&&P===M?A[P][N]=C:A[P][N]=C.clone().lerp(L,N/F)}for(let P=0;P<M;P++)for(let C=0;C<2*(M-P)-1;C++){const L=Math.floor(C/2);C%2===0?(p(A[P][L+1]),p(A[P+1][L]),p(A[P][L])):(p(A[P][L+1]),p(A[P+1][L+1]),p(A[P+1][L]))}}function c(x){const w=new Y;for(let E=0;E<s.length;E+=3)w.x=s[E+0],w.y=s[E+1],w.z=s[E+2],w.normalize().multiplyScalar(x),s[E+0]=w.x,s[E+1]=w.y,s[E+2]=w.z}function u(){const x=new Y;for(let w=0;w<s.length;w+=3){x.x=s[w+0],x.y=s[w+1],x.z=s[w+2];const E=y(x)/2/Math.PI+.5,b=g(x)/Math.PI+.5;o.push(E,1-b)}v(),h()}function h(){for(let x=0;x<o.length;x+=6){const w=o[x+0],E=o[x+2],b=o[x+4],M=Math.max(w,E,b),A=Math.min(w,E,b);M>.9&&A<.1&&(w<.2&&(o[x+0]+=1),E<.2&&(o[x+2]+=1),b<.2&&(o[x+4]+=1))}}function p(x){s.push(x.x,x.y,x.z)}function m(x,w){const E=x*3;w.x=e[E+0],w.y=e[E+1],w.z=e[E+2]}function v(){const x=new Y,w=new Y,E=new Y,b=new Y,M=new De,A=new De,P=new De;for(let C=0,L=0;C<s.length;C+=9,L+=6){x.set(s[C+0],s[C+1],s[C+2]),w.set(s[C+3],s[C+4],s[C+5]),E.set(s[C+6],s[C+7],s[C+8]),M.set(o[L+0],o[L+1]),A.set(o[L+2],o[L+3]),P.set(o[L+4],o[L+5]),b.copy(x).add(w).add(E).divideScalar(3);const F=y(b);_(M,L+0,x,F),_(A,L+2,w,F),_(P,L+4,E,F)}}function _(x,w,E,b){b<0&&x.x===1&&(o[w]=x.x-1),E.x===0&&E.z===0&&(o[w]=b/2/Math.PI+.5)}function y(x){return Math.atan2(x.z,-x.x)}function g(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ao(e.vertices,e.indices,e.radius,e.details)}}class fp extends Ao{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new fp(e.radius,e.detail)}}const Bf=new Y,Gf=new Y,cg=new Y,Hf=new zi;class LM extends Tt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),s=Math.cos(ma*t),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],u=["a","b","c"],h=new Array(3),p={},m=[];for(let v=0;v<l;v+=3){o?(c[0]=o.getX(v),c[1]=o.getX(v+1),c[2]=o.getX(v+2)):(c[0]=v,c[1]=v+1,c[2]=v+2);const{a:_,b:y,c:g}=Hf;if(_.fromBufferAttribute(a,c[0]),y.fromBufferAttribute(a,c[1]),g.fromBufferAttribute(a,c[2]),Hf.getNormal(cg),h[0]=`${Math.round(_.x*i)},${Math.round(_.y*i)},${Math.round(_.z*i)}`,h[1]=`${Math.round(y.x*i)},${Math.round(y.y*i)},${Math.round(y.z*i)}`,h[2]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let x=0;x<3;x++){const w=(x+1)%3,E=h[x],b=h[w],M=Hf[u[x]],A=Hf[u[w]],P=`${E}_${b}`,C=`${b}_${E}`;C in p&&p[C]?(cg.dot(p[C].normal)<=s&&(m.push(M.x,M.y,M.z),m.push(A.x,A.y,A.z)),p[C]=null):P in p||(p[P]={index0:c[x],index1:c[w],normal:cg.clone()})}}for(const v in p)if(p[v]){const{index0:_,index1:y}=p[v];Bf.fromBufferAttribute(a,_),Gf.fromBufferAttribute(a,y),m.push(Bf.x,Bf.y,Bf.z),m.push(Gf.x,Gf.y,Gf.z)}this.setAttribute("position",new st(m,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class va extends zu{constructor(e){super(e),this.uuid=er(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new zu().fromJSON(i))}return this}}const dU={triangulate:function(r,e,t=2){const n=e&&e.length,i=n?e[0]*t:r.length;let s=IM(r,0,i,t,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c,u,h,p,m;if(n&&(s=yU(r,e,s,t)),r.length>80*t){a=c=r[0],l=u=r[1];for(let v=t;v<i;v+=t)h=r[v],p=r[v+1],h<a&&(a=h),p<l&&(l=p),h>c&&(c=h),p>u&&(u=p);m=Math.max(c-a,u-l),m=m!==0?32767/m:0}return Bu(s,o,t,a,l,m,0),o}};function IM(r,e,t,n,i){let s,o;if(i===RU(r,e,t,n)>0)for(s=e;s<t;s+=n)o=j1(s,r[s],r[s+1],o);else for(s=t-n;s>=e;s-=n)o=j1(s,r[s],r[s+1],o);return o&&dp(o,o.next)&&(Hu(o),o=o.next),o}function Ea(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(dp(t,t.next)||yn(t.prev,t,t.next)===0)){if(Hu(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Bu(r,e,t,n,i,s,o){if(!r)return;!o&&s&&EU(r,n,i,s);let a=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?mU(r,n,i,s):pU(r)){e.push(l.i/t|0),e.push(r.i/t|0),e.push(c.i/t|0),Hu(r),r=c.next,a=c.next;continue}if(r=c,r===a){o?o===1?(r=gU(Ea(r),e,t),Bu(r,e,t,n,i,s,2)):o===2&&vU(r,e,t,n,i,s):Bu(Ea(r),e,t,n,i,s,1);break}}}function pU(r){const e=r.prev,t=r,n=r.next;if(yn(e,t,n)>=0)return!1;const i=e.x,s=t.x,o=n.x,a=e.y,l=t.y,c=n.y,u=i<s?i<o?i:o:s<o?s:o,h=a<l?a<c?a:c:l<c?l:c,p=i>s?i>o?i:o:s>o?s:o,m=a>l?a>c?a:c:l>c?l:c;let v=n.next;for(;v!==e;){if(v.x>=u&&v.x<=p&&v.y>=h&&v.y<=m&&Nl(i,a,s,l,o,c,v.x,v.y)&&yn(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function mU(r,e,t,n){const i=r.prev,s=r,o=r.next;if(yn(i,s,o)>=0)return!1;const a=i.x,l=s.x,c=o.x,u=i.y,h=s.y,p=o.y,m=a<l?a<c?a:c:l<c?l:c,v=u<h?u<p?u:p:h<p?h:p,_=a>l?a>c?a:c:l>c?l:c,y=u>h?u>p?u:p:h>p?h:p,g=hv(m,v,e,t,n),x=hv(_,y,e,t,n);let w=r.prevZ,E=r.nextZ;for(;w&&w.z>=g&&E&&E.z<=x;){if(w.x>=m&&w.x<=_&&w.y>=v&&w.y<=y&&w!==i&&w!==o&&Nl(a,u,l,h,c,p,w.x,w.y)&&yn(w.prev,w,w.next)>=0||(w=w.prevZ,E.x>=m&&E.x<=_&&E.y>=v&&E.y<=y&&E!==i&&E!==o&&Nl(a,u,l,h,c,p,E.x,E.y)&&yn(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;w&&w.z>=g;){if(w.x>=m&&w.x<=_&&w.y>=v&&w.y<=y&&w!==i&&w!==o&&Nl(a,u,l,h,c,p,w.x,w.y)&&yn(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;E&&E.z<=x;){if(E.x>=m&&E.x<=_&&E.y>=v&&E.y<=y&&E!==i&&E!==o&&Nl(a,u,l,h,c,p,E.x,E.y)&&yn(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function gU(r,e,t){let n=r;do{const i=n.prev,s=n.next.next;!dp(i,s)&&DM(i,n,n.next,s)&&Gu(i,s)&&Gu(s,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),Hu(n),Hu(n.next),n=r=s),n=n.next}while(n!==r);return Ea(n)}function vU(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&TU(o,a)){let l=UM(o,a);o=Ea(o,o.next),l=Ea(l,l.next),Bu(o,e,t,n,i,s,0),Bu(l,e,t,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function yU(r,e,t,n){const i=[];let s,o,a,l,c;for(s=0,o=e.length;s<o;s++)a=e[s]*n,l=s<o-1?e[s+1]*n:r.length,c=IM(r,a,l,n,!1),c===c.next&&(c.steiner=!0),i.push(MU(c));for(i.sort(_U),s=0;s<i.length;s++)t=xU(i[s],t);return t}function _U(r,e){return r.x-e.x}function xU(r,e){const t=wU(r,e);if(!t)return e;const n=UM(t,r);return Ea(n,n.next),Ea(t,t.next)}function wU(r,e){let t=e,n=-1/0,i;const s=r.x,o=r.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){const p=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(p<=s&&p>n&&(n=p,i=t.x<t.next.x?t:t.next,p===s))return i}t=t.next}while(t!==e);if(!i)return null;const a=i,l=i.x,c=i.y;let u=1/0,h;t=i;do s>=t.x&&t.x>=l&&s!==t.x&&Nl(o<c?s:n,o,l,c,o<c?n:s,o,t.x,t.y)&&(h=Math.abs(o-t.y)/(s-t.x),Gu(t,r)&&(h<u||h===u&&(t.x>i.x||t.x===i.x&&SU(i,t)))&&(i=t,u=h)),t=t.next;while(t!==a);return i}function SU(r,e){return yn(r.prev,r,e.prev)<0&&yn(e.next,r,r.next)<0}function EU(r,e,t,n){let i=r;do i.z===0&&(i.z=hv(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,bU(i)}function bU(r){let e,t,n,i,s,o,a,l,c=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<c&&(a++,n=n.nextZ,!!n);e++);for(l=c;a>0||l>0&&n;)a!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(o>1);return r}function hv(r,e,t,n,i){return r=(r-t)*i|0,e=(e-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function MU(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function Nl(r,e,t,n,i,s,o,a){return(i-o)*(e-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(i-o)*(n-a)}function TU(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!AU(r,e)&&(Gu(r,e)&&Gu(e,r)&&CU(r,e)&&(yn(r.prev,r,e.prev)||yn(r,e.prev,e))||dp(r,e)&&yn(r.prev,r,r.next)>0&&yn(e.prev,e,e.next)>0)}function yn(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function dp(r,e){return r.x===e.x&&r.y===e.y}function DM(r,e,t,n){const i=Wf(yn(r,e,t)),s=Wf(yn(r,e,n)),o=Wf(yn(t,n,r)),a=Wf(yn(t,n,e));return!!(i!==s&&o!==a||i===0&&Vf(r,t,e)||s===0&&Vf(r,n,e)||o===0&&Vf(t,r,n)||a===0&&Vf(t,e,n))}function Vf(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Wf(r){return r>0?1:r<0?-1:0}function AU(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&DM(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Gu(r,e){return yn(r.prev,r,r.next)<0?yn(r,e,r.next)>=0&&yn(r,r.prev,e)>=0:yn(r,e,r.prev)<0||yn(r,r.next,e)<0}function CU(r,e){let t=r,n=!1;const i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function UM(r,e){const t=new fv(r.i,r.x,r.y),n=new fv(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function j1(r,e,t,n){const i=new fv(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Hu(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function fv(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function RU(r,e,t,n){let i=0;for(let s=e,o=t-n;s<t;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}class as{static area(e){const t=e.length;let n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return as.area(e)<0}static triangulateShape(e,t){const n=[],i=[],s=[];Y1(e),q1(n,e);let o=e.length;t.forEach(Y1);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,q1(n,t[l]);const a=dU.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}}function Y1(r){const e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function q1(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}class pp extends Tt{constructor(e=new va([new De(.5,.5),new De(-.5,.5),new De(-.5,-.5),new De(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],s=[];for(let a=0,l=e.length;a<l;a++){const c=e[a];o(c)}this.setAttribute("position",new st(i,3)),this.setAttribute("uv",new st(s,2)),this.computeVertexNormals();function o(a){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let p=t.bevelEnabled!==void 0?t.bevelEnabled:!0,m=t.bevelThickness!==void 0?t.bevelThickness:.2,v=t.bevelSize!==void 0?t.bevelSize:m-.1,_=t.bevelOffset!==void 0?t.bevelOffset:0,y=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:PU;let w,E=!1,b,M,A,P;g&&(w=g.getSpacedPoints(u),E=!0,p=!1,b=g.computeFrenetFrames(u,!1),M=new Y,A=new Y,P=new Y),p||(y=0,m=0,v=0,_=0);const C=a.extractPoints(c);let L=C.shape;const F=C.holes;if(!as.isClockWise(L)){L=L.reverse();for(let z=0,oe=F.length;z<oe;z++){const te=F[z];as.isClockWise(te)&&(F[z]=te.reverse())}}const I=as.triangulateShape(L,F),X=L;for(let z=0,oe=F.length;z<oe;z++){const te=F[z];L=L.concat(te)}function q(z,oe,te){return oe||console.error("THREE.ExtrudeGeometry: vec does not exist"),z.clone().addScaledVector(oe,te)}const W=L.length,O=I.length;function k(z,oe,te){let se,$,Ie;const de=z.x-oe.x,Se=z.y-oe.y,Le=te.x-z.x,ge=te.y-z.y,He=de*de+Se*Se,j=de*ge-Se*Le;if(Math.abs(j)>Number.EPSILON){const H=Math.sqrt(He),ne=Math.sqrt(Le*Le+ge*ge),we=oe.x-Se/H,be=oe.y+de/H,Me=te.x-ge/ne,Fe=te.y+Le/ne,Ue=((Me-we)*ge-(Fe-be)*Le)/(de*ge-Se*Le);se=we+de*Ue-z.x,$=be+Se*Ue-z.y;const xe=se*se+$*$;if(xe<=2)return new De(se,$);Ie=Math.sqrt(xe/2)}else{let H=!1;de>Number.EPSILON?Le>Number.EPSILON&&(H=!0):de<-Number.EPSILON?Le<-Number.EPSILON&&(H=!0):Math.sign(Se)===Math.sign(ge)&&(H=!0),H?(se=-Se,$=de,Ie=Math.sqrt(He)):(se=de,$=Se,Ie=Math.sqrt(He/2))}return new De(se/Ie,$/Ie)}const G=[];for(let z=0,oe=X.length,te=oe-1,se=z+1;z<oe;z++,te++,se++)te===oe&&(te=0),se===oe&&(se=0),G[z]=k(X[z],X[te],X[se]);const B=[];let D,V=G.concat();for(let z=0,oe=F.length;z<oe;z++){const te=F[z];D=[];for(let se=0,$=te.length,Ie=$-1,de=se+1;se<$;se++,Ie++,de++)Ie===$&&(Ie=0),de===$&&(de=0),D[se]=k(te[se],te[Ie],te[de]);B.push(D),V=V.concat(D)}for(let z=0;z<y;z++){const oe=z/y,te=m*Math.cos(oe*Math.PI/2),se=v*Math.sin(oe*Math.PI/2)+_;for(let $=0,Ie=X.length;$<Ie;$++){const de=q(X[$],G[$],se);ce(de.x,de.y,-te)}for(let $=0,Ie=F.length;$<Ie;$++){const de=F[$];D=B[$];for(let Se=0,Le=de.length;Se<Le;Se++){const ge=q(de[Se],D[Se],se);ce(ge.x,ge.y,-te)}}}const Z=v+_;for(let z=0;z<W;z++){const oe=p?q(L[z],V[z],Z):L[z];E?(A.copy(b.normals[0]).multiplyScalar(oe.x),M.copy(b.binormals[0]).multiplyScalar(oe.y),P.copy(w[0]).add(A).add(M),ce(P.x,P.y,P.z)):ce(oe.x,oe.y,0)}for(let z=1;z<=u;z++)for(let oe=0;oe<W;oe++){const te=p?q(L[oe],V[oe],Z):L[oe];E?(A.copy(b.normals[z]).multiplyScalar(te.x),M.copy(b.binormals[z]).multiplyScalar(te.y),P.copy(w[z]).add(A).add(M),ce(P.x,P.y,P.z)):ce(te.x,te.y,h/u*z)}for(let z=y-1;z>=0;z--){const oe=z/y,te=m*Math.cos(oe*Math.PI/2),se=v*Math.sin(oe*Math.PI/2)+_;for(let $=0,Ie=X.length;$<Ie;$++){const de=q(X[$],G[$],se);ce(de.x,de.y,h+te)}for(let $=0,Ie=F.length;$<Ie;$++){const de=F[$];D=B[$];for(let Se=0,Le=de.length;Se<Le;Se++){const ge=q(de[Se],D[Se],se);E?ce(ge.x,ge.y+w[u-1].y,w[u-1].x+te):ce(ge.x,ge.y,h+te)}}}ee(),ie();function ee(){const z=i.length/3;if(p){let oe=0,te=W*oe;for(let se=0;se<O;se++){const $=I[se];le($[2]+te,$[1]+te,$[0]+te)}oe=u+y*2,te=W*oe;for(let se=0;se<O;se++){const $=I[se];le($[0]+te,$[1]+te,$[2]+te)}}else{for(let oe=0;oe<O;oe++){const te=I[oe];le(te[2],te[1],te[0])}for(let oe=0;oe<O;oe++){const te=I[oe];le(te[0]+W*u,te[1]+W*u,te[2]+W*u)}}n.addGroup(z,i.length/3-z,0)}function ie(){const z=i.length/3;let oe=0;ue(X,oe),oe+=X.length;for(let te=0,se=F.length;te<se;te++){const $=F[te];ue($,oe),oe+=$.length}n.addGroup(z,i.length/3-z,1)}function ue(z,oe){let te=z.length;for(;--te>=0;){const se=te;let $=te-1;$<0&&($=z.length-1);for(let Ie=0,de=u+y*2;Ie<de;Ie++){const Se=W*Ie,Le=W*(Ie+1),ge=oe+se+Se,He=oe+$+Se,j=oe+$+Le,H=oe+se+Le;Ae(ge,He,j,H)}}}function ce(z,oe,te){l.push(z),l.push(oe),l.push(te)}function le(z,oe,te){Ee(z),Ee(oe),Ee(te);const se=i.length/3,$=x.generateTopUV(n,i,se-3,se-2,se-1);ae($[0]),ae($[1]),ae($[2])}function Ae(z,oe,te,se){Ee(z),Ee(oe),Ee(se),Ee(oe),Ee(te),Ee(se);const $=i.length/3,Ie=x.generateSideWallUV(n,i,$-6,$-3,$-2,$-1);ae(Ie[0]),ae(Ie[1]),ae(Ie[3]),ae(Ie[1]),ae(Ie[2]),ae(Ie[3])}function Ee(z){i.push(l[z*3+0]),i.push(l[z*3+1]),i.push(l[z*3+2])}function ae(z){s.push(z.x),s.push(z.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return LU(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,o=e.shapes.length;s<o;s++){const a=t[e.shapes[s]];n.push(a)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new xy[i.type]().fromJSON(i)),new pp(n,e.options)}}const PU={generateTopUV:function(r,e,t,n,i){const s=e[t*3],o=e[t*3+1],a=e[n*3],l=e[n*3+1],c=e[i*3],u=e[i*3+1];return[new De(s,o),new De(a,l),new De(c,u)]},generateSideWallUV:function(r,e,t,n,i,s){const o=e[t*3],a=e[t*3+1],l=e[t*3+2],c=e[n*3],u=e[n*3+1],h=e[n*3+2],p=e[i*3],m=e[i*3+1],v=e[i*3+2],_=e[s*3],y=e[s*3+1],g=e[s*3+2];return Math.abs(a-u)<Math.abs(o-c)?[new De(o,1-l),new De(c,1-h),new De(p,1-v),new De(_,1-g)]:[new De(a,1-l),new De(u,1-h),new De(m,1-v),new De(y,1-g)]}};function LU(r,e,t){if(t.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){const s=r[n];t.shapes.push(s.uuid)}else t.shapes.push(r.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class mp extends Ao{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new mp(e.radius,e.detail)}}class lh extends Ao{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new lh(e.radius,e.detail)}}class gp extends Tt{constructor(e=.5,t=1,n=32,i=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:s,thetaLength:o},n=Math.max(3,n),i=Math.max(1,i);const a=[],l=[],c=[],u=[];let h=e;const p=(t-e)/i,m=new Y,v=new De;for(let _=0;_<=i;_++){for(let y=0;y<=n;y++){const g=s+y/n*o;m.x=h*Math.cos(g),m.y=h*Math.sin(g),l.push(m.x,m.y,m.z),c.push(0,0,1),v.x=(m.x/t+1)/2,v.y=(m.y/t+1)/2,u.push(v.x,v.y)}h+=p}for(let _=0;_<i;_++){const y=_*(n+1);for(let g=0;g<n;g++){const x=g+y,w=x,E=x+n+1,b=x+n+2,M=x+1;a.push(w,E,M),a.push(E,b,M)}}this.setIndex(a),this.setAttribute("position",new st(l,3)),this.setAttribute("normal",new st(c,3)),this.setAttribute("uv",new st(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gp(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class vp extends Tt{constructor(e=new va([new De(0,.5),new De(-.5,-.5),new De(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],s=[],o=[];let a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(a,l,u),a+=l,l=0;this.setIndex(n),this.setAttribute("position",new st(i,3)),this.setAttribute("normal",new st(s,3)),this.setAttribute("uv",new st(o,2));function c(u){const h=i.length/3,p=u.extractPoints(t);let m=p.shape;const v=p.holes;as.isClockWise(m)===!1&&(m=m.reverse());for(let y=0,g=v.length;y<g;y++){const x=v[y];as.isClockWise(x)===!0&&(v[y]=x.reverse())}const _=as.triangulateShape(m,v);for(let y=0,g=v.length;y<g;y++){const x=v[y];m=m.concat(x)}for(let y=0,g=m.length;y<g;y++){const x=m[y];i.push(x.x,x.y,0),s.push(0,0,1),o.push(x.x,x.y)}for(let y=0,g=_.length;y<g;y++){const x=_[y],w=x[0]+h,E=x[1]+h,b=x[2]+h;n.push(w,E,b),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return IU(t,e)}static fromJSON(e,t){const n=[];for(let i=0,s=e.shapes.length;i<s;i++){const o=t[e.shapes[i]];n.push(o)}return new vp(n,e.curveSegments)}}function IU(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,n=r.length;t<n;t++){const i=r[t];e.shapes.push(i.uuid)}else e.shapes.push(r.uuid);return e}class ch extends Tt{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(o+a,Math.PI);let c=0;const u=[],h=new Y,p=new Y,m=[],v=[],_=[],y=[];for(let g=0;g<=n;g++){const x=[],w=g/n;let E=0;g===0&&o===0?E=.5/t:g===n&&l===Math.PI&&(E=-.5/t);for(let b=0;b<=t;b++){const M=b/t;h.x=-e*Math.cos(i+M*s)*Math.sin(o+w*a),h.y=e*Math.cos(o+w*a),h.z=e*Math.sin(i+M*s)*Math.sin(o+w*a),v.push(h.x,h.y,h.z),p.copy(h).normalize(),_.push(p.x,p.y,p.z),y.push(M+E,1-w),x.push(c++)}u.push(x)}for(let g=0;g<n;g++)for(let x=0;x<t;x++){const w=u[g][x+1],E=u[g][x],b=u[g+1][x],M=u[g+1][x+1];(g!==0||o>0)&&m.push(w,E,M),(g!==n-1||l<Math.PI)&&m.push(E,b,M)}this.setIndex(m),this.setAttribute("position",new st(v,3)),this.setAttribute("normal",new st(_,3)),this.setAttribute("uv",new st(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ch(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class yp extends Ao{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new yp(e.radius,e.detail)}}class _p extends Tt{constructor(e=1,t=.4,n=12,i=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:s},n=Math.floor(n),i=Math.floor(i);const o=[],a=[],l=[],c=[],u=new Y,h=new Y,p=new Y;for(let m=0;m<=n;m++)for(let v=0;v<=i;v++){const _=v/i*s,y=m/n*Math.PI*2;h.x=(e+t*Math.cos(y))*Math.cos(_),h.y=(e+t*Math.cos(y))*Math.sin(_),h.z=t*Math.sin(y),a.push(h.x,h.y,h.z),u.x=e*Math.cos(_),u.y=e*Math.sin(_),p.subVectors(h,u).normalize(),l.push(p.x,p.y,p.z),c.push(v/i),c.push(m/n)}for(let m=1;m<=n;m++)for(let v=1;v<=i;v++){const _=(i+1)*m+v-1,y=(i+1)*(m-1)+v-1,g=(i+1)*(m-1)+v,x=(i+1)*m+v;o.push(_,y,x),o.push(y,g,x)}this.setIndex(o),this.setAttribute("position",new st(a,3)),this.setAttribute("normal",new st(l,3)),this.setAttribute("uv",new st(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _p(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class xp extends Tt{constructor(e=1,t=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);const a=[],l=[],c=[],u=[],h=new Y,p=new Y,m=new Y,v=new Y,_=new Y,y=new Y,g=new Y;for(let w=0;w<=n;++w){const E=w/n*s*Math.PI*2;x(E,s,o,e,m),x(E+.01,s,o,e,v),y.subVectors(v,m),g.addVectors(v,m),_.crossVectors(y,g),g.crossVectors(_,y),_.normalize(),g.normalize();for(let b=0;b<=i;++b){const M=b/i*Math.PI*2,A=-t*Math.cos(M),P=t*Math.sin(M);h.x=m.x+(A*g.x+P*_.x),h.y=m.y+(A*g.y+P*_.y),h.z=m.z+(A*g.z+P*_.z),l.push(h.x,h.y,h.z),p.subVectors(h,m).normalize(),c.push(p.x,p.y,p.z),u.push(w/n),u.push(b/i)}}for(let w=1;w<=n;w++)for(let E=1;E<=i;E++){const b=(i+1)*(w-1)+(E-1),M=(i+1)*w+(E-1),A=(i+1)*w+E,P=(i+1)*(w-1)+E;a.push(b,M,P),a.push(M,A,P)}this.setIndex(a),this.setAttribute("position",new st(l,3)),this.setAttribute("normal",new st(c,3)),this.setAttribute("uv",new st(u,2));function x(w,E,b,M,A){const P=Math.cos(w),C=Math.sin(w),L=b/E*w,F=Math.cos(L);A.x=M*(2+F)*.5*P,A.y=M*(2+F)*C*.5,A.z=M*Math.sin(L)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xp(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class ba extends Tt{constructor(e=new lp(new Y(-1,-1,0),new Y(-1,1,0),new Y(1,1,0)),t=64,n=1,i=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:s};const o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new Y,l=new Y,c=new De;let u=new Y;const h=[],p=[],m=[],v=[];_(),this.setIndex(v),this.setAttribute("position",new st(h,3)),this.setAttribute("normal",new st(p,3)),this.setAttribute("uv",new st(m,2));function _(){for(let w=0;w<t;w++)y(w);y(s===!1?t:0),x(),g()}function y(w){u=e.getPointAt(w/t,u);const E=o.normals[w],b=o.binormals[w];for(let M=0;M<=i;M++){const A=M/i*Math.PI*2,P=Math.sin(A),C=-Math.cos(A);l.x=C*E.x+P*b.x,l.y=C*E.y+P*b.y,l.z=C*E.z+P*b.z,l.normalize(),p.push(l.x,l.y,l.z),a.x=u.x+n*l.x,a.y=u.y+n*l.y,a.z=u.z+n*l.z,h.push(a.x,a.y,a.z)}}function g(){for(let w=1;w<=t;w++)for(let E=1;E<=i;E++){const b=(i+1)*(w-1)+(E-1),M=(i+1)*w+(E-1),A=(i+1)*w+E,P=(i+1)*(w-1)+E;v.push(b,M,P),v.push(M,A,P)}}function x(){for(let w=0;w<=t;w++)for(let E=0;E<=i;E++)c.x=w/t,c.y=E/i,m.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new ba(new xy[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class OM extends Tt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new Y,s=new Y;if(e.index!==null){const o=e.attributes.position,a=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:a.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const h=l[c],p=h.start,m=h.count;for(let v=p,_=p+m;v<_;v+=3)for(let y=0;y<3;y++){const g=a.getX(v+y),x=a.getX(v+(y+1)%3);i.fromBufferAttribute(o,g),s.fromBufferAttribute(o,x),Z1(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}}else{const o=e.attributes.position;for(let a=0,l=o.count/3;a<l;a++)for(let c=0;c<3;c++){const u=3*a+c,h=3*a+(c+1)%3;i.fromBufferAttribute(o,u),s.fromBufferAttribute(o,h),Z1(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new st(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Z1(r,e,t){const n=`${r.x},${r.y},${r.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${r.x},${r.y},${r.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}var K1=Object.freeze({__proto__:null,BoxGeometry:Ws,CapsuleGeometry:cp,CircleGeometry:up,ConeGeometry:hp,CylinderGeometry:La,DodecahedronGeometry:fp,EdgesGeometry:LM,ExtrudeGeometry:pp,IcosahedronGeometry:mp,LatheGeometry:ah,OctahedronGeometry:lh,PlaneGeometry:To,PolyhedronGeometry:Ao,RingGeometry:gp,ShapeGeometry:vp,SphereGeometry:ch,TetrahedronGeometry:yp,TorusGeometry:_p,TorusKnotGeometry:xp,TubeGeometry:ba,WireframeGeometry:OM});class NM extends oi{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ke(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class FM extends cs{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class wy extends oi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ke(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 Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mo,this.normalScale=new De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,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.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 kM extends wy{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new De(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Tn(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ke(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ke(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ke(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class zM extends oi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ke(16777215),this.specular=new Ke(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mo,this.normalScale=new De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ih,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class BM extends oi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ke(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mo,this.normalScale=new De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class GM extends oi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mo,this.normalScale=new De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class HM extends oi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ke(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mo,this.normalScale=new De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ih,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class VM extends oi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ke(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mo,this.normalScale=new De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class WM extends Pi{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function yr(r,e,t){return Sy(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)}function da(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function Sy(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function XM(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function dv(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){const a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i}function Ey(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)}function DU(r,e,t,n,i=30){const s=r.clone();s.name=e;const o=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],u=c.getValueSize(),h=[],p=[];for(let m=0;m<c.times.length;++m){const v=c.times[m]*i;if(!(v<t||v>=n)){h.push(c.times[m]);for(let _=0;_<u;++_)p.push(c.values[m*u+_])}}h.length!==0&&(c.times=da(h,c.times.constructor),c.values=da(p,c.values.constructor),o.push(c))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s}function UU(r,e=0,t=r,n=30){n<=0&&(n=30);const i=t.tracks.length,s=e/n;for(let o=0;o<i;++o){const a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;const c=r.tracks.find(function(g){return g.name===a.name&&g.ValueTypeName===l});if(c===void 0)continue;let u=0;const h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let p=0;const m=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(p=m/3);const v=a.times.length-1;let _;if(s<=a.times[0]){const g=u,x=h-u;_=yr(a.values,g,x)}else if(s>=a.times[v]){const g=v*h+u,x=g+h-u;_=yr(a.values,g,x)}else{const g=a.createInterpolant(),x=u,w=h-u;g.evaluate(s),_=yr(g.resultBuffer,x,w)}l==="quaternion"&&new si().fromArray(_).normalize().conjugate().toArray(_);const y=c.times.length;for(let g=0;g<y;++g){const x=g*m+p;if(l==="quaternion")si.multiplyQuaternionsFlat(c.values,x,_,0,c.values,x);else{const w=m-p*2;for(let E=0;E<w;++E)c.values[x+E]-=_[E]}}}return r.blendMode=Qv,r}const OU={arraySlice:yr,convertArray:da,isTypedArray:Sy,getKeyframeOrder:XM,sortedArray:dv,flattenJSON:Ey,subclip:DU,makeClipAdditive:UU};class uh{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];e:{t:{let o;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=t[++n],e<i)break t}o=t.length;break n}if(!(e>=s)){const a=t[1];e<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break t}o=n,n=0;break n}break e}for(;n<o;){const a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class jM extends uh{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ua,endingEnd:ua}}intervalChanged_(e,t,n){const i=this.parameterPositions;let s=e-2,o=e+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case ha:s=e,a=2*t-n;break;case Uu:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case ha:o=e,l=2*n-t;break;case Uu:o=1,l=n+i[1]-i[0];break;default:o=e-1,l=t}const c=(n-t)*.5,u=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=this._offsetPrev,h=this._offsetNext,p=this._weightPrev,m=this._weightNext,v=(n-t)/(i-t),_=v*v,y=_*v,g=-p*y+2*p*_-p*v,x=(1+p)*y+(-1.5-2*p)*_+(-.5+p)*v+1,w=(-1-m)*y+(1.5+m)*_+.5*v,E=m*y-m*_;for(let b=0;b!==a;++b)s[b]=g*o[u+b]+x*o[c+b]+w*o[l+b]+E*o[h+b];return s}}class by extends uh{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=(n-t)/(i-t),h=1-u;for(let p=0;p!==a;++p)s[p]=o[c+p]*h+o[l+p]*u;return s}}class YM extends uh{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Wr{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=da(t,this.TimeBufferType),this.values=da(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:da(e.times,Array),values:da(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new YM(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new by(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new jM(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Iu:t=this.InterpolantFactoryMethodDiscrete;break;case Du:t=this.InterpolantFactoryMethodLinear;break;case Sd:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Iu;case this.InterpolantFactoryMethodLinear:return Du;case this.InterpolantFactoryMethodSmooth:return Sd}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let s=0,o=i-1;for(;s!==i&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=yr(n,s,o),this.values=yr(this.values,s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&Sy(i))for(let a=0,l=i.length;a!==l;++a){const c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=yr(this.times),t=yr(this.values),n=this.getValueSize(),i=this.getInterpolation()===Sd,s=e.length-1;let o=1;for(let a=1;a<s;++a){let l=!1;const c=e[a],u=e[a+1];if(c!==u&&(a!==1||c!==e[0]))if(i)l=!0;else{const h=a*n,p=h-n,m=h+n;for(let v=0;v!==n;++v){const _=t[h+v];if(_!==t[p+v]||_!==t[m+v]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];const h=a*n,p=o*n;for(let m=0;m!==n;++m)t[p+m]=t[h+m]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=yr(e,0,o),this.values=yr(t,0,o*n)):(this.times=e,this.values=t),this}clone(){const e=yr(this.times,0),t=yr(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Wr.prototype.TimeBufferType=Float32Array;Wr.prototype.ValueBufferType=Float32Array;Wr.prototype.DefaultInterpolation=Du;class Ia extends Wr{}Ia.prototype.ValueTypeName="bool";Ia.prototype.ValueBufferType=Array;Ia.prototype.DefaultInterpolation=Iu;Ia.prototype.InterpolantFactoryMethodLinear=void 0;Ia.prototype.InterpolantFactoryMethodSmooth=void 0;class My extends Wr{}My.prototype.ValueTypeName="color";class Vu extends Wr{}Vu.prototype.ValueTypeName="number";class qM extends uh{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t);let c=e*a;for(let u=c+a;c!==u;c+=4)si.slerpFlat(s,0,o,c-a,o,c,l);return s}}class tc extends Wr{InterpolantFactoryMethodLinear(e){return new qM(this.times,this.values,this.getValueSize(),e)}}tc.prototype.ValueTypeName="quaternion";tc.prototype.DefaultInterpolation=Du;tc.prototype.InterpolantFactoryMethodSmooth=void 0;class Da extends Wr{}Da.prototype.ValueTypeName="string";Da.prototype.ValueBufferType=Array;Da.prototype.DefaultInterpolation=Iu;Da.prototype.InterpolantFactoryMethodLinear=void 0;Da.prototype.InterpolantFactoryMethodSmooth=void 0;class Wu extends Wr{}Wu.prototype.ValueTypeName="vector";class Xu{constructor(e,t=-1,n,i=$d){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=er(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(FU(n[o]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(Wr.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,o=[];for(let a=0;a<s;a++){let l=[],c=[];l.push((a+s-1)%s,a,(a+1)%s),c.push(0,1,0);const u=XM(l);l=dv(l,1,u),c=dv(c,1,u),!i&&l[0]===0&&(l.push(s),c.push(c[0])),o.push(new Vu(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){const c=e[a],u=c.name.match(s);if(u&&u.length>1){const h=u[1];let p=i[h];p||(i[h]=p=[]),p.push(c)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,p,m,v,_){if(m.length!==0){const y=[],g=[];Ey(m,y,g,v),y.length!==0&&_.push(new h(p,y,g))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h<c.length;h++){const p=c[h].keys;if(!(!p||p.length===0))if(p[0].morphTargets){const m={};let v;for(v=0;v<p.length;v++)if(p[v].morphTargets)for(let _=0;_<p[v].morphTargets.length;_++)m[p[v].morphTargets[_]]=-1;for(const _ in m){const y=[],g=[];for(let x=0;x!==p[v].morphTargets.length;++x){const w=p[v];y.push(w.time),g.push(w.morphTarget===_?1:0)}i.push(new Vu(".morphTargetInfluence["+_+"]",y,g))}l=m.length*o}else{const m=".bones["+t[h].name+"]";n(Wu,m+".position",p,"pos",i),n(tc,m+".quaternion",p,"rot",i),n(Wu,m+".scale",p,"scl",i)}}return i.length===0?null:new this(s,l,i,a)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function NU(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Vu;case"vector":case"vector2":case"vector3":case"vector4":return Wu;case"color":return My;case"quaternion":return tc;case"bool":case"boolean":return Ia;case"string":return Da}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function FU(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=NU(r.type);if(r.times===void 0){const t=[],n=[];Ey(r.keys,t,n,"value"),r.times=t,r.values=n}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const Ma={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};class Ty{constructor(e,t,n){const i=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){a++,s===!1&&i.onStart!==void 0&&i.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,i.onProgress!==void 0&&i.onProgress(u,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){const h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,p=c.length;h<p;h+=2){const m=c[h],v=c[h+1];if(m.global&&(m.lastIndex=0),m.test(u))return v}return null}}}const ZM=new Ty;class Gi{constructor(e){this.manager=e!==void 0?e:ZM,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Gi.DEFAULT_MATERIAL_NAME="__DEFAULT";const Cs={};class kU extends Error{constructor(e,t){super(e),this.response=t}}class Bs extends Gi{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Ma.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Cs[e]!==void 0){Cs[e].push({onLoad:t,onProgress:n,onError:i});return}Cs[e]=[],Cs[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=Cs[e],h=c.body.getReader(),p=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),m=p?parseInt(p):0,v=m!==0;let _=0;const y=new ReadableStream({start(g){x();function x(){h.read().then(({done:w,value:E})=>{if(w)g.close();else{_+=E.byteLength;const b=new ProgressEvent("progress",{lengthComputable:v,loaded:_,total:m});for(let M=0,A=u.length;M<A;M++){const P=u[M];P.onProgress&&P.onProgress(b)}g.enqueue(E),x()}})}}});return new Response(y)}else throw new kU(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(a),p=h&&h[1]?h[1].toLowerCase():void 0,m=new TextDecoder(p);return c.arrayBuffer().then(v=>m.decode(v))}}}).then(c=>{Ma.add(e,c);const u=Cs[e];delete Cs[e];for(let h=0,p=u.length;h<p;h++){const m=u[h];m.onLoad&&m.onLoad(c)}}).catch(c=>{const u=Cs[e];if(u===void 0)throw this.manager.itemError(e),c;delete Cs[e];for(let h=0,p=u.length;h<p;h++){const m=u[h];m.onError&&m.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class zU extends Gi{constructor(e){super(e)}load(e,t,n,i){const s=this,o=new Bs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n<e.length;n++){const i=Xu.parse(e[n]);t.push(i)}return t}}class BU extends Gi{constructor(e){super(e)}load(e,t,n,i){const s=this,o=[],a=new py,l=new Bs(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function u(h){l.load(e[h],function(p){const m=s.parse(p,!0);o[h]={width:m.width,height:m.height,format:m.format,mipmaps:m.mipmaps},c+=1,c===6&&(m.mipmapCount===1&&(a.minFilter=fn),a.image=o,a.format=m.format,a.needsUpdate=!0,t&&t(a))},n,i)}if(Array.isArray(e))for(let h=0,p=e.length;h<p;++h)u(h);else l.load(e,function(h){const p=s.parse(h,!0);if(p.isCubemap){const m=p.mipmaps.length/p.mipmapCount;for(let v=0;v<m;v++){o[v]={mipmaps:[]};for(let _=0;_<p.mipmapCount;_++)o[v].mipmaps.push(p.mipmaps[v*p.mipmapCount+_]),o[v].format=p.format,o[v].width=p.width,o[v].height=p.height}a.image=o}else a.image.width=p.width,a.image.height=p.height,a.mipmaps=p.mipmaps;p.mipmapCount===1&&(a.minFilter=fn),a.format=p.format,a.needsUpdate=!0,t&&t(a)},n,i);return a}}class ju extends Gi{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Ma.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=Fu("img");function l(){u(),Ma.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){u(),i&&i(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class GU extends Gi{constructor(e){super(e)}load(e,t,n,i){const s=new sh;s.colorSpace=Mt;const o=new ju(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(e[c],function(u){s.images[c]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,i)}for(let c=0;c<e.length;++c)l(c);return s}}class HU extends Gi{constructor(e){super(e)}load(e,t,n,i){const s=this,o=new Bl,a=new Bs(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(l){const c=s.parse(l);c&&(c.image!==void 0?o.image=c.image:c.data!==void 0&&(o.image.width=c.width,o.image.height=c.height,o.image.data=c.data),o.wrapS=c.wrapS!==void 0?c.wrapS:vi,o.wrapT=c.wrapT!==void 0?c.wrapT:vi,o.magFilter=c.magFilter!==void 0?c.magFilter:fn,o.minFilter=c.minFilter!==void 0?c.minFilter:fn,o.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0?o.colorSpace=c.colorSpace:c.encoding!==void 0&&(o.encoding=c.encoding),c.flipY!==void 0&&(o.flipY=c.flipY),c.format!==void 0&&(o.format=c.format),c.type!==void 0&&(o.type=c.type),c.mipmaps!==void 0&&(o.mipmaps=c.mipmaps,o.minFilter=So),c.mipmapCount===1&&(o.minFilter=fn),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c))},n,i),o}}class KM extends Gi{constructor(e){super(e)}load(e,t,n,i){const s=new Sn,o=new ju(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class Co extends jt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ke(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}class $M extends Co{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(jt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ke(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const ug=new yt,$1=new Y,J1=new Y;class Ay{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new De(512,512),this.map=null,this.mapPass=null,this.matrix=new yt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new oh,this._frameExtents=new De(1,1),this._viewportCount=1,this._viewports=[new Xt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;$1.setFromMatrixPosition(e.matrixWorld),t.position.copy($1),J1.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(J1),t.updateMatrixWorld(),ug.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ug),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(ug)}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.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class VU extends Ay{constructor(){super(new zn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=Wl*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class JM extends Co{constructor(e,t,n=0,i=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(jt.DEFAULT_UP),this.updateMatrix(),this.target=new jt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new VU}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Q1=new yt,kc=new Y,hg=new Y;class WU extends Ay{constructor(){super(new zn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new De(4,2),this._viewportCount=6,this._viewports=[new Xt(2,1,1,1),new Xt(0,1,1,1),new Xt(3,1,1,1),new Xt(1,1,1,1),new Xt(3,0,1,1),new Xt(1,0,1,1)],this._cubeDirections=[new Y(1,0,0),new Y(-1,0,0),new Y(0,0,1),new Y(0,0,-1),new Y(0,1,0),new Y(0,-1,0)],this._cubeUps=[new Y(0,1,0),new Y(0,1,0),new Y(0,1,0),new Y(0,1,0),new Y(0,0,1),new Y(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),kc.setFromMatrixPosition(e.matrixWorld),n.position.copy(kc),hg.copy(n.position),hg.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(hg),n.updateMatrixWorld(),i.makeTranslation(-kc.x,-kc.y,-kc.z),Q1.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Q1)}}class QM extends Co{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new WU}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class XU extends Ay{constructor(){super(new Pa(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class eT extends Co{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(jt.DEFAULT_UP),this.updateMatrix(),this.target=new jt,this.shadow=new XU}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class tT extends Co{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class nT extends Co{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class iT{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Y)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*i),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],1.092548*(n*i)),t.addScaledVector(o[5],1.092548*(i*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(n*s)),t.addScaledVector(o[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*i),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*n),t.addScaledVector(o[4],2*.429043*n*i),t.addScaledVector(o[5],2*.429043*i*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*n*s),t.addScaledVector(o[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+i*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+i*3);return e}static getBasisAt(e,t){const n=e.x,i=e.y,s=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-i*i)}}class wp extends Co{constructor(e=new iT,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Sp extends Gi{constructor(e){super(e),this.textures={}}load(e,t,n,i){const s=this,o=new Bs(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){const t=this.textures;function n(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const i=Sp.createMaterialFromType(e.type);if(e.uuid!==void 0&&(i.uuid=e.uuid),e.name!==void 0&&(i.name=e.name),e.color!==void 0&&i.color!==void 0&&i.color.setHex(e.color),e.roughness!==void 0&&(i.roughness=e.roughness),e.metalness!==void 0&&(i.metalness=e.metalness),e.sheen!==void 0&&(i.sheen=e.sheen),e.sheenColor!==void 0&&(i.sheenColor=new Ke().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(i.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(e.emissive),e.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(e.specular),e.specularIntensity!==void 0&&(i.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(i.shininess=e.shininess),e.clearcoat!==void 0&&(i.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=e.clearcoatRoughness),e.iridescence!==void 0&&(i.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(i.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(i.transmission=e.transmission),e.thickness!==void 0&&(i.thickness=e.thickness),e.attenuationDistance!==void 0&&(i.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(i.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(i.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(i.fog=e.fog),e.flatShading!==void 0&&(i.flatShading=e.flatShading),e.blending!==void 0&&(i.blending=e.blending),e.combine!==void 0&&(i.combine=e.combine),e.side!==void 0&&(i.side=e.side),e.shadowSide!==void 0&&(i.shadowSide=e.shadowSide),e.opacity!==void 0&&(i.opacity=e.opacity),e.transparent!==void 0&&(i.transparent=e.transparent),e.alphaTest!==void 0&&(i.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(i.alphaHash=e.alphaHash),e.depthTest!==void 0&&(i.depthTest=e.depthTest),e.depthWrite!==void 0&&(i.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(i.colorWrite=e.colorWrite),e.stencilWrite!==void 0&&(i.stencilWrite=e.stencilWrite),e.stencilWriteMask!==void 0&&(i.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(i.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(i.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(i.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(i.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(i.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(i.stencilZPass=e.stencilZPass),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(i.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(i.rotation=e.rotation),e.linewidth!==1&&(i.linewidth=e.linewidth),e.dashSize!==void 0&&(i.dashSize=e.dashSize),e.gapSize!==void 0&&(i.gapSize=e.gapSize),e.scale!==void 0&&(i.scale=e.scale),e.polygonOffset!==void 0&&(i.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(i.dithering=e.dithering),e.alphaToCoverage!==void 0&&(i.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(i.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(i.visible=e.visible),e.toneMapped!==void 0&&(i.toneMapped=e.toneMapped),e.userData!==void 0&&(i.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const o=e.uniforms[s];switch(i.uniforms[s]={},o.type){case"t":i.uniforms[s].value=n(o.value);break;case"c":i.uniforms[s].value=new Ke().setHex(o.value);break;case"v2":i.uniforms[s].value=new De().fromArray(o.value);break;case"v3":i.uniforms[s].value=new Y().fromArray(o.value);break;case"v4":i.uniforms[s].value=new Xt().fromArray(o.value);break;case"m3":i.uniforms[s].value=new Ct().fromArray(o.value);break;case"m4":i.uniforms[s].value=new yt().fromArray(o.value);break;default:i.uniforms[s].value=o.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(i.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)i.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(i.lights=e.lights),e.clipping!==void 0&&(i.clipping=e.clipping),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new De().fromArray(s)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new De().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(i.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:NM,SpriteMaterial:hy,RawShaderMaterial:FM,ShaderMaterial:cs,PointsMaterial:dy,MeshPhysicalMaterial:kM,MeshStandardMaterial:wy,MeshPhongMaterial:zM,MeshToonMaterial:BM,MeshNormalMaterial:GM,MeshLambertMaterial:HM,MeshDepthMaterial:ep,MeshDistanceMaterial:tp,MeshBasicMaterial:Vs,MeshMatcapMaterial:VM,LineDashedMaterial:WM,LineBasicMaterial:Pi,Material:oi};return new t[e]}}class pv{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Cy extends Tt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class rT extends Gi{constructor(e){super(e)}load(e,t,n,i){const s=this,o=new Bs(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){const t={},n={};function i(m,v){if(t[v]!==void 0)return t[v];const y=m.interleavedBuffers[v],g=s(m,y.buffer),x=Dl(y.type,g),w=new rp(x,y.stride);return w.uuid=y.uuid,t[v]=w,w}function s(m,v){if(n[v]!==void 0)return n[v];const y=m.arrayBuffers[v],g=new Uint32Array(y).buffer;return n[v]=g,g}const o=e.isInstancedBufferGeometry?new Cy:new Tt,a=e.data.index;if(a!==void 0){const m=Dl(a.type,a.array);o.setIndex(new $t(m,1))}const l=e.data.attributes;for(const m in l){const v=l[m];let _;if(v.isInterleavedBufferAttribute){const y=i(e.data,v.data);_=new wa(y,v.itemSize,v.offset,v.normalized)}else{const y=Dl(v.type,v.array),g=v.isInstancedBufferAttribute?Sa:$t;_=new g(y,v.itemSize,v.normalized)}v.name!==void 0&&(_.name=v.name),v.usage!==void 0&&_.setUsage(v.usage),v.updateRange!==void 0&&(_.updateRange.offset=v.updateRange.offset,_.updateRange.count=v.updateRange.count),o.setAttribute(m,_)}const c=e.data.morphAttributes;if(c)for(const m in c){const v=c[m],_=[];for(let y=0,g=v.length;y<g;y++){const x=v[y];let w;if(x.isInterleavedBufferAttribute){const E=i(e.data,x.data);w=new wa(E,x.itemSize,x.offset,x.normalized)}else{const E=Dl(x.type,x.array);w=new $t(E,x.itemSize,x.normalized)}x.name!==void 0&&(w.name=x.name),_.push(w)}o.morphAttributes[m]=_}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let m=0,v=h.length;m!==v;++m){const _=h[m];o.addGroup(_.start,_.count,_.materialIndex)}const p=e.data.boundingSphere;if(p!==void 0){const m=new Y;p.center!==void 0&&m.fromArray(p.center),o.boundingSphere=new rr(m,p.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}}class jU extends Gi{constructor(e){super(e)}load(e,t,n,i){const s=this,o=this.path===""?pv.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const a=new Bs(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(h){i!==void 0&&i(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},n,i)}async loadAsync(e,t){const n=this,i=this.path===""?pv.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||i;const s=new Bs(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const o=await s.loadAsync(e,t),a=JSON.parse(o),l=a.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await n.parseAsync(a)}parse(e,t){const n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,i),o=this.parseImages(e.images,function(){t!==void 0&&t(c)}),a=this.parseTextures(e.textures,o),l=this.parseMaterials(e.materials,a),c=this.parseObject(e.object,s,l,a,n),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),t!==void 0){let h=!1;for(const p in o)if(o[p].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),l=this.parseObject(e.object,i,a,o,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),l}parseShapes(e){const t={};if(e!==void 0)for(let n=0,i=e.length;n<i;n++){const s=new va().fromJSON(e[n]);t[s.uuid]=s}return t}parseSkeletons(e,t){const n={},i={};if(t.traverse(function(s){s.isBone&&(i[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){const a=new sp().fromJSON(e[s],i);n[a.uuid]=a}return n}parseGeometries(e,t){const n={};if(e!==void 0){const i=new rT;for(let s=0,o=e.length;s<o;s++){let a;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(l);break;default:l.type in K1?a=K1[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}a.uuid=l.uuid,l.name!==void 0&&(a.name=l.name),l.userData!==void 0&&(a.userData=l.userData),n[l.uuid]=a}}return n}parseMaterials(e,t){const n={},i={};if(e!==void 0){const s=new Sp;s.setTextures(t);for(let o=0,a=e.length;o<a;o++){const l=e[o];n[l.uuid]===void 0&&(n[l.uuid]=s.parse(l)),i[l.uuid]=n[l.uuid]}}return i}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const i=e[n],s=Xu.parse(i);t[s.uuid]=s}return t}parseImages(e,t){const n=this,i={};let s;function o(l){return n.manager.itemStart(l),s.load(l,function(){n.manager.itemEnd(l)},void 0,function(){n.manager.itemError(l),n.manager.itemEnd(l)})}function a(l){if(typeof l=="string"){const c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:n.resourcePath+c;return o(u)}else return l.data?{data:Dl(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new Ty(t);s=new ju(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){const h=e[c],p=h.url;if(Array.isArray(p)){const m=[];for(let v=0,_=p.length;v<_;v++){const y=p[v],g=a(y);g!==null&&(g instanceof HTMLImageElement?m.push(g):m.push(new Bl(g.data,g.width,g.height)))}i[h.uuid]=new fa(m)}else{const m=a(h.url);i[h.uuid]=new fa(m)}}}return i}async parseImagesAsync(e){const t=this,n={};let i;async function s(o){if(typeof o=="string"){const a=o,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await i.loadAsync(l)}else return o.data?{data:Dl(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){i=new ju(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){const l=e[o],c=l.url;if(Array.isArray(c)){const u=[];for(let h=0,p=c.length;h<p;h++){const m=c[h],v=await s(m);v!==null&&(v instanceof HTMLImageElement?u.push(v):u.push(new Bl(v.data,v.width,v.height)))}n[l.uuid]=new fa(u)}else{const u=await s(l.url);n[l.uuid]=new fa(u)}}}return n}parseTextures(e,t){function n(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}const i={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){const a=e[s];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);const l=t[a.image],c=l.data;let u;Array.isArray(c)?(u=new sh,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new Bl:u=new Sn,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=n(a.mapping,YU)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=n(a.wrap[0],ew),u.wrapT=n(a.wrap[1],ew)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.encoding!==void 0&&(u.encoding=a.encoding),a.minFilter!==void 0&&(u.minFilter=n(a.minFilter,tw)),a.magFilter!==void 0&&(u.magFilter=n(a.magFilter,tw)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),i[a.uuid]=u}return i}parseObject(e,t,n,i,s){let o;function a(p){return t[p]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",p),t[p]}function l(p){if(p!==void 0){if(Array.isArray(p)){const m=[];for(let v=0,_=p.length;v<_;v++){const y=p[v];n[y]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",y),m.push(n[y])}return m}return n[p]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",p),n[p]}}function c(p){return i[p]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",p),i[p]}let u,h;switch(e.type){case"Scene":o=new ku,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new Ke(e.background):o.background=c(e.background)),e.environment!==void 0&&(o.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new ip(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new np(e.fog.color,e.fog.density))),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity);break;case"PerspectiveCamera":o=new zn(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new Pa(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new tT(e.color,e.intensity);break;case"DirectionalLight":o=new eT(e.color,e.intensity);break;case"PointLight":o=new QM(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new nT(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new JM(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new $M(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new wp().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),h=l(e.material),o=new EM(u,h),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),h=l(e.material),o=new _n(u,h);break;case"InstancedMesh":u=a(e.geometry),h=l(e.material);const p=e.count,m=e.instanceMatrix,v=e.instanceColor;o=new bM(u,h,p),o.instanceMatrix=new Sa(new Float32Array(m.array),16),v!==void 0&&(o.instanceColor=new Sa(new Float32Array(v.array),v.itemSize));break;case"LOD":o=new SM;break;case"Line":o=new bo(a(e.geometry),l(e.material));break;case"LineLoop":o=new MM(a(e.geometry),l(e.material));break;case"LineSegments":o=new hs(a(e.geometry),l(e.material));break;case"PointCloud":case"Points":o=new TM(a(e.geometry),l(e.material));break;case"Sprite":o=new wM(l(e.material));break;case"Group":o=new Ol;break;case"Bone":o=new fy;break;default:o=new jt}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const p=e.children;for(let m=0;m<p.length;m++)o.add(this.parseObject(p[m],t,n,i,s))}if(e.animations!==void 0){const p=e.animations;for(let m=0;m<p.length;m++){const v=p[m];o.animations.push(s[v])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);const p=e.levels;for(let m=0;m<p.length;m++){const v=p[m],_=o.getObjectByProperty("uuid",v.object);_!==void 0&&o.addLevel(_,v.distance,v.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const i=t[n.skeleton];i===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}}const YU={UVMapping:Zd,CubeReflectionMapping:xo,CubeRefractionMapping:wo,EquirectangularReflectionMapping:Cu,EquirectangularRefractionMapping:Ru,CubeUVReflectionMapping:Jl},ew={RepeatWrapping:Pu,ClampToEdgeWrapping:vi,MirroredRepeatWrapping:Lu},tw={NearestFilter:Dn,NearestMipmapNearestFilter:Id,NearestMipmapLinearFilter:vu,LinearFilter:fn,LinearMipmapNearestFilter:jv,LinearMipmapLinearFilter:So};class qU extends Gi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=Ma.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){Ma.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){i&&i(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}let Xf;class Ry{static getContext(){return Xf===void 0&&(Xf=new(window.AudioContext||window.webkitAudioContext)),Xf}static setContext(e){Xf=e}}class ZU extends Gi{constructor(e){super(e)}load(e,t,n,i){const s=this,o=new Bs(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{const c=l.slice(0);Ry.getContext().decodeAudioData(c,function(h){t(h)},a)}catch(c){a(c)}},n,i);function a(l){i?i(l):console.error(l),s.manager.itemError(e)}}}class KU extends wp{constructor(e,t,n=1){super(void 0,n),this.isHemisphereLightProbe=!0;const i=new Ke().set(e),s=new Ke().set(t),o=new Y(i.r,i.g,i.b),a=new Y(s.r,s.g,s.b),l=Math.sqrt(Math.PI),c=l*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(a).multiplyScalar(l),this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(c)}}class $U extends wp{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const n=new Ke().set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const nw=new yt,iw=new yt,Zo=new yt;class JU{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new zn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new zn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Zo.copy(e.projectionMatrix);const i=t.eyeSep/2,s=i*t.near/t.focus,o=t.near*Math.tan(ma*t.fov*.5)/t.zoom;let a,l;iw.elements[12]=-i,nw.elements[12]=i,a=-o*t.aspect+s,l=o*t.aspect+s,Zo.elements[0]=2*t.near/(l-a),Zo.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(Zo),a=-o*t.aspect-s,l=o*t.aspect-s,Zo.elements[0]=2*t.near/(l-a),Zo.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(Zo)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(iw),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(nw)}}class Py{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=rw(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=rw();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function rw(){return(typeof performance>"u"?Date:performance).now()}const Ko=new Y,sw=new si,QU=new Y,$o=new Y;class e3 extends jt{constructor(){super(),this.type="AudioListener",this.context=Ry.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Py}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Ko,sw,QU),$o.set(0,0,-1).applyQuaternion(sw),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Ko.x,i),t.positionY.linearRampToValueAtTime(Ko.y,i),t.positionZ.linearRampToValueAtTime(Ko.z,i),t.forwardX.linearRampToValueAtTime($o.x,i),t.forwardY.linearRampToValueAtTime($o.y,i),t.forwardZ.linearRampToValueAtTime($o.z,i),t.upX.linearRampToValueAtTime(n.x,i),t.upY.linearRampToValueAtTime(n.y,i),t.upZ.linearRampToValueAtTime(n.z,i)}else t.setPosition(Ko.x,Ko.y,Ko.z),t.setOrientation($o.x,$o.y,$o.z,n.x,n.y,n.z)}}class sT extends jt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const Jo=new Y,ow=new si,t3=new Y,Qo=new Y;class n3 extends sT{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Jo,ow,t3),Qo.set(0,0,1).applyQuaternion(ow);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Jo.x,n),t.positionY.linearRampToValueAtTime(Jo.y,n),t.positionZ.linearRampToValueAtTime(Jo.z,n),t.orientationX.linearRampToValueAtTime(Qo.x,n),t.orientationY.linearRampToValueAtTime(Qo.y,n),t.orientationZ.linearRampToValueAtTime(Qo.z,n)}else t.setPosition(Jo.x,Jo.y,Jo.z),t.setOrientation(Qo.x,Qo.y,Qo.z)}}class i3{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class oT{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,s,o;switch(t){case"quaternion":i=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,s=e*i+i;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)n[s+a]=n[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(n,s,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(n,i,l,1-s,t)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,o=i;s!==o;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,s){if(i>=.5)for(let o=0;o!==s;++o)e[t+o]=e[n+o]}_slerp(e,t,n,i){si.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){const o=this._workIndex*s;si.multiplyQuaternionsFlat(e,o,e,t,e,n),si.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,n,i,s){const o=1-i;for(let a=0;a!==s;++a){const l=t+a;e[l]=e[l]*o+e[n+a]*i}}_lerpAdditive(e,t,n,i,s){for(let o=0;o!==s;++o){const a=t+o;e[a]=e[a]+e[n+o]*i}}}const Ly="\\[\\]\\.:\\/",r3=new RegExp("["+Ly+"]","g"),Iy="[^"+Ly+"]",s3="[^"+Ly.replace("\\.","")+"]",o3=/((?:WC+[\/:])*)/.source.replace("WC",Iy),a3=/(WCOD+)?/.source.replace("WCOD",s3),l3=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Iy),c3=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Iy),u3=new RegExp("^"+o3+a3+l3+c3+"$"),h3=["material","materials","bones","map"];class f3{constructor(e,t,n){const i=n||zt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class zt{constructor(e,t,n){this.path=t,this.parsedPath=n||zt.parseTrackName(t),this.node=zt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new zt.Composite(e,t,n):new zt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(r3,"")}static parseTrackName(e){const t=u3.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);h3.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let o=0;o<s.length;o++){const a=s[o];if(a.name===t||a.uuid===t)return a;const l=n(a.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let s=t.propertyIndex;if(e||(e=zt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const o=e[i];if(o===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}zt.Composite=f3;zt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};zt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};zt.prototype.GetterByBindingType=[zt.prototype._getValue_direct,zt.prototype._getValue_array,zt.prototype._getValue_arrayElement,zt.prototype._getValue_toArray];zt.prototype.SetterByBindingTypeAndVersioning=[[zt.prototype._setValue_direct,zt.prototype._setValue_direct_setNeedsUpdate,zt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[zt.prototype._setValue_array,zt.prototype._setValue_array_setNeedsUpdate,zt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[zt.prototype._setValue_arrayElement,zt.prototype._setValue_arrayElement_setNeedsUpdate,zt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[zt.prototype._setValue_fromArray,zt.prototype._setValue_fromArray_setNeedsUpdate,zt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class d3{constructor(){this.isAnimationObjectGroup=!0,this.uuid=er(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,i=arguments.length;n!==i;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,i=this._parsedPaths,s=this._bindings,o=s.length;let a,l=e.length,c=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){const p=arguments[u],m=p.uuid;let v=t[m];if(v===void 0){v=l++,t[m]=v,e.push(p);for(let _=0,y=o;_!==y;++_)s[_].push(new zt(p,n[_],i[_]))}else if(v<c){a=e[v];const _=--c,y=e[_];t[y.uuid]=v,e[v]=y,t[m]=_,e[_]=p;for(let g=0,x=o;g!==x;++g){const w=s[g],E=w[_];let b=w[v];w[v]=E,b===void 0&&(b=new zt(p,n[g],i[g])),w[_]=b}}else e[v]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const l=arguments[o],c=l.uuid,u=t[c];if(u!==void 0&&u>=s){const h=s++,p=e[h];t[p.uuid]=u,e[u]=p,t[c]=h,e[h]=l;for(let m=0,v=i;m!==v;++m){const _=n[m],y=_[h],g=_[u];_[u]=y,_[h]=g}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){const c=arguments[a],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){const p=--s,m=e[p],v=--o,_=e[v];t[m.uuid]=h,e[h]=m,t[_.uuid]=p,e[p]=_,e.pop();for(let y=0,g=i;y!==g;++y){const x=n[y],w=x[p],E=x[v];x[h]=w,x[p]=E,x.pop()}}else{const p=--o,m=e[p];p>0&&(t[m.uuid]=h),e[h]=m,e.pop();for(let v=0,_=i;v!==_;++v){const y=n[v];y[h]=y[p],y.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const s=this._bindings;if(i!==void 0)return s[i];const o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);i=s.length,n[e]=i,o.push(e),a.push(t),s.push(h);for(let p=u,m=l.length;p!==m;++p){const v=l[p];h[p]=new zt(v,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=n,o[n]=l,o.pop(),s[n]=s[a],s.pop(),i[n]=i[a],i.pop()}}}class aT{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const s=t.tracks,o=s.length,a=new Array(o),l={endingStart:ua,endingEnd:ua};for(let c=0;c!==o;++c){const u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=jb,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,s=e._clip.duration,o=s/i,a=i/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,s=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+n,c[0]=e/o,c[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*n;l<0||n===0?t=0:(this._startTime=null,t=n*l)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Qv:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case $d:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,s=this._loopCount;const o=n===Yb;if(e===0)return s===-1?i:o&&(s&1)===1?t-i:i;if(n===Xb){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<0){const a=Math.floor(i/t);i-=t*a,s+=Math.abs(a);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=ha,i.endingEnd=ha):(e?i.endingStart=this.zeroSlopeAtStart?ha:ua:i.endingStart=Uu,t?i.endingEnd=this.zeroSlopeAtEnd?ha:ua:i.endingEnd=Uu)}_scheduleFading(e,t,n){const i=this._mixer,s=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=t,a[1]=s+e,l[1]=n,this}}const p3=new Float32Array(1);class m3 extends Hs{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,s=i.length,o=e._propertyBindings,a=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){const p=i[h],m=p.name;let v=u[m];if(v!==void 0)++v.referenceCount,o[h]=v;else{if(v=o[h],v!==void 0){v._cacheIndex===null&&(++v.referenceCount,this._addInactiveBinding(v,l,m));continue}const _=t&&t._propertyBindings[h].binding.parsedPath;v=new oT(zt.create(n,m,_),p.ValueTypeName,p.getValueSize()),++v.referenceCount,this._addInactiveBinding(v,l,m),o[h]=v}a[h].resultBuffer=v.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,s=this._actionsByClip;let o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{const a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=i.length,i.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,o=this._actionsByClip,a=o[s],l=a.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;const h=a.actionByRoot,p=(e._localRoot||this._root).uuid;delete h[p],l.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,s=this._bindings;let o=i[t];o===void 0&&(o={},i[t]=o),o[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,s=n.path,o=this._bindingsByRootAndName,a=o[i],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new by(new Float32Array(2),new Float32Array(2),1,p3),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,s=t[i];e.__cacheIndex=i,t[i]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){const i=t||this._root,s=i.uuid;let o=typeof e=="string"?Xu.findByName(i,e):e;const a=o!==null?o.uuid:e,l=this._actionsByClip[a];let c=null;if(n===void 0&&(o!==null?n=o.blendMode:n=$d),l!==void 0){const h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===n)return h;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;const u=new aT(this,o,t,n);return this._bindAction(u,c),this._addInactiveAction(u,a,s),u}existingAction(e,t){const n=t||this._root,i=n.uuid,s=typeof e=="string"?Xu.findByName(n,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,s,o);const a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,s=i[n];if(s!==void 0){const o=s.knownActions;for(let a=0,l=o.length;a!==l;++a){const c=o[a];this._deactivateAction(c);const u=c._cacheIndex,h=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const o in n){const a=n[o].actionByRoot,l=a[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const i=this._bindingsByRootAndName,s=i[t];if(s!==void 0)for(const o in s){const a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class Dy{constructor(e){this.value=e}clone(){return new Dy(this.value.clone===void 0?this.value:this.value.clone())}}let g3=0;class v3 extends Hs{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:g3++}),this.name="",this.usage=Ou,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,i=t.length;n<i;n++)this.uniforms.push(t[n].clone());return this}clone(){return new this.constructor().copy(this)}}class y3 extends rp{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class _3{constructor(e,t,n,i,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}class Uy{constructor(e,t,n=0,i=1/0){this.ray=new Ql(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new ga,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return mv(e,this,n,t),n.sort(aw),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)mv(e[i],this,n,t);return n.sort(aw),n}}function aw(r,e){return r.distance-e.distance}function mv(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){const i=r.children;for(let s=0,o=i.length;s<o;s++)mv(i[s],e,t,!0)}}class lT{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Tn(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class x3{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}const lw=new De;class w3{constructor(e=new De(1/0,1/0),t=new De(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=lw.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,lw).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const cw=new Y,jf=new Y;class S3{constructor(e=new Y,t=new Y){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){cw.subVectors(e,this.start),jf.subVectors(this.end,this.start);const n=jf.dot(jf);let s=jf.dot(cw)/n;return t&&(s=Tn(s,0,1)),s}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const uw=new Y;class E3 extends jt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Tt,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){const c=o/l*Math.PI*2,u=a/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}n.setAttribute("position",new st(i,3));const s=new Pi({fog:!1,toneMapped:!1});this.cone=new hs(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),uw.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(uw),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const ao=new Y,Yf=new yt,fg=new yt;class b3 extends hs{constructor(e){const t=cT(e),n=new Tt,i=[],s=[],o=new Ke(0,0,1),a=new Ke(0,1,0);for(let c=0;c<t.length;c++){const u=t[c];u.parent&&u.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}n.setAttribute("position",new st(i,3)),n.setAttribute("color",new st(s,3));const l=new Pi({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,i=n.getAttribute("position");fg.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){const a=t[s];a.parent&&a.parent.isBone&&(Yf.multiplyMatrices(fg,a.matrixWorld),ao.setFromMatrixPosition(Yf),i.setXYZ(o,ao.x,ao.y,ao.z),Yf.multiplyMatrices(fg,a.parent.matrixWorld),ao.setFromMatrixPosition(Yf),i.setXYZ(o+1,ao.x,ao.y,ao.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function cT(r){const e=[];r.isBone===!0&&e.push(r);for(let t=0;t<r.children.length;t++)e.push.apply(e,cT(r.children[t]));return e}class M3 extends _n{constructor(e,t,n){const i=new ch(t,4,2),s=new Vs({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const T3=new Y,hw=new Ke,fw=new Ke;class A3 extends jt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new lh(t);i.rotateY(Math.PI*.5),this.material=new Vs({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=i.getAttribute("position"),o=new Float32Array(s.count*3);i.setAttribute("color",new $t(o,3)),this.add(new _n(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");hw.copy(this.light.color),fw.copy(this.light.groundColor);for(let n=0,i=t.count;n<i;n++){const s=n<i/2?hw:fw;t.setXYZ(n,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(T3.setFromMatrixPosition(this.light.matrixWorld).negate())}}class C3 extends hs{constructor(e=10,t=10,n=4473924,i=8947848){n=new Ke(n),i=new Ke(i);const s=t/2,o=e/t,a=e/2,l=[],c=[];for(let p=0,m=0,v=-a;p<=t;p++,v+=o){l.push(-a,0,v,a,0,v),l.push(v,0,-a,v,0,a);const _=p===s?n:i;_.toArray(c,m),m+=3,_.toArray(c,m),m+=3,_.toArray(c,m),m+=3,_.toArray(c,m),m+=3}const u=new Tt;u.setAttribute("position",new st(l,3)),u.setAttribute("color",new st(c,3));const h=new Pi({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class R3 extends hs{constructor(e=10,t=16,n=8,i=64,s=4473924,o=8947848){s=new Ke(s),o=new Ke(o);const a=[],l=[];if(t>1)for(let h=0;h<t;h++){const p=h/t*(Math.PI*2),m=Math.sin(p)*e,v=Math.cos(p)*e;a.push(0,0,0),a.push(m,0,v);const _=h&1?s:o;l.push(_.r,_.g,_.b),l.push(_.r,_.g,_.b)}for(let h=0;h<n;h++){const p=h&1?s:o,m=e-e/n*h;for(let v=0;v<i;v++){let _=v/i*(Math.PI*2),y=Math.sin(_)*m,g=Math.cos(_)*m;a.push(y,0,g),l.push(p.r,p.g,p.b),_=(v+1)/i*(Math.PI*2),y=Math.sin(_)*m,g=Math.cos(_)*m,a.push(y,0,g),l.push(p.r,p.g,p.b)}}const c=new Tt;c.setAttribute("position",new st(a,3)),c.setAttribute("color",new st(l,3));const u=new Pi({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const dw=new Y,qf=new Y,pw=new Y;class P3 extends jt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let i=new Tt;i.setAttribute("position",new st([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new Pi({fog:!1,toneMapped:!1});this.lightPlane=new bo(i,s),this.add(this.lightPlane),i=new Tt,i.setAttribute("position",new st([0,0,0,0,0,1],3)),this.targetLine=new bo(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),dw.setFromMatrixPosition(this.light.matrixWorld),qf.setFromMatrixPosition(this.light.target.matrixWorld),pw.subVectors(qf,dw),this.lightPlane.lookAt(qf),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(qf),this.targetLine.scale.z=pw.length()}}const Zf=new Y,Mn=new rh;class L3 extends hs{constructor(e){const t=new Tt,n=new Pi({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(v,_){l(v),l(_)}function l(v){i.push(0,0,0),s.push(0,0,0),o[v]===void 0&&(o[v]=[]),o[v].push(i.length/3-1)}t.setAttribute("position",new st(i,3)),t.setAttribute("color",new st(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const c=new Ke(16755200),u=new Ke(16711680),h=new Ke(43775),p=new Ke(16777215),m=new Ke(3355443);this.setColors(c,u,h,p,m)}setColors(e,t,n,i,s){const a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,n=1,i=1;Mn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),In("c",t,e,Mn,0,0,-1),In("t",t,e,Mn,0,0,1),In("n1",t,e,Mn,-n,-i,-1),In("n2",t,e,Mn,n,-i,-1),In("n3",t,e,Mn,-n,i,-1),In("n4",t,e,Mn,n,i,-1),In("f1",t,e,Mn,-n,-i,1),In("f2",t,e,Mn,n,-i,1),In("f3",t,e,Mn,-n,i,1),In("f4",t,e,Mn,n,i,1),In("u1",t,e,Mn,n*.7,i*1.1,-1),In("u2",t,e,Mn,-n*.7,i*1.1,-1),In("u3",t,e,Mn,0,i*2,-1),In("cf1",t,e,Mn,-n,0,1),In("cf2",t,e,Mn,n,0,1),In("cf3",t,e,Mn,0,-i,1),In("cf4",t,e,Mn,0,i,1),In("cn1",t,e,Mn,-n,0,-1),In("cn2",t,e,Mn,n,0,-1),In("cn3",t,e,Mn,0,-i,-1),In("cn4",t,e,Mn,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function In(r,e,t,n,i,s,o){Zf.set(i,s,o).unproject(n);const a=e[r];if(a!==void 0){const l=t.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],Zf.x,Zf.y,Zf.z)}}const Kf=new ir;class I3 extends hs{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),s=new Tt;s.setIndex(new $t(n,1)),s.setAttribute("position",new $t(i,3)),super(s,new Pi({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Kf.setFromObject(this.object),Kf.isEmpty())return;const t=Kf.min,n=Kf.max,i=this.geometry.attributes.position,s=i.array;s[0]=n.x,s[1]=n.y,s[2]=n.z,s[3]=t.x,s[4]=n.y,s[5]=n.z,s[6]=t.x,s[7]=t.y,s[8]=n.z,s[9]=n.x,s[10]=t.y,s[11]=n.z,s[12]=n.x,s[13]=n.y,s[14]=t.z,s[15]=t.x,s[16]=n.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=n.x,s[22]=t.y,s[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class D3 extends hs{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Tt;s.setIndex(new $t(n,1)),s.setAttribute("position",new st(i,3)),super(s,new Pi({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class U3 extends bo{constructor(e,t=1,n=16776960){const i=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new Tt;o.setAttribute("position",new st(s,3)),o.computeBoundingSphere(),super(o,new Pi({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new Tt;l.setAttribute("position",new st(a,3)),l.computeBoundingSphere(),this.add(new _n(l,new Vs({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const mw=new Y;let $f,dg;class O3 extends jt{constructor(e=new Y(0,0,1),t=new Y(0,0,0),n=1,i=16776960,s=n*.2,o=s*.2){super(),this.type="ArrowHelper",$f===void 0&&($f=new Tt,$f.setAttribute("position",new st([0,0,0,0,1,0],3)),dg=new La(0,.5,1,5,1),dg.translate(0,-.5,0)),this.position.copy(t),this.line=new bo($f,new Pi({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new _n(dg,new Vs({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{mw.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(mw,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class N3 extends hs{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Tt;i.setAttribute("position",new st(t,3)),i.setAttribute("color",new st(n,3));const s=new Pi({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){const i=new Ke,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class F3{constructor(){this.type="ShapePath",this.color=new Ke,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new zu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,o){return this.currentPath.bezierCurveTo(e,t,n,i,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const x=[];for(let w=0,E=g.length;w<E;w++){const b=g[w],M=new va;M.curves=b.curves,x.push(M)}return x}function n(g,x){const w=x.length;let E=!1;for(let b=w-1,M=0;M<w;b=M++){let A=x[b],P=x[M],C=P.x-A.x,L=P.y-A.y;if(Math.abs(L)>Number.EPSILON){if(L<0&&(A=x[M],C=-C,P=x[b],L=-L),g.y<A.y||g.y>P.y)continue;if(g.y===A.y){if(g.x===A.x)return!0}else{const F=L*(g.x-A.x)-C*(g.y-A.y);if(F===0)return!0;if(F<0)continue;E=!E}}else{if(g.y!==A.y)continue;if(P.x<=g.x&&g.x<=A.x||A.x<=g.x&&g.x<=P.x)return!0}}return E}const i=as.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,l;const c=[];if(s.length===1)return a=s[0],l=new va,l.curves=a.curves,c.push(l),c;let u=!i(s[0].getPoints());u=e?!u:u;const h=[],p=[];let m=[],v=0,_;p[v]=void 0,m[v]=[];for(let g=0,x=s.length;g<x;g++)a=s[g],_=a.getPoints(),o=i(_),o=e?!o:o,o?(!u&&p[v]&&v++,p[v]={s:new va,p:_},p[v].s.curves=a.curves,u&&v++,m[v]=[]):m[v].push({h:a,p:_[0]});if(!p[0])return t(s);if(p.length>1){let g=!1,x=0;for(let w=0,E=p.length;w<E;w++)h[w]=[];for(let w=0,E=p.length;w<E;w++){const b=m[w];for(let M=0;M<b.length;M++){const A=b[M];let P=!0;for(let C=0;C<p.length;C++)n(A.p,p[C].p)&&(w!==C&&x++,P?(P=!1,h[C].push(A)):g=!0);P&&h[w].push(A)}}x>0&&g===!1&&(m=h)}let y;for(let g=0,x=p.length;g<x;g++){l=p[g].s,c.push(l),y=m[g];for(let w=0,E=y.length;w<E;w++)l.holes.push(y[w].h)}return c}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Yd}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Yd);const uT=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Xv,AddEquation:aa,AddOperation:Lb,AdditiveAnimationBlendMode:Qv,AdditiveBlending:I0,AlphaFormat:kb,AlwaysCompare:rM,AlwaysDepth:bb,AlwaysStencilFunc:Kb,AmbientLight:tT,AmbientLightProbe:$U,AnimationAction:aT,AnimationClip:Xu,AnimationLoader:zU,AnimationMixer:m3,AnimationObjectGroup:d3,AnimationUtils:OU,ArcCurve:AM,ArrayCamera:vM,ArrowHelper:O3,Audio:sT,AudioAnalyser:i3,AudioContext:Ry,AudioListener:e3,AudioLoader:ZU,AxesHelper:N3,BackSide:yi,BasicDepthPacking:qb,BasicShadowMap:ub,Bone:fy,BooleanKeyframeTrack:Ia,Box2:w3,Box3:ir,Box3Helper:D3,BoxGeometry:Ws,BoxHelper:I3,BufferAttribute:$t,BufferGeometry:Tt,BufferGeometryLoader:rT,ByteType:Nb,Cache:Ma,Camera:rh,CameraHelper:L3,CanvasTexture:sU,CapsuleGeometry:cp,CatmullRomCurve3:CM,CineonToneMapping:Ub,CircleGeometry:up,ClampToEdgeWrapping:vi,Clock:Py,Color:Ke,ColorKeyframeTrack:My,ColorManagement:vr,CompressedArrayTexture:rU,CompressedTexture:py,CompressedTextureLoader:BU,ConeGeometry:hp,CubeCamera:cM,CubeReflectionMapping:xo,CubeRefractionMapping:wo,CubeTexture:sh,CubeTextureLoader:GU,CubeUVReflectionMapping:Jl,CubicBezierCurve:gy,CubicBezierCurve3:RM,CubicInterpolant:jM,CullFaceBack:L0,CullFaceFront:cb,CullFaceFrontBack:Q2,CullFaceNone:lb,Curve:Vr,CurvePath:PM,CustomBlending:hb,CustomToneMapping:Ob,CylinderGeometry:La,Cylindrical:x3,Data3DTexture:sy,DataArrayTexture:Jd,DataTexture:Bl,DataTextureLoader:HU,DataUtils:hR,DecrementStencilOp:hC,DecrementWrapStencilOp:dC,DefaultLoadingManager:ZM,DepthFormat:go,DepthStencilFormat:xa,DepthTexture:yM,DirectionalLight:eT,DirectionalLightHelper:P3,DiscreteInterpolant:YM,DisplayP3ColorSpace:ny,DodecahedronGeometry:fp,DoubleSide:vn,DstAlphaFactor:yb,DstColorFactor:xb,DynamicCopyUsage:CC,DynamicDrawUsage:SC,DynamicReadUsage:MC,EdgesGeometry:LM,EllipseCurve:op,EqualCompare:Qb,EqualDepth:Tb,EqualStencilFunc:vC,EquirectangularReflectionMapping:Cu,EquirectangularRefractionMapping:Ru,Euler:Eo,EventDispatcher:Hs,ExtrudeGeometry:pp,FileLoader:Bs,Float16BufferAttribute:vR,Float32BufferAttribute:st,Float64BufferAttribute:yR,FloatType:rs,Fog:ip,FogExp2:np,FramebufferTexture:iU,FrontSide:ls,Frustum:oh,GLBufferAttribute:_3,GLSL1:PC,GLSL3:ov,GreaterCompare:tM,GreaterDepth:Cb,GreaterEqualCompare:iM,GreaterEqualDepth:Ab,GreaterEqualStencilFunc:wC,GreaterStencilFunc:_C,GridHelper:C3,Group:Ol,HalfFloatType:Vl,HemisphereLight:$M,HemisphereLightHelper:A3,HemisphereLightProbe:KU,IcosahedronGeometry:mp,ImageBitmapLoader:qU,ImageLoader:ju,ImageUtils:ry,IncrementStencilOp:uC,IncrementWrapStencilOp:fC,InstancedBufferAttribute:Sa,InstancedBufferGeometry:Cy,InstancedInterleavedBuffer:y3,InstancedMesh:bM,Int16BufferAttribute:mR,Int32BufferAttribute:gR,Int8BufferAttribute:fR,IntType:Yv,InterleavedBuffer:rp,InterleavedBufferAttribute:wa,Interpolant:uh,InterpolateDiscrete:Iu,InterpolateLinear:Du,InterpolateSmooth:Sd,InvertStencilOp:pC,KeepStencilOp:Ed,KeyframeTrack:Wr,LOD:SM,LatheGeometry:ah,Layers:ga,LessCompare:Jb,LessDepth:Mb,LessEqualCompare:eM,LessEqualDepth:Ld,LessEqualStencilFunc:yC,LessStencilFunc:gC,Light:Co,LightProbe:wp,Line:bo,Line3:S3,LineBasicMaterial:Pi,LineCurve:ap,LineCurve3:vy,LineDashedMaterial:WM,LineLoop:MM,LineSegments:hs,LinearEncoding:ey,LinearFilter:fn,LinearInterpolant:by,LinearMipMapLinearFilter:rC,LinearMipMapNearestFilter:iC,LinearMipmapLinearFilter:So,LinearMipmapNearestFilter:jv,LinearSRGBColorSpace:Br,LinearToneMapping:Ib,Loader:Gi,LoaderUtils:pv,LoadingManager:Ty,LoopOnce:Xb,LoopPingPong:Yb,LoopRepeat:jb,LuminanceAlphaFormat:Bb,LuminanceFormat:zb,MOUSE:ab,Material:oi,MaterialLoader:Sp,MathUtils:Od,Matrix3:Ct,Matrix4:yt,MaxEquation:N0,Mesh:_n,MeshBasicMaterial:Vs,MeshDepthMaterial:ep,MeshDistanceMaterial:tp,MeshLambertMaterial:HM,MeshMatcapMaterial:VM,MeshNormalMaterial:GM,MeshPhongMaterial:zM,MeshPhysicalMaterial:kM,MeshStandardMaterial:wy,MeshToonMaterial:BM,MinEquation:O0,MirroredRepeatWrapping:Lu,MixOperation:Pb,MultiplyBlending:U0,MultiplyOperation:ih,NearestFilter:Dn,NearestMipMapLinearFilter:nC,NearestMipMapNearestFilter:tC,NearestMipmapLinearFilter:vu,NearestMipmapNearestFilter:Id,NeverCompare:$b,NeverDepth:Eb,NeverStencilFunc:mC,NoBlending:Fs,NoColorSpace:yo,NoToneMapping:zr,NormalAnimationBlendMode:$d,NormalBlending:pa,NotEqualCompare:nM,NotEqualDepth:Rb,NotEqualStencilFunc:xC,NumberKeyframeTrack:Vu,Object3D:jt,ObjectLoader:jU,ObjectSpaceNormalMap:Zb,OctahedronGeometry:lh,OneFactor:mb,OneMinusDstAlphaFactor:_b,OneMinusDstColorFactor:wb,OneMinusSrcAlphaFactor:Wv,OneMinusSrcColorFactor:vb,OrthographicCamera:Pa,PCFShadowMap:qd,PCFSoftShadowMap:gu,PMREMGenerator:lv,Path:zu,PerspectiveCamera:zn,Plane:Us,PlaneGeometry:To,PlaneHelper:U3,PointLight:QM,PointLightHelper:M3,Points:TM,PointsMaterial:dy,PolarGridHelper:R3,PolyhedronGeometry:Ao,PositionalAudio:n3,PropertyBinding:zt,PropertyMixer:oT,QuadraticBezierCurve:yy,QuadraticBezierCurve3:lp,Quaternion:si,QuaternionKeyframeTrack:tc,QuaternionLinearInterpolant:qM,RED_GREEN_RGTC2_Format:rv,RED_RGTC1_Format:Wb,REVISION:Yd,RGBADepthPacking:ty,RGBAFormat:Bi,RGBAIntegerFormat:Jv,RGBA_ASTC_10x10_Format:ev,RGBA_ASTC_10x5_Format:$0,RGBA_ASTC_10x6_Format:J0,RGBA_ASTC_10x8_Format:Q0,RGBA_ASTC_12x10_Format:tv,RGBA_ASTC_12x12_Format:nv,RGBA_ASTC_4x4_Format:V0,RGBA_ASTC_5x4_Format:W0,RGBA_ASTC_5x5_Format:X0,RGBA_ASTC_6x5_Format:j0,RGBA_ASTC_6x6_Format:Y0,RGBA_ASTC_8x5_Format:q0,RGBA_ASTC_8x6_Format:Z0,RGBA_ASTC_8x8_Format:K0,RGBA_BPTC_Format:wd,RGBA_ETC2_EAC_Format:H0,RGBA_PVRTC_2BPPV1_Format:B0,RGBA_PVRTC_4BPPV1_Format:z0,RGBA_S3TC_DXT1_Format:yd,RGBA_S3TC_DXT3_Format:_d,RGBA_S3TC_DXT5_Format:xd,RGB_ETC1_Format:Vb,RGB_ETC2_Format:G0,RGB_PVRTC_2BPPV1_Format:k0,RGB_PVRTC_4BPPV1_Format:F0,RGB_S3TC_DXT1_Format:vd,RGFormat:Hb,RGIntegerFormat:$v,RawShaderMaterial:FM,Ray:Ql,Raycaster:Uy,RectAreaLight:nT,RedFormat:Gb,RedIntegerFormat:Kv,ReinhardToneMapping:Db,RepeatWrapping:Pu,ReplaceStencilOp:cC,ReverseSubtractEquation:db,RingGeometry:gp,SIGNED_RED_GREEN_RGTC2_Format:sv,SIGNED_RED_RGTC1_Format:iv,SRGBColorSpace:Mt,Scene:ku,ShaderChunk:bt,ShaderLib:Nr,ShaderMaterial:cs,ShadowMaterial:NM,Shape:va,ShapeGeometry:vp,ShapePath:F3,ShapeUtils:as,ShortType:Fb,Skeleton:sp,SkeletonHelper:b3,SkinnedMesh:EM,Source:fa,Sphere:rr,SphereGeometry:ch,Spherical:lT,SphericalHarmonics3:iT,SplineCurve:_y,SpotLight:JM,SpotLightHelper:E3,Sprite:wM,SpriteMaterial:hy,SrcAlphaFactor:Vv,SrcAlphaSaturateFactor:Sb,SrcColorFactor:gb,StaticCopyUsage:AC,StaticDrawUsage:Ou,StaticReadUsage:bC,StereoCamera:JU,StreamCopyUsage:RC,StreamDrawUsage:EC,StreamReadUsage:TC,StringKeyframeTrack:Da,SubtractEquation:fb,SubtractiveBlending:D0,TOUCH:J2,TangentSpaceNormalMap:Mo,TetrahedronGeometry:yp,Texture:Sn,TextureLoader:KM,TorusGeometry:_p,TorusKnotGeometry:xp,Triangle:zi,TriangleFanDrawMode:aC,TriangleStripDrawMode:oC,TrianglesDrawMode:sC,TubeGeometry:ba,TwoPassDoubleSide:eC,UVMapping:Zd,Uint16BufferAttribute:oy,Uint32BufferAttribute:ay,Uint8BufferAttribute:dR,Uint8ClampedBufferAttribute:pR,Uniform:Dy,UniformsGroup:v3,UniformsLib:Je,UniformsUtils:ly,UnsignedByteType:os,UnsignedInt248Type:mo,UnsignedIntType:Ns,UnsignedShort4444Type:qv,UnsignedShort5551Type:Zv,UnsignedShortType:Kd,VSMShadowMap:Or,Vector2:De,Vector3:Y,Vector4:Xt,VectorKeyframeTrack:Wu,VideoTexture:nU,WebGL1Renderer:_M,WebGL3DRenderTarget:eR,WebGLArrayRenderTarget:QC,WebGLCoordinateSystem:ss,WebGLCubeRenderTarget:uM,WebGLMultipleRenderTargets:tR,WebGLRenderTarget:Gr,WebGLRenderer:uy,WebGLUtils:gM,WebGPUCoordinateSystem:Nu,WireframeGeometry:OM,WrapAroundEnding:Uu,ZeroCurvatureEnding:ua,ZeroFactor:pb,ZeroSlopeEnding:ha,ZeroStencilOp:lC,_SRGBAFormat:Dd,sRGBEncoding:vo},Symbol.toStringTag,{value:"Module"}));var pg={exports:{}},lo={};/**
|
|
* @license React
|
|
* react-reconciler-constants.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 gw;function k3(){return gw||(gw=1,lo.ConcurrentRoot=1,lo.ContinuousEventPriority=4,lo.DefaultEventPriority=16,lo.DiscreteEventPriority=1,lo.IdleEventPriority=536870912,lo.LegacyRoot=0),lo}var vw;function z3(){return vw||(vw=1,pg.exports=k3()),pg.exports}var Fl=z3();function B3(r){let e;const t=new Set,n=(c,u)=>{const h=typeof c=="function"?c(e):c;if(h!==e){const p=e;e=u?h:Object.assign({},e,h),t.forEach(m=>m(e,p))}},i=()=>e,s=(c,u=i,h=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let p=u(e);function m(){const v=u(e);if(!h(p,v)){const _=p;c(p=v,_)}}return t.add(m),()=>t.delete(m)},l={setState:n,getState:i,subscribe:(c,u,h)=>u||h?s(c,u,h):(t.add(c),()=>t.delete(c)),destroy:()=>t.clear()};return e=r(n,i,l),l}const G3=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),yw=G3?K.useEffect:K.useLayoutEffect;function H3(r){const e=typeof r=="function"?B3(r):r,t=(n=e.getState,i=Object.is)=>{const[,s]=K.useReducer(y=>y+1,0),o=e.getState(),a=K.useRef(o),l=K.useRef(n),c=K.useRef(i),u=K.useRef(!1),h=K.useRef();h.current===void 0&&(h.current=n(o));let p,m=!1;(a.current!==o||l.current!==n||c.current!==i||u.current)&&(p=n(o),m=!i(h.current,p)),yw(()=>{m&&(h.current=p),a.current=o,l.current=n,c.current=i,u.current=!1});const v=K.useRef(o);yw(()=>{const y=()=>{try{const x=e.getState(),w=l.current(x);c.current(h.current,w)||(a.current=x,h.current=w,s())}catch{u.current=!0,s()}},g=e.subscribe(y);return e.getState()!==v.current&&y(),g},[]);const _=m?p:h.current;return K.useDebugValue(_),_};return Object.assign(t,e),t[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const n=[t,e];return{next(){const i=n.length<=0;return{value:n.shift(),done:i}}}},t}var mg={exports:{}},gg={exports:{}},vg={};/**
|
|
* @license React
|
|
* scheduler.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 _w;function V3(){return _w||(_w=1,(function(r){function e(k,G){var B=k.length;k.push(G);e:for(;0<B;){var D=B-1>>>1,V=k[D];if(0<i(V,G))k[D]=G,k[B]=V,B=D;else break e}}function t(k){return k.length===0?null:k[0]}function n(k){if(k.length===0)return null;var G=k[0],B=k.pop();if(B!==G){k[0]=B;e:for(var D=0,V=k.length,Z=V>>>1;D<Z;){var ee=2*(D+1)-1,ie=k[ee],ue=ee+1,ce=k[ue];if(0>i(ie,B))ue<V&&0>i(ce,ie)?(k[D]=ce,k[ue]=B,D=ue):(k[D]=ie,k[ee]=B,D=ee);else if(ue<V&&0>i(ce,B))k[D]=ce,k[ue]=B,D=ue;else break e}}return G}function i(k,G){var B=k.sortIndex-G.sortIndex;return B!==0?B:k.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;r.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();r.unstable_now=function(){return o.now()-a}}var l=[],c=[],u=1,h=null,p=3,m=!1,v=!1,_=!1,y=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(k){for(var G=t(c);G!==null;){if(G.callback===null)n(c);else if(G.startTime<=k)n(c),G.sortIndex=G.expirationTime,e(l,G);else break;G=t(c)}}function E(k){if(_=!1,w(k),!v)if(t(l)!==null)v=!0,W(b);else{var G=t(c);G!==null&&O(E,G.startTime-k)}}function b(k,G){v=!1,_&&(_=!1,g(P),P=-1),m=!0;var B=p;try{for(w(G),h=t(l);h!==null&&(!(h.expirationTime>G)||k&&!F());){var D=h.callback;if(typeof D=="function"){h.callback=null,p=h.priorityLevel;var V=D(h.expirationTime<=G);G=r.unstable_now(),typeof V=="function"?h.callback=V:h===t(l)&&n(l),w(G)}else n(l);h=t(l)}if(h!==null)var Z=!0;else{var ee=t(c);ee!==null&&O(E,ee.startTime-G),Z=!1}return Z}finally{h=null,p=B,m=!1}}var M=!1,A=null,P=-1,C=5,L=-1;function F(){return!(r.unstable_now()-L<C)}function N(){if(A!==null){var k=r.unstable_now();L=k;var G=!0;try{G=A(!0,k)}finally{G?I():(M=!1,A=null)}}else M=!1}var I;if(typeof x=="function")I=function(){x(N)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,q=X.port2;X.port1.onmessage=N,I=function(){q.postMessage(null)}}else I=function(){y(N,0)};function W(k){A=k,M||(M=!0,I())}function O(k,G){P=y(function(){k(r.unstable_now())},G)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function(k){k.callback=null},r.unstable_continueExecution=function(){v||m||(v=!0,W(b))},r.unstable_forceFrameRate=function(k){0>k||125<k?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):C=0<k?Math.floor(1e3/k):5},r.unstable_getCurrentPriorityLevel=function(){return p},r.unstable_getFirstCallbackNode=function(){return t(l)},r.unstable_next=function(k){switch(p){case 1:case 2:case 3:var G=3;break;default:G=p}var B=p;p=G;try{return k()}finally{p=B}},r.unstable_pauseExecution=function(){},r.unstable_requestPaint=function(){},r.unstable_runWithPriority=function(k,G){switch(k){case 1:case 2:case 3:case 4:case 5:break;default:k=3}var B=p;p=k;try{return G()}finally{p=B}},r.unstable_scheduleCallback=function(k,G,B){var D=r.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?D+B:D):B=D,k){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=B+V,k={id:u++,callback:G,priorityLevel:k,startTime:B,expirationTime:V,sortIndex:-1},B>D?(k.sortIndex=B,e(c,k),t(l)===null&&k===t(c)&&(_?(g(P),P=-1):_=!0,O(E,B-D))):(k.sortIndex=V,e(l,k),v||m||(v=!0,W(b))),k},r.unstable_shouldYield=F,r.unstable_wrapCallback=function(k){var G=p;return function(){var B=p;p=G;try{return k.apply(this,arguments)}finally{p=B}}}})(vg)),vg}var xw;function W3(){return xw||(xw=1,gg.exports=V3()),gg.exports}/**
|
|
* @license React
|
|
* react-reconciler.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 yg,ww;function X3(){return ww||(ww=1,yg=function(e){var t={},n=Hv(),i=W3(),s=Object.assign;function o(f){for(var d="https://reactjs.org/docs/error-decoder.html?invariant="+f,S=1;S<arguments.length;S++)d+="&args[]="+encodeURIComponent(arguments[S]);return"Minified React error #"+f+"; visit "+d+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var a=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,l=Symbol.for("react.element"),c=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),v=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),E=Symbol.for("react.offscreen"),b=Symbol.iterator;function M(f){return f===null||typeof f!="object"?null:(f=b&&f[b]||f["@@iterator"],typeof f=="function"?f:null)}function A(f){if(f==null)return null;if(typeof f=="function")return f.displayName||f.name||null;if(typeof f=="string")return f;switch(f){case u:return"Fragment";case c:return"Portal";case p:return"Profiler";case h:return"StrictMode";case y:return"Suspense";case g:return"SuspenseList"}if(typeof f=="object")switch(f.$$typeof){case v:return(f.displayName||"Context")+".Consumer";case m:return(f._context.displayName||"Context")+".Provider";case _:var d=f.render;return f=f.displayName,f||(f=d.displayName||d.name||"",f=f!==""?"ForwardRef("+f+")":"ForwardRef"),f;case x:return d=f.displayName||null,d!==null?d:A(f.type)||"Memo";case w:d=f._payload,f=f._init;try{return A(f(d))}catch{}}return null}function P(f){var d=f.type;switch(f.tag){case 24:return"Cache";case 9:return(d.displayName||"Context")+".Consumer";case 10:return(d._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return f=d.render,f=f.displayName||f.name||"",d.displayName||(f!==""?"ForwardRef("+f+")":"ForwardRef");case 7:return"Fragment";case 5:return d;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return A(d);case 8:return d===h?"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 d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d}return null}function C(f){var d=f,S=f;if(f.alternate)for(;d.return;)d=d.return;else{f=d;do d=f,(d.flags&4098)!==0&&(S=d.return),f=d.return;while(f)}return d.tag===3?S:null}function L(f){if(C(f)!==f)throw Error(o(188))}function F(f){var d=f.alternate;if(!d){if(d=C(f),d===null)throw Error(o(188));return d!==f?null:f}for(var S=f,T=d;;){var R=S.return;if(R===null)break;var U=R.alternate;if(U===null){if(T=R.return,T!==null){S=T;continue}break}if(R.child===U.child){for(U=R.child;U;){if(U===S)return L(R),f;if(U===T)return L(R),d;U=U.sibling}throw Error(o(188))}if(S.return!==T.return)S=R,T=U;else{for(var Q=!1,he=R.child;he;){if(he===S){Q=!0,S=R,T=U;break}if(he===T){Q=!0,T=R,S=U;break}he=he.sibling}if(!Q){for(he=U.child;he;){if(he===S){Q=!0,S=U,T=R;break}if(he===T){Q=!0,T=U,S=R;break}he=he.sibling}if(!Q)throw Error(o(189))}}if(S.alternate!==T)throw Error(o(190))}if(S.tag!==3)throw Error(o(188));return S.stateNode.current===S?f:d}function N(f){return f=F(f),f!==null?I(f):null}function I(f){if(f.tag===5||f.tag===6)return f;for(f=f.child;f!==null;){var d=I(f);if(d!==null)return d;f=f.sibling}return null}function X(f){if(f.tag===5||f.tag===6)return f;for(f=f.child;f!==null;){if(f.tag!==4){var d=X(f);if(d!==null)return d}f=f.sibling}return null}var q=Array.isArray,W=e.getPublicInstance,O=e.getRootHostContext,k=e.getChildHostContext,G=e.prepareForCommit,B=e.resetAfterCommit,D=e.createInstance,V=e.appendInitialChild,Z=e.finalizeInitialChildren,ee=e.prepareUpdate,ie=e.shouldSetTextContent,ue=e.createTextInstance,ce=e.scheduleTimeout,le=e.cancelTimeout,Ae=e.noTimeout,Ee=e.isPrimaryRenderer,ae=e.supportsMutation,z=e.supportsPersistence,oe=e.supportsHydration,te=e.getInstanceFromNode,se=e.preparePortalMount,$=e.getCurrentEventPriority,Ie=e.detachDeletedInstance,de=e.supportsMicrotasks,Se=e.scheduleMicrotask,Le=e.supportsTestSelectors,ge=e.findFiberRoot,He=e.getBoundingRect,j=e.getTextContent,H=e.isHiddenSubtree,ne=e.matchAccessibilityRole,we=e.setFocusIfFocusable,be=e.setupIntersectionObserver,Me=e.appendChild,Fe=e.appendChildToContainer,Ue=e.commitTextUpdate,xe=e.commitMount,Be=e.commitUpdate,$e=e.insertBefore,Ve=e.insertInContainerBefore,Oe=e.removeChild,We=e.removeChildFromContainer,nt=e.resetTextContent,pt=e.hideInstance,re=e.hideTextInstance,ze=e.unhideInstance,ve=e.unhideTextInstance,Ge=e.clearContainer,Ye=e.cloneInstance,_t=e.createContainerChildSet,It=e.appendChildToContainerChildSet,Ft=e.finalizeContainerChildren,Ot=e.replaceContainerChildren,Yt=e.cloneHiddenInstance,Nt=e.cloneHiddenTextInstance,Rt=e.canHydrateInstance,li=e.canHydrateTextInstance,jn=e.canHydrateSuspenseInstance,Bt=e.isSuspenseInstancePending,sn=e.isSuspenseInstanceFallback,ti=e.registerSuspenseInstanceRetry,tn=e.getNextHydratableSibling,dn=e.getFirstHydratableChild,Gn=e.getFirstHydratableChildWithinContainer,sr=e.getFirstHydratableChildWithinSuspenseInstance,_i=e.hydrateInstance,J=e.hydrateTextInstance,me=e.hydrateSuspenseInstance,Re=e.getNextHydratableInstanceAfterSuspenseInstance,pe=e.commitHydratedContainer,Pe=e.commitHydratedSuspenseInstance,it=e.clearSuspenseBoundary,lt=e.clearSuspenseBoundaryFromContainer,ct=e.shouldDeleteUnhydratedTailInstances,dt=e.didNotMatchHydratedContainerTextInstance,wt=e.didNotMatchHydratedTextInstance,ke;function ut(f){if(ke===void 0)try{throw Error()}catch(S){var d=S.stack.trim().match(/\n( *(at )?)/);ke=d&&d[1]||""}return`
|
|
`+ke+f}var Jt=!1;function Gt(f,d){if(!f||Jt)return"";Jt=!0;var S=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(d)if(d=function(){throw Error()},Object.defineProperty(d.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(d,[])}catch(Xe){var T=Xe}Reflect.construct(f,[],d)}else{try{d.call()}catch(Xe){T=Xe}f.call(d.prototype)}else{try{throw Error()}catch(Xe){T=Xe}f()}}catch(Xe){if(Xe&&T&&typeof Xe.stack=="string"){for(var R=Xe.stack.split(`
|
|
`),U=T.stack.split(`
|
|
`),Q=R.length-1,he=U.length-1;1<=Q&&0<=he&&R[Q]!==U[he];)he--;for(;1<=Q&&0<=he;Q--,he--)if(R[Q]!==U[he]){if(Q!==1||he!==1)do if(Q--,he--,0>he||R[Q]!==U[he]){var Ce=`
|
|
`+R[Q].replace(" at new "," at ");return f.displayName&&Ce.includes("<anonymous>")&&(Ce=Ce.replace("<anonymous>",f.displayName)),Ce}while(1<=Q&&0<=he);break}}}finally{Jt=!1,Error.prepareStackTrace=S}return(f=f?f.displayName||f.name:"")?ut(f):""}var Yn=Object.prototype.hasOwnProperty,ci=[],qt=-1;function mt(f){return{current:f}}function kt(f){0>qt||(f.current=ci[qt],ci[qt]=null,qt--)}function gt(f,d){qt++,ci[qt]=f.current,f.current=d}var Cn={},En=mt(Cn),cn=mt(!1),Ii=Cn;function Qt(f,d){var S=f.type.contextTypes;if(!S)return Cn;var T=f.stateNode;if(T&&T.__reactInternalMemoizedUnmaskedChildContext===d)return T.__reactInternalMemoizedMaskedChildContext;var R={},U;for(U in S)R[U]=d[U];return T&&(f=f.stateNode,f.__reactInternalMemoizedUnmaskedChildContext=d,f.__reactInternalMemoizedMaskedChildContext=R),R}function on(f){return f=f.childContextTypes,f!=null}function xi(){kt(cn),kt(En)}function Un(f,d,S){if(En.current!==Cn)throw Error(o(168));gt(En,d),gt(cn,S)}function Xr(f,d,S){var T=f.stateNode;if(d=d.childContextTypes,typeof T.getChildContext!="function")return S;T=T.getChildContext();for(var R in T)if(!(R in d))throw Error(o(108,P(f)||"Unknown",R));return s({},S,T)}function jr(f){return f=(f=f.stateNode)&&f.__reactInternalMemoizedMergedChildContext||Cn,Ii=En.current,gt(En,f),gt(cn,cn.current),!0}function ui(f,d,S){var T=f.stateNode;if(!T)throw Error(o(169));S?(f=Xr(f,d,Ii),T.__reactInternalMemoizedMergedChildContext=f,kt(cn),kt(En),gt(En,f)):kt(cn),gt(cn,S)}var Vi=Math.clz32?Math.clz32:xh,Oa=Math.log,Ro=Math.LN2;function xh(f){return f>>>=0,f===0?32:31-(Oa(f)/Ro|0)|0}var fs=64,ds=4194304;function ps(f){switch(f&-f){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 f&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return f&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return f}}function Po(f,d){var S=f.pendingLanes;if(S===0)return 0;var T=0,R=f.suspendedLanes,U=f.pingedLanes,Q=S&268435455;if(Q!==0){var he=Q&~R;he!==0?T=ps(he):(U&=Q,U!==0&&(T=ps(U)))}else Q=S&~R,Q!==0?T=ps(Q):U!==0&&(T=ps(U));if(T===0)return 0;if(d!==0&&d!==T&&(d&R)===0&&(R=T&-T,U=d&-d,R>=U||R===16&&(U&4194240)!==0))return d;if((T&4)!==0&&(T|=S&16),d=f.entangledLanes,d!==0)for(f=f.entanglements,d&=T;0<d;)S=31-Vi(d),R=1<<S,T|=f[S],d&=~R;return T}function wh(f,d){switch(f){case 1:case 2:case 4:return d+250;case 8:case 16:case 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 d+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function sc(f,d){for(var S=f.suspendedLanes,T=f.pingedLanes,R=f.expirationTimes,U=f.pendingLanes;0<U;){var Q=31-Vi(U),he=1<<Q,Ce=R[Q];Ce===-1?((he&S)===0||(he&T)!==0)&&(R[Q]=wh(he,d)):Ce<=d&&(f.expiredLanes|=he),U&=~he}}function ms(f){return f=f.pendingLanes&-1073741825,f!==0?f:f&1073741824?1073741824:0}function Na(f){for(var d=[],S=0;31>S;S++)d.push(f);return d}function Yr(f,d,S){f.pendingLanes|=d,d!==536870912&&(f.suspendedLanes=0,f.pingedLanes=0),f=f.eventTimes,d=31-Vi(d),f[d]=S}function Ys(f,d){var S=f.pendingLanes&~d;f.pendingLanes=d,f.suspendedLanes=0,f.pingedLanes=0,f.expiredLanes&=d,f.mutableReadLanes&=d,f.entangledLanes&=d,d=f.entanglements;var T=f.eventTimes;for(f=f.expirationTimes;0<S;){var R=31-Vi(S),U=1<<R;d[R]=0,T[R]=-1,f[R]=-1,S&=~U}}function qr(f,d){var S=f.entangledLanes|=d;for(f=f.entanglements;S;){var T=31-Vi(S),R=1<<T;R&d|f[T]&d&&(f[T]|=d),S&=~R}}var Ut=0;function oc(f){return f&=-f,1<f?4<f?(f&268435455)!==0?16:536870912:4:1}var gs=i.unstable_scheduleCallback,Fa=i.unstable_cancelCallback,ac=i.unstable_shouldYield,Sh=i.unstable_requestPaint,pn=i.unstable_now,Lo=i.unstable_ImmediatePriority,Eh=i.unstable_UserBlockingPriority,wi=i.unstable_NormalPriority,lc=i.unstable_IdlePriority,Io=null,Wi=null;function cc(f){if(Wi&&typeof Wi.onCommitFiberRoot=="function")try{Wi.onCommitFiberRoot(Io,f,void 0,(f.current.flags&128)===128)}catch{}}function bh(f,d){return f===d&&(f!==0||1/f===1/d)||f!==f&&d!==d}var Xi=typeof Object.is=="function"?Object.is:bh,Si=null,Zr=!1,or=!1;function uc(f){Si===null?Si=[f]:Si.push(f)}function hc(f){Zr=!0,uc(f)}function Di(){if(!or&&Si!==null){or=!0;var f=0,d=Ut;try{var S=Si;for(Ut=1;f<S.length;f++){var T=S[f];do T=T(!0);while(T!==null)}Si=null,Zr=!1}catch(R){throw Si!==null&&(Si=Si.slice(f+1)),gs(Lo,Di),R}finally{Ut=d,or=!1}}return null}var Do=a.ReactCurrentBatchConfig;function Uo(f,d){if(Xi(f,d))return!0;if(typeof f!="object"||f===null||typeof d!="object"||d===null)return!1;var S=Object.keys(f),T=Object.keys(d);if(S.length!==T.length)return!1;for(T=0;T<S.length;T++){var R=S[T];if(!Yn.call(d,R)||!Xi(f[R],d[R]))return!1}return!0}function Oo(f){switch(f.tag){case 5:return ut(f.type);case 16:return ut("Lazy");case 13:return ut("Suspense");case 19:return ut("SuspenseList");case 0:case 2:case 15:return f=Gt(f.type,!1),f;case 11:return f=Gt(f.type.render,!1),f;case 1:return f=Gt(f.type,!0),f;default:return""}}function Ei(f,d){if(f&&f.defaultProps){d=s({},d),f=f.defaultProps;for(var S in f)d[S]===void 0&&(d[S]=f[S]);return d}return d}var qn=mt(null),ka=null,Tr=null,qs=null;function za(){qs=Tr=ka=null}function Mh(f,d,S){Ee?(gt(qn,d._currentValue),d._currentValue=S):(gt(qn,d._currentValue2),d._currentValue2=S)}function Zn(f){var d=qn.current;kt(qn),Ee?f._currentValue=d:f._currentValue2=d}function bi(f,d,S){for(;f!==null;){var T=f.alternate;if((f.childLanes&d)!==d?(f.childLanes|=d,T!==null&&(T.childLanes|=d)):T!==null&&(T.childLanes&d)!==d&&(T.childLanes|=d),f===S)break;f=f.return}}function Rn(f,d){ka=f,qs=Tr=null,f=f.dependencies,f!==null&&f.firstContext!==null&&((f.lanes&d)!==0&&(Zi=!0),f.firstContext=null)}function Pn(f){var d=Ee?f._currentValue:f._currentValue2;if(qs!==f)if(f={context:f,memoizedValue:d,next:null},Tr===null){if(ka===null)throw Error(o(308));Tr=f,ka.dependencies={lanes:0,firstContext:f}}else Tr=Tr.next=f;return d}var ji=null,Zs=!1;function Gp(f){f.updateQueue={baseState:f.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function g_(f,d){f=f.updateQueue,d.updateQueue===f&&(d.updateQueue={baseState:f.baseState,firstBaseUpdate:f.firstBaseUpdate,lastBaseUpdate:f.lastBaseUpdate,shared:f.shared,effects:f.effects})}function vs(f,d){return{eventTime:f,lane:d,tag:0,payload:null,callback:null,next:null}}function Ks(f,d){var S=f.updateQueue;S!==null&&(S=S.shared,On!==null&&(f.mode&1)!==0&&(Dt&2)===0?(f=S.interleaved,f===null?(d.next=d,ji===null?ji=[S]:ji.push(S)):(d.next=f.next,f.next=d),S.interleaved=d):(f=S.pending,f===null?d.next=d:(d.next=f.next,f.next=d),S.pending=d))}function Th(f,d,S){if(d=d.updateQueue,d!==null&&(d=d.shared,(S&4194240)!==0)){var T=d.lanes;T&=f.pendingLanes,S|=T,d.lanes=S,qr(f,S)}}function v_(f,d){var S=f.updateQueue,T=f.alternate;if(T!==null&&(T=T.updateQueue,S===T)){var R=null,U=null;if(S=S.firstBaseUpdate,S!==null){do{var Q={eventTime:S.eventTime,lane:S.lane,tag:S.tag,payload:S.payload,callback:S.callback,next:null};U===null?R=U=Q:U=U.next=Q,S=S.next}while(S!==null);U===null?R=U=d:U=U.next=d}else R=U=d;S={baseState:T.baseState,firstBaseUpdate:R,lastBaseUpdate:U,shared:T.shared,effects:T.effects},f.updateQueue=S;return}f=S.lastBaseUpdate,f===null?S.firstBaseUpdate=d:f.next=d,S.lastBaseUpdate=d}function Ah(f,d,S,T){var R=f.updateQueue;Zs=!1;var U=R.firstBaseUpdate,Q=R.lastBaseUpdate,he=R.shared.pending;if(he!==null){R.shared.pending=null;var Ce=he,Xe=Ce.next;Ce.next=null,Q===null?U=Xe:Q.next=Xe,Q=Ce;var rt=f.alternate;rt!==null&&(rt=rt.updateQueue,he=rt.lastBaseUpdate,he!==Q&&(he===null?rt.firstBaseUpdate=Xe:he.next=Xe,rt.lastBaseUpdate=Ce))}if(U!==null){var St=R.baseState;Q=0,rt=Xe=Ce=null,he=U;do{var ht=he.lane,nn=he.eventTime;if((T&ht)===ht){rt!==null&&(rt=rt.next={eventTime:nn,lane:0,tag:he.tag,payload:he.payload,callback:he.callback,next:null});e:{var at=f,pi=he;switch(ht=d,nn=S,pi.tag){case 1:if(at=pi.payload,typeof at=="function"){St=at.call(nn,St,ht);break e}St=at;break e;case 3:at.flags=at.flags&-65537|128;case 0:if(at=pi.payload,ht=typeof at=="function"?at.call(nn,St,ht):at,ht==null)break e;St=s({},St,ht);break e;case 2:Zs=!0}}he.callback!==null&&he.lane!==0&&(f.flags|=64,ht=R.effects,ht===null?R.effects=[he]:ht.push(he))}else nn={eventTime:nn,lane:ht,tag:he.tag,payload:he.payload,callback:he.callback,next:null},rt===null?(Xe=rt=nn,Ce=St):rt=rt.next=nn,Q|=ht;if(he=he.next,he===null){if(he=R.shared.pending,he===null)break;ht=he,he=ht.next,ht.next=null,R.lastBaseUpdate=ht,R.shared.pending=null}}while(!0);if(rt===null&&(Ce=St),R.baseState=Ce,R.firstBaseUpdate=Xe,R.lastBaseUpdate=rt,d=R.shared.interleaved,d!==null){R=d;do Q|=R.lane,R=R.next;while(R!==d)}else U===null&&(R.shared.lanes=0);qa|=Q,f.lanes=Q,f.memoizedState=St}}function y_(f,d,S){if(f=d.effects,d.effects=null,f!==null)for(d=0;d<f.length;d++){var T=f[d],R=T.callback;if(R!==null){if(T.callback=null,T=S,typeof R!="function")throw Error(o(191,R));R.call(T)}}}var __=new n.Component().refs;function Hp(f,d,S,T){d=f.memoizedState,S=S(T,d),S=S==null?d:s({},d,S),f.memoizedState=S,f.lanes===0&&(f.updateQueue.baseState=S)}var Ch={isMounted:function(f){return(f=f._reactInternals)?C(f)===f:!1},enqueueSetState:function(f,d,S){f=f._reactInternals;var T=Ti(),R=Qs(f),U=vs(T,R);U.payload=d,S!=null&&(U.callback=S),Ks(f,U),d=hr(f,R,T),d!==null&&Th(d,f,R)},enqueueReplaceState:function(f,d,S){f=f._reactInternals;var T=Ti(),R=Qs(f),U=vs(T,R);U.tag=1,U.payload=d,S!=null&&(U.callback=S),Ks(f,U),d=hr(f,R,T),d!==null&&Th(d,f,R)},enqueueForceUpdate:function(f,d){f=f._reactInternals;var S=Ti(),T=Qs(f),R=vs(S,T);R.tag=2,d!=null&&(R.callback=d),Ks(f,R),d=hr(f,T,S),d!==null&&Th(d,f,T)}};function x_(f,d,S,T,R,U,Q){return f=f.stateNode,typeof f.shouldComponentUpdate=="function"?f.shouldComponentUpdate(T,U,Q):d.prototype&&d.prototype.isPureReactComponent?!Uo(S,T)||!Uo(R,U):!0}function w_(f,d,S){var T=!1,R=Cn,U=d.contextType;return typeof U=="object"&&U!==null?U=Pn(U):(R=on(d)?Ii:En.current,T=d.contextTypes,U=(T=T!=null)?Qt(f,R):Cn),d=new d(S,U),f.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Ch,f.stateNode=d,d._reactInternals=f,T&&(f=f.stateNode,f.__reactInternalMemoizedUnmaskedChildContext=R,f.__reactInternalMemoizedMaskedChildContext=U),d}function S_(f,d,S,T){f=d.state,typeof d.componentWillReceiveProps=="function"&&d.componentWillReceiveProps(S,T),typeof d.UNSAFE_componentWillReceiveProps=="function"&&d.UNSAFE_componentWillReceiveProps(S,T),d.state!==f&&Ch.enqueueReplaceState(d,d.state,null)}function Vp(f,d,S,T){var R=f.stateNode;R.props=S,R.state=f.memoizedState,R.refs=__,Gp(f);var U=d.contextType;typeof U=="object"&&U!==null?R.context=Pn(U):(U=on(d)?Ii:En.current,R.context=Qt(f,U)),R.state=f.memoizedState,U=d.getDerivedStateFromProps,typeof U=="function"&&(Hp(f,d,U,S),R.state=f.memoizedState),typeof d.getDerivedStateFromProps=="function"||typeof R.getSnapshotBeforeUpdate=="function"||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(d=R.state,typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount(),d!==R.state&&Ch.enqueueReplaceState(R,R.state,null),Ah(f,S,R,T),R.state=f.memoizedState),typeof R.componentDidMount=="function"&&(f.flags|=4194308)}var Ba=[],Ga=0,Rh=null,Ph=0,ar=[],lr=0,No=null,ys=1,_s="";function Fo(f,d){Ba[Ga++]=Ph,Ba[Ga++]=Rh,Rh=f,Ph=d}function E_(f,d,S){ar[lr++]=ys,ar[lr++]=_s,ar[lr++]=No,No=f;var T=ys;f=_s;var R=32-Vi(T)-1;T&=~(1<<R),S+=1;var U=32-Vi(d)+R;if(30<U){var Q=R-R%5;U=(T&(1<<Q)-1).toString(32),T>>=Q,R-=Q,ys=1<<32-Vi(d)+R|S<<R|T,_s=U+f}else ys=1<<U|S<<R|T,_s=f}function Wp(f){f.return!==null&&(Fo(f,1),E_(f,1,0))}function Xp(f){for(;f===Rh;)Rh=Ba[--Ga],Ba[Ga]=null,Ph=Ba[--Ga],Ba[Ga]=null;for(;f===No;)No=ar[--lr],ar[lr]=null,_s=ar[--lr],ar[lr]=null,ys=ar[--lr],ar[lr]=null}var Yi=null,qi=null,un=!1,fc=!1,Ar=null;function b_(f,d){var S=fr(5,null,null,0);S.elementType="DELETED",S.stateNode=d,S.return=f,d=f.deletions,d===null?(f.deletions=[S],f.flags|=16):d.push(S)}function M_(f,d){switch(f.tag){case 5:return d=Rt(d,f.type,f.pendingProps),d!==null?(f.stateNode=d,Yi=f,qi=dn(d),!0):!1;case 6:return d=li(d,f.pendingProps),d!==null?(f.stateNode=d,Yi=f,qi=null,!0):!1;case 13:if(d=jn(d),d!==null){var S=No!==null?{id:ys,overflow:_s}:null;return f.memoizedState={dehydrated:d,treeContext:S,retryLane:1073741824},S=fr(18,null,null,0),S.stateNode=d,S.return=f,f.child=S,Yi=f,qi=null,!0}return!1;default:return!1}}function jp(f){return(f.mode&1)!==0&&(f.flags&128)===0}function Yp(f){if(un){var d=qi;if(d){var S=d;if(!M_(f,d)){if(jp(f))throw Error(o(418));d=tn(S);var T=Yi;d&&M_(f,d)?b_(T,S):(f.flags=f.flags&-4097|2,un=!1,Yi=f)}}else{if(jp(f))throw Error(o(418));f.flags=f.flags&-4097|2,un=!1,Yi=f}}}function T_(f){for(f=f.return;f!==null&&f.tag!==5&&f.tag!==3&&f.tag!==13;)f=f.return;Yi=f}function dc(f){if(!oe||f!==Yi)return!1;if(!un)return T_(f),un=!0,!1;if(f.tag!==3&&(f.tag!==5||ct(f.type)&&!ie(f.type,f.memoizedProps))){var d=qi;if(d){if(jp(f)){for(f=qi;f;)f=tn(f);throw Error(o(418))}for(;d;)b_(f,d),d=tn(d)}}if(T_(f),f.tag===13){if(!oe)throw Error(o(316));if(f=f.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(o(317));qi=Re(f)}else qi=Yi?tn(f.stateNode):null;return!0}function Ha(){oe&&(qi=Yi=null,fc=un=!1)}function qp(f){Ar===null?Ar=[f]:Ar.push(f)}function pc(f,d,S){if(f=S.ref,f!==null&&typeof f!="function"&&typeof f!="object"){if(S._owner){if(S=S._owner,S){if(S.tag!==1)throw Error(o(309));var T=S.stateNode}if(!T)throw Error(o(147,f));var R=T,U=""+f;return d!==null&&d.ref!==null&&typeof d.ref=="function"&&d.ref._stringRef===U?d.ref:(d=function(Q){var he=R.refs;he===__&&(he=R.refs={}),Q===null?delete he[U]:he[U]=Q},d._stringRef=U,d)}if(typeof f!="string")throw Error(o(284));if(!S._owner)throw Error(o(290,f))}return f}function Lh(f,d){throw f=Object.prototype.toString.call(d),Error(o(31,f==="[object Object]"?"object with keys {"+Object.keys(d).join(", ")+"}":f))}function A_(f){var d=f._init;return d(f._payload)}function C_(f){function d(ye,fe){if(f){var Te=ye.deletions;Te===null?(ye.deletions=[fe],ye.flags|=16):Te.push(fe)}}function S(ye,fe){if(!f)return null;for(;fe!==null;)d(ye,fe),fe=fe.sibling;return null}function T(ye,fe){for(ye=new Map;fe!==null;)fe.key!==null?ye.set(fe.key,fe):ye.set(fe.index,fe),fe=fe.sibling;return ye}function R(ye,fe){return ye=to(ye,fe),ye.index=0,ye.sibling=null,ye}function U(ye,fe,Te){return ye.index=Te,f?(Te=ye.alternate,Te!==null?(Te=Te.index,Te<fe?(ye.flags|=2,fe):Te):(ye.flags|=2,fe)):(ye.flags|=1048576,fe)}function Q(ye){return f&&ye.alternate===null&&(ye.flags|=2),ye}function he(ye,fe,Te,et){return fe===null||fe.tag!==6?(fe=Lm(Te,ye.mode,et),fe.return=ye,fe):(fe=R(fe,Te),fe.return=ye,fe)}function Ce(ye,fe,Te,et){var ot=Te.type;return ot===u?rt(ye,fe,Te.props.children,et,Te.key):fe!==null&&(fe.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===w&&A_(ot)===fe.type)?(et=R(fe,Te.props),et.ref=pc(ye,fe,Te),et.return=ye,et):(et=cf(Te.type,Te.key,Te.props,null,ye.mode,et),et.ref=pc(ye,fe,Te),et.return=ye,et)}function Xe(ye,fe,Te,et){return fe===null||fe.tag!==4||fe.stateNode.containerInfo!==Te.containerInfo||fe.stateNode.implementation!==Te.implementation?(fe=Im(Te,ye.mode,et),fe.return=ye,fe):(fe=R(fe,Te.children||[]),fe.return=ye,fe)}function rt(ye,fe,Te,et,ot){return fe===null||fe.tag!==7?(fe=Wo(Te,ye.mode,et,ot),fe.return=ye,fe):(fe=R(fe,Te),fe.return=ye,fe)}function St(ye,fe,Te){if(typeof fe=="string"&&fe!==""||typeof fe=="number")return fe=Lm(""+fe,ye.mode,Te),fe.return=ye,fe;if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case l:return Te=cf(fe.type,fe.key,fe.props,null,ye.mode,Te),Te.ref=pc(ye,null,fe),Te.return=ye,Te;case c:return fe=Im(fe,ye.mode,Te),fe.return=ye,fe;case w:var et=fe._init;return St(ye,et(fe._payload),Te)}if(q(fe)||M(fe))return fe=Wo(fe,ye.mode,Te,null),fe.return=ye,fe;Lh(ye,fe)}return null}function ht(ye,fe,Te,et){var ot=fe!==null?fe.key:null;if(typeof Te=="string"&&Te!==""||typeof Te=="number")return ot!==null?null:he(ye,fe,""+Te,et);if(typeof Te=="object"&&Te!==null){switch(Te.$$typeof){case l:return Te.key===ot?Ce(ye,fe,Te,et):null;case c:return Te.key===ot?Xe(ye,fe,Te,et):null;case w:return ot=Te._init,ht(ye,fe,ot(Te._payload),et)}if(q(Te)||M(Te))return ot!==null?null:rt(ye,fe,Te,et,null);Lh(ye,Te)}return null}function nn(ye,fe,Te,et,ot){if(typeof et=="string"&&et!==""||typeof et=="number")return ye=ye.get(Te)||null,he(fe,ye,""+et,ot);if(typeof et=="object"&&et!==null){switch(et.$$typeof){case l:return ye=ye.get(et.key===null?Te:et.key)||null,Ce(fe,ye,et,ot);case c:return ye=ye.get(et.key===null?Te:et.key)||null,Xe(fe,ye,et,ot);case w:var Pt=et._init;return nn(ye,fe,Te,Pt(et._payload),ot)}if(q(et)||M(et))return ye=ye.get(Te)||null,rt(fe,ye,et,ot,null);Lh(fe,et)}return null}function at(ye,fe,Te,et){for(var ot=null,Pt=null,Et=fe,Ht=fe=0,$n=null;Et!==null&&Ht<Te.length;Ht++){Et.index>Ht?($n=Et,Et=null):$n=Et.sibling;var Vt=ht(ye,Et,Te[Ht],et);if(Vt===null){Et===null&&(Et=$n);break}f&&Et&&Vt.alternate===null&&d(ye,Et),fe=U(Vt,fe,Ht),Pt===null?ot=Vt:Pt.sibling=Vt,Pt=Vt,Et=$n}if(Ht===Te.length)return S(ye,Et),un&&Fo(ye,Ht),ot;if(Et===null){for(;Ht<Te.length;Ht++)Et=St(ye,Te[Ht],et),Et!==null&&(fe=U(Et,fe,Ht),Pt===null?ot=Et:Pt.sibling=Et,Pt=Et);return un&&Fo(ye,Ht),ot}for(Et=T(ye,Et);Ht<Te.length;Ht++)$n=nn(Et,ye,Ht,Te[Ht],et),$n!==null&&(f&&$n.alternate!==null&&Et.delete($n.key===null?Ht:$n.key),fe=U($n,fe,Ht),Pt===null?ot=$n:Pt.sibling=$n,Pt=$n);return f&&Et.forEach(function(no){return d(ye,no)}),un&&Fo(ye,Ht),ot}function pi(ye,fe,Te,et){var ot=M(Te);if(typeof ot!="function")throw Error(o(150));if(Te=ot.call(Te),Te==null)throw Error(o(151));for(var Pt=ot=null,Et=fe,Ht=fe=0,$n=null,Vt=Te.next();Et!==null&&!Vt.done;Ht++,Vt=Te.next()){Et.index>Ht?($n=Et,Et=null):$n=Et.sibling;var no=ht(ye,Et,Vt.value,et);if(no===null){Et===null&&(Et=$n);break}f&&Et&&no.alternate===null&&d(ye,Et),fe=U(no,fe,Ht),Pt===null?ot=no:Pt.sibling=no,Pt=no,Et=$n}if(Vt.done)return S(ye,Et),un&&Fo(ye,Ht),ot;if(Et===null){for(;!Vt.done;Ht++,Vt=Te.next())Vt=St(ye,Vt.value,et),Vt!==null&&(fe=U(Vt,fe,Ht),Pt===null?ot=Vt:Pt.sibling=Vt,Pt=Vt);return un&&Fo(ye,Ht),ot}for(Et=T(ye,Et);!Vt.done;Ht++,Vt=Te.next())Vt=nn(Et,ye,Ht,Vt.value,et),Vt!==null&&(f&&Vt.alternate!==null&&Et.delete(Vt.key===null?Ht:Vt.key),fe=U(Vt,fe,Ht),Pt===null?ot=Vt:Pt.sibling=Vt,Pt=Vt);return f&&Et.forEach(function(Y2){return d(ye,Y2)}),un&&Fo(ye,Ht),ot}function dr(ye,fe,Te,et){if(typeof Te=="object"&&Te!==null&&Te.type===u&&Te.key===null&&(Te=Te.props.children),typeof Te=="object"&&Te!==null){switch(Te.$$typeof){case l:e:{for(var ot=Te.key,Pt=fe;Pt!==null;){if(Pt.key===ot){if(ot=Te.type,ot===u){if(Pt.tag===7){S(ye,Pt.sibling),fe=R(Pt,Te.props.children),fe.return=ye,ye=fe;break e}}else if(Pt.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===w&&A_(ot)===Pt.type){S(ye,Pt.sibling),fe=R(Pt,Te.props),fe.ref=pc(ye,Pt,Te),fe.return=ye,ye=fe;break e}S(ye,Pt);break}else d(ye,Pt);Pt=Pt.sibling}Te.type===u?(fe=Wo(Te.props.children,ye.mode,et,Te.key),fe.return=ye,ye=fe):(et=cf(Te.type,Te.key,Te.props,null,ye.mode,et),et.ref=pc(ye,fe,Te),et.return=ye,ye=et)}return Q(ye);case c:e:{for(Pt=Te.key;fe!==null;){if(fe.key===Pt)if(fe.tag===4&&fe.stateNode.containerInfo===Te.containerInfo&&fe.stateNode.implementation===Te.implementation){S(ye,fe.sibling),fe=R(fe,Te.children||[]),fe.return=ye,ye=fe;break e}else{S(ye,fe);break}else d(ye,fe);fe=fe.sibling}fe=Im(Te,ye.mode,et),fe.return=ye,ye=fe}return Q(ye);case w:return Pt=Te._init,dr(ye,fe,Pt(Te._payload),et)}if(q(Te))return at(ye,fe,Te,et);if(M(Te))return pi(ye,fe,Te,et);Lh(ye,Te)}return typeof Te=="string"&&Te!==""||typeof Te=="number"?(Te=""+Te,fe!==null&&fe.tag===6?(S(ye,fe.sibling),fe=R(fe,Te),fe.return=ye,ye=fe):(S(ye,fe),fe=Lm(Te,ye.mode,et),fe.return=ye,ye=fe),Q(ye)):S(ye,fe)}return dr}var Va=C_(!0),R_=C_(!1),mc={},cr=mt(mc),gc=mt(mc),Wa=mt(mc);function Kr(f){if(f===mc)throw Error(o(174));return f}function Zp(f,d){gt(Wa,d),gt(gc,f),gt(cr,mc),f=O(d),kt(cr),gt(cr,f)}function Xa(){kt(cr),kt(gc),kt(Wa)}function P_(f){var d=Kr(Wa.current),S=Kr(cr.current);d=k(S,f.type,d),S!==d&&(gt(gc,f),gt(cr,d))}function Kp(f){gc.current===f&&(kt(cr),kt(gc))}var mn=mt(0);function Ih(f){for(var d=f;d!==null;){if(d.tag===13){var S=d.memoizedState;if(S!==null&&(S=S.dehydrated,S===null||Bt(S)||sn(S)))return d}else if(d.tag===19&&d.memoizedProps.revealOrder!==void 0){if((d.flags&128)!==0)return d}else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===f)break;for(;d.sibling===null;){if(d.return===null||d.return===f)return null;d=d.return}d.sibling.return=d.return,d=d.sibling}return null}var $p=[];function Jp(){for(var f=0;f<$p.length;f++){var d=$p[f];Ee?d._workInProgressVersionPrimary=null:d._workInProgressVersionSecondary=null}$p.length=0}var Dh=a.ReactCurrentDispatcher,ur=a.ReactCurrentBatchConfig,ja=0,bn=null,hi=null,Kn=null,Uh=!1,vc=!1,yc=0,y2=0;function fi(){throw Error(o(321))}function Qp(f,d){if(d===null)return!1;for(var S=0;S<d.length&&S<f.length;S++)if(!Xi(f[S],d[S]))return!1;return!0}function em(f,d,S,T,R,U){if(ja=U,bn=d,d.memoizedState=null,d.updateQueue=null,d.lanes=0,Dh.current=f===null||f.memoizedState===null?S2:E2,f=S(T,R),vc){U=0;do{if(vc=!1,yc=0,25<=U)throw Error(o(301));U+=1,Kn=hi=null,d.updateQueue=null,Dh.current=b2,f=S(T,R)}while(vc)}if(Dh.current=zh,d=hi!==null&&hi.next!==null,ja=0,Kn=hi=bn=null,Uh=!1,d)throw Error(o(300));return f}function tm(){var f=yc!==0;return yc=0,f}function xs(){var f={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Kn===null?bn.memoizedState=Kn=f:Kn=Kn.next=f,Kn}function $r(){if(hi===null){var f=bn.alternate;f=f!==null?f.memoizedState:null}else f=hi.next;var d=Kn===null?bn.memoizedState:Kn.next;if(d!==null)Kn=d,hi=f;else{if(f===null)throw Error(o(310));hi=f,f={memoizedState:hi.memoizedState,baseState:hi.baseState,baseQueue:hi.baseQueue,queue:hi.queue,next:null},Kn===null?bn.memoizedState=Kn=f:Kn=Kn.next=f}return Kn}function ko(f,d){return typeof d=="function"?d(f):d}function Oh(f){var d=$r(),S=d.queue;if(S===null)throw Error(o(311));S.lastRenderedReducer=f;var T=hi,R=T.baseQueue,U=S.pending;if(U!==null){if(R!==null){var Q=R.next;R.next=U.next,U.next=Q}T.baseQueue=R=U,S.pending=null}if(R!==null){U=R.next,T=T.baseState;var he=Q=null,Ce=null,Xe=U;do{var rt=Xe.lane;if((ja&rt)===rt)Ce!==null&&(Ce=Ce.next={lane:0,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null}),T=Xe.hasEagerState?Xe.eagerState:f(T,Xe.action);else{var St={lane:rt,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null};Ce===null?(he=Ce=St,Q=T):Ce=Ce.next=St,bn.lanes|=rt,qa|=rt}Xe=Xe.next}while(Xe!==null&&Xe!==U);Ce===null?Q=T:Ce.next=he,Xi(T,d.memoizedState)||(Zi=!0),d.memoizedState=T,d.baseState=Q,d.baseQueue=Ce,S.lastRenderedState=T}if(f=S.interleaved,f!==null){R=f;do U=R.lane,bn.lanes|=U,qa|=U,R=R.next;while(R!==f)}else R===null&&(S.lanes=0);return[d.memoizedState,S.dispatch]}function Nh(f){var d=$r(),S=d.queue;if(S===null)throw Error(o(311));S.lastRenderedReducer=f;var T=S.dispatch,R=S.pending,U=d.memoizedState;if(R!==null){S.pending=null;var Q=R=R.next;do U=f(U,Q.action),Q=Q.next;while(Q!==R);Xi(U,d.memoizedState)||(Zi=!0),d.memoizedState=U,d.baseQueue===null&&(d.baseState=U),S.lastRenderedState=U}return[U,T]}function L_(){}function I_(f,d){var S=bn,T=$r(),R=d(),U=!Xi(T.memoizedState,R);if(U&&(T.memoizedState=R,Zi=!0),T=T.queue,xc(O_.bind(null,S,T,f),[f]),T.getSnapshot!==d||U||Kn!==null&&Kn.memoizedState.tag&1){if(S.flags|=2048,_c(9,U_.bind(null,S,T,R,d),void 0,null),On===null)throw Error(o(349));(ja&30)!==0||D_(S,d,R)}return R}function D_(f,d,S){f.flags|=16384,f={getSnapshot:d,value:S},d=bn.updateQueue,d===null?(d={lastEffect:null,stores:null},bn.updateQueue=d,d.stores=[f]):(S=d.stores,S===null?d.stores=[f]:S.push(f))}function U_(f,d,S,T){d.value=S,d.getSnapshot=T,N_(d)&&hr(f,1,-1)}function O_(f,d,S){return S(function(){N_(d)&&hr(f,1,-1)})}function N_(f){var d=f.getSnapshot;f=f.value;try{var S=d();return!Xi(f,S)}catch{return!0}}function nm(f){var d=xs();return typeof f=="function"&&(f=f()),d.memoizedState=d.baseState=f,f={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ko,lastRenderedState:f},d.queue=f,f=f.dispatch=w2.bind(null,bn,f),[d.memoizedState,f]}function _c(f,d,S,T){return f={tag:f,create:d,destroy:S,deps:T,next:null},d=bn.updateQueue,d===null?(d={lastEffect:null,stores:null},bn.updateQueue=d,d.lastEffect=f.next=f):(S=d.lastEffect,S===null?d.lastEffect=f.next=f:(T=S.next,S.next=f,f.next=T,d.lastEffect=f)),f}function F_(){return $r().memoizedState}function Fh(f,d,S,T){var R=xs();bn.flags|=f,R.memoizedState=_c(1|d,S,void 0,T===void 0?null:T)}function kh(f,d,S,T){var R=$r();T=T===void 0?null:T;var U=void 0;if(hi!==null){var Q=hi.memoizedState;if(U=Q.destroy,T!==null&&Qp(T,Q.deps)){R.memoizedState=_c(d,S,U,T);return}}bn.flags|=f,R.memoizedState=_c(1|d,S,U,T)}function im(f,d){return Fh(8390656,8,f,d)}function xc(f,d){return kh(2048,8,f,d)}function k_(f,d){return kh(4,2,f,d)}function z_(f,d){return kh(4,4,f,d)}function B_(f,d){if(typeof d=="function")return f=f(),d(f),function(){d(null)};if(d!=null)return f=f(),d.current=f,function(){d.current=null}}function G_(f,d,S){return S=S!=null?S.concat([f]):null,kh(4,4,B_.bind(null,d,f),S)}function rm(){}function H_(f,d){var S=$r();d=d===void 0?null:d;var T=S.memoizedState;return T!==null&&d!==null&&Qp(d,T[1])?T[0]:(S.memoizedState=[f,d],f)}function V_(f,d){var S=$r();d=d===void 0?null:d;var T=S.memoizedState;return T!==null&&d!==null&&Qp(d,T[1])?T[0]:(f=f(),S.memoizedState=[f,d],f)}function _2(f,d){var S=Ut;Ut=S!==0&&4>S?S:4,f(!0);var T=ur.transition;ur.transition={};try{f(!1),d()}finally{Ut=S,ur.transition=T}}function W_(){return $r().memoizedState}function x2(f,d,S){var T=Qs(f);S={lane:T,action:S,hasEagerState:!1,eagerState:null,next:null},X_(f)?j_(d,S):(Y_(f,d,S),S=Ti(),f=hr(f,T,S),f!==null&&q_(f,d,T))}function w2(f,d,S){var T=Qs(f),R={lane:T,action:S,hasEagerState:!1,eagerState:null,next:null};if(X_(f))j_(d,R);else{Y_(f,d,R);var U=f.alternate;if(f.lanes===0&&(U===null||U.lanes===0)&&(U=d.lastRenderedReducer,U!==null))try{var Q=d.lastRenderedState,he=U(Q,S);if(R.hasEagerState=!0,R.eagerState=he,Xi(he,Q))return}catch{}finally{}S=Ti(),f=hr(f,T,S),f!==null&&q_(f,d,T)}}function X_(f){var d=f.alternate;return f===bn||d!==null&&d===bn}function j_(f,d){vc=Uh=!0;var S=f.pending;S===null?d.next=d:(d.next=S.next,S.next=d),f.pending=d}function Y_(f,d,S){On!==null&&(f.mode&1)!==0&&(Dt&2)===0?(f=d.interleaved,f===null?(S.next=S,ji===null?ji=[d]:ji.push(d)):(S.next=f.next,f.next=S),d.interleaved=S):(f=d.pending,f===null?S.next=S:(S.next=f.next,f.next=S),d.pending=S)}function q_(f,d,S){if((S&4194240)!==0){var T=d.lanes;T&=f.pendingLanes,S|=T,d.lanes=S,qr(f,S)}}var zh={readContext:Pn,useCallback:fi,useContext:fi,useEffect:fi,useImperativeHandle:fi,useInsertionEffect:fi,useLayoutEffect:fi,useMemo:fi,useReducer:fi,useRef:fi,useState:fi,useDebugValue:fi,useDeferredValue:fi,useTransition:fi,useMutableSource:fi,useSyncExternalStore:fi,useId:fi,unstable_isNewReconciler:!1},S2={readContext:Pn,useCallback:function(f,d){return xs().memoizedState=[f,d===void 0?null:d],f},useContext:Pn,useEffect:im,useImperativeHandle:function(f,d,S){return S=S!=null?S.concat([f]):null,Fh(4194308,4,B_.bind(null,d,f),S)},useLayoutEffect:function(f,d){return Fh(4194308,4,f,d)},useInsertionEffect:function(f,d){return Fh(4,2,f,d)},useMemo:function(f,d){var S=xs();return d=d===void 0?null:d,f=f(),S.memoizedState=[f,d],f},useReducer:function(f,d,S){var T=xs();return d=S!==void 0?S(d):d,T.memoizedState=T.baseState=d,f={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:f,lastRenderedState:d},T.queue=f,f=f.dispatch=x2.bind(null,bn,f),[T.memoizedState,f]},useRef:function(f){var d=xs();return f={current:f},d.memoizedState=f},useState:nm,useDebugValue:rm,useDeferredValue:function(f){var d=nm(f),S=d[0],T=d[1];return im(function(){var R=ur.transition;ur.transition={};try{T(f)}finally{ur.transition=R}},[f]),S},useTransition:function(){var f=nm(!1),d=f[0];return f=_2.bind(null,f[1]),xs().memoizedState=f,[d,f]},useMutableSource:function(){},useSyncExternalStore:function(f,d,S){var T=bn,R=xs();if(un){if(S===void 0)throw Error(o(407));S=S()}else{if(S=d(),On===null)throw Error(o(349));(ja&30)!==0||D_(T,d,S)}R.memoizedState=S;var U={value:S,getSnapshot:d};return R.queue=U,im(O_.bind(null,T,U,f),[f]),T.flags|=2048,_c(9,U_.bind(null,T,U,S,d),void 0,null),S},useId:function(){var f=xs(),d=On.identifierPrefix;if(un){var S=_s,T=ys;S=(T&~(1<<32-Vi(T)-1)).toString(32)+S,d=":"+d+"R"+S,S=yc++,0<S&&(d+="H"+S.toString(32)),d+=":"}else S=y2++,d=":"+d+"r"+S.toString(32)+":";return f.memoizedState=d},unstable_isNewReconciler:!1},E2={readContext:Pn,useCallback:H_,useContext:Pn,useEffect:xc,useImperativeHandle:G_,useInsertionEffect:k_,useLayoutEffect:z_,useMemo:V_,useReducer:Oh,useRef:F_,useState:function(){return Oh(ko)},useDebugValue:rm,useDeferredValue:function(f){var d=Oh(ko),S=d[0],T=d[1];return xc(function(){var R=ur.transition;ur.transition={};try{T(f)}finally{ur.transition=R}},[f]),S},useTransition:function(){var f=Oh(ko)[0],d=$r().memoizedState;return[f,d]},useMutableSource:L_,useSyncExternalStore:I_,useId:W_,unstable_isNewReconciler:!1},b2={readContext:Pn,useCallback:H_,useContext:Pn,useEffect:xc,useImperativeHandle:G_,useInsertionEffect:k_,useLayoutEffect:z_,useMemo:V_,useReducer:Nh,useRef:F_,useState:function(){return Nh(ko)},useDebugValue:rm,useDeferredValue:function(f){var d=Nh(ko),S=d[0],T=d[1];return xc(function(){var R=ur.transition;ur.transition={};try{T(f)}finally{ur.transition=R}},[f]),S},useTransition:function(){var f=Nh(ko)[0],d=$r().memoizedState;return[f,d]},useMutableSource:L_,useSyncExternalStore:I_,useId:W_,unstable_isNewReconciler:!1};function sm(f,d){try{var S="",T=d;do S+=Oo(T),T=T.return;while(T);var R=S}catch(U){R=`
|
|
Error generating stack: `+U.message+`
|
|
`+U.stack}return{value:f,source:d,stack:R}}function om(f,d){try{console.error(d.value)}catch(S){setTimeout(function(){throw S})}}var M2=typeof WeakMap=="function"?WeakMap:Map;function Z_(f,d,S){S=vs(-1,S),S.tag=3,S.payload={element:null};var T=d.value;return S.callback=function(){tf||(tf=!0,bm=T),om(f,d)},S}function K_(f,d,S){S=vs(-1,S),S.tag=3;var T=f.type.getDerivedStateFromError;if(typeof T=="function"){var R=d.value;S.payload=function(){return T(R)},S.callback=function(){om(f,d)}}var U=f.stateNode;return U!==null&&typeof U.componentDidCatch=="function"&&(S.callback=function(){om(f,d),typeof T!="function"&&($s===null?$s=new Set([this]):$s.add(this));var Q=d.stack;this.componentDidCatch(d.value,{componentStack:Q!==null?Q:""})}),S}function $_(f,d,S){var T=f.pingCache;if(T===null){T=f.pingCache=new M2;var R=new Set;T.set(d,R)}else R=T.get(d),R===void 0&&(R=new Set,T.set(d,R));R.has(S)||(R.add(S),f=z2.bind(null,f,d,S),d.then(f,f))}function J_(f){do{var d;if((d=f.tag===13)&&(d=f.memoizedState,d=d!==null?d.dehydrated!==null:!0),d)return f;f=f.return}while(f!==null);return null}function Q_(f,d,S,T,R){return(f.mode&1)===0?(f===d?f.flags|=65536:(f.flags|=128,S.flags|=131072,S.flags&=-52805,S.tag===1&&(S.alternate===null?S.tag=17:(d=vs(-1,1),d.tag=2,Ks(S,d))),S.lanes|=1),f):(f.flags|=65536,f.lanes=R,f)}function Jr(f){f.flags|=4}function ex(f,d){if(f!==null&&f.child===d.child)return!0;if((d.flags&16)!==0)return!1;for(f=d.child;f!==null;){if((f.flags&12854)!==0||(f.subtreeFlags&12854)!==0)return!1;f=f.sibling}return!0}var wc,Sc,Bh,Gh;if(ae)wc=function(f,d){for(var S=d.child;S!==null;){if(S.tag===5||S.tag===6)V(f,S.stateNode);else if(S.tag!==4&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===d)break;for(;S.sibling===null;){if(S.return===null||S.return===d)return;S=S.return}S.sibling.return=S.return,S=S.sibling}},Sc=function(){},Bh=function(f,d,S,T,R){if(f=f.memoizedProps,f!==T){var U=d.stateNode,Q=Kr(cr.current);S=ee(U,S,f,T,R,Q),(d.updateQueue=S)&&Jr(d)}},Gh=function(f,d,S,T){S!==T&&Jr(d)};else if(z){wc=function(f,d,S,T){for(var R=d.child;R!==null;){if(R.tag===5){var U=R.stateNode;S&&T&&(U=Yt(U,R.type,R.memoizedProps,R)),V(f,U)}else if(R.tag===6)U=R.stateNode,S&&T&&(U=Nt(U,R.memoizedProps,R)),V(f,U);else if(R.tag!==4){if(R.tag===22&&R.memoizedState!==null)U=R.child,U!==null&&(U.return=R),wc(f,R,!0,!0);else if(R.child!==null){R.child.return=R,R=R.child;continue}}if(R===d)break;for(;R.sibling===null;){if(R.return===null||R.return===d)return;R=R.return}R.sibling.return=R.return,R=R.sibling}};var tx=function(f,d,S,T){for(var R=d.child;R!==null;){if(R.tag===5){var U=R.stateNode;S&&T&&(U=Yt(U,R.type,R.memoizedProps,R)),It(f,U)}else if(R.tag===6)U=R.stateNode,S&&T&&(U=Nt(U,R.memoizedProps,R)),It(f,U);else if(R.tag!==4){if(R.tag===22&&R.memoizedState!==null)U=R.child,U!==null&&(U.return=R),tx(f,R,!0,!0);else if(R.child!==null){R.child.return=R,R=R.child;continue}}if(R===d)break;for(;R.sibling===null;){if(R.return===null||R.return===d)return;R=R.return}R.sibling.return=R.return,R=R.sibling}};Sc=function(f,d){var S=d.stateNode;if(!ex(f,d)){f=S.containerInfo;var T=_t(f);tx(T,d,!1,!1),S.pendingChildren=T,Jr(d),Ft(f,T)}},Bh=function(f,d,S,T,R){var U=f.stateNode,Q=f.memoizedProps;if((f=ex(f,d))&&Q===T)d.stateNode=U;else{var he=d.stateNode,Ce=Kr(cr.current),Xe=null;Q!==T&&(Xe=ee(he,S,Q,T,R,Ce)),f&&Xe===null?d.stateNode=U:(U=Ye(U,Xe,S,Q,T,d,f,he),Z(U,S,T,R,Ce)&&Jr(d),d.stateNode=U,f?Jr(d):wc(U,d,!1,!1))}},Gh=function(f,d,S,T){S!==T?(f=Kr(Wa.current),S=Kr(cr.current),d.stateNode=ue(T,f,S,d),Jr(d)):d.stateNode=f.stateNode}}else Sc=function(){},Bh=function(){},Gh=function(){};function Ec(f,d){if(!un)switch(f.tailMode){case"hidden":d=f.tail;for(var S=null;d!==null;)d.alternate!==null&&(S=d),d=d.sibling;S===null?f.tail=null:S.sibling=null;break;case"collapsed":S=f.tail;for(var T=null;S!==null;)S.alternate!==null&&(T=S),S=S.sibling;T===null?d||f.tail===null?f.tail=null:f.tail.sibling=null:T.sibling=null}}function di(f){var d=f.alternate!==null&&f.alternate.child===f.child,S=0,T=0;if(d)for(var R=f.child;R!==null;)S|=R.lanes|R.childLanes,T|=R.subtreeFlags&14680064,T|=R.flags&14680064,R.return=f,R=R.sibling;else for(R=f.child;R!==null;)S|=R.lanes|R.childLanes,T|=R.subtreeFlags,T|=R.flags,R.return=f,R=R.sibling;return f.subtreeFlags|=T,f.childLanes=S,d}function T2(f,d,S){var T=d.pendingProps;switch(Xp(d),d.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return di(d),null;case 1:return on(d.type)&&xi(),di(d),null;case 3:return T=d.stateNode,Xa(),kt(cn),kt(En),Jp(),T.pendingContext&&(T.context=T.pendingContext,T.pendingContext=null),(f===null||f.child===null)&&(dc(d)?Jr(d):f===null||f.memoizedState.isDehydrated&&(d.flags&256)===0||(d.flags|=1024,Ar!==null&&(Am(Ar),Ar=null))),Sc(f,d),di(d),null;case 5:Kp(d),S=Kr(Wa.current);var R=d.type;if(f!==null&&d.stateNode!=null)Bh(f,d,R,T,S),f.ref!==d.ref&&(d.flags|=512,d.flags|=2097152);else{if(!T){if(d.stateNode===null)throw Error(o(166));return di(d),null}if(f=Kr(cr.current),dc(d)){if(!oe)throw Error(o(175));f=_i(d.stateNode,d.type,d.memoizedProps,S,f,d,!fc),d.updateQueue=f,f!==null&&Jr(d)}else{var U=D(R,T,S,f,d);wc(U,d,!1,!1),d.stateNode=U,Z(U,R,T,S,f)&&Jr(d)}d.ref!==null&&(d.flags|=512,d.flags|=2097152)}return di(d),null;case 6:if(f&&d.stateNode!=null)Gh(f,d,f.memoizedProps,T);else{if(typeof T!="string"&&d.stateNode===null)throw Error(o(166));if(f=Kr(Wa.current),S=Kr(cr.current),dc(d)){if(!oe)throw Error(o(176));if(f=d.stateNode,T=d.memoizedProps,(S=J(f,T,d,!fc))&&(R=Yi,R!==null))switch(U=(R.mode&1)!==0,R.tag){case 3:dt(R.stateNode.containerInfo,f,T,U);break;case 5:wt(R.type,R.memoizedProps,R.stateNode,f,T,U)}S&&Jr(d)}else d.stateNode=ue(T,f,S,d)}return di(d),null;case 13:if(kt(mn),T=d.memoizedState,un&&qi!==null&&(d.mode&1)!==0&&(d.flags&128)===0){for(f=qi;f;)f=tn(f);return Ha(),d.flags|=98560,d}if(T!==null&&T.dehydrated!==null){if(T=dc(d),f===null){if(!T)throw Error(o(318));if(!oe)throw Error(o(344));if(f=d.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(o(317));me(f,d)}else Ha(),(d.flags&128)===0&&(d.memoizedState=null),d.flags|=4;return di(d),null}return Ar!==null&&(Am(Ar),Ar=null),(d.flags&128)!==0?(d.lanes=S,d):(T=T!==null,S=!1,f===null?dc(d):S=f.memoizedState!==null,T&&!S&&(d.child.flags|=8192,(d.mode&1)!==0&&(f===null||(mn.current&1)!==0?Hn===0&&(Hn=3):Rm())),d.updateQueue!==null&&(d.flags|=4),di(d),null);case 4:return Xa(),Sc(f,d),f===null&&se(d.stateNode.containerInfo),di(d),null;case 10:return Zn(d.type._context),di(d),null;case 17:return on(d.type)&&xi(),di(d),null;case 19:if(kt(mn),R=d.memoizedState,R===null)return di(d),null;if(T=(d.flags&128)!==0,U=R.rendering,U===null)if(T)Ec(R,!1);else{if(Hn!==0||f!==null&&(f.flags&128)!==0)for(f=d.child;f!==null;){if(U=Ih(f),U!==null){for(d.flags|=128,Ec(R,!1),f=U.updateQueue,f!==null&&(d.updateQueue=f,d.flags|=4),d.subtreeFlags=0,f=S,T=d.child;T!==null;)S=T,R=f,S.flags&=14680066,U=S.alternate,U===null?(S.childLanes=0,S.lanes=R,S.child=null,S.subtreeFlags=0,S.memoizedProps=null,S.memoizedState=null,S.updateQueue=null,S.dependencies=null,S.stateNode=null):(S.childLanes=U.childLanes,S.lanes=U.lanes,S.child=U.child,S.subtreeFlags=0,S.deletions=null,S.memoizedProps=U.memoizedProps,S.memoizedState=U.memoizedState,S.updateQueue=U.updateQueue,S.type=U.type,R=U.dependencies,S.dependencies=R===null?null:{lanes:R.lanes,firstContext:R.firstContext}),T=T.sibling;return gt(mn,mn.current&1|2),d.child}f=f.sibling}R.tail!==null&&pn()>Em&&(d.flags|=128,T=!0,Ec(R,!1),d.lanes=4194304)}else{if(!T)if(f=Ih(U),f!==null){if(d.flags|=128,T=!0,f=f.updateQueue,f!==null&&(d.updateQueue=f,d.flags|=4),Ec(R,!0),R.tail===null&&R.tailMode==="hidden"&&!U.alternate&&!un)return di(d),null}else 2*pn()-R.renderingStartTime>Em&&S!==1073741824&&(d.flags|=128,T=!0,Ec(R,!1),d.lanes=4194304);R.isBackwards?(U.sibling=d.child,d.child=U):(f=R.last,f!==null?f.sibling=U:d.child=U,R.last=U)}return R.tail!==null?(d=R.tail,R.rendering=d,R.tail=d.sibling,R.renderingStartTime=pn(),d.sibling=null,f=mn.current,gt(mn,T?f&1|2:f&1),d):(di(d),null);case 22:case 23:return Cm(),T=d.memoizedState!==null,f!==null&&f.memoizedState!==null!==T&&(d.flags|=8192),T&&(d.mode&1)!==0?(Ki&1073741824)!==0&&(di(d),ae&&d.subtreeFlags&6&&(d.flags|=8192)):di(d),null;case 24:return null;case 25:return null}throw Error(o(156,d.tag))}var A2=a.ReactCurrentOwner,Zi=!1;function Mi(f,d,S,T){d.child=f===null?R_(d,null,S,T):Va(d,f.child,S,T)}function nx(f,d,S,T,R){S=S.render;var U=d.ref;return Rn(d,R),T=em(f,d,S,T,U,R),S=tm(),f!==null&&!Zi?(d.updateQueue=f.updateQueue,d.flags&=-2053,f.lanes&=~R,ws(f,d,R)):(un&&S&&Wp(d),d.flags|=1,Mi(f,d,T,R),d.child)}function ix(f,d,S,T,R){if(f===null){var U=S.type;return typeof U=="function"&&!Pm(U)&&U.defaultProps===void 0&&S.compare===null&&S.defaultProps===void 0?(d.tag=15,d.type=U,rx(f,d,U,T,R)):(f=cf(S.type,null,T,d,d.mode,R),f.ref=d.ref,f.return=d,d.child=f)}if(U=f.child,(f.lanes&R)===0){var Q=U.memoizedProps;if(S=S.compare,S=S!==null?S:Uo,S(Q,T)&&f.ref===d.ref)return ws(f,d,R)}return d.flags|=1,f=to(U,T),f.ref=d.ref,f.return=d,d.child=f}function rx(f,d,S,T,R){if(f!==null&&Uo(f.memoizedProps,T)&&f.ref===d.ref)if(Zi=!1,(f.lanes&R)!==0)(f.flags&131072)!==0&&(Zi=!0);else return d.lanes=f.lanes,ws(f,d,R);return am(f,d,S,T,R)}function sx(f,d,S){var T=d.pendingProps,R=T.children,U=f!==null?f.memoizedState:null;if(T.mode==="hidden")if((d.mode&1)===0)d.memoizedState={baseLanes:0,cachePool:null},gt(Ya,Ki),Ki|=S;else if((S&1073741824)!==0)d.memoizedState={baseLanes:0,cachePool:null},T=U!==null?U.baseLanes:S,gt(Ya,Ki),Ki|=T;else return f=U!==null?U.baseLanes|S:S,d.lanes=d.childLanes=1073741824,d.memoizedState={baseLanes:f,cachePool:null},d.updateQueue=null,gt(Ya,Ki),Ki|=f,null;else U!==null?(T=U.baseLanes|S,d.memoizedState=null):T=S,gt(Ya,Ki),Ki|=T;return Mi(f,d,R,S),d.child}function ox(f,d){var S=d.ref;(f===null&&S!==null||f!==null&&f.ref!==S)&&(d.flags|=512,d.flags|=2097152)}function am(f,d,S,T,R){var U=on(S)?Ii:En.current;return U=Qt(d,U),Rn(d,R),S=em(f,d,S,T,U,R),T=tm(),f!==null&&!Zi?(d.updateQueue=f.updateQueue,d.flags&=-2053,f.lanes&=~R,ws(f,d,R)):(un&&T&&Wp(d),d.flags|=1,Mi(f,d,S,R),d.child)}function ax(f,d,S,T,R){if(on(S)){var U=!0;jr(d)}else U=!1;if(Rn(d,R),d.stateNode===null)f!==null&&(f.alternate=null,d.alternate=null,d.flags|=2),w_(d,S,T),Vp(d,S,T,R),T=!0;else if(f===null){var Q=d.stateNode,he=d.memoizedProps;Q.props=he;var Ce=Q.context,Xe=S.contextType;typeof Xe=="object"&&Xe!==null?Xe=Pn(Xe):(Xe=on(S)?Ii:En.current,Xe=Qt(d,Xe));var rt=S.getDerivedStateFromProps,St=typeof rt=="function"||typeof Q.getSnapshotBeforeUpdate=="function";St||typeof Q.UNSAFE_componentWillReceiveProps!="function"&&typeof Q.componentWillReceiveProps!="function"||(he!==T||Ce!==Xe)&&S_(d,Q,T,Xe),Zs=!1;var ht=d.memoizedState;Q.state=ht,Ah(d,T,Q,R),Ce=d.memoizedState,he!==T||ht!==Ce||cn.current||Zs?(typeof rt=="function"&&(Hp(d,S,rt,T),Ce=d.memoizedState),(he=Zs||x_(d,S,he,T,ht,Ce,Xe))?(St||typeof Q.UNSAFE_componentWillMount!="function"&&typeof Q.componentWillMount!="function"||(typeof Q.componentWillMount=="function"&&Q.componentWillMount(),typeof Q.UNSAFE_componentWillMount=="function"&&Q.UNSAFE_componentWillMount()),typeof Q.componentDidMount=="function"&&(d.flags|=4194308)):(typeof Q.componentDidMount=="function"&&(d.flags|=4194308),d.memoizedProps=T,d.memoizedState=Ce),Q.props=T,Q.state=Ce,Q.context=Xe,T=he):(typeof Q.componentDidMount=="function"&&(d.flags|=4194308),T=!1)}else{Q=d.stateNode,g_(f,d),he=d.memoizedProps,Xe=d.type===d.elementType?he:Ei(d.type,he),Q.props=Xe,St=d.pendingProps,ht=Q.context,Ce=S.contextType,typeof Ce=="object"&&Ce!==null?Ce=Pn(Ce):(Ce=on(S)?Ii:En.current,Ce=Qt(d,Ce));var nn=S.getDerivedStateFromProps;(rt=typeof nn=="function"||typeof Q.getSnapshotBeforeUpdate=="function")||typeof Q.UNSAFE_componentWillReceiveProps!="function"&&typeof Q.componentWillReceiveProps!="function"||(he!==St||ht!==Ce)&&S_(d,Q,T,Ce),Zs=!1,ht=d.memoizedState,Q.state=ht,Ah(d,T,Q,R);var at=d.memoizedState;he!==St||ht!==at||cn.current||Zs?(typeof nn=="function"&&(Hp(d,S,nn,T),at=d.memoizedState),(Xe=Zs||x_(d,S,Xe,T,ht,at,Ce)||!1)?(rt||typeof Q.UNSAFE_componentWillUpdate!="function"&&typeof Q.componentWillUpdate!="function"||(typeof Q.componentWillUpdate=="function"&&Q.componentWillUpdate(T,at,Ce),typeof Q.UNSAFE_componentWillUpdate=="function"&&Q.UNSAFE_componentWillUpdate(T,at,Ce)),typeof Q.componentDidUpdate=="function"&&(d.flags|=4),typeof Q.getSnapshotBeforeUpdate=="function"&&(d.flags|=1024)):(typeof Q.componentDidUpdate!="function"||he===f.memoizedProps&&ht===f.memoizedState||(d.flags|=4),typeof Q.getSnapshotBeforeUpdate!="function"||he===f.memoizedProps&&ht===f.memoizedState||(d.flags|=1024),d.memoizedProps=T,d.memoizedState=at),Q.props=T,Q.state=at,Q.context=Ce,T=Xe):(typeof Q.componentDidUpdate!="function"||he===f.memoizedProps&&ht===f.memoizedState||(d.flags|=4),typeof Q.getSnapshotBeforeUpdate!="function"||he===f.memoizedProps&&ht===f.memoizedState||(d.flags|=1024),T=!1)}return lm(f,d,S,T,U,R)}function lm(f,d,S,T,R,U){ox(f,d);var Q=(d.flags&128)!==0;if(!T&&!Q)return R&&ui(d,S,!1),ws(f,d,U);T=d.stateNode,A2.current=d;var he=Q&&typeof S.getDerivedStateFromError!="function"?null:T.render();return d.flags|=1,f!==null&&Q?(d.child=Va(d,f.child,null,U),d.child=Va(d,null,he,U)):Mi(f,d,he,U),d.memoizedState=T.state,R&&ui(d,S,!0),d.child}function lx(f){var d=f.stateNode;d.pendingContext?Un(f,d.pendingContext,d.pendingContext!==d.context):d.context&&Un(f,d.context,!1),Zp(f,d.containerInfo)}function cx(f,d,S,T,R){return Ha(),qp(R),d.flags|=256,Mi(f,d,S,T),d.child}var Hh={dehydrated:null,treeContext:null,retryLane:0};function Vh(f){return{baseLanes:f,cachePool:null}}function ux(f,d,S){var T=d.pendingProps,R=mn.current,U=!1,Q=(d.flags&128)!==0,he;if((he=Q)||(he=f!==null&&f.memoizedState===null?!1:(R&2)!==0),he?(U=!0,d.flags&=-129):(f===null||f.memoizedState!==null)&&(R|=1),gt(mn,R&1),f===null)return Yp(d),f=d.memoizedState,f!==null&&(f=f.dehydrated,f!==null)?((d.mode&1)===0?d.lanes=1:sn(f)?d.lanes=8:d.lanes=1073741824,null):(R=T.children,f=T.fallback,U?(T=d.mode,U=d.child,R={mode:"hidden",children:R},(T&1)===0&&U!==null?(U.childLanes=0,U.pendingProps=R):U=uf(R,T,0,null),f=Wo(f,T,S,null),U.return=d,f.return=d,U.sibling=f,d.child=U,d.child.memoizedState=Vh(S),d.memoizedState=Hh,f):cm(d,R));if(R=f.memoizedState,R!==null){if(he=R.dehydrated,he!==null){if(Q)return d.flags&256?(d.flags&=-257,Wh(f,d,S,Error(o(422)))):d.memoizedState!==null?(d.child=f.child,d.flags|=128,null):(U=T.fallback,R=d.mode,T=uf({mode:"visible",children:T.children},R,0,null),U=Wo(U,R,S,null),U.flags|=2,T.return=d,U.return=d,T.sibling=U,d.child=T,(d.mode&1)!==0&&Va(d,f.child,null,S),d.child.memoizedState=Vh(S),d.memoizedState=Hh,U);if((d.mode&1)===0)d=Wh(f,d,S,null);else if(sn(he))d=Wh(f,d,S,Error(o(419)));else if(T=(S&f.childLanes)!==0,Zi||T){if(T=On,T!==null){switch(S&-S){case 4:U=2;break;case 16:U=8;break;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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:U=32;break;case 536870912:U=268435456;break;default:U=0}T=(U&(T.suspendedLanes|S))!==0?0:U,T!==0&&T!==R.retryLane&&(R.retryLane=T,hr(f,T,-1))}Rm(),d=Wh(f,d,S,Error(o(421)))}else Bt(he)?(d.flags|=128,d.child=f.child,d=B2.bind(null,f),ti(he,d),d=null):(S=R.treeContext,oe&&(qi=sr(he),Yi=d,un=!0,Ar=null,fc=!1,S!==null&&(ar[lr++]=ys,ar[lr++]=_s,ar[lr++]=No,ys=S.id,_s=S.overflow,No=d)),d=cm(d,d.pendingProps.children),d.flags|=4096);return d}return U?(T=fx(f,d,T.children,T.fallback,S),U=d.child,R=f.child.memoizedState,U.memoizedState=R===null?Vh(S):{baseLanes:R.baseLanes|S,cachePool:null},U.childLanes=f.childLanes&~S,d.memoizedState=Hh,T):(S=hx(f,d,T.children,S),d.memoizedState=null,S)}return U?(T=fx(f,d,T.children,T.fallback,S),U=d.child,R=f.child.memoizedState,U.memoizedState=R===null?Vh(S):{baseLanes:R.baseLanes|S,cachePool:null},U.childLanes=f.childLanes&~S,d.memoizedState=Hh,T):(S=hx(f,d,T.children,S),d.memoizedState=null,S)}function cm(f,d){return d=uf({mode:"visible",children:d},f.mode,0,null),d.return=f,f.child=d}function hx(f,d,S,T){var R=f.child;return f=R.sibling,S=to(R,{mode:"visible",children:S}),(d.mode&1)===0&&(S.lanes=T),S.return=d,S.sibling=null,f!==null&&(T=d.deletions,T===null?(d.deletions=[f],d.flags|=16):T.push(f)),d.child=S}function fx(f,d,S,T,R){var U=d.mode;f=f.child;var Q=f.sibling,he={mode:"hidden",children:S};return(U&1)===0&&d.child!==f?(S=d.child,S.childLanes=0,S.pendingProps=he,d.deletions=null):(S=to(f,he),S.subtreeFlags=f.subtreeFlags&14680064),Q!==null?T=to(Q,T):(T=Wo(T,U,R,null),T.flags|=2),T.return=d,S.return=d,S.sibling=T,d.child=S,T}function Wh(f,d,S,T){return T!==null&&qp(T),Va(d,f.child,null,S),f=cm(d,d.pendingProps.children),f.flags|=2,d.memoizedState=null,f}function dx(f,d,S){f.lanes|=d;var T=f.alternate;T!==null&&(T.lanes|=d),bi(f.return,d,S)}function um(f,d,S,T,R){var U=f.memoizedState;U===null?f.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:T,tail:S,tailMode:R}:(U.isBackwards=d,U.rendering=null,U.renderingStartTime=0,U.last=T,U.tail=S,U.tailMode=R)}function px(f,d,S){var T=d.pendingProps,R=T.revealOrder,U=T.tail;if(Mi(f,d,T.children,S),T=mn.current,(T&2)!==0)T=T&1|2,d.flags|=128;else{if(f!==null&&(f.flags&128)!==0)e:for(f=d.child;f!==null;){if(f.tag===13)f.memoizedState!==null&&dx(f,S,d);else if(f.tag===19)dx(f,S,d);else if(f.child!==null){f.child.return=f,f=f.child;continue}if(f===d)break e;for(;f.sibling===null;){if(f.return===null||f.return===d)break e;f=f.return}f.sibling.return=f.return,f=f.sibling}T&=1}if(gt(mn,T),(d.mode&1)===0)d.memoizedState=null;else switch(R){case"forwards":for(S=d.child,R=null;S!==null;)f=S.alternate,f!==null&&Ih(f)===null&&(R=S),S=S.sibling;S=R,S===null?(R=d.child,d.child=null):(R=S.sibling,S.sibling=null),um(d,!1,R,S,U);break;case"backwards":for(S=null,R=d.child,d.child=null;R!==null;){if(f=R.alternate,f!==null&&Ih(f)===null){d.child=R;break}f=R.sibling,R.sibling=S,S=R,R=f}um(d,!0,S,null,U);break;case"together":um(d,!1,null,null,void 0);break;default:d.memoizedState=null}return d.child}function ws(f,d,S){if(f!==null&&(d.dependencies=f.dependencies),qa|=d.lanes,(S&d.childLanes)===0)return null;if(f!==null&&d.child!==f.child)throw Error(o(153));if(d.child!==null){for(f=d.child,S=to(f,f.pendingProps),d.child=S,S.return=d;f.sibling!==null;)f=f.sibling,S=S.sibling=to(f,f.pendingProps),S.return=d;S.sibling=null}return d.child}function C2(f,d,S){switch(d.tag){case 3:lx(d),Ha();break;case 5:P_(d);break;case 1:on(d.type)&&jr(d);break;case 4:Zp(d,d.stateNode.containerInfo);break;case 10:Mh(d,d.type._context,d.memoizedProps.value);break;case 13:var T=d.memoizedState;if(T!==null)return T.dehydrated!==null?(gt(mn,mn.current&1),d.flags|=128,null):(S&d.child.childLanes)!==0?ux(f,d,S):(gt(mn,mn.current&1),f=ws(f,d,S),f!==null?f.sibling:null);gt(mn,mn.current&1);break;case 19:if(T=(S&d.childLanes)!==0,(f.flags&128)!==0){if(T)return px(f,d,S);d.flags|=128}var R=d.memoizedState;if(R!==null&&(R.rendering=null,R.tail=null,R.lastEffect=null),gt(mn,mn.current),T)break;return null;case 22:case 23:return d.lanes=0,sx(f,d,S)}return ws(f,d,S)}function R2(f,d){switch(Xp(d),d.tag){case 1:return on(d.type)&&xi(),f=d.flags,f&65536?(d.flags=f&-65537|128,d):null;case 3:return Xa(),kt(cn),kt(En),Jp(),f=d.flags,(f&65536)!==0&&(f&128)===0?(d.flags=f&-65537|128,d):null;case 5:return Kp(d),null;case 13:if(kt(mn),f=d.memoizedState,f!==null&&f.dehydrated!==null){if(d.alternate===null)throw Error(o(340));Ha()}return f=d.flags,f&65536?(d.flags=f&-65537|128,d):null;case 19:return kt(mn),null;case 4:return Xa(),null;case 10:return Zn(d.type._context),null;case 22:case 23:return Cm(),null;case 24:return null;default:return null}}var Xh=!1,zo=!1,P2=typeof WeakSet=="function"?WeakSet:Set,Qe=null;function jh(f,d){var S=f.ref;if(S!==null)if(typeof S=="function")try{S(null)}catch(T){Ni(f,d,T)}else S.current=null}function hm(f,d,S){try{S()}catch(T){Ni(f,d,T)}}var mx=!1;function L2(f,d){for(G(f.containerInfo),Qe=d;Qe!==null;)if(f=Qe,d=f.child,(f.subtreeFlags&1028)!==0&&d!==null)d.return=f,Qe=d;else for(;Qe!==null;){f=Qe;try{var S=f.alternate;if((f.flags&1024)!==0)switch(f.tag){case 0:case 11:case 15:break;case 1:if(S!==null){var T=S.memoizedProps,R=S.memoizedState,U=f.stateNode,Q=U.getSnapshotBeforeUpdate(f.elementType===f.type?T:Ei(f.type,T),R);U.__reactInternalSnapshotBeforeUpdate=Q}break;case 3:ae&&Ge(f.stateNode.containerInfo);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(he){Ni(f,f.return,he)}if(d=f.sibling,d!==null){d.return=f.return,Qe=d;break}Qe=f.return}return S=mx,mx=!1,S}function Bo(f,d,S){var T=d.updateQueue;if(T=T!==null?T.lastEffect:null,T!==null){var R=T=T.next;do{if((R.tag&f)===f){var U=R.destroy;R.destroy=void 0,U!==void 0&&hm(d,S,U)}R=R.next}while(R!==T)}}function bc(f,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var S=d=d.next;do{if((S.tag&f)===f){var T=S.create;S.destroy=T()}S=S.next}while(S!==d)}}function fm(f){var d=f.ref;if(d!==null){var S=f.stateNode;switch(f.tag){case 5:f=W(S);break;default:f=S}typeof d=="function"?d(f):d.current=f}}function gx(f,d,S){if(Wi&&typeof Wi.onCommitFiberUnmount=="function")try{Wi.onCommitFiberUnmount(Io,d)}catch{}switch(d.tag){case 0:case 11:case 14:case 15:if(f=d.updateQueue,f!==null&&(f=f.lastEffect,f!==null)){var T=f=f.next;do{var R=T,U=R.destroy;R=R.tag,U!==void 0&&((R&2)!==0||(R&4)!==0)&&hm(d,S,U),T=T.next}while(T!==f)}break;case 1:if(jh(d,S),f=d.stateNode,typeof f.componentWillUnmount=="function")try{f.props=d.memoizedProps,f.state=d.memoizedState,f.componentWillUnmount()}catch(Q){Ni(d,S,Q)}break;case 5:jh(d,S);break;case 4:ae?Sx(f,d,S):z&&z&&(d=d.stateNode.containerInfo,S=_t(d),Ot(d,S))}}function vx(f,d,S){for(var T=d;;)if(gx(f,T,S),T.child===null||ae&&T.tag===4){if(T===d)break;for(;T.sibling===null;){if(T.return===null||T.return===d)return;T=T.return}T.sibling.return=T.return,T=T.sibling}else T.child.return=T,T=T.child}function yx(f){var d=f.alternate;d!==null&&(f.alternate=null,yx(d)),f.child=null,f.deletions=null,f.sibling=null,f.tag===5&&(d=f.stateNode,d!==null&&Ie(d)),f.stateNode=null,f.return=null,f.dependencies=null,f.memoizedProps=null,f.memoizedState=null,f.pendingProps=null,f.stateNode=null,f.updateQueue=null}function _x(f){return f.tag===5||f.tag===3||f.tag===4}function xx(f){e:for(;;){for(;f.sibling===null;){if(f.return===null||_x(f.return))return null;f=f.return}for(f.sibling.return=f.return,f=f.sibling;f.tag!==5&&f.tag!==6&&f.tag!==18;){if(f.flags&2||f.child===null||f.tag===4)continue e;f.child.return=f,f=f.child}if(!(f.flags&2))return f.stateNode}}function wx(f){if(ae){e:{for(var d=f.return;d!==null;){if(_x(d))break e;d=d.return}throw Error(o(160))}var S=d;switch(S.tag){case 5:d=S.stateNode,S.flags&32&&(nt(d),S.flags&=-33),S=xx(f),pm(f,S,d);break;case 3:case 4:d=S.stateNode.containerInfo,S=xx(f),dm(f,S,d);break;default:throw Error(o(161))}}}function dm(f,d,S){var T=f.tag;if(T===5||T===6)f=f.stateNode,d?Ve(S,f,d):Fe(S,f);else if(T!==4&&(f=f.child,f!==null))for(dm(f,d,S),f=f.sibling;f!==null;)dm(f,d,S),f=f.sibling}function pm(f,d,S){var T=f.tag;if(T===5||T===6)f=f.stateNode,d?$e(S,f,d):Me(S,f);else if(T!==4&&(f=f.child,f!==null))for(pm(f,d,S),f=f.sibling;f!==null;)pm(f,d,S),f=f.sibling}function Sx(f,d,S){for(var T=d,R=!1,U,Q;;){if(!R){R=T.return;e:for(;;){if(R===null)throw Error(o(160));switch(U=R.stateNode,R.tag){case 5:Q=!1;break e;case 3:U=U.containerInfo,Q=!0;break e;case 4:U=U.containerInfo,Q=!0;break e}R=R.return}R=!0}if(T.tag===5||T.tag===6)vx(f,T,S),Q?We(U,T.stateNode):Oe(U,T.stateNode);else if(T.tag===18)Q?lt(U,T.stateNode):it(U,T.stateNode);else if(T.tag===4){if(T.child!==null){U=T.stateNode.containerInfo,Q=!0,T.child.return=T,T=T.child;continue}}else if(gx(f,T,S),T.child!==null){T.child.return=T,T=T.child;continue}if(T===d)break;for(;T.sibling===null;){if(T.return===null||T.return===d)return;T=T.return,T.tag===4&&(R=!1)}T.sibling.return=T.return,T=T.sibling}}function mm(f,d){if(ae){switch(d.tag){case 0:case 11:case 14:case 15:Bo(3,d,d.return),bc(3,d),Bo(5,d,d.return);return;case 1:return;case 5:var S=d.stateNode;if(S!=null){var T=d.memoizedProps;f=f!==null?f.memoizedProps:T;var R=d.type,U=d.updateQueue;d.updateQueue=null,U!==null&&Be(S,U,R,f,T,d)}return;case 6:if(d.stateNode===null)throw Error(o(162));S=d.memoizedProps,Ue(d.stateNode,f!==null?f.memoizedProps:S,S);return;case 3:oe&&f!==null&&f.memoizedState.isDehydrated&&pe(d.stateNode.containerInfo);return;case 12:return;case 13:Yh(d);return;case 19:Yh(d);return;case 17:return}throw Error(o(163))}switch(d.tag){case 0:case 11:case 14:case 15:Bo(3,d,d.return),bc(3,d),Bo(5,d,d.return);return;case 12:return;case 13:Yh(d);return;case 19:Yh(d);return;case 3:oe&&f!==null&&f.memoizedState.isDehydrated&&pe(d.stateNode.containerInfo);break;case 22:case 23:return}e:if(z){switch(d.tag){case 1:case 5:case 6:break e;case 3:case 4:d=d.stateNode,Ot(d.containerInfo,d.pendingChildren);break e}throw Error(o(163))}}function Yh(f){var d=f.updateQueue;if(d!==null){f.updateQueue=null;var S=f.stateNode;S===null&&(S=f.stateNode=new P2),d.forEach(function(T){var R=G2.bind(null,f,T);S.has(T)||(S.add(T),T.then(R,R))})}}function I2(f,d){for(Qe=d;Qe!==null;){d=Qe;var S=d.deletions;if(S!==null)for(var T=0;T<S.length;T++){var R=S[T];try{var U=f;ae?Sx(U,R,d):vx(U,R,d);var Q=R.alternate;Q!==null&&(Q.return=null),R.return=null}catch(ot){Ni(R,d,ot)}}if(S=d.child,(d.subtreeFlags&12854)!==0&&S!==null)S.return=d,Qe=S;else for(;Qe!==null;){d=Qe;try{var he=d.flags;if(he&32&&ae&&nt(d.stateNode),he&512){var Ce=d.alternate;if(Ce!==null){var Xe=Ce.ref;Xe!==null&&(typeof Xe=="function"?Xe(null):Xe.current=null)}}if(he&8192)switch(d.tag){case 13:if(d.memoizedState!==null){var rt=d.alternate;(rt===null||rt.memoizedState===null)&&(Sm=pn())}break;case 22:var St=d.memoizedState!==null,ht=d.alternate,nn=ht!==null&&ht.memoizedState!==null;if(S=d,ae){e:if(T=S,R=St,U=null,ae)for(var at=T;;){if(at.tag===5){if(U===null){U=at;var pi=at.stateNode;R?pt(pi):ze(at.stateNode,at.memoizedProps)}}else if(at.tag===6){if(U===null){var dr=at.stateNode;R?re(dr):ve(dr,at.memoizedProps)}}else if((at.tag!==22&&at.tag!==23||at.memoizedState===null||at===T)&&at.child!==null){at.child.return=at,at=at.child;continue}if(at===T)break;for(;at.sibling===null;){if(at.return===null||at.return===T)break e;U===at&&(U=null),at=at.return}U===at&&(U=null),at.sibling.return=at.return,at=at.sibling}}if(St&&!nn&&(S.mode&1)!==0){Qe=S;for(var ye=S.child;ye!==null;){for(S=Qe=ye;Qe!==null;){T=Qe;var fe=T.child;switch(T.tag){case 0:case 11:case 14:case 15:Bo(4,T,T.return);break;case 1:jh(T,T.return);var Te=T.stateNode;if(typeof Te.componentWillUnmount=="function"){var et=T.return;try{Te.props=T.memoizedProps,Te.state=T.memoizedState,Te.componentWillUnmount()}catch(ot){Ni(T,et,ot)}}break;case 5:jh(T,T.return);break;case 22:if(T.memoizedState!==null){Mx(S);continue}}fe!==null?(fe.return=T,Qe=fe):Mx(S)}ye=ye.sibling}}}switch(he&4102){case 2:wx(d),d.flags&=-3;break;case 6:wx(d),d.flags&=-3,mm(d.alternate,d);break;case 4096:d.flags&=-4097;break;case 4100:d.flags&=-4097,mm(d.alternate,d);break;case 4:mm(d.alternate,d)}}catch(ot){Ni(d,d.return,ot)}if(S=d.sibling,S!==null){S.return=d.return,Qe=S;break}Qe=d.return}}}function D2(f,d,S){Qe=f,Ex(f)}function Ex(f,d,S){for(var T=(f.mode&1)!==0;Qe!==null;){var R=Qe,U=R.child;if(R.tag===22&&T){var Q=R.memoizedState!==null||Xh;if(!Q){var he=R.alternate,Ce=he!==null&&he.memoizedState!==null||zo;he=Xh;var Xe=zo;if(Xh=Q,(zo=Ce)&&!Xe)for(Qe=R;Qe!==null;)Q=Qe,Ce=Q.child,Q.tag===22&&Q.memoizedState!==null?Tx(R):Ce!==null?(Ce.return=Q,Qe=Ce):Tx(R);for(;U!==null;)Qe=U,Ex(U),U=U.sibling;Qe=R,Xh=he,zo=Xe}bx(f)}else(R.subtreeFlags&8772)!==0&&U!==null?(U.return=R,Qe=U):bx(f)}}function bx(f){for(;Qe!==null;){var d=Qe;if((d.flags&8772)!==0){var S=d.alternate;try{if((d.flags&8772)!==0)switch(d.tag){case 0:case 11:case 15:zo||bc(5,d);break;case 1:var T=d.stateNode;if(d.flags&4&&!zo)if(S===null)T.componentDidMount();else{var R=d.elementType===d.type?S.memoizedProps:Ei(d.type,S.memoizedProps);T.componentDidUpdate(R,S.memoizedState,T.__reactInternalSnapshotBeforeUpdate)}var U=d.updateQueue;U!==null&&y_(d,U,T);break;case 3:var Q=d.updateQueue;if(Q!==null){if(S=null,d.child!==null)switch(d.child.tag){case 5:S=W(d.child.stateNode);break;case 1:S=d.child.stateNode}y_(d,Q,S)}break;case 5:var he=d.stateNode;S===null&&d.flags&4&&xe(he,d.type,d.memoizedProps,d);break;case 6:break;case 4:break;case 12:break;case 13:if(oe&&d.memoizedState===null){var Ce=d.alternate;if(Ce!==null){var Xe=Ce.memoizedState;if(Xe!==null){var rt=Xe.dehydrated;rt!==null&&Pe(rt)}}}break;case 19:case 17:case 21:case 22:case 23:break;default:throw Error(o(163))}zo||d.flags&512&&fm(d)}catch(St){Ni(d,d.return,St)}}if(d===f){Qe=null;break}if(S=d.sibling,S!==null){S.return=d.return,Qe=S;break}Qe=d.return}}function Mx(f){for(;Qe!==null;){var d=Qe;if(d===f){Qe=null;break}var S=d.sibling;if(S!==null){S.return=d.return,Qe=S;break}Qe=d.return}}function Tx(f){for(;Qe!==null;){var d=Qe;try{switch(d.tag){case 0:case 11:case 15:var S=d.return;try{bc(4,d)}catch(Ce){Ni(d,S,Ce)}break;case 1:var T=d.stateNode;if(typeof T.componentDidMount=="function"){var R=d.return;try{T.componentDidMount()}catch(Ce){Ni(d,R,Ce)}}var U=d.return;try{fm(d)}catch(Ce){Ni(d,U,Ce)}break;case 5:var Q=d.return;try{fm(d)}catch(Ce){Ni(d,Q,Ce)}}}catch(Ce){Ni(d,d.return,Ce)}if(d===f){Qe=null;break}var he=d.sibling;if(he!==null){he.return=d.return,Qe=he;break}Qe=d.return}}var qh=0,Zh=1,Kh=2,$h=3,Jh=4;if(typeof Symbol=="function"&&Symbol.for){var Mc=Symbol.for;qh=Mc("selector.component"),Zh=Mc("selector.has_pseudo_class"),Kh=Mc("selector.role"),$h=Mc("selector.test_id"),Jh=Mc("selector.text")}function gm(f){var d=te(f);if(d!=null){if(typeof d.memoizedProps["data-testname"]!="string")throw Error(o(364));return d}if(f=ge(f),f===null)throw Error(o(362));return f.stateNode.current}function vm(f,d){switch(d.$$typeof){case qh:if(f.type===d.value)return!0;break;case Zh:e:{d=d.value,f=[f,0];for(var S=0;S<f.length;){var T=f[S++],R=f[S++],U=d[R];if(T.tag!==5||!H(T)){for(;U!=null&&vm(T,U);)R++,U=d[R];if(R===d.length){d=!0;break e}else for(T=T.child;T!==null;)f.push(T,R),T=T.sibling}}d=!1}return d;case Kh:if(f.tag===5&&ne(f.stateNode,d.value))return!0;break;case Jh:if((f.tag===5||f.tag===6)&&(f=j(f),f!==null&&0<=f.indexOf(d.value)))return!0;break;case $h:if(f.tag===5&&(f=f.memoizedProps["data-testname"],typeof f=="string"&&f.toLowerCase()===d.value.toLowerCase()))return!0;break;default:throw Error(o(365))}return!1}function ym(f){switch(f.$$typeof){case qh:return"<"+(A(f.value)||"Unknown")+">";case Zh:return":has("+(ym(f)||"")+")";case Kh:return'[role="'+f.value+'"]';case Jh:return'"'+f.value+'"';case $h:return'[data-testname="'+f.value+'"]';default:throw Error(o(365))}}function Ax(f,d){var S=[];f=[f,0];for(var T=0;T<f.length;){var R=f[T++],U=f[T++],Q=d[U];if(R.tag!==5||!H(R)){for(;Q!=null&&vm(R,Q);)U++,Q=d[U];if(U===d.length)S.push(R);else for(R=R.child;R!==null;)f.push(R,U),R=R.sibling}}return S}function _m(f,d){if(!Le)throw Error(o(363));f=gm(f),f=Ax(f,d),d=[],f=Array.from(f);for(var S=0;S<f.length;){var T=f[S++];if(T.tag===5)H(T)||d.push(T.stateNode);else for(T=T.child;T!==null;)f.push(T),T=T.sibling}return d}var U2=Math.ceil,Qh=a.ReactCurrentDispatcher,xm=a.ReactCurrentOwner,Ln=a.ReactCurrentBatchConfig,Dt=0,On=null,Nn=null,ni=0,Ki=0,Ya=mt(0),Hn=0,Tc=null,qa=0,ef=0,wm=0,Ac=null,Ui=null,Sm=0,Em=1/0;function Za(){Em=pn()+500}var tf=!1,bm=null,$s=null,nf=!1,Js=null,rf=0,Cc=0,Mm=null,sf=-1,of=0;function Ti(){return(Dt&6)!==0?pn():sf!==-1?sf:sf=pn()}function Qs(f){return(f.mode&1)===0?1:(Dt&2)!==0&&ni!==0?ni&-ni:Do.transition!==null?(of===0&&(f=fs,fs<<=1,(fs&4194240)===0&&(fs=64),of=f),of):(f=Ut,f!==0?f:$())}function hr(f,d,S){if(50<Cc)throw Cc=0,Mm=null,Error(o(185));var T=af(f,d);return T===null?null:(Yr(T,d,S),((Dt&2)===0||T!==On)&&(T===On&&((Dt&2)===0&&(ef|=d),Hn===4&&eo(T,ni)),Oi(T,S),d===1&&Dt===0&&(f.mode&1)===0&&(Za(),Zr&&Di())),T)}function af(f,d){f.lanes|=d;var S=f.alternate;for(S!==null&&(S.lanes|=d),S=f,f=f.return;f!==null;)f.childLanes|=d,S=f.alternate,S!==null&&(S.childLanes|=d),S=f,f=f.return;return S.tag===3?S.stateNode:null}function Oi(f,d){var S=f.callbackNode;sc(f,d);var T=Po(f,f===On?ni:0);if(T===0)S!==null&&Fa(S),f.callbackNode=null,f.callbackPriority=0;else if(d=T&-T,f.callbackPriority!==d){if(S!=null&&Fa(S),d===1)f.tag===0?hc(Rx.bind(null,f)):uc(Rx.bind(null,f)),de?Se(function(){Dt===0&&Di()}):gs(Lo,Di),S=null;else{switch(oc(T)){case 1:S=Lo;break;case 4:S=Eh;break;case 16:S=wi;break;case 536870912:S=lc;break;default:S=wi}S=kx(S,Cx.bind(null,f))}f.callbackPriority=d,f.callbackNode=S}}function Cx(f,d){if(sf=-1,of=0,(Dt&6)!==0)throw Error(o(327));var S=f.callbackNode;if(Vo()&&f.callbackNode!==S)return null;var T=Po(f,f===On?ni:0);if(T===0)return null;if((T&30)!==0||(T&f.expiredLanes)!==0||d)d=lf(f,T);else{d=T;var R=Dt;Dt|=2;var U=Ix();(On!==f||ni!==d)&&(Za(),Go(f,d));do try{F2();break}catch(he){Lx(f,he)}while(!0);za(),Qh.current=U,Dt=R,Nn!==null?d=0:(On=null,ni=0,d=Hn)}if(d!==0){if(d===2&&(R=ms(f),R!==0&&(T=R,d=Tm(f,R))),d===1)throw S=Tc,Go(f,0),eo(f,T),Oi(f,pn()),S;if(d===6)eo(f,T);else{if(R=f.current.alternate,(T&30)===0&&!O2(R)&&(d=lf(f,T),d===2&&(U=ms(f),U!==0&&(T=U,d=Tm(f,U))),d===1))throw S=Tc,Go(f,0),eo(f,T),Oi(f,pn()),S;switch(f.finishedWork=R,f.finishedLanes=T,d){case 0:case 1:throw Error(o(345));case 2:Ho(f,Ui);break;case 3:if(eo(f,T),(T&130023424)===T&&(d=Sm+500-pn(),10<d)){if(Po(f,0)!==0)break;if(R=f.suspendedLanes,(R&T)!==T){Ti(),f.pingedLanes|=f.suspendedLanes&R;break}f.timeoutHandle=ce(Ho.bind(null,f,Ui),d);break}Ho(f,Ui);break;case 4:if(eo(f,T),(T&4194240)===T)break;for(d=f.eventTimes,R=-1;0<T;){var Q=31-Vi(T);U=1<<Q,Q=d[Q],Q>R&&(R=Q),T&=~U}if(T=R,T=pn()-T,T=(120>T?120:480>T?480:1080>T?1080:1920>T?1920:3e3>T?3e3:4320>T?4320:1960*U2(T/1960))-T,10<T){f.timeoutHandle=ce(Ho.bind(null,f,Ui),T);break}Ho(f,Ui);break;case 5:Ho(f,Ui);break;default:throw Error(o(329))}}}return Oi(f,pn()),f.callbackNode===S?Cx.bind(null,f):null}function Tm(f,d){var S=Ac;return f.current.memoizedState.isDehydrated&&(Go(f,d).flags|=256),f=lf(f,d),f!==2&&(d=Ui,Ui=S,d!==null&&Am(d)),f}function Am(f){Ui===null?Ui=f:Ui.push.apply(Ui,f)}function O2(f){for(var d=f;;){if(d.flags&16384){var S=d.updateQueue;if(S!==null&&(S=S.stores,S!==null))for(var T=0;T<S.length;T++){var R=S[T],U=R.getSnapshot;R=R.value;try{if(!Xi(U(),R))return!1}catch{return!1}}}if(S=d.child,d.subtreeFlags&16384&&S!==null)S.return=d,d=S;else{if(d===f)break;for(;d.sibling===null;){if(d.return===null||d.return===f)return!0;d=d.return}d.sibling.return=d.return,d=d.sibling}}return!0}function eo(f,d){for(d&=~wm,d&=~ef,f.suspendedLanes|=d,f.pingedLanes&=~d,f=f.expirationTimes;0<d;){var S=31-Vi(d),T=1<<S;f[S]=-1,d&=~T}}function Rx(f){if((Dt&6)!==0)throw Error(o(327));Vo();var d=Po(f,0);if((d&1)===0)return Oi(f,pn()),null;var S=lf(f,d);if(f.tag!==0&&S===2){var T=ms(f);T!==0&&(d=T,S=Tm(f,T))}if(S===1)throw S=Tc,Go(f,0),eo(f,d),Oi(f,pn()),S;if(S===6)throw Error(o(345));return f.finishedWork=f.current.alternate,f.finishedLanes=d,Ho(f,Ui),Oi(f,pn()),null}function Px(f){Js!==null&&Js.tag===0&&(Dt&6)===0&&Vo();var d=Dt;Dt|=1;var S=Ln.transition,T=Ut;try{if(Ln.transition=null,Ut=1,f)return f()}finally{Ut=T,Ln.transition=S,Dt=d,(Dt&6)===0&&Di()}}function Cm(){Ki=Ya.current,kt(Ya)}function Go(f,d){f.finishedWork=null,f.finishedLanes=0;var S=f.timeoutHandle;if(S!==Ae&&(f.timeoutHandle=Ae,le(S)),Nn!==null)for(S=Nn.return;S!==null;){var T=S;switch(Xp(T),T.tag){case 1:T=T.type.childContextTypes,T!=null&&xi();break;case 3:Xa(),kt(cn),kt(En),Jp();break;case 5:Kp(T);break;case 4:Xa();break;case 13:kt(mn);break;case 19:kt(mn);break;case 10:Zn(T.type._context);break;case 22:case 23:Cm()}S=S.return}if(On=f,Nn=f=to(f.current,null),ni=Ki=d,Hn=0,Tc=null,wm=ef=qa=0,Ui=Ac=null,ji!==null){for(d=0;d<ji.length;d++)if(S=ji[d],T=S.interleaved,T!==null){S.interleaved=null;var R=T.next,U=S.pending;if(U!==null){var Q=U.next;U.next=R,T.next=Q}S.pending=T}ji=null}return f}function Lx(f,d){do{var S=Nn;try{if(za(),Dh.current=zh,Uh){for(var T=bn.memoizedState;T!==null;){var R=T.queue;R!==null&&(R.pending=null),T=T.next}Uh=!1}if(ja=0,Kn=hi=bn=null,vc=!1,yc=0,xm.current=null,S===null||S.return===null){Hn=1,Tc=d,Nn=null;break}e:{var U=f,Q=S.return,he=S,Ce=d;if(d=ni,he.flags|=32768,Ce!==null&&typeof Ce=="object"&&typeof Ce.then=="function"){var Xe=Ce,rt=he,St=rt.tag;if((rt.mode&1)===0&&(St===0||St===11||St===15)){var ht=rt.alternate;ht?(rt.updateQueue=ht.updateQueue,rt.memoizedState=ht.memoizedState,rt.lanes=ht.lanes):(rt.updateQueue=null,rt.memoizedState=null)}var nn=J_(Q);if(nn!==null){nn.flags&=-257,Q_(nn,Q,he,U,d),nn.mode&1&&$_(U,Xe,d),d=nn,Ce=Xe;var at=d.updateQueue;if(at===null){var pi=new Set;pi.add(Ce),d.updateQueue=pi}else at.add(Ce);break e}else{if((d&1)===0){$_(U,Xe,d),Rm();break e}Ce=Error(o(426))}}else if(un&&he.mode&1){var dr=J_(Q);if(dr!==null){(dr.flags&65536)===0&&(dr.flags|=256),Q_(dr,Q,he,U,d),qp(Ce);break e}}U=Ce,Hn!==4&&(Hn=2),Ac===null?Ac=[U]:Ac.push(U),Ce=sm(Ce,he),he=Q;do{switch(he.tag){case 3:he.flags|=65536,d&=-d,he.lanes|=d;var ye=Z_(he,Ce,d);v_(he,ye);break e;case 1:U=Ce;var fe=he.type,Te=he.stateNode;if((he.flags&128)===0&&(typeof fe.getDerivedStateFromError=="function"||Te!==null&&typeof Te.componentDidCatch=="function"&&($s===null||!$s.has(Te)))){he.flags|=65536,d&=-d,he.lanes|=d;var et=K_(he,U,d);v_(he,et);break e}}he=he.return}while(he!==null)}Ux(S)}catch(ot){d=ot,Nn===S&&S!==null&&(Nn=S=S.return);continue}break}while(!0)}function Ix(){var f=Qh.current;return Qh.current=zh,f===null?zh:f}function Rm(){(Hn===0||Hn===3||Hn===2)&&(Hn=4),On===null||(qa&268435455)===0&&(ef&268435455)===0||eo(On,ni)}function lf(f,d){var S=Dt;Dt|=2;var T=Ix();On===f&&ni===d||Go(f,d);do try{N2();break}catch(R){Lx(f,R)}while(!0);if(za(),Dt=S,Qh.current=T,Nn!==null)throw Error(o(261));return On=null,ni=0,Hn}function N2(){for(;Nn!==null;)Dx(Nn)}function F2(){for(;Nn!==null&&!ac();)Dx(Nn)}function Dx(f){var d=Fx(f.alternate,f,Ki);f.memoizedProps=f.pendingProps,d===null?Ux(f):Nn=d,xm.current=null}function Ux(f){var d=f;do{var S=d.alternate;if(f=d.return,(d.flags&32768)===0){if(S=T2(S,d,Ki),S!==null){Nn=S;return}}else{if(S=R2(S,d),S!==null){S.flags&=32767,Nn=S;return}if(f!==null)f.flags|=32768,f.subtreeFlags=0,f.deletions=null;else{Hn=6,Nn=null;return}}if(d=d.sibling,d!==null){Nn=d;return}Nn=d=f}while(d!==null);Hn===0&&(Hn=5)}function Ho(f,d){var S=Ut,T=Ln.transition;try{Ln.transition=null,Ut=1,k2(f,d,S)}finally{Ln.transition=T,Ut=S}return null}function k2(f,d,S){do Vo();while(Js!==null);if((Dt&6)!==0)throw Error(o(327));var T=f.finishedWork,R=f.finishedLanes;if(T===null)return null;if(f.finishedWork=null,f.finishedLanes=0,T===f.current)throw Error(o(177));f.callbackNode=null,f.callbackPriority=0;var U=T.lanes|T.childLanes;if(Ys(f,U),f===On&&(Nn=On=null,ni=0),(T.subtreeFlags&2064)===0&&(T.flags&2064)===0||nf||(nf=!0,kx(wi,function(){return Vo(),null})),U=(T.flags&15990)!==0,(T.subtreeFlags&15990)!==0||U){U=Ln.transition,Ln.transition=null;var Q=Ut;Ut=1;var he=Dt;Dt|=4,xm.current=null,L2(f,T),I2(f,T),B(f.containerInfo),f.current=T,D2(T),Sh(),Dt=he,Ut=Q,Ln.transition=U}else f.current=T;if(nf&&(nf=!1,Js=f,rf=R),U=f.pendingLanes,U===0&&($s=null),cc(T.stateNode),Oi(f,pn()),d!==null)for(S=f.onRecoverableError,T=0;T<d.length;T++)S(d[T]);if(tf)throw tf=!1,f=bm,bm=null,f;return(rf&1)!==0&&f.tag!==0&&Vo(),U=f.pendingLanes,(U&1)!==0?f===Mm?Cc++:(Cc=0,Mm=f):Cc=0,Di(),null}function Vo(){if(Js!==null){var f=oc(rf),d=Ln.transition,S=Ut;try{if(Ln.transition=null,Ut=16>f?16:f,Js===null)var T=!1;else{if(f=Js,Js=null,rf=0,(Dt&6)!==0)throw Error(o(331));var R=Dt;for(Dt|=4,Qe=f.current;Qe!==null;){var U=Qe,Q=U.child;if((Qe.flags&16)!==0){var he=U.deletions;if(he!==null){for(var Ce=0;Ce<he.length;Ce++){var Xe=he[Ce];for(Qe=Xe;Qe!==null;){var rt=Qe;switch(rt.tag){case 0:case 11:case 15:Bo(8,rt,U)}var St=rt.child;if(St!==null)St.return=rt,Qe=St;else for(;Qe!==null;){rt=Qe;var ht=rt.sibling,nn=rt.return;if(yx(rt),rt===Xe){Qe=null;break}if(ht!==null){ht.return=nn,Qe=ht;break}Qe=nn}}}var at=U.alternate;if(at!==null){var pi=at.child;if(pi!==null){at.child=null;do{var dr=pi.sibling;pi.sibling=null,pi=dr}while(pi!==null)}}Qe=U}}if((U.subtreeFlags&2064)!==0&&Q!==null)Q.return=U,Qe=Q;else e:for(;Qe!==null;){if(U=Qe,(U.flags&2048)!==0)switch(U.tag){case 0:case 11:case 15:Bo(9,U,U.return)}var ye=U.sibling;if(ye!==null){ye.return=U.return,Qe=ye;break e}Qe=U.return}}var fe=f.current;for(Qe=fe;Qe!==null;){Q=Qe;var Te=Q.child;if((Q.subtreeFlags&2064)!==0&&Te!==null)Te.return=Q,Qe=Te;else e:for(Q=fe;Qe!==null;){if(he=Qe,(he.flags&2048)!==0)try{switch(he.tag){case 0:case 11:case 15:bc(9,he)}}catch(ot){Ni(he,he.return,ot)}if(he===Q){Qe=null;break e}var et=he.sibling;if(et!==null){et.return=he.return,Qe=et;break e}Qe=he.return}}if(Dt=R,Di(),Wi&&typeof Wi.onPostCommitFiberRoot=="function")try{Wi.onPostCommitFiberRoot(Io,f)}catch{}T=!0}return T}finally{Ut=S,Ln.transition=d}}return!1}function Ox(f,d,S){d=sm(S,d),d=Z_(f,d,1),Ks(f,d),d=Ti(),f=af(f,1),f!==null&&(Yr(f,1,d),Oi(f,d))}function Ni(f,d,S){if(f.tag===3)Ox(f,f,S);else for(;d!==null;){if(d.tag===3){Ox(d,f,S);break}else if(d.tag===1){var T=d.stateNode;if(typeof d.type.getDerivedStateFromError=="function"||typeof T.componentDidCatch=="function"&&($s===null||!$s.has(T))){f=sm(S,f),f=K_(d,f,1),Ks(d,f),f=Ti(),d=af(d,1),d!==null&&(Yr(d,1,f),Oi(d,f));break}}d=d.return}}function z2(f,d,S){var T=f.pingCache;T!==null&&T.delete(d),d=Ti(),f.pingedLanes|=f.suspendedLanes&S,On===f&&(ni&S)===S&&(Hn===4||Hn===3&&(ni&130023424)===ni&&500>pn()-Sm?Go(f,0):wm|=S),Oi(f,d)}function Nx(f,d){d===0&&((f.mode&1)===0?d=1:(d=ds,ds<<=1,(ds&130023424)===0&&(ds=4194304)));var S=Ti();f=af(f,d),f!==null&&(Yr(f,d,S),Oi(f,S))}function B2(f){var d=f.memoizedState,S=0;d!==null&&(S=d.retryLane),Nx(f,S)}function G2(f,d){var S=0;switch(f.tag){case 13:var T=f.stateNode,R=f.memoizedState;R!==null&&(S=R.retryLane);break;case 19:T=f.stateNode;break;default:throw Error(o(314))}T!==null&&T.delete(d),Nx(f,S)}var Fx;Fx=function(f,d,S){if(f!==null)if(f.memoizedProps!==d.pendingProps||cn.current)Zi=!0;else{if((f.lanes&S)===0&&(d.flags&128)===0)return Zi=!1,C2(f,d,S);Zi=(f.flags&131072)!==0}else Zi=!1,un&&(d.flags&1048576)!==0&&E_(d,Ph,d.index);switch(d.lanes=0,d.tag){case 2:var T=d.type;f!==null&&(f.alternate=null,d.alternate=null,d.flags|=2),f=d.pendingProps;var R=Qt(d,En.current);Rn(d,S),R=em(null,d,T,f,R,S);var U=tm();return d.flags|=1,typeof R=="object"&&R!==null&&typeof R.render=="function"&&R.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,on(T)?(U=!0,jr(d)):U=!1,d.memoizedState=R.state!==null&&R.state!==void 0?R.state:null,Gp(d),R.updater=Ch,d.stateNode=R,R._reactInternals=d,Vp(d,T,f,S),d=lm(null,d,T,!0,U,S)):(d.tag=0,un&&U&&Wp(d),Mi(null,d,R,S),d=d.child),d;case 16:T=d.elementType;e:{switch(f!==null&&(f.alternate=null,d.alternate=null,d.flags|=2),f=d.pendingProps,R=T._init,T=R(T._payload),d.type=T,R=d.tag=V2(T),f=Ei(T,f),R){case 0:d=am(null,d,T,f,S);break e;case 1:d=ax(null,d,T,f,S);break e;case 11:d=nx(null,d,T,f,S);break e;case 14:d=ix(null,d,T,Ei(T.type,f),S);break e}throw Error(o(306,T,""))}return d;case 0:return T=d.type,R=d.pendingProps,R=d.elementType===T?R:Ei(T,R),am(f,d,T,R,S);case 1:return T=d.type,R=d.pendingProps,R=d.elementType===T?R:Ei(T,R),ax(f,d,T,R,S);case 3:e:{if(lx(d),f===null)throw Error(o(387));T=d.pendingProps,U=d.memoizedState,R=U.element,g_(f,d),Ah(d,T,null,S);var Q=d.memoizedState;if(T=Q.element,oe&&U.isDehydrated)if(U={element:T,isDehydrated:!1,cache:Q.cache,transitions:Q.transitions},d.updateQueue.baseState=U,d.memoizedState=U,d.flags&256){R=Error(o(423)),d=cx(f,d,T,S,R);break e}else if(T!==R){R=Error(o(424)),d=cx(f,d,T,S,R);break e}else for(oe&&(qi=Gn(d.stateNode.containerInfo),Yi=d,un=!0,Ar=null,fc=!1),S=R_(d,null,T,S),d.child=S;S;)S.flags=S.flags&-3|4096,S=S.sibling;else{if(Ha(),T===R){d=ws(f,d,S);break e}Mi(f,d,T,S)}d=d.child}return d;case 5:return P_(d),f===null&&Yp(d),T=d.type,R=d.pendingProps,U=f!==null?f.memoizedProps:null,Q=R.children,ie(T,R)?Q=null:U!==null&&ie(T,U)&&(d.flags|=32),ox(f,d),Mi(f,d,Q,S),d.child;case 6:return f===null&&Yp(d),null;case 13:return ux(f,d,S);case 4:return Zp(d,d.stateNode.containerInfo),T=d.pendingProps,f===null?d.child=Va(d,null,T,S):Mi(f,d,T,S),d.child;case 11:return T=d.type,R=d.pendingProps,R=d.elementType===T?R:Ei(T,R),nx(f,d,T,R,S);case 7:return Mi(f,d,d.pendingProps,S),d.child;case 8:return Mi(f,d,d.pendingProps.children,S),d.child;case 12:return Mi(f,d,d.pendingProps.children,S),d.child;case 10:e:{if(T=d.type._context,R=d.pendingProps,U=d.memoizedProps,Q=R.value,Mh(d,T,Q),U!==null)if(Xi(U.value,Q)){if(U.children===R.children&&!cn.current){d=ws(f,d,S);break e}}else for(U=d.child,U!==null&&(U.return=d);U!==null;){var he=U.dependencies;if(he!==null){Q=U.child;for(var Ce=he.firstContext;Ce!==null;){if(Ce.context===T){if(U.tag===1){Ce=vs(-1,S&-S),Ce.tag=2;var Xe=U.updateQueue;if(Xe!==null){Xe=Xe.shared;var rt=Xe.pending;rt===null?Ce.next=Ce:(Ce.next=rt.next,rt.next=Ce),Xe.pending=Ce}}U.lanes|=S,Ce=U.alternate,Ce!==null&&(Ce.lanes|=S),bi(U.return,S,d),he.lanes|=S;break}Ce=Ce.next}}else if(U.tag===10)Q=U.type===d.type?null:U.child;else if(U.tag===18){if(Q=U.return,Q===null)throw Error(o(341));Q.lanes|=S,he=Q.alternate,he!==null&&(he.lanes|=S),bi(Q,S,d),Q=U.sibling}else Q=U.child;if(Q!==null)Q.return=U;else for(Q=U;Q!==null;){if(Q===d){Q=null;break}if(U=Q.sibling,U!==null){U.return=Q.return,Q=U;break}Q=Q.return}U=Q}Mi(f,d,R.children,S),d=d.child}return d;case 9:return R=d.type,T=d.pendingProps.children,Rn(d,S),R=Pn(R),T=T(R),d.flags|=1,Mi(f,d,T,S),d.child;case 14:return T=d.type,R=Ei(T,d.pendingProps),R=Ei(T.type,R),ix(f,d,T,R,S);case 15:return rx(f,d,d.type,d.pendingProps,S);case 17:return T=d.type,R=d.pendingProps,R=d.elementType===T?R:Ei(T,R),f!==null&&(f.alternate=null,d.alternate=null,d.flags|=2),d.tag=1,on(T)?(f=!0,jr(d)):f=!1,Rn(d,S),w_(d,T,R),Vp(d,T,R,S),lm(null,d,T,!0,f,S);case 19:return px(f,d,S);case 22:return sx(f,d,S)}throw Error(o(156,d.tag))};function kx(f,d){return gs(f,d)}function H2(f,d,S,T){this.tag=f,this.key=S,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=T,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fr(f,d,S,T){return new H2(f,d,S,T)}function Pm(f){return f=f.prototype,!(!f||!f.isReactComponent)}function V2(f){if(typeof f=="function")return Pm(f)?1:0;if(f!=null){if(f=f.$$typeof,f===_)return 11;if(f===x)return 14}return 2}function to(f,d){var S=f.alternate;return S===null?(S=fr(f.tag,d,f.key,f.mode),S.elementType=f.elementType,S.type=f.type,S.stateNode=f.stateNode,S.alternate=f,f.alternate=S):(S.pendingProps=d,S.type=f.type,S.flags=0,S.subtreeFlags=0,S.deletions=null),S.flags=f.flags&14680064,S.childLanes=f.childLanes,S.lanes=f.lanes,S.child=f.child,S.memoizedProps=f.memoizedProps,S.memoizedState=f.memoizedState,S.updateQueue=f.updateQueue,d=f.dependencies,S.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext},S.sibling=f.sibling,S.index=f.index,S.ref=f.ref,S}function cf(f,d,S,T,R,U){var Q=2;if(T=f,typeof f=="function")Pm(f)&&(Q=1);else if(typeof f=="string")Q=5;else e:switch(f){case u:return Wo(S.children,R,U,d);case h:Q=8,R|=8;break;case p:return f=fr(12,S,d,R|2),f.elementType=p,f.lanes=U,f;case y:return f=fr(13,S,d,R),f.elementType=y,f.lanes=U,f;case g:return f=fr(19,S,d,R),f.elementType=g,f.lanes=U,f;case E:return uf(S,R,U,d);default:if(typeof f=="object"&&f!==null)switch(f.$$typeof){case m:Q=10;break e;case v:Q=9;break e;case _:Q=11;break e;case x:Q=14;break e;case w:Q=16,T=null;break e}throw Error(o(130,f==null?f:typeof f,""))}return d=fr(Q,S,d,R),d.elementType=f,d.type=T,d.lanes=U,d}function Wo(f,d,S,T){return f=fr(7,f,T,d),f.lanes=S,f}function uf(f,d,S,T){return f=fr(22,f,T,d),f.elementType=E,f.lanes=S,f.stateNode={},f}function Lm(f,d,S){return f=fr(6,f,null,d),f.lanes=S,f}function Im(f,d,S){return d=fr(4,f.children!==null?f.children:[],f.key,d),d.lanes=S,d.stateNode={containerInfo:f.containerInfo,pendingChildren:null,implementation:f.implementation},d}function W2(f,d,S,T,R){this.tag=d,this.containerInfo=f,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=Ae,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Na(0),this.expirationTimes=Na(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Na(0),this.identifierPrefix=T,this.onRecoverableError=R,oe&&(this.mutableSourceEagerHydrationData=null)}function zx(f,d,S,T,R,U,Q,he,Ce){return f=new W2(f,d,S,he,Ce),d===1?(d=1,U===!0&&(d|=8)):d=0,U=fr(3,null,null,d),f.current=U,U.stateNode=f,U.memoizedState={element:T,isDehydrated:S,cache:null,transitions:null},Gp(U),f}function Bx(f){if(!f)return Cn;f=f._reactInternals;e:{if(C(f)!==f||f.tag!==1)throw Error(o(170));var d=f;do{switch(d.tag){case 3:d=d.stateNode.context;break e;case 1:if(on(d.type)){d=d.stateNode.__reactInternalMemoizedMergedChildContext;break e}}d=d.return}while(d!==null);throw Error(o(171))}if(f.tag===1){var S=f.type;if(on(S))return Xr(f,S,d)}return d}function Gx(f){var d=f._reactInternals;if(d===void 0)throw typeof f.render=="function"?Error(o(188)):(f=Object.keys(f).join(","),Error(o(268,f)));return f=N(d),f===null?null:f.stateNode}function Hx(f,d){if(f=f.memoizedState,f!==null&&f.dehydrated!==null){var S=f.retryLane;f.retryLane=S!==0&&S<d?S:d}}function Dm(f,d){Hx(f,d),(f=f.alternate)&&Hx(f,d)}function X2(f){return f=N(f),f===null?null:f.stateNode}function j2(){return null}return t.attemptContinuousHydration=function(f){if(f.tag===13){var d=Ti();hr(f,134217728,d),Dm(f,134217728)}},t.attemptHydrationAtCurrentPriority=function(f){if(f.tag===13){var d=Ti(),S=Qs(f);hr(f,S,d),Dm(f,S)}},t.attemptSynchronousHydration=function(f){switch(f.tag){case 3:var d=f.stateNode;if(d.current.memoizedState.isDehydrated){var S=ps(d.pendingLanes);S!==0&&(qr(d,S|1),Oi(d,pn()),(Dt&6)===0&&(Za(),Di()))}break;case 13:var T=Ti();Px(function(){return hr(f,1,T)}),Dm(f,1)}},t.batchedUpdates=function(f,d){var S=Dt;Dt|=1;try{return f(d)}finally{Dt=S,Dt===0&&(Za(),Zr&&Di())}},t.createComponentSelector=function(f){return{$$typeof:qh,value:f}},t.createContainer=function(f,d,S,T,R,U,Q){return zx(f,d,!1,null,S,T,R,U,Q)},t.createHasPseudoClassSelector=function(f){return{$$typeof:Zh,value:f}},t.createHydrationContainer=function(f,d,S,T,R,U,Q,he,Ce){return f=zx(S,T,!0,f,R,U,Q,he,Ce),f.context=Bx(null),S=f.current,T=Ti(),R=Qs(S),U=vs(T,R),U.callback=d??null,Ks(S,U),f.current.lanes=R,Yr(f,R,T),Oi(f,T),f},t.createPortal=function(f,d,S){var T=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:T==null?null:""+T,children:f,containerInfo:d,implementation:S}},t.createRoleSelector=function(f){return{$$typeof:Kh,value:f}},t.createTestNameSelector=function(f){return{$$typeof:$h,value:f}},t.createTextSelector=function(f){return{$$typeof:Jh,value:f}},t.deferredUpdates=function(f){var d=Ut,S=Ln.transition;try{return Ln.transition=null,Ut=16,f()}finally{Ut=d,Ln.transition=S}},t.discreteUpdates=function(f,d,S,T,R){var U=Ut,Q=Ln.transition;try{return Ln.transition=null,Ut=1,f(d,S,T,R)}finally{Ut=U,Ln.transition=Q,Dt===0&&Za()}},t.findAllNodes=_m,t.findBoundingRects=function(f,d){if(!Le)throw Error(o(363));d=_m(f,d),f=[];for(var S=0;S<d.length;S++)f.push(He(d[S]));for(d=f.length-1;0<d;d--){S=f[d];for(var T=S.x,R=T+S.width,U=S.y,Q=U+S.height,he=d-1;0<=he;he--)if(d!==he){var Ce=f[he],Xe=Ce.x,rt=Xe+Ce.width,St=Ce.y,ht=St+Ce.height;if(T>=Xe&&U>=St&&R<=rt&&Q<=ht){f.splice(d,1);break}else if(T!==Xe||S.width!==Ce.width||ht<U||St>Q){if(!(U!==St||S.height!==Ce.height||rt<T||Xe>R)){Xe>T&&(Ce.width+=Xe-T,Ce.x=T),rt<R&&(Ce.width=R-Xe),f.splice(d,1);break}}else{St>U&&(Ce.height+=St-U,Ce.y=U),ht<Q&&(Ce.height=Q-St),f.splice(d,1);break}}}return f},t.findHostInstance=Gx,t.findHostInstanceWithNoPortals=function(f){return f=F(f),f=f!==null?X(f):null,f===null?null:f.stateNode},t.findHostInstanceWithWarning=function(f){return Gx(f)},t.flushControlled=function(f){var d=Dt;Dt|=1;var S=Ln.transition,T=Ut;try{Ln.transition=null,Ut=1,f()}finally{Ut=T,Ln.transition=S,Dt=d,Dt===0&&(Za(),Di())}},t.flushPassiveEffects=Vo,t.flushSync=Px,t.focusWithin=function(f,d){if(!Le)throw Error(o(363));for(f=gm(f),d=Ax(f,d),d=Array.from(d),f=0;f<d.length;){var S=d[f++];if(!H(S)){if(S.tag===5&&we(S.stateNode))return!0;for(S=S.child;S!==null;)d.push(S),S=S.sibling}}return!1},t.getCurrentUpdatePriority=function(){return Ut},t.getFindAllNodesFailureDescription=function(f,d){if(!Le)throw Error(o(363));var S=0,T=[];f=[gm(f),0];for(var R=0;R<f.length;){var U=f[R++],Q=f[R++],he=d[Q];if((U.tag!==5||!H(U))&&(vm(U,he)&&(T.push(ym(he)),Q++,Q>S&&(S=Q)),Q<d.length))for(U=U.child;U!==null;)f.push(U,Q),U=U.sibling}if(S<d.length){for(f=[];S<d.length;S++)f.push(ym(d[S]));return`findAllNodes was able to match part of the selector:
|
|
`+(T.join(" > ")+`
|
|
|
|
No matching component was found for:
|
|
`)+f.join(" > ")}return null},t.getPublicRootInstance=function(f){if(f=f.current,!f.child)return null;switch(f.child.tag){case 5:return W(f.child.stateNode);default:return f.child.stateNode}},t.injectIntoDevTools=function(f){if(f={bundleType:f.bundleType,version:f.version,rendererPackageName:f.rendererPackageName,rendererConfig:f.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:a.ReactCurrentDispatcher,findHostInstanceByFiber:X2,findFiberByHostInstance:f.findFiberByHostInstance||j2,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")f=!1;else{var d=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(d.isDisabled||!d.supportsFiber)f=!0;else{try{Io=d.inject(f),Wi=d}catch{}f=!!d.checkDCE}}return f},t.isAlreadyRendering=function(){return!1},t.observeVisibleRects=function(f,d,S,T){if(!Le)throw Error(o(363));f=_m(f,d);var R=be(f,S,T).disconnect;return{disconnect:function(){R()}}},t.registerMutableSourceForHydration=function(f,d){var S=d._getVersion;S=S(d._source),f.mutableSourceEagerHydrationData==null?f.mutableSourceEagerHydrationData=[d,S]:f.mutableSourceEagerHydrationData.push(d,S)},t.runWithPriority=function(f,d){var S=Ut;try{return Ut=f,d()}finally{Ut=S}},t.shouldError=function(){return null},t.shouldSuspend=function(){return!1},t.updateContainer=function(f,d,S,T){var R=d.current,U=Ti(),Q=Qs(R);return S=Bx(S),d.context===null?d.context=S:d.pendingContext=S,d=vs(U,Q),d.payload={element:f},T=T===void 0?null:T,T!==null&&(d.callback=T),Ks(R,d),f=hr(R,Q,U),f!==null&&Th(f,R,Q),Q},t}),yg}var Sw;function j3(){return Sw||(Sw=1,mg.exports=X3()),mg.exports}var Y3=j3();const q3=Hr(Y3);var _g={exports:{}},xg={};/**
|
|
* @license React
|
|
* scheduler.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 Ew;function Z3(){return Ew||(Ew=1,(function(r){function e(k,G){var B=k.length;k.push(G);e:for(;0<B;){var D=B-1>>>1,V=k[D];if(0<i(V,G))k[D]=G,k[B]=V,B=D;else break e}}function t(k){return k.length===0?null:k[0]}function n(k){if(k.length===0)return null;var G=k[0],B=k.pop();if(B!==G){k[0]=B;e:for(var D=0,V=k.length,Z=V>>>1;D<Z;){var ee=2*(D+1)-1,ie=k[ee],ue=ee+1,ce=k[ue];if(0>i(ie,B))ue<V&&0>i(ce,ie)?(k[D]=ce,k[ue]=B,D=ue):(k[D]=ie,k[ee]=B,D=ee);else if(ue<V&&0>i(ce,B))k[D]=ce,k[ue]=B,D=ue;else break e}}return G}function i(k,G){var B=k.sortIndex-G.sortIndex;return B!==0?B:k.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;r.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();r.unstable_now=function(){return o.now()-a}}var l=[],c=[],u=1,h=null,p=3,m=!1,v=!1,_=!1,y=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(k){for(var G=t(c);G!==null;){if(G.callback===null)n(c);else if(G.startTime<=k)n(c),G.sortIndex=G.expirationTime,e(l,G);else break;G=t(c)}}function E(k){if(_=!1,w(k),!v)if(t(l)!==null)v=!0,W(b);else{var G=t(c);G!==null&&O(E,G.startTime-k)}}function b(k,G){v=!1,_&&(_=!1,g(P),P=-1),m=!0;var B=p;try{for(w(G),h=t(l);h!==null&&(!(h.expirationTime>G)||k&&!F());){var D=h.callback;if(typeof D=="function"){h.callback=null,p=h.priorityLevel;var V=D(h.expirationTime<=G);G=r.unstable_now(),typeof V=="function"?h.callback=V:h===t(l)&&n(l),w(G)}else n(l);h=t(l)}if(h!==null)var Z=!0;else{var ee=t(c);ee!==null&&O(E,ee.startTime-G),Z=!1}return Z}finally{h=null,p=B,m=!1}}var M=!1,A=null,P=-1,C=5,L=-1;function F(){return!(r.unstable_now()-L<C)}function N(){if(A!==null){var k=r.unstable_now();L=k;var G=!0;try{G=A(!0,k)}finally{G?I():(M=!1,A=null)}}else M=!1}var I;if(typeof x=="function")I=function(){x(N)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,q=X.port2;X.port1.onmessage=N,I=function(){q.postMessage(null)}}else I=function(){y(N,0)};function W(k){A=k,M||(M=!0,I())}function O(k,G){P=y(function(){k(r.unstable_now())},G)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function(k){k.callback=null},r.unstable_continueExecution=function(){v||m||(v=!0,W(b))},r.unstable_forceFrameRate=function(k){0>k||125<k?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):C=0<k?Math.floor(1e3/k):5},r.unstable_getCurrentPriorityLevel=function(){return p},r.unstable_getFirstCallbackNode=function(){return t(l)},r.unstable_next=function(k){switch(p){case 1:case 2:case 3:var G=3;break;default:G=p}var B=p;p=G;try{return k()}finally{p=B}},r.unstable_pauseExecution=function(){},r.unstable_requestPaint=function(){},r.unstable_runWithPriority=function(k,G){switch(k){case 1:case 2:case 3:case 4:case 5:break;default:k=3}var B=p;p=k;try{return G()}finally{p=B}},r.unstable_scheduleCallback=function(k,G,B){var D=r.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?D+B:D):B=D,k){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=B+V,k={id:u++,callback:G,priorityLevel:k,startTime:B,expirationTime:V,sortIndex:-1},B>D?(k.sortIndex=B,e(c,k),t(l)===null&&k===t(c)&&(_?(g(P),P=-1):_=!0,O(E,B-D))):(k.sortIndex=V,e(l,k),v||m||(v=!0,W(b))),k},r.unstable_shouldYield=F,r.unstable_wrapCallback=function(k){var G=p;return function(){var B=p;p=G;try{return k.apply(this,arguments)}finally{p=B}}}})(xg)),xg}var bw;function K3(){return bw||(bw=1,_g.exports=Z3()),_g.exports}var Mw=K3();const $3=r=>typeof r=="object"&&typeof r.then=="function",Jf=[];function J3(r,e,t=(n,i)=>n===i){if(r===e)return!0;if(!r||!e)return!1;const n=r.length;if(e.length!==n)return!1;for(let i=0;i<n;i++)if(!t(r[i],e[i]))return!1;return!0}function Q3(r,e=null,t=!1,n={}){e===null&&(e=[r]);for(const s of Jf)if(J3(e,s.keys,s.equal)){if(t)return;if(Object.prototype.hasOwnProperty.call(s,"error"))throw s.error;if(Object.prototype.hasOwnProperty.call(s,"response"))return n.lifespan&&n.lifespan>0&&(s.timeout&&clearTimeout(s.timeout),s.timeout=setTimeout(s.remove,n.lifespan)),s.response;if(!t)throw s.promise}const i={keys:e,equal:n.equal,remove:()=>{const s=Jf.indexOf(i);s!==-1&&Jf.splice(s,1)},promise:($3(r)?r:r(...e)).then(s=>{i.response=s,n.lifespan&&n.lifespan>0&&(i.timeout=setTimeout(i.remove,n.lifespan))}).catch(s=>i.error=s)};if(Jf.push(i),!t)throw i.promise}const eO=(r,e,t)=>Q3(r,e,!1,t),Oy={},hT=r=>void Object.assign(Oy,r);function tO(r,e){function t(u,{args:h=[],attach:p,...m},v){let _=`${u[0].toUpperCase()}${u.slice(1)}`,y;if(u==="primitive"){if(m.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const g=m.object;y=Ll(g,{type:u,root:v,attach:p,primitive:!0})}else{const g=Oy[_];if(!g)throw new Error(`R3F: ${_} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(!Array.isArray(h))throw new Error("R3F: The args prop must be an array!");y=Ll(new g(...h),{type:u,root:v,attach:p,memoizedProps:{args:h}})}return y.__r3f.attach===void 0&&(y instanceof Tt?y.__r3f.attach="geometry":y instanceof oi&&(y.__r3f.attach="material")),_!=="inject"&&Eg(y,m),y}function n(u,h){let p=!1;if(h){var m,v;(m=h.__r3f)!=null&&m.attach?Sg(u,h,h.__r3f.attach):h.isObject3D&&u.isObject3D&&(u.add(h),p=!0),p||(v=u.__r3f)==null||v.objects.push(h),h.__r3f||Ll(h,{}),h.__r3f.parent=u,vv(h),Il(h)}}function i(u,h,p){let m=!1;if(h){var v,_;if((v=h.__r3f)!=null&&v.attach)Sg(u,h,h.__r3f.attach);else if(h.isObject3D&&u.isObject3D){h.parent=u,h.dispatchEvent({type:"added"});const y=u.children.filter(x=>x!==h),g=y.indexOf(p);u.children=[...y.slice(0,g),h,...y.slice(g)],m=!0}m||(_=u.__r3f)==null||_.objects.push(h),h.__r3f||Ll(h,{}),h.__r3f.parent=u,vv(h),Il(h)}}function s(u,h,p=!1){u&&[...u].forEach(m=>o(h,m,p))}function o(u,h,p){if(h){var m,v,_;if(h.__r3f&&(h.__r3f.parent=null),(m=u.__r3f)!=null&&m.objects&&(u.__r3f.objects=u.__r3f.objects.filter(E=>E!==h)),(v=h.__r3f)!=null&&v.attach)Pw(u,h,h.__r3f.attach);else if(h.isObject3D&&u.isObject3D){var y;u.remove(h),(y=h.__r3f)!=null&&y.root&&lO(h.__r3f.root,h)}const x=(_=h.__r3f)==null?void 0:_.primitive,w=p===void 0?h.dispose!==null&&!x:p;if(!x){var g;s((g=h.__r3f)==null?void 0:g.objects,h,w),s(h.children,h,w)}delete h.__r3f,w&&h.dispose&&h.type!=="Scene"&&Mw.unstable_scheduleCallback(Mw.unstable_IdlePriority,()=>{try{h.dispose()}catch{}}),Il(u)}}function a(u,h,p,m){var v;const _=(v=u.__r3f)==null?void 0:v.parent;if(!_)return;const y=t(h,p,u.__r3f.root);if(u.children){for(const g of u.children)g.__r3f&&n(y,g);u.children=u.children.filter(g=>!g.__r3f)}u.__r3f.objects.forEach(g=>n(y,g)),u.__r3f.objects=[],u.__r3f.autoRemovedBeforeAppend||o(_,u),y.parent&&(y.__r3f.autoRemovedBeforeAppend=!0),n(_,y),y.raycast&&y.__r3f.eventCount&&y.__r3f.root.getState().internal.interaction.push(y),[m,m.alternate].forEach(g=>{g!==null&&(g.stateNode=y,g.ref&&(typeof g.ref=="function"?g.ref(y):g.ref.current=y))})}const l=()=>console.warn("Text is not allowed in the R3F tree! This could be stray whitespace or characters.");return{reconciler:q3({createInstance:t,removeChild:o,appendChild:n,appendInitialChild:n,insertBefore:i,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(u,h)=>{if(!h)return;const p=u.getState().scene;p.__r3f&&(p.__r3f.root=u,n(p,h))},removeChildFromContainer:(u,h)=>{h&&o(u.getState().scene,h)},insertInContainerBefore:(u,h,p)=>{if(!h||!p)return;const m=u.getState().scene;m.__r3f&&i(m,h,p)},getRootHostContext:()=>null,getChildHostContext:u=>u,finalizeInitialChildren(u){var h;return!!((h=u==null?void 0:u.__r3f)!=null?h:{}).handlers},prepareUpdate(u,h,p,m){var v;if(((v=u==null?void 0:u.__r3f)!=null?v:{}).primitive&&m.object&&m.object!==u)return[!0];{const{args:y=[],children:g,...x}=m,{args:w=[],children:E,...b}=p;if(!Array.isArray(y))throw new Error("R3F: the args prop must be an array!");if(y.some((A,P)=>A!==w[P]))return[!0];const M=yT(u,x,b,!0);return M.changes.length?[!1,M]:null}},commitUpdate(u,[h,p],m,v,_,y){h?a(u,m,_,y):Eg(u,p)},commitMount(u,h,p,m){var v;const _=(v=u.__r3f)!=null?v:{};u.raycast&&_.handlers&&_.eventCount&&u.__r3f.root.getState().internal.interaction.push(u)},getPublicInstance:u=>u,prepareForCommit:()=>null,preparePortalMount:u=>Ll(u.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(u){var h;const{attach:p,parent:m}=(h=u.__r3f)!=null?h:{};p&&m&&Pw(m,u,p),u.isObject3D&&(u.visible=!1),Il(u)},unhideInstance(u,h){var p;const{attach:m,parent:v}=(p=u.__r3f)!=null?p:{};m&&v&&Sg(v,u,m),(u.isObject3D&&h.visible==null||h.visible)&&(u.visible=!0),Il(u)},createTextInstance:l,hideTextInstance:l,unhideTextInstance:l,getCurrentEventPriority:()=>e?e():Fl.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&hn.fun(performance.now)?performance.now:hn.fun(Date.now)?Date.now:()=>0,scheduleTimeout:hn.fun(setTimeout)?setTimeout:void 0,cancelTimeout:hn.fun(clearTimeout)?clearTimeout:void 0}),applyProps:Eg}}var Tw,Aw;const wg=r=>"colorSpace"in r||"outputColorSpace"in r,fT=()=>{var r;return(r=Oy.ColorManagement)!=null?r:null},dT=r=>r&&r.isOrthographicCamera,nO=r=>r&&r.hasOwnProperty("current"),hh=typeof window<"u"&&((Tw=window.document)!=null&&Tw.createElement||((Aw=window.navigator)==null?void 0:Aw.product)==="ReactNative")?K.useLayoutEffect:K.useEffect;function pT(r){const e=K.useRef(r);return hh(()=>void(e.current=r),[r]),e}function iO({set:r}){return hh(()=>(r(new Promise(()=>null)),()=>r(!1)),[r]),null}class mT extends K.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}mT.getDerivedStateFromError=()=>({error:!0});const gT="__default",Cw=new Map,rO=r=>r&&!!r.memoized&&!!r.changes;function vT(r){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(r)?Math.min(Math.max(r[0],t),r[1]):r}const zc=r=>{var e;return(e=r.__r3f)==null?void 0:e.root.getState()},hn={obj:r=>r===Object(r)&&!hn.arr(r)&&typeof r!="function",fun:r=>typeof r=="function",str:r=>typeof r=="string",num:r=>typeof r=="number",boo:r=>typeof r=="boolean",und:r=>r===void 0,arr:r=>Array.isArray(r),equ(r,e,{arrays:t="shallow",objects:n="reference",strict:i=!0}={}){if(typeof r!=typeof e||!!r!=!!e)return!1;if(hn.str(r)||hn.num(r))return r===e;const s=hn.obj(r);if(s&&n==="reference")return r===e;const o=hn.arr(r);if(o&&t==="reference")return r===e;if((o||s)&&r===e)return!0;let a;for(a in r)if(!(a in e))return!1;if(s&&t==="shallow"&&n==="shallow"){for(a in i?e:r)if(!hn.equ(r[a],e[a],{strict:i,objects:"reference"}))return!1}else for(a in i?e:r)if(r[a]!==e[a])return!1;if(hn.und(a)){if(o&&r.length===0&&e.length===0||s&&Object.keys(r).length===0&&Object.keys(e).length===0)return!0;if(r!==e)return!1}return!0}};function sO(r){r.dispose&&r.type!=="Scene"&&r.dispose();for(const e in r)e.dispose==null||e.dispose(),delete r[e]}function Ll(r,e){const t=r;return t.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...e},r}function gv(r,e){let t=r;if(e.includes("-")){const n=e.split("-"),i=n.pop();return t=n.reduce((s,o)=>s[o],r),{target:t,key:i}}else return{target:t,key:e}}const Rw=/-\d+$/;function Sg(r,e,t){if(hn.str(t)){if(Rw.test(t)){const s=t.replace(Rw,""),{target:o,key:a}=gv(r,s);Array.isArray(o[a])||(o[a]=[])}const{target:n,key:i}=gv(r,t);e.__r3f.previousAttach=n[i],n[i]=e}else e.__r3f.previousAttach=t(r,e)}function Pw(r,e,t){var n,i;if(hn.str(t)){const{target:s,key:o}=gv(r,t),a=e.__r3f.previousAttach;a===void 0?delete s[o]:s[o]=a}else(n=e.__r3f)==null||n.previousAttach==null||n.previousAttach(r,e);(i=e.__r3f)==null||delete i.previousAttach}function yT(r,{children:e,key:t,ref:n,...i},{children:s,key:o,ref:a,...l}={},c=!1){var u;const h=(u=r==null?void 0:r.__r3f)!=null?u:{},p=Object.entries(i),m=[];if(c){const _=Object.keys(l);for(let y=0;y<_.length;y++)i.hasOwnProperty(_[y])||p.unshift([_[y],gT+"remove"])}p.forEach(([_,y])=>{var g;if((g=r.__r3f)!=null&&g.primitive&&_==="object"||hn.equ(y,l[_]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(_))return m.push([_,y,!0,[]]);let x=[];_.includes("-")&&(x=_.split("-")),m.push([_,y,!1,x]);for(const w in i){const E=i[w];w.startsWith(`${_}-`)&&m.push([w,E,!1,w.split("-")])}});const v={...i};return h.memoizedProps&&h.memoizedProps.args&&(v.args=h.memoizedProps.args),h.memoizedProps&&h.memoizedProps.attach&&(v.attach=h.memoizedProps.attach),{memoized:v,changes:m}}function Eg(r,e){var t,n,i;const s=(t=r.__r3f)!=null?t:{},o=s.root,a=(n=o==null||o.getState==null?void 0:o.getState())!=null?n:{},{memoized:l,changes:c}=rO(e)?e:yT(r,e),u=s.eventCount;r.__r3f&&(r.__r3f.memoizedProps=l);for(let p=0;p<c.length;p++){let[m,v,_,y]=c[p];if(wg(r)){const E="srgb",b="srgb-linear";m==="encoding"?(m="colorSpace",v=v===3001?E:b):m==="outputEncoding"&&(m="outputColorSpace",v=v===3001?E:b)}let g=r,x=g[m];if(y.length&&(x=y.reduce((w,E)=>w[E],r),!(x&&x.set))){const[w,...E]=y.reverse();g=E.reverse().reduce((b,M)=>b[M],r),m=w}if(v===gT+"remove")if(g.constructor){let w=Cw.get(g.constructor);w||(w=new g.constructor,Cw.set(g.constructor,w)),v=w[m]}else v=0;if(_)v?s.handlers[m]=v:delete s.handlers[m],s.eventCount=Object.keys(s.handlers).length;else if(x&&x.set&&(x.copy||x instanceof ga)){if(Array.isArray(v))x.fromArray?x.fromArray(v):x.set(...v);else if(x.copy&&v&&v.constructor&&x.constructor===v.constructor)x.copy(v);else if(v!==void 0){const w=x instanceof Ke;!w&&x.setScalar?x.setScalar(v):x instanceof ga&&v instanceof ga?x.mask=v.mask:x.set(v),!fT()&&!a.linear&&w&&x.convertSRGBToLinear()}}else if(g[m]=v,g[m]instanceof Sn&&g[m].format===Bi&&g[m].type===os){const w=g[m];wg(w)&&wg(a.gl)?w.colorSpace=a.gl.outputColorSpace:w.encoding=a.gl.outputEncoding}Il(r)}if(s.parent&&a.internal&&r.raycast&&u!==s.eventCount){const p=a.internal.interaction.indexOf(r);p>-1&&a.internal.interaction.splice(p,1),s.eventCount&&a.internal.interaction.push(r)}return!(c.length===1&&c[0][0]==="onUpdate")&&c.length&&(i=r.__r3f)!=null&&i.parent&&vv(r),r}function Il(r){var e,t;const n=(e=r.__r3f)==null||(t=e.root)==null||t.getState==null?void 0:t.getState();n&&n.internal.frames===0&&n.invalidate()}function vv(r){r.onUpdate==null||r.onUpdate(r)}function oO(r,e){r.manual||(dT(r)?(r.left=e.width/-2,r.right=e.width/2,r.top=e.height/2,r.bottom=e.height/-2):r.aspect=e.width/e.height,r.updateProjectionMatrix(),r.updateMatrixWorld())}function Qf(r){return(r.eventObject||r.object).uuid+"/"+r.index+r.instanceId}function aO(){var r;const e=typeof self<"u"&&self||typeof window<"u"&&window;if(!e)return Fl.DefaultEventPriority;switch((r=e.event)==null?void 0:r.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return Fl.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return Fl.ContinuousEventPriority;default:return Fl.DefaultEventPriority}}function _T(r,e,t,n){const i=t.get(e);i&&(t.delete(e),t.size===0&&(r.delete(n),i.target.releasePointerCapture(n)))}function lO(r,e){const{internal:t}=r.getState();t.interaction=t.interaction.filter(n=>n!==e),t.initialHits=t.initialHits.filter(n=>n!==e),t.hovered.forEach((n,i)=>{(n.eventObject===e||n.object===e)&&t.hovered.delete(i)}),t.capturedMap.forEach((n,i)=>{_T(t.capturedMap,e,n,i)})}function cO(r){function e(l){const{internal:c}=r.getState(),u=l.offsetX-c.initialClick[0],h=l.offsetY-c.initialClick[1];return Math.round(Math.sqrt(u*u+h*h))}function t(l){return l.filter(c=>["Move","Over","Enter","Out","Leave"].some(u=>{var h;return(h=c.__r3f)==null?void 0:h.handlers["onPointer"+u]}))}function n(l,c){const u=r.getState(),h=new Set,p=[],m=c?c(u.internal.interaction):u.internal.interaction;for(let g=0;g<m.length;g++){const x=zc(m[g]);x&&(x.raycaster.camera=void 0)}u.previousRoot||u.events.compute==null||u.events.compute(l,u);function v(g){const x=zc(g);if(!x||!x.events.enabled||x.raycaster.camera===null)return[];if(x.raycaster.camera===void 0){var w;x.events.compute==null||x.events.compute(l,x,(w=x.previousRoot)==null?void 0:w.getState()),x.raycaster.camera===void 0&&(x.raycaster.camera=null)}return x.raycaster.camera?x.raycaster.intersectObject(g,!0):[]}let _=m.flatMap(v).sort((g,x)=>{const w=zc(g.object),E=zc(x.object);return!w||!E?g.distance-x.distance:E.events.priority-w.events.priority||g.distance-x.distance}).filter(g=>{const x=Qf(g);return h.has(x)?!1:(h.add(x),!0)});u.events.filter&&(_=u.events.filter(_,u));for(const g of _){let x=g.object;for(;x;){var y;(y=x.__r3f)!=null&&y.eventCount&&p.push({...g,eventObject:x}),x=x.parent}}if("pointerId"in l&&u.internal.capturedMap.has(l.pointerId))for(let g of u.internal.capturedMap.get(l.pointerId).values())h.has(Qf(g.intersection))||p.push(g.intersection);return p}function i(l,c,u,h){const p=r.getState();if(l.length){const m={stopped:!1};for(const v of l){const _=zc(v.object)||p,{raycaster:y,pointer:g,camera:x,internal:w}=_,E=new Y(g.x,g.y,0).unproject(x),b=L=>{var F,N;return(F=(N=w.capturedMap.get(L))==null?void 0:N.has(v.eventObject))!=null?F:!1},M=L=>{const F={intersection:v,target:c.target};w.capturedMap.has(L)?w.capturedMap.get(L).set(v.eventObject,F):w.capturedMap.set(L,new Map([[v.eventObject,F]])),c.target.setPointerCapture(L)},A=L=>{const F=w.capturedMap.get(L);F&&_T(w.capturedMap,v.eventObject,F,L)};let P={};for(let L in c){let F=c[L];typeof F!="function"&&(P[L]=F)}let C={...v,...P,pointer:g,intersections:l,stopped:m.stopped,delta:u,unprojectedPoint:E,ray:y.ray,camera:x,stopPropagation(){const L="pointerId"in c&&w.capturedMap.get(c.pointerId);if((!L||L.has(v.eventObject))&&(C.stopped=m.stopped=!0,w.hovered.size&&Array.from(w.hovered.values()).find(F=>F.eventObject===v.eventObject))){const F=l.slice(0,l.indexOf(v));s([...F,v])}},target:{hasPointerCapture:b,setPointerCapture:M,releasePointerCapture:A},currentTarget:{hasPointerCapture:b,setPointerCapture:M,releasePointerCapture:A},nativeEvent:c};if(h(C),m.stopped===!0)break}}return l}function s(l){const{internal:c}=r.getState();for(const u of c.hovered.values())if(!l.length||!l.find(h=>h.object===u.object&&h.index===u.index&&h.instanceId===u.instanceId)){const p=u.eventObject.__r3f,m=p==null?void 0:p.handlers;if(c.hovered.delete(Qf(u)),p!=null&&p.eventCount){const v={...u,intersections:l};m.onPointerOut==null||m.onPointerOut(v),m.onPointerLeave==null||m.onPointerLeave(v)}}}function o(l,c){for(let u=0;u<c.length;u++){const h=c[u].__r3f;h==null||h.handlers.onPointerMissed==null||h.handlers.onPointerMissed(l)}}function a(l){switch(l){case"onPointerLeave":case"onPointerCancel":return()=>s([]);case"onLostPointerCapture":return c=>{const{internal:u}=r.getState();"pointerId"in c&&u.capturedMap.has(c.pointerId)&&requestAnimationFrame(()=>{u.capturedMap.has(c.pointerId)&&(u.capturedMap.delete(c.pointerId),s([]))})}}return function(u){const{onPointerMissed:h,internal:p}=r.getState();p.lastEvent.current=u;const m=l==="onPointerMove",v=l==="onClick"||l==="onContextMenu"||l==="onDoubleClick",y=n(u,m?t:void 0),g=v?e(u):0;l==="onPointerDown"&&(p.initialClick=[u.offsetX,u.offsetY],p.initialHits=y.map(w=>w.eventObject)),v&&!y.length&&g<=2&&(o(u,p.interaction),h&&h(u)),m&&s(y);function x(w){const E=w.eventObject,b=E.__r3f,M=b==null?void 0:b.handlers;if(b!=null&&b.eventCount)if(m){if(M.onPointerOver||M.onPointerEnter||M.onPointerOut||M.onPointerLeave){const A=Qf(w),P=p.hovered.get(A);P?P.stopped&&w.stopPropagation():(p.hovered.set(A,w),M.onPointerOver==null||M.onPointerOver(w),M.onPointerEnter==null||M.onPointerEnter(w))}M.onPointerMove==null||M.onPointerMove(w)}else{const A=M[l];A?(!v||p.initialHits.includes(E))&&(o(u,p.interaction.filter(P=>!p.initialHits.includes(P))),A(w)):v&&p.initialHits.includes(E)&&o(u,p.interaction.filter(P=>!p.initialHits.includes(P)))}}i(y,u,g,x)}}return{handlePointer:a}}const xT=r=>!!(r!=null&&r.render),wT=K.createContext(null),uO=(r,e)=>{const t=H3((a,l)=>{const c=new Y,u=new Y,h=new Y;function p(g=l().camera,x=u,w=l().size){const{width:E,height:b,top:M,left:A}=w,P=E/b;x instanceof Y?h.copy(x):h.set(...x);const C=g.getWorldPosition(c).distanceTo(h);if(dT(g))return{width:E/g.zoom,height:b/g.zoom,top:M,left:A,factor:1,distance:C,aspect:P};{const L=g.fov*Math.PI/180,F=2*Math.tan(L/2)*C,N=F*(E/b);return{width:N,height:F,top:M,left:A,factor:E/N,distance:C,aspect:P}}}let m;const v=g=>a(x=>({performance:{...x.performance,current:g}})),_=new De;return{set:a,get:l,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(g=1)=>r(l(),g),advance:(g,x)=>e(g,x,l()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new Py,pointer:_,mouse:_,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const g=l();m&&clearTimeout(m),g.performance.current!==g.performance.min&&v(g.performance.min),m=setTimeout(()=>v(l().performance.max),g.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:p},setEvents:g=>a(x=>({...x,events:{...x.events,...g}})),setSize:(g,x,w,E,b)=>{const M=l().camera,A={width:g,height:x,top:E||0,left:b||0,updateStyle:w};a(P=>({size:A,viewport:{...P.viewport,...p(M,u,A)}}))},setDpr:g=>a(x=>{const w=vT(g);return{viewport:{...x.viewport,dpr:w,initialDpr:x.viewport.initialDpr||w}}}),setFrameloop:(g="always")=>{const x=l().clock;x.stop(),x.elapsedTime=0,g!=="never"&&(x.start(),x.elapsedTime=0),a(()=>({frameloop:g}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:K.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(g,x,w)=>{const E=l().internal;return E.priority=E.priority+(x>0?1:0),E.subscribers.push({ref:g,priority:x,store:w}),E.subscribers=E.subscribers.sort((b,M)=>b.priority-M.priority),()=>{const b=l().internal;b!=null&&b.subscribers&&(b.priority=b.priority-(x>0?1:0),b.subscribers=b.subscribers.filter(M=>M.ref!==g))}}}}}),n=t.getState();let i=n.size,s=n.viewport.dpr,o=n.camera;return t.subscribe(()=>{const{camera:a,size:l,viewport:c,gl:u,set:h}=t.getState();if(l!==i||c.dpr!==s){var p;i=l,s=c.dpr,oO(a,l),u.setPixelRatio(c.dpr);const m=(p=l.updateStyle)!=null?p:typeof HTMLCanvasElement<"u"&&u.domElement instanceof HTMLCanvasElement;u.setSize(l.width,l.height,m)}a!==o&&(o=a,h(m=>({viewport:{...m.viewport,...m.viewport.getCurrentViewport(a)}})))}),t.subscribe(a=>r(a)),t};function hO(r,e){const t={callback:r};return e.add(t),()=>void e.delete(t)}let ed,ST=new Set,fO=new Set,dO=new Set;const pO=r=>hO(r,ST);function bg(r,e){if(r.size)for(const{callback:t}of r.values())t(e)}function Bc(r,e){switch(r){case"before":return bg(ST,e);case"after":return bg(fO,e);case"tail":return bg(dO,e)}}let Mg,Tg;function Ag(r,e,t){let n=e.clock.getDelta();for(e.frameloop==="never"&&typeof r=="number"&&(n=r-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=r),Mg=e.internal.subscribers,ed=0;ed<Mg.length;ed++)Tg=Mg[ed],Tg.ref.current(Tg.store.getState(),n,t);return!e.internal.priority&&e.gl.render&&e.gl.render(e.scene,e.camera),e.internal.frames=Math.max(0,e.internal.frames-1),e.frameloop==="always"?1:e.internal.frames}function mO(r){let e=!1,t,n,i;function s(l){n=requestAnimationFrame(s),e=!0,t=0,Bc("before",l);for(const u of r.values()){var c;i=u.store.getState(),i.internal.active&&(i.frameloop==="always"||i.internal.frames>0)&&!((c=i.gl.xr)!=null&&c.isPresenting)&&(t+=Ag(l,i))}if(Bc("after",l),t===0)return Bc("tail",l),e=!1,cancelAnimationFrame(n)}function o(l,c=1){var u;if(!l)return r.forEach(h=>o(h.store.getState()),c);(u=l.gl.xr)!=null&&u.isPresenting||!l.internal.active||l.frameloop==="never"||(l.internal.frames=Math.min(60,l.internal.frames+c),e||(e=!0,requestAnimationFrame(s)))}function a(l,c=!0,u,h){if(c&&Bc("before",l),u)Ag(l,u,h);else for(const p of r.values())Ag(l,p.store.getState());c&&Bc("after",l)}return{loop:s,invalidate:o,advance:a}}function ET(){const r=K.useContext(wT);if(!r)throw new Error("R3F: Hooks can only be used within the Canvas component!");return r}function Bn(r=t=>t,e){return ET()(r,e)}function Ep(r,e=0){const t=ET(),n=t.getState().internal.subscribe,i=pT(r);return hh(()=>n(i,e,t),[e,n,t]),null}const jl=new Map,{invalidate:Lw,advance:Iw}=mO(jl),{reconciler:Nd,applyProps:oa}=tO(jl,aO),yl={objects:"shallow",strict:!1},gO=(r,e)=>{const t=typeof r=="function"?r(e):r;return xT(t)?t:new uy({powerPreference:"high-performance",canvas:e,antialias:!0,alpha:!0,...r})};function vO(r,e){if(e)return e;if(typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement&&r.parentElement){const{width:t,height:n,top:i,left:s}=r.parentElement.getBoundingClientRect();return{width:t,height:n,top:i,left:s}}else if(typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas)return{width:r.width,height:r.height,top:0,left:0};return{width:0,height:0,top:0,left:0}}function yO(r){const e=jl.get(r),t=e==null?void 0:e.fiber,n=e==null?void 0:e.store;e&&console.warn("R3F.createRoot should only be called once!");const i=typeof reportError=="function"?reportError:console.error,s=n||uO(Lw,Iw),o=t||Nd.createContainer(s,Fl.ConcurrentRoot,null,!1,null,"",i,null);e||jl.set(r,{fiber:o,store:s});let a,l=!1,c;return{configure(u={}){let{gl:h,size:p,scene:m,events:v,onCreated:_,shadows:y=!1,linear:g=!1,flat:x=!1,legacy:w=!1,orthographic:E=!1,frameloop:b="always",dpr:M=[1,2],performance:A,raycaster:P,camera:C,onPointerMissed:L}=u,F=s.getState(),N=F.gl;F.gl||F.set({gl:N=gO(h,r)});let I=F.raycaster;I||F.set({raycaster:I=new Uy});const{params:X,...q}=P||{};if(hn.equ(q,I,yl)||oa(I,{...q}),hn.equ(X,I.params,yl)||oa(I,{params:{...I.params,...X}}),!F.camera||F.camera===c&&!hn.equ(c,C,yl)){c=C;const D=C instanceof rh,V=D?C:E?new Pa(0,0,0,0,.1,1e3):new zn(75,0,.1,1e3);D||(V.position.z=5,C&&oa(V,C),!F.camera&&!(C!=null&&C.rotation)&&V.lookAt(0,0,0)),F.set({camera:V})}if(!F.scene){let D;m instanceof ku?D=m:(D=new ku,m&&oa(D,m)),F.set({scene:Ll(D)})}if(!F.xr){const D=(ee,ie)=>{const ue=s.getState();ue.frameloop!=="never"&&Iw(ee,!0,ue,ie)},V=()=>{const ee=s.getState();ee.gl.xr.enabled=ee.gl.xr.isPresenting,ee.gl.xr.setAnimationLoop(ee.gl.xr.isPresenting?D:null),ee.gl.xr.isPresenting||Lw(ee)},Z={connect(){const ee=s.getState().gl;ee.xr.addEventListener("sessionstart",V),ee.xr.addEventListener("sessionend",V)},disconnect(){const ee=s.getState().gl;ee.xr.removeEventListener("sessionstart",V),ee.xr.removeEventListener("sessionend",V)}};N.xr&&Z.connect(),F.set({xr:Z})}if(N.shadowMap){const D=N.shadowMap.enabled,V=N.shadowMap.type;if(N.shadowMap.enabled=!!y,hn.boo(y))N.shadowMap.type=gu;else if(hn.str(y)){var W;const Z={basic:ub,percentage:qd,soft:gu,variance:Or};N.shadowMap.type=(W=Z[y])!=null?W:gu}else hn.obj(y)&&Object.assign(N.shadowMap,y);(D!==N.shadowMap.enabled||V!==N.shadowMap.type)&&(N.shadowMap.needsUpdate=!0)}const O=fT();O&&("enabled"in O?O.enabled=!w:"legacyMode"in O&&(O.legacyMode=w)),oa(N,{outputEncoding:g?3e3:3001,toneMapping:x?zr:Xv}),F.legacy!==w&&F.set(()=>({legacy:w})),F.linear!==g&&F.set(()=>({linear:g})),F.flat!==x&&F.set(()=>({flat:x})),h&&!hn.fun(h)&&!xT(h)&&!hn.equ(h,N,yl)&&oa(N,h),v&&!F.events.handlers&&F.set({events:v(s)});const B=vO(r,p);return hn.equ(B,F.size,yl)||F.setSize(B.width,B.height,B.updateStyle,B.top,B.left),M&&F.viewport.dpr!==vT(M)&&F.setDpr(M),F.frameloop!==b&&F.setFrameloop(b),F.onPointerMissed||F.set({onPointerMissed:L}),A&&!hn.equ(A,F.performance,yl)&&F.set(D=>({performance:{...D.performance,...A}})),a=_,l=!0,this},render(u){return l||this.configure(),Nd.updateContainer(K.createElement(_O,{store:s,children:u,onCreated:a,rootElement:r}),o,null,()=>{}),s},unmount(){bT(r)}}}function _O({store:r,children:e,onCreated:t,rootElement:n}){return hh(()=>{const i=r.getState();i.set(s=>({internal:{...s.internal,active:!0}})),t&&t(i),r.getState().events.connected||i.events.connect==null||i.events.connect(n)},[]),K.createElement(wT.Provider,{value:r},e)}function bT(r,e){const t=jl.get(r),n=t==null?void 0:t.fiber;if(n){const i=t==null?void 0:t.store.getState();i&&(i.internal.active=!1),Nd.updateContainer(null,n,null,()=>{i&&setTimeout(()=>{try{var s,o,a,l;i.events.disconnect==null||i.events.disconnect(),(s=i.gl)==null||(o=s.renderLists)==null||o.dispose==null||o.dispose(),(a=i.gl)==null||a.forceContextLoss==null||a.forceContextLoss(),(l=i.gl)!=null&&l.xr&&i.xr.disconnect(),sO(i),jl.delete(r)}catch{}},500)})}}Nd.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:K.version});function Ta(){return Ta=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},Ta.apply(null,arguments)}function Dw(r,e){let t;return(...n)=>{window.clearTimeout(t),t=window.setTimeout(()=>r(...n),e)}}function xO({debounce:r,scroll:e,polyfill:t,offsetSize:n}={debounce:0,scroll:!1,offsetSize:!1}){const i=t||(typeof window>"u"?class{}:window.ResizeObserver);if(!i)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,o]=K.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),a=K.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:s,orientationHandler:null}),l=r?typeof r=="number"?r:r.scroll:null,c=r?typeof r=="number"?r:r.resize:null,u=K.useRef(!1);K.useEffect(()=>(u.current=!0,()=>void(u.current=!1)));const[h,p,m]=K.useMemo(()=>{const g=()=>{if(!a.current.element)return;const{left:x,top:w,width:E,height:b,bottom:M,right:A,x:P,y:C}=a.current.element.getBoundingClientRect(),L={left:x,top:w,width:E,height:b,bottom:M,right:A,x:P,y:C};a.current.element instanceof HTMLElement&&n&&(L.height=a.current.element.offsetHeight,L.width=a.current.element.offsetWidth),Object.freeze(L),u.current&&!bO(a.current.lastBounds,L)&&o(a.current.lastBounds=L)};return[g,c?Dw(g,c):g,l?Dw(g,l):g]},[o,n,l,c]);function v(){a.current.scrollContainers&&(a.current.scrollContainers.forEach(g=>g.removeEventListener("scroll",m,!0)),a.current.scrollContainers=null),a.current.resizeObserver&&(a.current.resizeObserver.disconnect(),a.current.resizeObserver=null),a.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",a.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",a.current.orientationHandler))}function _(){a.current.element&&(a.current.resizeObserver=new i(m),a.current.resizeObserver.observe(a.current.element),e&&a.current.scrollContainers&&a.current.scrollContainers.forEach(g=>g.addEventListener("scroll",m,{capture:!0,passive:!0})),a.current.orientationHandler=()=>{m()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",a.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",a.current.orientationHandler))}const y=g=>{!g||g===a.current.element||(v(),a.current.element=g,a.current.scrollContainers=MT(g),_())};return SO(m,!!e),wO(p),K.useEffect(()=>{v(),_()},[e,m,p]),K.useEffect(()=>v,[]),[y,s,h]}function wO(r){K.useEffect(()=>{const e=r;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[r])}function SO(r,e){K.useEffect(()=>{if(e){const t=r;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",t,!0)}},[r,e])}function MT(r){const e=[];if(!r||r===document.body)return e;const{overflow:t,overflowX:n,overflowY:i}=window.getComputedStyle(r);return[t,n,i].some(s=>s==="auto"||s==="scroll")&&e.push(r),[...e,...MT(r.parentElement)]}const EO=["x","y","top","bottom","left","right","width","height"],bO=(r,e)=>EO.every(t=>r[t]===e[t]);var MO=Object.defineProperty,TO=Object.defineProperties,AO=Object.getOwnPropertyDescriptors,Uw=Object.getOwnPropertySymbols,CO=Object.prototype.hasOwnProperty,RO=Object.prototype.propertyIsEnumerable,Ow=(r,e,t)=>e in r?MO(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Nw=(r,e)=>{for(var t in e||(e={}))CO.call(e,t)&&Ow(r,t,e[t]);if(Uw)for(var t of Uw(e))RO.call(e,t)&&Ow(r,t,e[t]);return r},PO=(r,e)=>TO(r,AO(e)),Fw,kw;typeof window<"u"&&((Fw=window.document)!=null&&Fw.createElement||((kw=window.navigator)==null?void 0:kw.product)==="ReactNative")?K.useLayoutEffect:K.useEffect;function TT(r,e,t){if(!r)return;if(t(r)===!0)return r;let n=r.child;for(;n;){const i=TT(n,e,t);if(i)return i;n=n.sibling}}function AT(r){try{return Object.defineProperties(r,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return r}}const zw=console.error;console.error=function(){const r=[...arguments].join("");if(r!=null&&r.startsWith("Warning:")&&r.includes("useContext")){console.error=zw;return}return zw.apply(this,arguments)};const Ny=AT(K.createContext(null));class CT extends K.Component{render(){return K.createElement(Ny.Provider,{value:this._reactInternals},this.props.children)}}function LO(){const r=K.useContext(Ny);if(r===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const e=K.useId();return K.useMemo(()=>{for(const n of[r,r==null?void 0:r.alternate]){if(!n)continue;const i=TT(n,!1,s=>{let o=s.memoizedState;for(;o;){if(o.memoizedState===e)return!0;o=o.next}});if(i)return i}},[r,e])}function IO(){const r=LO(),[e]=K.useState(()=>new Map);e.clear();let t=r;for(;t;){if(t.type&&typeof t.type=="object"){const i=t.type._context===void 0&&t.type.Provider===t.type?t.type:t.type._context;i&&i!==Ny&&!e.has(i)&&e.set(i,K.useContext(AT(i)))}t=t.return}return e}function DO(){const r=IO();return K.useMemo(()=>Array.from(r.keys()).reduce((e,t)=>n=>K.createElement(e,null,K.createElement(t.Provider,PO(Nw({},n),{value:r.get(t)}))),e=>K.createElement(CT,Nw({},e))),[r])}const Cg={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function UO(r){const{handlePointer:e}=cO(r);return{priority:1,enabled:!0,compute(t,n,i){n.pointer.set(t.offsetX/n.size.width*2-1,-(t.offsetY/n.size.height)*2+1),n.raycaster.setFromCamera(n.pointer,n.camera)},connected:void 0,handlers:Object.keys(Cg).reduce((t,n)=>({...t,[n]:e(n)}),{}),update:()=>{var t;const{events:n,internal:i}=r.getState();(t=i.lastEvent)!=null&&t.current&&n.handlers&&n.handlers.onPointerMove(i.lastEvent.current)},connect:t=>{var n;const{set:i,events:s}=r.getState();s.disconnect==null||s.disconnect(),i(o=>({events:{...o.events,connected:t}})),Object.entries((n=s.handlers)!=null?n:[]).forEach(([o,a])=>{const[l,c]=Cg[o];t.addEventListener(l,a,{passive:c})})},disconnect:()=>{const{set:t,events:n}=r.getState();if(n.connected){var i;Object.entries((i=n.handlers)!=null?i:[]).forEach(([s,o])=>{if(n&&n.connected instanceof HTMLElement){const[a]=Cg[s];n.connected.removeEventListener(a,o)}}),t(s=>({events:{...s.events,connected:void 0}}))}}}}const OO=K.forwardRef(function({children:e,fallback:t,resize:n,style:i,gl:s,events:o=UO,eventSource:a,eventPrefix:l,shadows:c,linear:u,flat:h,legacy:p,orthographic:m,frameloop:v,dpr:_,performance:y,raycaster:g,camera:x,onPointerMissed:w,onCreated:E,...b},M){K.useMemo(()=>hT(uT),[]);const A=DO(),[P,C]=xO({scroll:!0,debounce:{scroll:50,resize:0},...n}),L=K.useRef(null),F=K.useRef(null);K.useImperativeHandle(M,()=>L.current);const N=pT(w),[I,X]=K.useState(!1),[q,W]=K.useState(!1);if(I)throw I;if(q)throw q;const O=K.useRef(null);hh(()=>{const G=L.current;C.width>0&&C.height>0&&G&&(O.current||(O.current=yO(G)),O.current.configure({gl:s,events:o,shadows:c,linear:u,flat:h,legacy:p,orthographic:m,frameloop:v,dpr:_,performance:y,raycaster:g,camera:x,size:C,onPointerMissed:(...B)=>N.current==null?void 0:N.current(...B),onCreated:B=>{B.events.connect==null||B.events.connect(a?nO(a)?a.current:a:F.current),l&&B.setEvents({compute:(D,V)=>{const Z=D[l+"X"],ee=D[l+"Y"];V.pointer.set(Z/V.size.width*2-1,-(ee/V.size.height)*2+1),V.raycaster.setFromCamera(V.pointer,V.camera)}}),E==null||E(B)}}),O.current.render(K.createElement(A,null,K.createElement(mT,{set:W},K.createElement(K.Suspense,{fallback:K.createElement(iO,{set:X})},e)))))}),K.useEffect(()=>{const G=L.current;if(G)return()=>bT(G)},[]);const k=a?"none":"auto";return K.createElement("div",Ta({ref:F,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:k,...i}},b),K.createElement("div",{ref:P,style:{width:"100%",height:"100%"}},K.createElement("canvas",{ref:L,style:{display:"block"}},t)))}),NO=K.forwardRef(function(e,t){return K.createElement(CT,null,K.createElement(OO,Ta({},e,{ref:t})))});function FO(r,e,t){var n,i=1;r==null&&(r=0),e==null&&(e=0),t==null&&(t=0);function s(){var o,a=n.length,l,c=0,u=0,h=0;for(o=0;o<a;++o)l=n[o],c+=l.x||0,u+=l.y||0,h+=l.z||0;for(c=(c/a-r)*i,u=(u/a-e)*i,h=(h/a-t)*i,o=0;o<a;++o)l=n[o],c&&(l.x-=c),u&&(l.y-=u),h&&(l.z-=h)}return s.initialize=function(o){n=o},s.x=function(o){return arguments.length?(r=+o,s):r},s.y=function(o){return arguments.length?(e=+o,s):e},s.z=function(o){return arguments.length?(t=+o,s):t},s.strength=function(o){return arguments.length?(i=+o,s):i},s}function kO(r){const e=+this._x.call(null,r);return RT(this.cover(e),e,r)}function RT(r,e,t){if(isNaN(e))return r;var n,i=r._root,s={data:t},o=r._x0,a=r._x1,l,c,u,h,p;if(!i)return r._root=s,r;for(;i.length;)if((u=e>=(l=(o+a)/2))?o=l:a=l,n=i,!(i=i[h=+u]))return n[h]=s,r;if(c=+r._x.call(null,i.data),e===c)return s.next=i,n?n[h]=s:r._root=s,r;do n=n?n[h]=new Array(2):r._root=new Array(2),(u=e>=(l=(o+a)/2))?o=l:a=l;while((h=+u)==(p=+(c>=l)));return n[p]=i,n[h]=s,r}function zO(r){Array.isArray(r)||(r=Array.from(r));const e=r.length,t=new Float64Array(e);let n=1/0,i=-1/0;for(let s=0,o;s<e;++s)isNaN(o=+this._x.call(null,r[s]))||(t[s]=o,o<n&&(n=o),o>i&&(i=o));if(n>i)return this;this.cover(n).cover(i);for(let s=0;s<e;++s)RT(this,t[s],r[s]);return this}function BO(r){if(isNaN(r=+r))return this;var e=this._x0,t=this._x1;if(isNaN(e))t=(e=Math.floor(r))+1;else{for(var n=t-e||1,i=this._root,s,o;e>r||r>=t;)switch(o=+(r<e),s=new Array(2),s[o]=i,i=s,n*=2,o){case 0:t=e+n;break;case 1:e=t-n;break}this._root&&this._root.length&&(this._root=i)}return this._x0=e,this._x1=t,this}function GO(){var r=[];return this.visit(function(e){if(!e.length)do r.push(e.data);while(e=e.next)}),r}function HO(r){return arguments.length?this.cover(+r[0][0]).cover(+r[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function ks(r,e,t){this.node=r,this.x0=e,this.x1=t}function VO(r,e){var t,n=this._x0,i,s,o=this._x1,a=[],l=this._root,c,u;for(l&&a.push(new ks(l,n,o)),e==null?e=1/0:(n=r-e,o=r+e);c=a.pop();)if(!(!(l=c.node)||(i=c.x0)>o||(s=c.x1)<n))if(l.length){var h=(i+s)/2;a.push(new ks(l[1],h,s),new ks(l[0],i,h)),(u=+(r>=h))&&(c=a[a.length-1],a[a.length-1]=a[a.length-1-u],a[a.length-1-u]=c)}else{var p=Math.abs(r-+this._x.call(null,l.data));p<e&&(e=p,n=r-p,o=r+p,t=l.data)}return t}function WO(r){if(isNaN(l=+this._x.call(null,r)))return this;var e,t=this._root,n,i,s,o=this._x0,a=this._x1,l,c,u,h,p;if(!t)return this;if(t.length)for(;;){if((u=l>=(c=(o+a)/2))?o=c:a=c,e=t,!(t=t[h=+u]))return this;if(!t.length)break;e[h+1&1]&&(n=e,p=h)}for(;t.data!==r;)if(i=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,i?(s?i.next=s:delete i.next,this):e?(s?e[h]=s:delete e[h],(t=e[0]||e[1])&&t===(e[1]||e[0])&&!t.length&&(n?n[p]=t:this._root=t),this):(this._root=s,this)}function XO(r){for(var e=0,t=r.length;e<t;++e)this.remove(r[e]);return this}function jO(){return this._root}function YO(){var r=0;return this.visit(function(e){if(!e.length)do++r;while(e=e.next)}),r}function qO(r){var e=[],t,n=this._root,i,s,o;for(n&&e.push(new ks(n,this._x0,this._x1));t=e.pop();)if(!r(n=t.node,s=t.x0,o=t.x1)&&n.length){var a=(s+o)/2;(i=n[1])&&e.push(new ks(i,a,o)),(i=n[0])&&e.push(new ks(i,s,a))}return this}function ZO(r){var e=[],t=[],n;for(this._root&&e.push(new ks(this._root,this._x0,this._x1));n=e.pop();){var i=n.node;if(i.length){var s,o=n.x0,a=n.x1,l=(o+a)/2;(s=i[0])&&e.push(new ks(s,o,l)),(s=i[1])&&e.push(new ks(s,l,a))}t.push(n)}for(;n=t.pop();)r(n.node,n.x0,n.x1);return this}function KO(r){return r[0]}function $O(r){return arguments.length?(this._x=r,this):this._x}function Fy(r,e){var t=new ky(e??KO,NaN,NaN);return r==null?t:t.addAll(r)}function ky(r,e,t){this._x=r,this._x0=e,this._x1=t,this._root=void 0}function Bw(r){for(var e={data:r.data},t=e;r=r.next;)t=t.next={data:r.data};return e}var Hi=Fy.prototype=ky.prototype;Hi.copy=function(){var r=new ky(this._x,this._x0,this._x1),e=this._root,t,n;if(!e)return r;if(!e.length)return r._root=Bw(e),r;for(t=[{source:e,target:r._root=new Array(2)}];e=t.pop();)for(var i=0;i<2;++i)(n=e.source[i])&&(n.length?t.push({source:n,target:e.target[i]=new Array(2)}):e.target[i]=Bw(n));return r};Hi.add=kO;Hi.addAll=zO;Hi.cover=BO;Hi.data=GO;Hi.extent=HO;Hi.find=VO;Hi.remove=WO;Hi.removeAll=XO;Hi.root=jO;Hi.size=YO;Hi.visit=qO;Hi.visitAfter=ZO;Hi.x=$O;function JO(r){const e=+this._x.call(null,r),t=+this._y.call(null,r);return PT(this.cover(e,t),e,t,r)}function PT(r,e,t,n){if(isNaN(e)||isNaN(t))return r;var i,s=r._root,o={data:n},a=r._x0,l=r._y0,c=r._x1,u=r._y1,h,p,m,v,_,y,g,x;if(!s)return r._root=o,r;for(;s.length;)if((_=e>=(h=(a+c)/2))?a=h:c=h,(y=t>=(p=(l+u)/2))?l=p:u=p,i=s,!(s=s[g=y<<1|_]))return i[g]=o,r;if(m=+r._x.call(null,s.data),v=+r._y.call(null,s.data),e===m&&t===v)return o.next=s,i?i[g]=o:r._root=o,r;do i=i?i[g]=new Array(4):r._root=new Array(4),(_=e>=(h=(a+c)/2))?a=h:c=h,(y=t>=(p=(l+u)/2))?l=p:u=p;while((g=y<<1|_)===(x=(v>=p)<<1|m>=h));return i[x]=s,i[g]=o,r}function QO(r){var e,t,n=r.length,i,s,o=new Array(n),a=new Array(n),l=1/0,c=1/0,u=-1/0,h=-1/0;for(t=0;t<n;++t)isNaN(i=+this._x.call(null,e=r[t]))||isNaN(s=+this._y.call(null,e))||(o[t]=i,a[t]=s,i<l&&(l=i),i>u&&(u=i),s<c&&(c=s),s>h&&(h=s));if(l>u||c>h)return this;for(this.cover(l,c).cover(u,h),t=0;t<n;++t)PT(this,o[t],a[t],r[t]);return this}function eN(r,e){if(isNaN(r=+r)||isNaN(e=+e))return this;var t=this._x0,n=this._y0,i=this._x1,s=this._y1;if(isNaN(t))i=(t=Math.floor(r))+1,s=(n=Math.floor(e))+1;else{for(var o=i-t||1,a=this._root,l,c;t>r||r>=i||n>e||e>=s;)switch(c=(e<n)<<1|r<t,l=new Array(4),l[c]=a,a=l,o*=2,c){case 0:i=t+o,s=n+o;break;case 1:t=i-o,s=n+o;break;case 2:i=t+o,n=s-o;break;case 3:t=i-o,n=s-o;break}this._root&&this._root.length&&(this._root=a)}return this._x0=t,this._y0=n,this._x1=i,this._y1=s,this}function tN(){var r=[];return this.visit(function(e){if(!e.length)do r.push(e.data);while(e=e.next)}),r}function nN(r){return arguments.length?this.cover(+r[0][0],+r[0][1]).cover(+r[1][0],+r[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function Ri(r,e,t,n,i){this.node=r,this.x0=e,this.y0=t,this.x1=n,this.y1=i}function iN(r,e,t){var n,i=this._x0,s=this._y0,o,a,l,c,u=this._x1,h=this._y1,p=[],m=this._root,v,_;for(m&&p.push(new Ri(m,i,s,u,h)),t==null?t=1/0:(i=r-t,s=e-t,u=r+t,h=e+t,t*=t);v=p.pop();)if(!(!(m=v.node)||(o=v.x0)>u||(a=v.y0)>h||(l=v.x1)<i||(c=v.y1)<s))if(m.length){var y=(o+l)/2,g=(a+c)/2;p.push(new Ri(m[3],y,g,l,c),new Ri(m[2],o,g,y,c),new Ri(m[1],y,a,l,g),new Ri(m[0],o,a,y,g)),(_=(e>=g)<<1|r>=y)&&(v=p[p.length-1],p[p.length-1]=p[p.length-1-_],p[p.length-1-_]=v)}else{var x=r-+this._x.call(null,m.data),w=e-+this._y.call(null,m.data),E=x*x+w*w;if(E<t){var b=Math.sqrt(t=E);i=r-b,s=e-b,u=r+b,h=e+b,n=m.data}}return n}function rN(r){if(isNaN(u=+this._x.call(null,r))||isNaN(h=+this._y.call(null,r)))return this;var e,t=this._root,n,i,s,o=this._x0,a=this._y0,l=this._x1,c=this._y1,u,h,p,m,v,_,y,g;if(!t)return this;if(t.length)for(;;){if((v=u>=(p=(o+l)/2))?o=p:l=p,(_=h>=(m=(a+c)/2))?a=m:c=m,e=t,!(t=t[y=_<<1|v]))return this;if(!t.length)break;(e[y+1&3]||e[y+2&3]||e[y+3&3])&&(n=e,g=y)}for(;t.data!==r;)if(i=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,i?(s?i.next=s:delete i.next,this):e?(s?e[y]=s:delete e[y],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[g]=t:this._root=t),this):(this._root=s,this)}function sN(r){for(var e=0,t=r.length;e<t;++e)this.remove(r[e]);return this}function oN(){return this._root}function aN(){var r=0;return this.visit(function(e){if(!e.length)do++r;while(e=e.next)}),r}function lN(r){var e=[],t,n=this._root,i,s,o,a,l;for(n&&e.push(new Ri(n,this._x0,this._y0,this._x1,this._y1));t=e.pop();)if(!r(n=t.node,s=t.x0,o=t.y0,a=t.x1,l=t.y1)&&n.length){var c=(s+a)/2,u=(o+l)/2;(i=n[3])&&e.push(new Ri(i,c,u,a,l)),(i=n[2])&&e.push(new Ri(i,s,u,c,l)),(i=n[1])&&e.push(new Ri(i,c,o,a,u)),(i=n[0])&&e.push(new Ri(i,s,o,c,u))}return this}function cN(r){var e=[],t=[],n;for(this._root&&e.push(new Ri(this._root,this._x0,this._y0,this._x1,this._y1));n=e.pop();){var i=n.node;if(i.length){var s,o=n.x0,a=n.y0,l=n.x1,c=n.y1,u=(o+l)/2,h=(a+c)/2;(s=i[0])&&e.push(new Ri(s,o,a,u,h)),(s=i[1])&&e.push(new Ri(s,u,a,l,h)),(s=i[2])&&e.push(new Ri(s,o,h,u,c)),(s=i[3])&&e.push(new Ri(s,u,h,l,c))}t.push(n)}for(;n=t.pop();)r(n.node,n.x0,n.y0,n.x1,n.y1);return this}function uN(r){return r[0]}function hN(r){return arguments.length?(this._x=r,this):this._x}function fN(r){return r[1]}function dN(r){return arguments.length?(this._y=r,this):this._y}function zy(r,e,t){var n=new By(e??uN,t??fN,NaN,NaN,NaN,NaN);return r==null?n:n.addAll(r)}function By(r,e,t,n,i,s){this._x=r,this._y=e,this._x0=t,this._y0=n,this._x1=i,this._y1=s,this._root=void 0}function Gw(r){for(var e={data:r.data},t=e;r=r.next;)t=t.next={data:r.data};return e}var Li=zy.prototype=By.prototype;Li.copy=function(){var r=new By(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,t,n;if(!e)return r;if(!e.length)return r._root=Gw(e),r;for(t=[{source:e,target:r._root=new Array(4)}];e=t.pop();)for(var i=0;i<4;++i)(n=e.source[i])&&(n.length?t.push({source:n,target:e.target[i]=new Array(4)}):e.target[i]=Gw(n));return r};Li.add=JO;Li.addAll=QO;Li.cover=eN;Li.data=tN;Li.extent=nN;Li.find=iN;Li.remove=rN;Li.removeAll=sN;Li.root=oN;Li.size=aN;Li.visit=lN;Li.visitAfter=cN;Li.x=hN;Li.y=dN;function pN(r){const e=+this._x.call(null,r),t=+this._y.call(null,r),n=+this._z.call(null,r);return LT(this.cover(e,t,n),e,t,n,r)}function LT(r,e,t,n,i){if(isNaN(e)||isNaN(t)||isNaN(n))return r;var s,o=r._root,a={data:i},l=r._x0,c=r._y0,u=r._z0,h=r._x1,p=r._y1,m=r._z1,v,_,y,g,x,w,E,b,M,A,P;if(!o)return r._root=a,r;for(;o.length;)if((E=e>=(v=(l+h)/2))?l=v:h=v,(b=t>=(_=(c+p)/2))?c=_:p=_,(M=n>=(y=(u+m)/2))?u=y:m=y,s=o,!(o=o[A=M<<2|b<<1|E]))return s[A]=a,r;if(g=+r._x.call(null,o.data),x=+r._y.call(null,o.data),w=+r._z.call(null,o.data),e===g&&t===x&&n===w)return a.next=o,s?s[A]=a:r._root=a,r;do s=s?s[A]=new Array(8):r._root=new Array(8),(E=e>=(v=(l+h)/2))?l=v:h=v,(b=t>=(_=(c+p)/2))?c=_:p=_,(M=n>=(y=(u+m)/2))?u=y:m=y;while((A=M<<2|b<<1|E)===(P=(w>=y)<<2|(x>=_)<<1|g>=v));return s[P]=o,s[A]=a,r}function mN(r){Array.isArray(r)||(r=Array.from(r));const e=r.length,t=new Float64Array(e),n=new Float64Array(e),i=new Float64Array(e);let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0;for(let h=0,p,m,v,_;h<e;++h)isNaN(m=+this._x.call(null,p=r[h]))||isNaN(v=+this._y.call(null,p))||isNaN(_=+this._z.call(null,p))||(t[h]=m,n[h]=v,i[h]=_,m<s&&(s=m),m>l&&(l=m),v<o&&(o=v),v>c&&(c=v),_<a&&(a=_),_>u&&(u=_));if(s>l||o>c||a>u)return this;this.cover(s,o,a).cover(l,c,u);for(let h=0;h<e;++h)LT(this,t[h],n[h],i[h],r[h]);return this}function gN(r,e,t){if(isNaN(r=+r)||isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,i=this._y0,s=this._z0,o=this._x1,a=this._y1,l=this._z1;if(isNaN(n))o=(n=Math.floor(r))+1,a=(i=Math.floor(e))+1,l=(s=Math.floor(t))+1;else{for(var c=o-n||1,u=this._root,h,p;n>r||r>=o||i>e||e>=a||s>t||t>=l;)switch(p=(t<s)<<2|(e<i)<<1|r<n,h=new Array(8),h[p]=u,u=h,c*=2,p){case 0:o=n+c,a=i+c,l=s+c;break;case 1:n=o-c,a=i+c,l=s+c;break;case 2:o=n+c,i=a-c,l=s+c;break;case 3:n=o-c,i=a-c,l=s+c;break;case 4:o=n+c,a=i+c,s=l-c;break;case 5:n=o-c,a=i+c,s=l-c;break;case 6:o=n+c,i=a-c,s=l-c;break;case 7:n=o-c,i=a-c,s=l-c;break}this._root&&this._root.length&&(this._root=u)}return this._x0=n,this._y0=i,this._z0=s,this._x1=o,this._y1=a,this._z1=l,this}function vN(){var r=[];return this.visit(function(e){if(!e.length)do r.push(e.data);while(e=e.next)}),r}function yN(r){return arguments.length?this.cover(+r[0][0],+r[0][1],+r[0][2]).cover(+r[1][0],+r[1][1],+r[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function rn(r,e,t,n,i,s,o){this.node=r,this.x0=e,this.y0=t,this.z0=n,this.x1=i,this.y1=s,this.z1=o}function _N(r,e,t,n){var i,s=this._x0,o=this._y0,a=this._z0,l,c,u,h,p,m,v=this._x1,_=this._y1,y=this._z1,g=[],x=this._root,w,E;for(x&&g.push(new rn(x,s,o,a,v,_,y)),n==null?n=1/0:(s=r-n,o=e-n,a=t-n,v=r+n,_=e+n,y=t+n,n*=n);w=g.pop();)if(!(!(x=w.node)||(l=w.x0)>v||(c=w.y0)>_||(u=w.z0)>y||(h=w.x1)<s||(p=w.y1)<o||(m=w.z1)<a))if(x.length){var b=(l+h)/2,M=(c+p)/2,A=(u+m)/2;g.push(new rn(x[7],b,M,A,h,p,m),new rn(x[6],l,M,A,b,p,m),new rn(x[5],b,c,A,h,M,m),new rn(x[4],l,c,A,b,M,m),new rn(x[3],b,M,u,h,p,A),new rn(x[2],l,M,u,b,p,A),new rn(x[1],b,c,u,h,M,A),new rn(x[0],l,c,u,b,M,A)),(E=(t>=A)<<2|(e>=M)<<1|r>=b)&&(w=g[g.length-1],g[g.length-1]=g[g.length-1-E],g[g.length-1-E]=w)}else{var P=r-+this._x.call(null,x.data),C=e-+this._y.call(null,x.data),L=t-+this._z.call(null,x.data),F=P*P+C*C+L*L;if(F<n){var N=Math.sqrt(n=F);s=r-N,o=e-N,a=t-N,v=r+N,_=e+N,y=t+N,i=x.data}}return i}const xN=(r,e,t,n,i,s)=>Math.sqrt((r-n)**2+(e-i)**2+(t-s)**2);function wN(r,e,t,n){const i=[],s=r-n,o=e-n,a=t-n,l=r+n,c=e+n,u=t+n;return this.visit((h,p,m,v,_,y,g)=>{if(!h.length)do{const x=h.data;xN(r,e,t,this._x(x),this._y(x),this._z(x))<=n&&i.push(x)}while(h=h.next);return p>l||m>c||v>u||_<s||y<o||g<a}),i}function SN(r){if(isNaN(p=+this._x.call(null,r))||isNaN(m=+this._y.call(null,r))||isNaN(v=+this._z.call(null,r)))return this;var e,t=this._root,n,i,s,o=this._x0,a=this._y0,l=this._z0,c=this._x1,u=this._y1,h=this._z1,p,m,v,_,y,g,x,w,E,b,M;if(!t)return this;if(t.length)for(;;){if((x=p>=(_=(o+c)/2))?o=_:c=_,(w=m>=(y=(a+u)/2))?a=y:u=y,(E=v>=(g=(l+h)/2))?l=g:h=g,e=t,!(t=t[b=E<<2|w<<1|x]))return this;if(!t.length)break;(e[b+1&7]||e[b+2&7]||e[b+3&7]||e[b+4&7]||e[b+5&7]||e[b+6&7]||e[b+7&7])&&(n=e,M=b)}for(;t.data!==r;)if(i=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,i?(s?i.next=s:delete i.next,this):e?(s?e[b]=s:delete e[b],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[M]=t:this._root=t),this):(this._root=s,this)}function EN(r){for(var e=0,t=r.length;e<t;++e)this.remove(r[e]);return this}function bN(){return this._root}function MN(){var r=0;return this.visit(function(e){if(!e.length)do++r;while(e=e.next)}),r}function TN(r){var e=[],t,n=this._root,i,s,o,a,l,c,u;for(n&&e.push(new rn(n,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=e.pop();)if(!r(n=t.node,s=t.x0,o=t.y0,a=t.z0,l=t.x1,c=t.y1,u=t.z1)&&n.length){var h=(s+l)/2,p=(o+c)/2,m=(a+u)/2;(i=n[7])&&e.push(new rn(i,h,p,m,l,c,u)),(i=n[6])&&e.push(new rn(i,s,p,m,h,c,u)),(i=n[5])&&e.push(new rn(i,h,o,m,l,p,u)),(i=n[4])&&e.push(new rn(i,s,o,m,h,p,u)),(i=n[3])&&e.push(new rn(i,h,p,a,l,c,m)),(i=n[2])&&e.push(new rn(i,s,p,a,h,c,m)),(i=n[1])&&e.push(new rn(i,h,o,a,l,p,m)),(i=n[0])&&e.push(new rn(i,s,o,a,h,p,m))}return this}function AN(r){var e=[],t=[],n;for(this._root&&e.push(new rn(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));n=e.pop();){var i=n.node;if(i.length){var s,o=n.x0,a=n.y0,l=n.z0,c=n.x1,u=n.y1,h=n.z1,p=(o+c)/2,m=(a+u)/2,v=(l+h)/2;(s=i[0])&&e.push(new rn(s,o,a,l,p,m,v)),(s=i[1])&&e.push(new rn(s,p,a,l,c,m,v)),(s=i[2])&&e.push(new rn(s,o,m,l,p,u,v)),(s=i[3])&&e.push(new rn(s,p,m,l,c,u,v)),(s=i[4])&&e.push(new rn(s,o,a,v,p,m,h)),(s=i[5])&&e.push(new rn(s,p,a,v,c,m,h)),(s=i[6])&&e.push(new rn(s,o,m,v,p,u,h)),(s=i[7])&&e.push(new rn(s,p,m,v,c,u,h))}t.push(n)}for(;n=t.pop();)r(n.node,n.x0,n.y0,n.z0,n.x1,n.y1,n.z1);return this}function CN(r){return r[0]}function RN(r){return arguments.length?(this._x=r,this):this._x}function PN(r){return r[1]}function LN(r){return arguments.length?(this._y=r,this):this._y}function IN(r){return r[2]}function DN(r){return arguments.length?(this._z=r,this):this._z}function Gy(r,e,t,n){var i=new Hy(e??CN,t??PN,n??IN,NaN,NaN,NaN,NaN,NaN,NaN);return r==null?i:i.addAll(r)}function Hy(r,e,t,n,i,s,o,a,l){this._x=r,this._y=e,this._z=t,this._x0=n,this._y0=i,this._z0=s,this._x1=o,this._y1=a,this._z1=l,this._root=void 0}function Hw(r){for(var e={data:r.data},t=e;r=r.next;)t=t.next={data:r.data};return e}var ai=Gy.prototype=Hy.prototype;ai.copy=function(){var r=new Hy(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),e=this._root,t,n;if(!e)return r;if(!e.length)return r._root=Hw(e),r;for(t=[{source:e,target:r._root=new Array(8)}];e=t.pop();)for(var i=0;i<8;++i)(n=e.source[i])&&(n.length?t.push({source:n,target:e.target[i]=new Array(8)}):e.target[i]=Hw(n));return r};ai.add=pN;ai.addAll=mN;ai.cover=gN;ai.data=vN;ai.extent=yN;ai.find=_N;ai.findAllWithinRadius=wN;ai.remove=SN;ai.removeAll=EN;ai.root=bN;ai.size=MN;ai.visit=TN;ai.visitAfter=AN;ai.x=RN;ai.y=LN;ai.z=DN;function xn(r){return function(){return r}}function xr(r){return(r()-.5)*1e-6}function Rg(r){return r.x+r.vx}function Vw(r){return r.y+r.vy}function UN(r){return r.z+r.vz}function IT(r){var e,t,n,i,s=1,o=1;typeof r!="function"&&(r=xn(r==null?1:+r));function a(){for(var u,h=e.length,p,m,v,_,y,g,x,w=0;w<o;++w)for(p=(t===1?Fy(e,Rg):t===2?zy(e,Rg,Vw):t===3?Gy(e,Rg,Vw,UN):null).visitAfter(l),u=0;u<h;++u)m=e[u],g=n[m.index],x=g*g,v=m.x+m.vx,t>1&&(_=m.y+m.vy),t>2&&(y=m.z+m.vz),p.visit(E);function E(b,M,A,P,C,L,F){var N=[M,A,P,C,L,F],I=N[0],X=N[1],q=N[2],W=N[t],O=N[t+1],k=N[t+2],G=b.data,B=b.r,D=g+B;if(G){if(G.index>m.index){var V=v-G.x-G.vx,Z=t>1?_-G.y-G.vy:0,ee=t>2?y-G.z-G.vz:0,ie=V*V+Z*Z+ee*ee;ie<D*D&&(V===0&&(V=xr(i),ie+=V*V),t>1&&Z===0&&(Z=xr(i),ie+=Z*Z),t>2&&ee===0&&(ee=xr(i),ie+=ee*ee),ie=(D-(ie=Math.sqrt(ie)))/ie*s,m.vx+=(V*=ie)*(D=(B*=B)/(x+B)),t>1&&(m.vy+=(Z*=ie)*D),t>2&&(m.vz+=(ee*=ie)*D),G.vx-=V*(D=1-D),t>1&&(G.vy-=Z*D),t>2&&(G.vz-=ee*D))}return}return I>v+D||W<v-D||t>1&&(X>_+D||O<_-D)||t>2&&(q>y+D||k<y-D)}}function l(u){if(u.data)return u.r=n[u.data.index];for(var h=u.r=0;h<Math.pow(2,t);++h)u[h]&&u[h].r>u.r&&(u.r=u[h].r)}function c(){if(e){var u,h=e.length,p;for(n=new Array(h),u=0;u<h;++u)p=e[u],n[p.index]=+r(p,u,e)}}return a.initialize=function(u,...h){e=u,i=h.find(p=>typeof p=="function")||Math.random,t=h.find(p=>[1,2,3].includes(p))||2,c()},a.iterations=function(u){return arguments.length?(o=+u,a):o},a.strength=function(u){return arguments.length?(s=+u,a):s},a.radius=function(u){return arguments.length?(r=typeof u=="function"?u:xn(+u),c(),a):r},a}function ON(r){return r.index}function Ww(r,e){var t=r.get(e);if(!t)throw new Error("node not found: "+e);return t}function DT(r){var e=ON,t=p,n,i=xn(30),s,o,a,l,c,u,h=1;r==null&&(r=[]);function p(g){return 1/Math.min(l[g.source.index],l[g.target.index])}function m(g){for(var x=0,w=r.length;x<h;++x)for(var E=0,b,M,A,P=0,C=0,L=0,F,N;E<w;++E)b=r[E],M=b.source,A=b.target,P=A.x+A.vx-M.x-M.vx||xr(u),a>1&&(C=A.y+A.vy-M.y-M.vy||xr(u)),a>2&&(L=A.z+A.vz-M.z-M.vz||xr(u)),F=Math.sqrt(P*P+C*C+L*L),F=(F-s[E])/F*g*n[E],P*=F,C*=F,L*=F,A.vx-=P*(N=c[E]),a>1&&(A.vy-=C*N),a>2&&(A.vz-=L*N),M.vx+=P*(N=1-N),a>1&&(M.vy+=C*N),a>2&&(M.vz+=L*N)}function v(){if(o){var g,x=o.length,w=r.length,E=new Map(o.map((M,A)=>[e(M,A,o),M])),b;for(g=0,l=new Array(x);g<w;++g)b=r[g],b.index=g,typeof b.source!="object"&&(b.source=Ww(E,b.source)),typeof b.target!="object"&&(b.target=Ww(E,b.target)),l[b.source.index]=(l[b.source.index]||0)+1,l[b.target.index]=(l[b.target.index]||0)+1;for(g=0,c=new Array(w);g<w;++g)b=r[g],c[g]=l[b.source.index]/(l[b.source.index]+l[b.target.index]);n=new Array(w),_(),s=new Array(w),y()}}function _(){if(o)for(var g=0,x=r.length;g<x;++g)n[g]=+t(r[g],g,r)}function y(){if(o)for(var g=0,x=r.length;g<x;++g)s[g]=+i(r[g],g,r)}return m.initialize=function(g,...x){o=g,u=x.find(w=>typeof w=="function")||Math.random,a=x.find(w=>[1,2,3].includes(w))||2,v()},m.links=function(g){return arguments.length?(r=g,v(),m):r},m.id=function(g){return arguments.length?(e=g,m):e},m.iterations=function(g){return arguments.length?(h=+g,m):h},m.strength=function(g){return arguments.length?(t=typeof g=="function"?g:xn(+g),_(),m):t},m.distance=function(g){return arguments.length?(i=typeof g=="function"?g:xn(+g),y(),m):i},m}var NN={value:()=>{}};function UT(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Md(t)}function Md(r){this._=r}function FN(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");if(i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Md.prototype=UT.prototype={constructor:Md,on:function(r,e){var t=this._,n=FN(r+"",t),i,s=-1,o=n.length;if(arguments.length<2){for(;++s<o;)if((i=(r=n[s]).type)&&(i=kN(t[i],r.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(i=(r=n[s]).type)t[i]=Xw(t[i],r.name,e);else if(e==null)for(i in t)t[i]=Xw(t[i],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new Md(r)},call:function(r,e){if((i=arguments.length-2)>0)for(var t=new Array(i),n=0,i,s;n<i;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(s=this._[r],n=0,i=s.length;n<i;++n)s[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],i=0,s=n.length;i<s;++i)n[i].value.apply(e,t)}};function kN(r,e){for(var t=0,n=r.length,i;t<n;++t)if((i=r[t]).name===e)return i.value}function Xw(r,e,t){for(var n=0,i=r.length;n<i;++n)if(r[n].name===e){r[n]=NN,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var Yl=0,du=0,Gc=0,OT=1e3,Fd,pu,kd=0,Aa=0,bp=0,Yu=typeof performance=="object"&&performance.now?performance:Date,NT=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function FT(){return Aa||(NT(zN),Aa=Yu.now()+bp)}function zN(){Aa=0}function yv(){this._call=this._time=this._next=null}yv.prototype=kT.prototype={constructor:yv,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?FT():+t)+(e==null?0:+e),!this._next&&pu!==this&&(pu?pu._next=this:Fd=this,pu=this),this._call=r,this._time=t,_v()},stop:function(){this._call&&(this._call=null,this._time=1/0,_v())}};function kT(r,e,t){var n=new yv;return n.restart(r,e,t),n}function BN(){FT(),++Yl;for(var r=Fd,e;r;)(e=Aa-r._time)>=0&&r._call.call(void 0,e),r=r._next;--Yl}function jw(){Aa=(kd=Yu.now())+bp,Yl=du=0;try{BN()}finally{Yl=0,HN(),Aa=0}}function GN(){var r=Yu.now(),e=r-kd;e>OT&&(bp-=e,kd=r)}function HN(){for(var r,e=Fd,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:Fd=t);pu=r,_v(n)}function _v(r){if(!Yl){du&&(du=clearTimeout(du));var e=r-Aa;e>24?(r<1/0&&(du=setTimeout(jw,r-Yu.now()-bp)),Gc&&(Gc=clearInterval(Gc))):(Gc||(kd=Yu.now(),Gc=setInterval(GN,OT)),Yl=1,NT(jw))}}const VN=1664525,WN=1013904223,Yw=4294967296;function XN(){let r=1;return()=>(r=(VN*r+WN)%Yw)/Yw}var qw=3;function Pg(r){return r.x}function Zw(r){return r.y}function jN(r){return r.z}var YN=10,qN=Math.PI*(3-Math.sqrt(5)),ZN=Math.PI*20/(9+Math.sqrt(221));function zT(r,e){e=e||2;var t=Math.min(qw,Math.max(1,Math.round(e))),n,i=1,s=.001,o=1-Math.pow(s,1/300),a=0,l=.6,c=new Map,u=kT(m),h=UT("tick","end"),p=XN();r==null&&(r=[]);function m(){v(),h.call("tick",n),i<s&&(u.stop(),h.call("end",n))}function v(g){var x,w=r.length,E;g===void 0&&(g=1);for(var b=0;b<g;++b)for(i+=(a-i)*o,c.forEach(function(M){M(i)}),x=0;x<w;++x)E=r[x],E.fx==null?E.x+=E.vx*=l:(E.x=E.fx,E.vx=0),t>1&&(E.fy==null?E.y+=E.vy*=l:(E.y=E.fy,E.vy=0)),t>2&&(E.fz==null?E.z+=E.vz*=l:(E.z=E.fz,E.vz=0));return n}function _(){for(var g=0,x=r.length,w;g<x;++g){if(w=r[g],w.index=g,w.fx!=null&&(w.x=w.fx),w.fy!=null&&(w.y=w.fy),w.fz!=null&&(w.z=w.fz),isNaN(w.x)||t>1&&isNaN(w.y)||t>2&&isNaN(w.z)){var E=YN*(t>2?Math.cbrt(.5+g):t>1?Math.sqrt(.5+g):g),b=g*qN,M=g*ZN;t===1?w.x=E:t===2?(w.x=E*Math.cos(b),w.y=E*Math.sin(b)):(w.x=E*Math.sin(b)*Math.cos(M),w.y=E*Math.cos(b),w.z=E*Math.sin(b)*Math.sin(M))}(isNaN(w.vx)||t>1&&isNaN(w.vy)||t>2&&isNaN(w.vz))&&(w.vx=0,t>1&&(w.vy=0),t>2&&(w.vz=0))}}function y(g){return g.initialize&&g.initialize(r,p,t),g}return _(),n={tick:v,restart:function(){return u.restart(m),n},stop:function(){return u.stop(),n},numDimensions:function(g){return arguments.length?(t=Math.min(qw,Math.max(1,Math.round(g))),c.forEach(y),n):t},nodes:function(g){return arguments.length?(r=g,_(),c.forEach(y),n):r},alpha:function(g){return arguments.length?(i=+g,n):i},alphaMin:function(g){return arguments.length?(s=+g,n):s},alphaDecay:function(g){return arguments.length?(o=+g,n):+o},alphaTarget:function(g){return arguments.length?(a=+g,n):a},velocityDecay:function(g){return arguments.length?(l=1-g,n):1-l},randomSource:function(g){return arguments.length?(p=g,c.forEach(y),n):p},force:function(g,x){return arguments.length>1?(x==null?c.delete(g):c.set(g,y(x)),n):c.get(g)},find:function(){var g=Array.prototype.slice.call(arguments),x=g.shift()||0,w=(t>1?g.shift():null)||0,E=(t>2?g.shift():null)||0,b=g.shift()||1/0,M=0,A=r.length,P,C,L,F,N,I;for(b*=b,M=0;M<A;++M)N=r[M],P=x-N.x,C=w-(N.y||0),L=E-(N.z||0),F=P*P+C*C+L*L,F<b&&(I=N,b=F);return I},on:function(g,x){return arguments.length>1?(h.on(g,x),n):h.on(g)}}}function BT(){var r,e,t,n,i,s=xn(-30),o,a=1,l=1/0,c=.81;function u(v){var _,y=r.length,g=(e===1?Fy(r,Pg):e===2?zy(r,Pg,Zw):e===3?Gy(r,Pg,Zw,jN):null).visitAfter(p);for(i=v,_=0;_<y;++_)t=r[_],g.visit(m)}function h(){if(r){var v,_=r.length,y;for(o=new Array(_),v=0;v<_;++v)y=r[v],o[y.index]=+s(y,v,r)}}function p(v){var _=0,y,g,x=0,w,E,b,M,A=v.length;if(A){for(w=E=b=M=0;M<A;++M)(y=v[M])&&(g=Math.abs(y.value))&&(_+=y.value,x+=g,w+=g*(y.x||0),E+=g*(y.y||0),b+=g*(y.z||0));_*=Math.sqrt(4/A),v.x=w/x,e>1&&(v.y=E/x),e>2&&(v.z=b/x)}else{y=v,y.x=y.data.x,e>1&&(y.y=y.data.y),e>2&&(y.z=y.data.z);do _+=o[y.data.index];while(y=y.next)}v.value=_}function m(v,_,y,g,x){if(!v.value)return!0;var w=[y,g,x][e-1],E=v.x-t.x,b=e>1?v.y-t.y:0,M=e>2?v.z-t.z:0,A=w-_,P=E*E+b*b+M*M;if(A*A/c<P)return P<l&&(E===0&&(E=xr(n),P+=E*E),e>1&&b===0&&(b=xr(n),P+=b*b),e>2&&M===0&&(M=xr(n),P+=M*M),P<a&&(P=Math.sqrt(a*P)),t.vx+=E*v.value*i/P,e>1&&(t.vy+=b*v.value*i/P),e>2&&(t.vz+=M*v.value*i/P)),!0;if(v.length||P>=l)return;(v.data!==t||v.next)&&(E===0&&(E=xr(n),P+=E*E),e>1&&b===0&&(b=xr(n),P+=b*b),e>2&&M===0&&(M=xr(n),P+=M*M),P<a&&(P=Math.sqrt(a*P)));do v.data!==t&&(A=o[v.data.index]*i/P,t.vx+=E*A,e>1&&(t.vy+=b*A),e>2&&(t.vz+=M*A));while(v=v.next)}return u.initialize=function(v,..._){r=v,n=_.find(y=>typeof y=="function")||Math.random,e=_.find(y=>[1,2,3].includes(y))||2,h()},u.strength=function(v){return arguments.length?(s=typeof v=="function"?v:xn(+v),h(),u):s},u.distanceMin=function(v){return arguments.length?(a=v*v,u):Math.sqrt(a)},u.distanceMax=function(v){return arguments.length?(l=v*v,u):Math.sqrt(l)},u.theta=function(v){return arguments.length?(c=v*v,u):Math.sqrt(c)},u}function KN(r,e,t,n){var i,s,o=xn(.1),a,l;typeof r!="function"&&(r=xn(+r)),e==null&&(e=0),t==null&&(t=0),n==null&&(n=0);function c(h){for(var p=0,m=i.length;p<m;++p){var v=i[p],_=v.x-e||1e-6,y=(v.y||0)-t||1e-6,g=(v.z||0)-n||1e-6,x=Math.sqrt(_*_+y*y+g*g),w=(l[p]-x)*a[p]*h/x;v.vx+=_*w,s>1&&(v.vy+=y*w),s>2&&(v.vz+=g*w)}}function u(){if(i){var h,p=i.length;for(a=new Array(p),l=new Array(p),h=0;h<p;++h)l[h]=+r(i[h],h,i),a[h]=isNaN(l[h])?0:+o(i[h],h,i)}}return c.initialize=function(h,...p){i=h,s=p.find(m=>[1,2,3].includes(m))||2,u()},c.strength=function(h){return arguments.length?(o=typeof h=="function"?h:xn(+h),u(),c):o},c.radius=function(h){return arguments.length?(r=typeof h=="function"?h:xn(+h),u(),c):r},c.x=function(h){return arguments.length?(e=+h,c):e},c.y=function(h){return arguments.length?(t=+h,c):t},c.z=function(h){return arguments.length?(n=+h,c):n},c}function xv(r){var e=xn(.1),t,n,i;typeof r!="function"&&(r=xn(r==null?0:+r));function s(a){for(var l=0,c=t.length,u;l<c;++l)u=t[l],u.vx+=(i[l]-u.x)*n[l]*a}function o(){if(t){var a,l=t.length;for(n=new Array(l),i=new Array(l),a=0;a<l;++a)n[a]=isNaN(i[a]=+r(t[a],a,t))?0:+e(t[a],a,t)}}return s.initialize=function(a){t=a,o()},s.strength=function(a){return arguments.length?(e=typeof a=="function"?a:xn(+a),o(),s):e},s.x=function(a){return arguments.length?(r=typeof a=="function"?a:xn(+a),o(),s):r},s}function wv(r){var e=xn(.1),t,n,i;typeof r!="function"&&(r=xn(r==null?0:+r));function s(a){for(var l=0,c=t.length,u;l<c;++l)u=t[l],u.vy+=(i[l]-u.y)*n[l]*a}function o(){if(t){var a,l=t.length;for(n=new Array(l),i=new Array(l),a=0;a<l;++a)n[a]=isNaN(i[a]=+r(t[a],a,t))?0:+e(t[a],a,t)}}return s.initialize=function(a){t=a,o()},s.strength=function(a){return arguments.length?(e=typeof a=="function"?a:xn(+a),o(),s):e},s.y=function(a){return arguments.length?(r=typeof a=="function"?a:xn(+a),o(),s):r},s}function $N(r){var e=xn(.1),t,n,i;typeof r!="function"&&(r=xn(r==null?0:+r));function s(a){for(var l=0,c=t.length,u;l<c;++l)u=t[l],u.vz+=(i[l]-u.z)*n[l]*a}function o(){if(t){var a,l=t.length;for(n=new Array(l),i=new Array(l),a=0;a<l;++a)n[a]=isNaN(i[a]=+r(t[a],a,t))?0:+e(t[a],a,t)}}return s.initialize=function(a){t=a,o()},s.strength=function(a){return arguments.length?(e=typeof a=="function"?a:xn(+a),o(),s):e},s.z=function(a){return arguments.length?(r=typeof a=="function"?a:xn(+a),o(),s):r},s}function JN(r){var e=0,t=r.children,n=t&&t.length;if(!n)e=1;else for(;--n>=0;)e+=t[n].value;r.value=e}function QN(){return this.eachAfter(JN)}function eF(r,e){let t=-1;for(const n of this)r.call(e,n,++t,this);return this}function tF(r,e){for(var t=this,n=[t],i,s,o=-1;t=n.pop();)if(r.call(e,t,++o,this),i=t.children)for(s=i.length-1;s>=0;--s)n.push(i[s]);return this}function nF(r,e){for(var t=this,n=[t],i=[],s,o,a,l=-1;t=n.pop();)if(i.push(t),s=t.children)for(o=0,a=s.length;o<a;++o)n.push(s[o]);for(;t=i.pop();)r.call(e,t,++l,this);return this}function iF(r,e){let t=-1;for(const n of this)if(r.call(e,n,++t,this))return n}function rF(r){return this.eachAfter(function(e){for(var t=+r(e.data)||0,n=e.children,i=n&&n.length;--i>=0;)t+=n[i].value;e.value=t})}function sF(r){return this.eachBefore(function(e){e.children&&e.children.sort(r)})}function oF(r){for(var e=this,t=aF(e,r),n=[e];e!==t;)e=e.parent,n.push(e);for(var i=n.length;r!==t;)n.splice(i,0,r),r=r.parent;return n}function aF(r,e){if(r===e)return r;var t=r.ancestors(),n=e.ancestors(),i=null;for(r=t.pop(),e=n.pop();r===e;)i=r,r=t.pop(),e=n.pop();return i}function lF(){for(var r=this,e=[r];r=r.parent;)e.push(r);return e}function cF(){return Array.from(this)}function uF(){var r=[];return this.eachBefore(function(e){e.children||r.push(e)}),r}function hF(){var r=this,e=[];return r.each(function(t){t!==r&&e.push({source:t.parent,target:t})}),e}function*fF(){var r=this,e,t=[r],n,i,s;do for(e=t.reverse(),t=[];r=e.pop();)if(yield r,n=r.children)for(i=0,s=n.length;i<s;++i)t.push(n[i]);while(t.length)}function Mp(r,e){r instanceof Map?(r=[void 0,r],e===void 0&&(e=mF)):e===void 0&&(e=pF);for(var t=new ql(r),n,i=[t],s,o,a,l;n=i.pop();)if((o=e(n.data))&&(l=(o=Array.from(o)).length))for(n.children=o,a=l-1;a>=0;--a)i.push(s=o[a]=new ql(o[a])),s.parent=n,s.depth=n.depth+1;return t.eachBefore(GT)}function dF(){return Mp(this).eachBefore(gF)}function pF(r){return r.children}function mF(r){return Array.isArray(r)?r[1]:null}function gF(r){r.data.value!==void 0&&(r.value=r.data.value),r.data=r.data.data}function GT(r){var e=0;do r.height=e;while((r=r.parent)&&r.height<++e)}function ql(r){this.data=r,this.depth=this.height=0,this.parent=null}ql.prototype=Mp.prototype={constructor:ql,count:QN,each:eF,eachAfter:nF,eachBefore:tF,find:iF,sum:rF,sort:sF,path:oF,ancestors:lF,descendants:cF,leaves:uF,links:hF,copy:dF,[Symbol.iterator]:fF};function Lg(r){return r==null?null:HT(r)}function HT(r){if(typeof r!="function")throw new Error;return r}function Hc(){return 0}function Vc(r){return function(){return r}}function vF(r){r.x0=Math.round(r.x0),r.y0=Math.round(r.y0),r.x1=Math.round(r.x1),r.y1=Math.round(r.y1)}function yF(r,e,t,n,i){for(var s=r.children,o,a=-1,l=s.length,c=r.value&&(n-e)/r.value;++a<l;)o=s[a],o.y0=t,o.y1=i,o.x0=e,o.x1=e+=o.value*c}var _F={depth:-1},Kw={},Ig={};function xF(r){return r.id}function wF(r){return r.parentId}function SF(){var r=xF,e=wF,t;function n(i){var s=Array.from(i),o=r,a=e,l,c,u,h,p,m,v,_,y=new Map;if(t!=null){const g=s.map((E,b)=>EF(t(E,b,i))),x=g.map($w),w=new Set(g).add("");for(const E of x)w.has(E)||(w.add(E),g.push(E),x.push($w(E)),s.push(Ig));o=(E,b)=>g[b],a=(E,b)=>x[b]}for(u=0,l=s.length;u<l;++u)c=s[u],m=s[u]=new ql(c),(v=o(c,u,i))!=null&&(v+="")&&(_=m.id=v,y.set(_,y.has(_)?Kw:m)),(v=a(c,u,i))!=null&&(v+="")&&(m.parent=v);for(u=0;u<l;++u)if(m=s[u],v=m.parent){if(p=y.get(v),!p)throw new Error("missing: "+v);if(p===Kw)throw new Error("ambiguous: "+v);p.children?p.children.push(m):p.children=[m],m.parent=p}else{if(h)throw new Error("multiple roots");h=m}if(!h)throw new Error("no root");if(t!=null){for(;h.data===Ig&&h.children.length===1;)h=h.children[0],--l;for(let g=s.length-1;g>=0&&(m=s[g],m.data===Ig);--g)m.data=null}if(h.parent=_F,h.eachBefore(function(g){g.depth=g.parent.depth+1,--l}).eachBefore(GT),h.parent=null,l>0)throw new Error("cycle");return h}return n.id=function(i){return arguments.length?(r=Lg(i),n):r},n.parentId=function(i){return arguments.length?(e=Lg(i),n):e},n.path=function(i){return arguments.length?(t=Lg(i),n):t},n}function EF(r){r=`${r}`;let e=r.length;return Sv(r,e-1)&&!Sv(r,e-2)&&(r=r.slice(0,-1)),r[0]==="/"?r:`/${r}`}function $w(r){let e=r.length;if(e<2)return"";for(;--e>1&&!Sv(r,e););return r.slice(0,e)}function Sv(r,e){if(r[e]==="/"){let t=0;for(;e>0&&r[--e]==="\\";)++t;if((t&1)===0)return!0}return!1}function bF(r,e){return r.parent===e.parent?1:2}function Dg(r){var e=r.children;return e?e[0]:r.t}function Ug(r){var e=r.children;return e?e[e.length-1]:r.t}function MF(r,e,t){var n=t/(e.i-r.i);e.c-=n,e.s+=t,r.c+=n,e.z+=t,e.m+=t}function TF(r){for(var e=0,t=0,n=r.children,i=n.length,s;--i>=0;)s=n[i],s.z+=e,s.m+=e,e+=s.s+(t+=s.c)}function AF(r,e,t){return r.a.parent===e.parent?r.a:t}function Td(r,e){this._=r,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=e}Td.prototype=Object.create(ql.prototype);function CF(r){for(var e=new Td(r,0),t,n=[e],i,s,o,a;t=n.pop();)if(s=t._.children)for(t.children=new Array(a=s.length),o=a-1;o>=0;--o)n.push(i=t.children[o]=new Td(s[o],o)),i.parent=t;return(e.parent=new Td(null,0)).children=[e],e}function RF(){var r=bF,e=1,t=1,n=null;function i(c){var u=CF(c);if(u.eachAfter(s),u.parent.m=-u.z,u.eachBefore(o),n)c.eachBefore(l);else{var h=c,p=c,m=c;c.eachBefore(function(x){x.x<h.x&&(h=x),x.x>p.x&&(p=x),x.depth>m.depth&&(m=x)});var v=h===p?1:r(h,p)/2,_=v-h.x,y=e/(p.x+v+_),g=t/(m.depth||1);c.eachBefore(function(x){x.x=(x.x+_)*y,x.y=x.depth*g})}return c}function s(c){var u=c.children,h=c.parent.children,p=c.i?h[c.i-1]:null;if(u){TF(c);var m=(u[0].z+u[u.length-1].z)/2;p?(c.z=p.z+r(c._,p._),c.m=c.z-m):c.z=m}else p&&(c.z=p.z+r(c._,p._));c.parent.A=a(c,p,c.parent.A||h[0])}function o(c){c._.x=c.z+c.parent.m,c.m+=c.parent.m}function a(c,u,h){if(u){for(var p=c,m=c,v=u,_=p.parent.children[0],y=p.m,g=m.m,x=v.m,w=_.m,E;v=Ug(v),p=Dg(p),v&&p;)_=Dg(_),m=Ug(m),m.a=c,E=v.z+x-p.z-y+r(v._,p._),E>0&&(MF(AF(v,c,h),c,E),y+=E,g+=E),x+=v.m,y+=p.m,w+=_.m,g+=m.m;v&&!Ug(m)&&(m.t=v,m.m+=x-g),p&&!Dg(_)&&(_.t=p,_.m+=y-w,h=c)}return h}function l(c){c.x*=e,c.y=c.depth*t}return i.separation=function(c){return arguments.length?(r=c,i):r},i.size=function(c){return arguments.length?(n=!1,e=+c[0],t=+c[1],i):n?null:[e,t]},i.nodeSize=function(c){return arguments.length?(n=!0,e=+c[0],t=+c[1],i):n?[e,t]:null},i}function PF(r,e,t,n,i){for(var s=r.children,o,a=-1,l=s.length,c=r.value&&(i-t)/r.value;++a<l;)o=s[a],o.x0=e,o.x1=n,o.y0=t,o.y1=t+=o.value*c}var LF=(1+Math.sqrt(5))/2;function IF(r,e,t,n,i,s){for(var o=[],a=e.children,l,c,u=0,h=0,p=a.length,m,v,_=e.value,y,g,x,w,E,b,M;u<p;){m=i-t,v=s-n;do y=a[h++].value;while(!y&&h<p);for(g=x=y,b=Math.max(v/m,m/v)/(_*r),M=y*y*b,E=Math.max(x/M,M/g);h<p;++h){if(y+=c=a[h].value,c<g&&(g=c),c>x&&(x=c),M=y*y*b,w=Math.max(x/M,M/g),w>E){y-=c;break}E=w}o.push(l={value:y,dice:m<v,children:a.slice(u,h)}),l.dice?yF(l,t,n,i,_?n+=v*y/_:s):PF(l,t,n,_?t+=m*y/_:i,s),_-=y,u=h}return o}const DF=(function r(e){function t(n,i,s,o,a){IF(e,n,i,s,o,a)}return t.ratio=function(n){return r((n=+n)>1?n:1)},t})(LF);function UF(){var r=DF,e=!1,t=1,n=1,i=[0],s=Hc,o=Hc,a=Hc,l=Hc,c=Hc;function u(p){return p.x0=p.y0=0,p.x1=t,p.y1=n,p.eachBefore(h),i=[0],e&&p.eachBefore(vF),p}function h(p){var m=i[p.depth],v=p.x0+m,_=p.y0+m,y=p.x1-m,g=p.y1-m;y<v&&(v=y=(v+y)/2),g<_&&(_=g=(_+g)/2),p.x0=v,p.y0=_,p.x1=y,p.y1=g,p.children&&(m=i[p.depth+1]=s(p)/2,v+=c(p)-m,_+=o(p)-m,y-=a(p)-m,g-=l(p)-m,y<v&&(v=y=(v+y)/2),g<_&&(_=g=(_+g)/2),r(p,v,_,y,g))}return u.round=function(p){return arguments.length?(e=!!p,u):e},u.size=function(p){return arguments.length?(t=+p[0],n=+p[1],u):[t,n]},u.tile=function(p){return arguments.length?(r=HT(p),u):r},u.padding=function(p){return arguments.length?u.paddingInner(p).paddingOuter(p):u.paddingInner()},u.paddingInner=function(p){return arguments.length?(s=typeof p=="function"?p:Vc(+p),u):s},u.paddingOuter=function(p){return arguments.length?u.paddingTop(p).paddingRight(p).paddingBottom(p).paddingLeft(p):u.paddingTop()},u.paddingTop=function(p){return arguments.length?(o=typeof p=="function"?p:Vc(+p),u):o},u.paddingRight=function(p){return arguments.length?(a=typeof p=="function"?p:Vc(+p),u):a},u.paddingBottom=function(p){return arguments.length?(l=typeof p=="function"?p:Vc(+p),u):l},u.paddingLeft=function(p){return arguments.length?(c=typeof p=="function"?p:Vc(+p),u):c},u}var Og,Jw;function Vy(){if(Jw)return Og;Jw=1;function r(t){return!t||typeof t!="object"||typeof t=="function"||Array.isArray(t)||t instanceof Set||t instanceof Map||t instanceof RegExp||t instanceof Date}function e(t,n){t=t||{};var i={};for(var s in n){var o=t[s],a=n[s];if(!r(a)){i[s]=e(o,a);continue}o===void 0?i[s]=a:i[s]=o}return i}return Og=e,Og}var Ng,Qw;function Xs(){return Qw||(Qw=1,Ng=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}),Ng}var Fg,eS;function OF(){if(eS)return Fg;eS=1;var r=Vy(),e=Xs(),t={dimensions:["x","y"],center:.5,scale:1};function n(s,o,a){if(!e(o))throw new Error("graphology-layout/random: the given graph is not a valid graphology instance.");a=r(a,t);var l=a.dimensions;if(!Array.isArray(l)||l.length!==2)throw new Error("graphology-layout/random: given dimensions are invalid.");var c=a.center,u=a.scale,h=Math.PI*2,p=(c-.5)*u,m=o.order,v=l[0],_=l[1];function y(w,E){return E[v]=u*Math.cos(w*h/m)+p,E[_]=u*Math.sin(w*h/m)+p,E}var g=0;if(!s){var x={};return o.forEachNode(function(w){x[w]=y(g++,{})}),x}o.updateEachNodeAttributes(function(w,E){return y(g++,E),E},{attributes:l})}var i=n.bind(null,!1);return i.assign=n.bind(null,!0),Fg=i,Fg}var NF=OF();const FF=Hr(NF);var kg,tS;function kF(){if(tS)return kg;tS=1;var r=0,e=1,t=2,n=3;function i(o,a){return o+"§"+a}function s(){return .01*(.5-Math.random())}return kg=function(a,l){var c=a.margin,u=a.ratio,h=a.expansion,p=a.gridSize,m=a.speed,v,_,y,g,x,w,E=!0,b=l.length,M=b/n|0,A=new Float32Array(M),P=new Float32Array(M),C=1/0,L=1/0,F=-1/0,N=-1/0;for(v=0;v<b;v+=n)y=l[v+r],g=l[v+e],w=l[v+t]*u+c,C=Math.min(C,y-w),F=Math.max(F,y+w),L=Math.min(L,g-w),N=Math.max(N,g+w);var I=F-C,X=N-L,q=(C+F)/2,W=(L+N)/2;C=q-h*I/2,F=q+h*I/2,L=W-h*X/2,N=W+h*X/2;var O=new Array(p*p),k=O.length,G;for(G=0;G<k;G++)O[G]=[];var B,D,V,Z,ee,ie,ue,ce,le,Ae;for(v=0;v<b;v+=n)for(y=l[v+r],g=l[v+e],w=l[v+t]*u+c,B=y-w,D=y+w,V=g-w,Z=g+w,ee=Math.floor(p*(B-C)/(F-C)),ie=Math.floor(p*(D-C)/(F-C)),ue=Math.floor(p*(V-L)/(N-L)),ce=Math.floor(p*(Z-L)/(N-L)),le=ee;le<=ie;le++)for(Ae=ue;Ae<=ce;Ae++)O[le*p+Ae].push(v);var Ee,ae=new Set,z,oe,te,se,$,Ie,de,Se,Le,ge,He,j,H;for(G=0;G<k;G++)for(Ee=O[G],v=0,x=Ee.length;v<x;v++)for(z=Ee[v],te=l[z+r],$=l[z+e],de=l[z+t],_=v+1;_<x;_++)oe=Ee[_],Le=i(z,oe),!(k>1&&ae.has(Le))&&(k>1&&ae.add(Le),se=l[oe+r],Ie=l[oe+e],Se=l[oe+t],ge=se-te,He=Ie-$,j=Math.sqrt(ge*ge+He*He),H=j<de*u+c+(Se*u+c),H&&(E=!1,oe=oe/n|0,j>0?(A[oe]+=ge/j*(1+de),P[oe]+=He/j*(1+de)):(A[oe]+=I*s(),P[oe]+=X*s())));for(v=0,_=0;v<b;v+=n,_++)l[v+r]+=A[_]*.1*m,l[v+e]+=P[_]*.1*m;return{converged:E}},kg}var ea={},nS;function zF(){if(nS)return ea;nS=1;var r=3;return ea.validateSettings=function(e){return"gridSize"in e&&typeof e.gridSize!="number"||e.gridSize<=0?{message:"the `gridSize` setting should be a positive number."}:"margin"in e&&typeof e.margin!="number"||e.margin<0?{message:"the `margin` setting should be 0 or a positive number."}:"expansion"in e&&typeof e.expansion!="number"||e.expansion<=0?{message:"the `expansion` setting should be a positive number."}:"ratio"in e&&typeof e.ratio!="number"||e.ratio<=0?{message:"the `ratio` setting should be a positive number."}:"speed"in e&&typeof e.speed!="number"||e.speed<=0?{message:"the `speed` setting should be a positive number."}:null},ea.graphToByteArray=function(e,t){var n=e.order,i=new Float32Array(n*r),s=0;return e.forEachNode(function(o,a){typeof t=="function"&&(a=t(o,a)),i[s]=a.x,i[s+1]=a.y,i[s+2]=a.size||1,s+=r}),i},ea.assignLayoutChanges=function(e,t,n){var i=0;e.forEachNode(function(s){var o={x:t[i],y:t[i+1]};typeof n=="function"&&(o=n(s,o)),e.mergeNodeAttributes(s,o),i+=r})},ea.collectLayoutChanges=function(e,t,n){var i={},s=0;return e.forEachNode(function(o){var a={x:t[s],y:t[s+1]};typeof n=="function"&&(a=n(o,a)),i[o]=a,s+=r}),i},ea.createWorker=function(t){var n=window.URL||window.webkitURL,i=t.toString(),s=n.createObjectURL(new Blob(["("+i+").call(this);"],{type:"text/javascript"})),o=new Worker(s);return n.revokeObjectURL(s),o},ea}var zg,iS;function BF(){return iS||(iS=1,zg={gridSize:20,margin:5,expansion:1.1,ratio:1,speed:3}),zg}var Bg,rS;function GF(){if(rS)return Bg;rS=1;var r=Xs(),e=kF(),t=zF(),n=BF(),i=500;function s(a,l,c){if(!r(l))throw new Error("graphology-layout-noverlap: the given graph is not a valid graphology instance.");typeof c=="number"?c={maxIterations:c}:c=c||{};var u=c.maxIterations||i;if(typeof u!="number"||u<=0)throw new Error("graphology-layout-force: you should provide a positive number of maximum iterations.");var h=Object.assign({},n,c.settings),p=t.validateSettings(h);if(p)throw new Error("graphology-layout-noverlap: "+p.message);var m=t.graphToByteArray(l,c.inputReducer),v=!1,_;for(_=0;_<u&&!v;_++)v=e(h,m).converged;if(a){t.assignLayoutChanges(l,m,c.outputReducer);return}return t.collectLayoutChanges(l,m,c.outputReducer)}var o=s.bind(null,!1);return o.assign=s.bind(null,!0),Bg=o,Bg}var HF=GF();const VF=Hr(HF);var Wc={},sS;function Tp(){if(sS)return Wc;sS=1;function r(n){return typeof n!="number"||isNaN(n)?1:n}function e(n,i){var s={},o=function(c){return typeof c>"u"?i:c};typeof i=="function"&&(o=i);var a=function(c){return o(c[n])},l=function(){return o(void 0)};return typeof n=="string"?(s.fromAttributes=a,s.fromGraph=function(c,u){return a(c.getNodeAttributes(u))},s.fromEntry=function(c,u){return a(u)}):typeof n=="function"?(s.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},s.fromGraph=function(c,u){return o(n(u,c.getNodeAttributes(u)))},s.fromEntry=function(c,u){return o(n(c,u))}):(s.fromAttributes=l,s.fromGraph=l,s.fromEntry=l),s}function t(n,i){var s={},o=function(c){return typeof c>"u"?i:c};typeof i=="function"&&(o=i);var a=function(c){return o(c[n])},l=function(){return o(void 0)};return typeof n=="string"?(s.fromAttributes=a,s.fromGraph=function(c,u){return a(c.getEdgeAttributes(u))},s.fromEntry=function(c,u){return a(u)},s.fromPartialEntry=s.fromEntry,s.fromMinimalEntry=s.fromEntry):typeof n=="function"?(s.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},s.fromGraph=function(c,u){var h=c.extremities(u);return o(n(u,c.getEdgeAttributes(u),h[0],h[1],c.getNodeAttributes(h[0]),c.getNodeAttributes(h[1]),c.isUndirected(u)))},s.fromEntry=function(c,u,h,p,m,v,_){return o(n(c,u,h,p,m,v,_))},s.fromPartialEntry=function(c,u,h,p){return o(n(c,u,h,p))},s.fromMinimalEntry=function(c,u){return o(n(c,u))}):(s.fromAttributes=l,s.fromGraph=l,s.fromEntry=l,s.fromMinimalEntry=l),s}return Wc.createNodeValueGetter=e,Wc.createEdgeValueGetter=t,Wc.createEdgeWeightGetter=function(n){return t(n,r)},Wc}var Gg,oS;function WF(){if(oS)return Gg;oS=1;var r=0,e=1,t=2,n=3,i=4,s=5,o=6,a=7,l=8,c=9,u=0,h=1,p=2,m=0,v=1,_=2,y=3,g=4,x=5,w=6,E=7,b=8,M=3,A=10,P=3,C=9,L=10;return Gg=function(N,I,X){var q,W,O,k,G,B,D,V,Z,ee,ie=I.length,ue=X.length,ce=N.adjustSizes,le=N.barnesHutTheta*N.barnesHutTheta,Ae,Ee,ae,z,oe,te,se,$=[];for(O=0;O<ie;O+=A)I[O+i]=I[O+t],I[O+s]=I[O+n],I[O+t]=0,I[O+n]=0;if(N.outboundAttractionDistribution){for(Ae=0,O=0;O<ie;O+=A)Ae+=I[O+o];Ae/=ie/A}if(N.barnesHutOptimize){var Ie=1/0,de=-1/0,Se=1/0,Le=-1/0,ge,He,j;for(O=0;O<ie;O+=A)Ie=Math.min(Ie,I[O+r]),de=Math.max(de,I[O+r]),Se=Math.min(Se,I[O+e]),Le=Math.max(Le,I[O+e]);var H=de-Ie,ne=Le-Se;for(H>ne?(Se-=(H-ne)/2,Le=Se+H):(Ie-=(ne-H)/2,de=Ie+ne),$[0+m]=-1,$[0+v]=(Ie+de)/2,$[0+_]=(Se+Le)/2,$[0+y]=Math.max(de-Ie,Le-Se),$[0+g]=-1,$[0+x]=-1,$[0+w]=0,$[0+E]=0,$[0+b]=0,q=1,O=0;O<ie;O+=A)for(W=0,j=M;;)if($[W+x]>=0){I[O+r]<$[W+v]?I[O+e]<$[W+_]?ge=$[W+x]:ge=$[W+x]+C:I[O+e]<$[W+_]?ge=$[W+x]+C*2:ge=$[W+x]+C*3,$[W+E]=($[W+E]*$[W+w]+I[O+r]*I[O+o])/($[W+w]+I[O+o]),$[W+b]=($[W+b]*$[W+w]+I[O+e]*I[O+o])/($[W+w]+I[O+o]),$[W+w]+=I[O+o],W=ge;continue}else if($[W+m]<0){$[W+m]=O;break}else{if($[W+x]=q*C,V=$[W+y]/2,Z=$[W+x],$[Z+m]=-1,$[Z+v]=$[W+v]-V,$[Z+_]=$[W+_]-V,$[Z+y]=V,$[Z+g]=Z+C,$[Z+x]=-1,$[Z+w]=0,$[Z+E]=0,$[Z+b]=0,Z+=C,$[Z+m]=-1,$[Z+v]=$[W+v]-V,$[Z+_]=$[W+_]+V,$[Z+y]=V,$[Z+g]=Z+C,$[Z+x]=-1,$[Z+w]=0,$[Z+E]=0,$[Z+b]=0,Z+=C,$[Z+m]=-1,$[Z+v]=$[W+v]+V,$[Z+_]=$[W+_]-V,$[Z+y]=V,$[Z+g]=Z+C,$[Z+x]=-1,$[Z+w]=0,$[Z+E]=0,$[Z+b]=0,Z+=C,$[Z+m]=-1,$[Z+v]=$[W+v]+V,$[Z+_]=$[W+_]+V,$[Z+y]=V,$[Z+g]=$[W+g],$[Z+x]=-1,$[Z+w]=0,$[Z+E]=0,$[Z+b]=0,q+=4,I[$[W+m]+r]<$[W+v]?I[$[W+m]+e]<$[W+_]?ge=$[W+x]:ge=$[W+x]+C:I[$[W+m]+e]<$[W+_]?ge=$[W+x]+C*2:ge=$[W+x]+C*3,$[W+w]=I[$[W+m]+o],$[W+E]=I[$[W+m]+r],$[W+b]=I[$[W+m]+e],$[ge+m]=$[W+m],$[W+m]=-1,I[O+r]<$[W+v]?I[O+e]<$[W+_]?He=$[W+x]:He=$[W+x]+C:I[O+e]<$[W+_]?He=$[W+x]+C*2:He=$[W+x]+C*3,ge===He)if(j--){W=ge;continue}else{j=M;break}$[He+m]=O;break}}if(N.barnesHutOptimize)for(Ee=N.scalingRatio,O=0;O<ie;O+=A)for(W=0;;)if($[W+x]>=0)if(te=Math.pow(I[O+r]-$[W+E],2)+Math.pow(I[O+e]-$[W+b],2),ee=$[W+y],4*ee*ee/te<le){if(ae=I[O+r]-$[W+E],z=I[O+e]-$[W+b],ce===!0?te>0?(se=Ee*I[O+o]*$[W+w]/te,I[O+t]+=ae*se,I[O+n]+=z*se):te<0&&(se=-Ee*I[O+o]*$[W+w]/Math.sqrt(te),I[O+t]+=ae*se,I[O+n]+=z*se):te>0&&(se=Ee*I[O+o]*$[W+w]/te,I[O+t]+=ae*se,I[O+n]+=z*se),W=$[W+g],W<0)break;continue}else{W=$[W+x];continue}else{if(B=$[W+m],B>=0&&B!==O&&(ae=I[O+r]-I[B+r],z=I[O+e]-I[B+e],te=ae*ae+z*z,ce===!0?te>0?(se=Ee*I[O+o]*I[B+o]/te,I[O+t]+=ae*se,I[O+n]+=z*se):te<0&&(se=-Ee*I[O+o]*I[B+o]/Math.sqrt(te),I[O+t]+=ae*se,I[O+n]+=z*se):te>0&&(se=Ee*I[O+o]*I[B+o]/te,I[O+t]+=ae*se,I[O+n]+=z*se)),W=$[W+g],W<0)break;continue}else for(Ee=N.scalingRatio,k=0;k<ie;k+=A)for(G=0;G<k;G+=A)ae=I[k+r]-I[G+r],z=I[k+e]-I[G+e],ce===!0?(te=Math.sqrt(ae*ae+z*z)-I[k+l]-I[G+l],te>0?(se=Ee*I[k+o]*I[G+o]/te/te,I[k+t]+=ae*se,I[k+n]+=z*se,I[G+t]-=ae*se,I[G+n]-=z*se):te<0&&(se=100*Ee*I[k+o]*I[G+o],I[k+t]+=ae*se,I[k+n]+=z*se,I[G+t]-=ae*se,I[G+n]-=z*se)):(te=Math.sqrt(ae*ae+z*z),te>0&&(se=Ee*I[k+o]*I[G+o]/te/te,I[k+t]+=ae*se,I[k+n]+=z*se,I[G+t]-=ae*se,I[G+n]-=z*se));for(Z=N.gravity/N.scalingRatio,Ee=N.scalingRatio,O=0;O<ie;O+=A)se=0,ae=I[O+r],z=I[O+e],te=Math.sqrt(Math.pow(ae,2)+Math.pow(z,2)),N.strongGravityMode?te>0&&(se=Ee*I[O+o]*Z):te>0&&(se=Ee*I[O+o]*Z/te),I[O+t]-=ae*se,I[O+n]-=z*se;for(Ee=1*(N.outboundAttractionDistribution?Ae:1),D=0;D<ue;D+=P)k=X[D+u],G=X[D+h],V=X[D+p],oe=Math.pow(V,N.edgeWeightInfluence),ae=I[k+r]-I[G+r],z=I[k+e]-I[G+e],ce===!0?(te=Math.sqrt(ae*ae+z*z)-I[k+l]-I[G+l],N.linLogMode?N.outboundAttractionDistribution?te>0&&(se=-Ee*oe*Math.log(1+te)/te/I[k+o]):te>0&&(se=-Ee*oe*Math.log(1+te)/te):N.outboundAttractionDistribution?te>0&&(se=-Ee*oe/I[k+o]):te>0&&(se=-Ee*oe)):(te=Math.sqrt(Math.pow(ae,2)+Math.pow(z,2)),N.linLogMode?N.outboundAttractionDistribution?te>0&&(se=-Ee*oe*Math.log(1+te)/te/I[k+o]):te>0&&(se=-Ee*oe*Math.log(1+te)/te):N.outboundAttractionDistribution?(te=1,se=-Ee*oe/I[k+o]):(te=1,se=-Ee*oe)),te>0&&(I[k+t]+=ae*se,I[k+n]+=z*se,I[G+t]-=ae*se,I[G+n]-=z*se);var we,be,Me,Fe,Ue,xe;if(ce===!0)for(O=0;O<ie;O+=A)I[O+c]!==1&&(we=Math.sqrt(Math.pow(I[O+t],2)+Math.pow(I[O+n],2)),we>L&&(I[O+t]=I[O+t]*L/we,I[O+n]=I[O+n]*L/we),be=I[O+o]*Math.sqrt((I[O+i]-I[O+t])*(I[O+i]-I[O+t])+(I[O+s]-I[O+n])*(I[O+s]-I[O+n])),Me=Math.sqrt((I[O+i]+I[O+t])*(I[O+i]+I[O+t])+(I[O+s]+I[O+n])*(I[O+s]+I[O+n]))/2,Fe=.1*Math.log(1+Me)/(1+Math.sqrt(be)),Ue=I[O+r]+I[O+t]*(Fe/N.slowDown),I[O+r]=Ue,xe=I[O+e]+I[O+n]*(Fe/N.slowDown),I[O+e]=xe);else for(O=0;O<ie;O+=A)I[O+c]!==1&&(be=I[O+o]*Math.sqrt((I[O+i]-I[O+t])*(I[O+i]-I[O+t])+(I[O+s]-I[O+n])*(I[O+s]-I[O+n])),Me=Math.sqrt((I[O+i]+I[O+t])*(I[O+i]+I[O+t])+(I[O+s]+I[O+n])*(I[O+s]+I[O+n]))/2,Fe=I[O+a]*Math.log(1+Me)/(1+Math.sqrt(be)),I[O+a]=Math.min(1,Math.sqrt(Fe*(Math.pow(I[O+t],2)+Math.pow(I[O+n],2))/(1+Math.sqrt(be)))),Ue=I[O+r]+I[O+t]*(Fe/N.slowDown),I[O+r]=Ue,xe=I[O+e]+I[O+n]*(Fe/N.slowDown),I[O+e]=xe);return{}},Gg}var Rs={},aS;function XF(){if(aS)return Rs;aS=1;var r=10,e=3;return Rs.assign=function(t){t=t||{};var n=Array.prototype.slice.call(arguments).slice(1),i,s,o;for(i=0,o=n.length;i<o;i++)if(n[i])for(s in n[i])t[s]=n[i][s];return t},Rs.validateSettings=function(t){return"linLogMode"in t&&typeof t.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&typeof t.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&typeof t.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&typeof t.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in t&&!(typeof t.scalingRatio=="number"&&t.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in t&&typeof t.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in t&&!(typeof t.gravity=="number"&&t.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in t&&!(typeof t.slowDown=="number"||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&typeof t.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in t&&!(typeof t.barnesHutTheta=="number"&&t.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},Rs.graphToByteArrays=function(t,n){var i=t.order,s=t.size,o={},a,l=new Float32Array(i*r),c=new Float32Array(s*e);return a=0,t.forEachNode(function(u,h){o[u]=a,l[a]=h.x,l[a+1]=h.y,l[a+2]=0,l[a+3]=0,l[a+4]=0,l[a+5]=0,l[a+6]=1,l[a+7]=1,l[a+8]=h.size||1,l[a+9]=h.fixed?1:0,a+=r}),a=0,t.forEachEdge(function(u,h,p,m,v,_,y){var g=o[p],x=o[m],w=n(u,h,p,m,v,_,y);l[g+6]+=w,l[x+6]+=w,c[a]=g,c[a+1]=x,c[a+2]=w,a+=e}),{nodes:l,edges:c}},Rs.assignLayoutChanges=function(t,n,i){var s=0;t.updateEachNodeAttributes(function(o,a){return a.x=n[s],a.y=n[s+1],s+=r,i?i(o,a):a})},Rs.readGraphPositions=function(t,n){var i=0;t.forEachNode(function(s,o){n[i]=o.x,n[i+1]=o.y,i+=r})},Rs.collectLayoutChanges=function(t,n,i){for(var s=t.nodes(),o={},a=0,l=0,c=n.length;a<c;a+=r){if(i){var u=Object.assign({},t.getNodeAttributes(s[l]));u.x=n[a],u.y=n[a+1],u=i(s[l],u),o[s[l]]={x:u.x,y:u.y}}else o[s[l]]={x:n[a],y:n[a+1]};l++}return o},Rs.createWorker=function(n){var i=window.URL||window.webkitURL,s=n.toString(),o=i.createObjectURL(new Blob(["("+s+").call(this);"],{type:"text/javascript"})),a=new Worker(o);return i.revokeObjectURL(o),a},Rs}var Hg,lS;function jF(){return lS||(lS=1,Hg={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),Hg}var Vg,cS;function YF(){if(cS)return Vg;cS=1;var r=Xs(),e=Tp().createEdgeWeightGetter,t=WF(),n=XF(),i=jF();function s(l,c,u){if(!r(c))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof u=="number"&&(u={iterations:u});var h=u.iterations;if(typeof h!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(h<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var p=e("getEdgeWeight"in u?u.getEdgeWeight:"weight").fromEntry,m=typeof u.outputReducer=="function"?u.outputReducer:null,v=n.assign({},i,u.settings),_=n.validateSettings(v);if(_)throw new Error("graphology-layout-forceatlas2: "+_.message);var y=n.graphToByteArrays(c,p),g;for(g=0;g<h;g++)t(v,y.nodes,y.edges);if(l){n.assignLayoutChanges(c,y.nodes,m);return}return n.collectLayoutChanges(c,y.nodes)}function o(l){var c=typeof l=="number"?l:l.order;return{barnesHutOptimize:c>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(c)}}var a=s.bind(null,!1);return a.assign=s.bind(null,!0),a.inferSettings=o,Vg=a,Vg}var qF=YF();const ZF=Hr(qF);var Wg,uS;function KF(){if(uS)return Wg;uS=1;var r=Vy(),e=Xs(),t={dimensions:["x","y"],center:.5,rng:Math.random,scale:1};function n(s,o,a){if(!e(o))throw new Error("graphology-layout/random: the given graph is not a valid graphology instance.");a=r(a,t);var l=a.dimensions;if(!Array.isArray(l)||l.length<1)throw new Error("graphology-layout/random: given dimensions are invalid.");var c=l.length,u=a.center,h=a.rng,p=a.scale,m=(u-.5)*p;function v(y){for(var g=0;g<c;g++)y[l[g]]=h()*p+m;return y}if(!s){var _={};return o.forEachNode(function(y){_[y]=v({})}),_}o.updateEachNodeAttributes(function(y,g){return v(g),g},{attributes:l})}var i=n.bind(null,!1);return i.assign=n.bind(null,!0),Wg=i,Wg}var $F=KF();const JF=Hr($F);var td={},Xg={},hS;function VT(){return hS||(hS=1,(function(r){var e=Math.pow(2,8)-1,t=Math.pow(2,16)-1,n=Math.pow(2,32)-1,i=Math.pow(2,7)-1,s=Math.pow(2,15)-1,o=Math.pow(2,31)-1;r.getPointerArray=function(l){var c=l-1;if(c<=e)return Uint8Array;if(c<=t)return Uint16Array;if(c<=n)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")},r.getSignedPointerArray=function(l){var c=l-1;return c<=i?Int8Array:c<=s?Int16Array:c<=o?Int32Array:Float64Array},r.getNumberType=function(l){return l===(l|0)?Math.sign(l)===-1?l<=127&&l>=-128?Int8Array:l<=32767&&l>=-32768?Int16Array:Int32Array:l<=255?Uint8Array:l<=65535?Uint16Array:Uint32Array:Float64Array};var a={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};r.getMinimalRepresentation=function(l,c){var u=null,h=0,p,m,v,_,y;for(_=0,y=l.length;_<y;_++)v=c?c(l[_]):l[_],m=r.getNumberType(v),p=a[m.name],p>h&&(h=p,u=m);return u},r.isTypedArray=function(l){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(l)},r.concat=function(){var l=0,c,u,h;for(c=0,h=arguments.length;c<h;c++)l+=arguments[c].length;var p=new arguments[0].constructor(l);for(c=0,u=0;c<h;c++)p.set(arguments[c],u),u+=arguments[c].length;return p},r.indices=function(l){for(var c=r.getPointerArray(l),u=new c(l),h=0;h<l;h++)u[h]=h;return u}})(Xg)),Xg}var fS;function QF(){if(fS)return td;fS=1;var r=VT(),e=Tp().createEdgeWeightGetter;function t(s,o){return s==="outbound"||s==="inbound"?o.directedSize+o.undirectedSize*2:s==="in"||s==="out"||s==="directed"?o.directedSize:o.undirectedSize*2}function n(s,o){o=o||"outbound";var a=s[o+"Neighbors"].bind(s),l=t(o,s),c=r.getPointerArray(l),u=r.getPointerArray(s.order);this.graph=s,this.neighborhood=new u(l),this.starts=new c(s.order+1),this.nodes=s.nodes();var h={},p,m,v,_,y,g,x=0;for(p=0,m=s.order;p<m;p++)h[this.nodes[p]]=p;for(p=0,m=s.order;p<m;p++)for(y=this.nodes[p],g=a(y),this.starts[p]=x,v=0,_=g.length;v<_;v++)this.neighborhood[x++]=h[g[v]];this.starts[p]=l}n.prototype.bounds=function(s){return[this.starts[s],this.starts[s+1]]},n.prototype.project=function(){var s=this,o={};return s.nodes.forEach(function(a,l){o[a]=Array.from(s.neighborhood.slice(s.starts[l],s.starts[l+1])).map(function(c){return s.nodes[c]})}),o},n.prototype.collect=function(s){var o,a,l={};for(o=0,a=s.length;o<a;o++)l[this.nodes[o]]=s[o];return l},n.prototype.assign=function(s,o){var a=0;this.graph.updateEachNodeAttributes(function(l,c){return c[s]=o[a++],c},{attributes:[s]})},td.NeighborhoodIndex=n;function i(s,o,a){a=a||"outbound";var l=s[a+"Edges"].bind(s),c=t(a,s),u=r.getPointerArray(c),h=r.getPointerArray(s.order),p=e(o).fromMinimalEntry;this.graph=s,this.neighborhood=new h(c),this.weights=new Float64Array(c),this.outDegrees=new Float64Array(s.order),this.starts=new u(s.order+1),this.nodes=s.nodes();var m={},v,_,y,g,x,w,E,b,M,A=0;for(v=0,_=s.order;v<_;v++)m[this.nodes[v]]=v;for(v=0,_=s.order;v<_;v++)for(x=this.nodes[v],E=l(x),this.starts[v]=A,y=0,g=E.length;y<g;y++)b=E[y],w=s.opposite(x,b),M=p(b,s.getEdgeAttributes(b)),this.neighborhood[A]=m[w],this.weights[A++]=M,this.outDegrees[v]+=M;this.starts[v]=c}return i.prototype.bounds=n.prototype.bounds,i.prototype.project=n.prototype.project,i.prototype.collect=n.prototype.collect,i.prototype.assign=n.prototype.assign,td.WeightedNeighborhoodIndex=i,td}var jg,dS;function ek(){if(dS)return jg;dS=1;var r=Xs(),e=Vy(),t=QF().WeightedNeighborhoodIndex,n={nodePagerankAttribute:"pagerank",getEdgeWeight:"weight",alpha:.85,maxIterations:100,tolerance:1e-6};function i(o,a,l){if(!r(a))throw new Error("graphology-metrics/centrality/pagerank: the given graph is not a valid graphology instance.");l=e(l,n);var c=l.alpha,u=l.maxIterations,h=l.tolerance,p=l.nodePagerankAttribute,m=a.order,v=1/m,_=new t(a,l.getEdgeWeight),y,g,x,w,E=new Float64Array(a.order),b=new Float64Array(_.weights.length),M=[];for(y=0;y<m;y++)for(E[y]=v,x=_.starts[y+1],w=_.outDegrees[y],w===0&&M.push(y),g=_.starts[y];g<x;g++)b[g]=_.weights[g]/w;for(var A=0,P=0,C,L,F,N=!1;A<u;){for(F=E,E=new Float64Array(a.order),C=0,y=0,x=M.length;y<x;y++)C+=F[M[y]];for(C*=c,y=0;y<m;y++){for(x=_.starts[y+1],g=_.starts[y];g<x;g++)L=_.neighborhood[g],E[L]+=c*F[y]*b[g];E[y]+=C*v+(1-c)*v}for(P=0,y=0;y<m;y++)P+=Math.abs(E[y]-F[y]);if(P<m*h){N=!0;break}A++}if(!N)throw Error("graphology-metrics/centrality/pagerank: failed to converge.");if(o){_.assign(p,E);return}return _.collect(E)}var s=i.bind(null,!1);return s.assign=i.bind(null,!0),jg=s,jg}var tk=ek();const nk=Hr(tk);var Xc={},pS;function ik(){if(pS)return Xc;pS=1;var r=Xs();function e(s,o,a,l){var c=o+"Centrality";if(!r(a))throw new Error("graphology-centrality/"+c+": the given graph is not a valid graphology instance.");if(o!=="degree"&&a.type==="undirected")throw new Error("graphology-centrality/"+c+": cannot compute "+o+" centrality on an undirected graph.");l=l||{};var u=l.nodeCentralityAttribute||c,h=a.order-1,p=a[o].bind(a);if(s){a.updateEachNodeAttributes(function(v,_){return _[u]=p(v)/h,_},{attributes:[u]});return}var m={};return a.forEachNode(function(v){m[v]=p(v)/h}),m}var t=e.bind(null,!1,"degree"),n=e.bind(null,!1,"inDegree"),i=e.bind(null,!1,"outDegree");return t.assign=e.bind(null,!0,"degree"),n.assign=e.bind(null,!0,"inDegree"),i.assign=e.bind(null,!0,"outDegree"),Xc.degreeCentrality=t,Xc.inDegreeCentrality=n,Xc.outDegreeCentrality=i,Xc}var rk=ik();const sk={},mS=r=>{let e;const t=new Set,n=(l,c)=>{const u=typeof l=="function"?l(e):l;if(!Object.is(u,e)){const h=e;e=c??typeof u!="object"?u:Object.assign({},e,u),t.forEach(p=>p(e,h))}},i=()=>e,a={setState:n,getState:i,subscribe:l=>(t.add(l),()=>t.delete(l)),destroy:()=>{(sk?"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."),t.clear()}};return e=r(n,i,a),a},ok=r=>r?mS(r):mS;var Yg={exports:{}},qg={},Zg={exports:{}},Kg={};/**
|
|
* @license React
|
|
* use-sync-external-store-shim.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 gS;function ak(){if(gS)return Kg;gS=1;var r=Hv();function e(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var t=typeof Object.is=="function"?Object.is:e,n=r.useState,i=r.useEffect,s=r.useLayoutEffect,o=r.useDebugValue;function a(h,p){var m=p(),v=n({inst:{value:m,getSnapshot:p}}),_=v[0].inst,y=v[1];return s(function(){_.value=m,_.getSnapshot=p,l(_)&&y({inst:_})},[h,m,p]),i(function(){return l(_)&&y({inst:_}),h(function(){l(_)&&y({inst:_})})},[h]),o(m),m}function l(h){var p=h.getSnapshot;h=h.value;try{var m=p();return!t(h,m)}catch{return!0}}function c(h,p){return p()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return Kg.useSyncExternalStore=r.useSyncExternalStore!==void 0?r.useSyncExternalStore:u,Kg}var vS;function lk(){return vS||(vS=1,Zg.exports=ak()),Zg.exports}/**
|
|
* @license React
|
|
* use-sync-external-store-shim/with-selector.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 yS;function ck(){if(yS)return qg;yS=1;var r=Hv(),e=lk();function t(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:t,i=e.useSyncExternalStore,s=r.useRef,o=r.useEffect,a=r.useMemo,l=r.useDebugValue;return qg.useSyncExternalStoreWithSelector=function(c,u,h,p,m){var v=s(null);if(v.current===null){var _={hasValue:!1,value:null};v.current=_}else _=v.current;v=a(function(){function g(M){if(!x){if(x=!0,w=M,M=p(M),m!==void 0&&_.hasValue){var A=_.value;if(m(A,M))return E=A}return E=M}if(A=E,n(w,M))return A;var P=p(M);return m!==void 0&&m(A,P)?A:(w=M,E=P)}var x=!1,w,E,b=h===void 0?null:h;return[function(){return g(u())},b===null?void 0:function(){return g(b())}]},[u,h,p,m]);var y=i(c,v[0],v[1]);return o(function(){_.hasValue=!0,_.value=y},[y]),l(y),y},qg}var _S;function uk(){return _S||(_S=1,Yg.exports=ck()),Yg.exports}var hk=uk();const fk=Hr(hk),dk={},{useSyncExternalStoreWithSelector:pk}=fk;function WT(r,e=r.getState,t){const n=pk(r.subscribe,r.getState,r.getServerState||r.getState,e,t);return K.useDebugValue(n),n}const xS=r=>{(dk?"production":void 0)!=="production"&&typeof r!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e=typeof r=="function"?ok(r):r,t=(n,i)=>WT(e,n,i);return Object.assign(t,e),t},mk=r=>r?xS(r):xS,gk={};function vk(){(gk?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `context` will be removed in a future version. Instead use `import { createStore, useStore } from 'zustand'`. See: https://github.com/pmndrs/zustand/discussions/1180.");const r=K.createContext(void 0);return{Provider:({createStore:i,children:s})=>{const o=K.useRef();return o.current||(o.current=i()),K.createElement(r.Provider,{value:o.current},s)},useStore:(i,s)=>{const o=K.useContext(r);if(!o)throw new Error("Seems like you have not used zustand provider as an ancestor.");return WT(o,i,s)},useStoreApi:()=>{const i=K.useContext(r);if(!i)throw new Error("Seems like you have not used zustand provider as an ancestor.");return K.useMemo(()=>({...i}),[i])}}}function yk(r,e,t){return Math.max(e,Math.min(r,t))}const ln={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function wS(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function SS(r,e,t,n=.15){return n===0?yk(r,e,t):r<e?-wS(e-r,t-e,n)+e:r>t?+wS(r-t,t-e,n)+t:r}function _k(r,[e,t],[n,i]){const[[s,o],[a,l]]=r;return[SS(e,s,o,n),SS(t,a,l,i)]}function xk(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function wk(r){var e=xk(r,"string");return typeof e=="symbol"?e:String(e)}function kn(r,e,t){return e=wk(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function ES(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function wn(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ES(Object(t),!0).forEach(function(n){kn(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ES(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const XT={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function bS(r){return r?r[0].toUpperCase()+r.slice(1):""}const Sk=["enter","leave"];function Ek(r=!1,e){return r&&!Sk.includes(e)}function bk(r,e="",t=!1){const n=XT[r],i=n&&n[e]||e;return"on"+bS(r)+bS(i)+(Ek(t,i)?"Capture":"")}const Mk=["gotpointercapture","lostpointercapture"];function Tk(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Mk.includes(e)?"capturecapture":"capture",i=!!~e.indexOf(n);return i&&(e=e.replace("capture","")),{device:e,capture:i,passive:t}}function Ak(r,e=""){const t=XT[r],n=t&&t[e]||e;return r+n}function Ap(r){return"touches"in r}function jT(r){return Ap(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Ck(r){return Array.from(r.touches).filter(e=>{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function Rk(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function YT(r){return Ap(r)?Rk(r)[0]:r}function Ev(r,e){try{const t=e.clientX-r.clientX,n=e.clientY-r.clientY,i=(e.clientX+r.clientX)/2,s=(e.clientY+r.clientY)/2,o=Math.hypot(t,n);return{angle:-(Math.atan2(t,n)*180)/Math.PI,distance:o,origin:[i,s]}}catch{}return null}function Pk(r){return Ck(r).map(e=>e.identifier)}function MS(r,e){const[t,n]=Array.from(r.touches).filter(i=>e.includes(i.identifier));return Ev(t,n)}function $g(r){const e=YT(r);return Ap(r)?e.identifier:e.pointerId}function Zl(r){const e=YT(r);return[e.clientX,e.clientY]}const TS=40,AS=800;function qT(r){let{deltaX:e,deltaY:t,deltaMode:n}=r;return n===1?(e*=TS,t*=TS):n===2&&(e*=AS,t*=AS),[e,t]}function Lk(r){var e,t;const{scrollX:n,scrollY:i,scrollLeft:s,scrollTop:o}=r.currentTarget;return[(e=n??s)!==null&&e!==void 0?e:0,(t=i??o)!==null&&t!==void 0?t:0]}function Ik(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:i,ctrlKey:s}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:i,ctrlKey:s})}return e}function zd(r,...e){return typeof r=="function"?r(...e):r}function Dk(){}function Uk(...r){return r.length===0?Dk:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function CS(r,e){return Object.assign({},e,r||{})}const Ok=32;class ZT{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:i}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=i,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?zd(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:i}=this;t.args=this.args;let s=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,i.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,i.locked=!!document.pointerLockElement,Object.assign(i,Ik(e)),i.down=i.pressed=i.buttons%2===1||i.touches>0,s=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const M=t._delta.map(Math.abs);ln.addTo(t._distance,M)}this.axisIntent&&this.axisIntent(e);const[o,a]=t._movement,[l,c]=n.threshold,{_step:u,values:h}=t;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(o)>=l&&h[0]),u[1]===!1&&(u[1]=Math.abs(a)>=c&&h[1])):(u[0]===!1&&(u[0]=Math.abs(o)>=l&&Math.sign(o)*l),u[1]===!1&&(u[1]=Math.abs(a)>=c&&Math.sign(a)*c)),t.intentional=u[0]!==!1||u[1]!==!1,!t.intentional)return;const p=[0,0];if(n.hasCustomTransform){const[M,A]=h;p[0]=u[0]!==!1?M-u[0]:0,p[1]=u[1]!==!1?A-u[1]:0}else p[0]=u[0]!==!1?o-u[0]:0,p[1]=u[1]!==!1?a-u[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(p);const m=t.offset,v=t._active&&!t._blocked||t.active;v&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=i[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=zd(n.bounds,t)),this.setup&&this.setup()),t.movement=p,this.computeOffset()));const[_,y]=t.offset,[[g,x],[w,E]]=t._bounds;t.overflow=[_<g?-1:_>x?1:0,y<w?-1:y>E?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const b=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=_k(t._bounds,t.offset,b),t.delta=ln.sub(t.offset,m),this.computeMovement(),v&&(!t.last||s>Ok)){t.delta=ln.sub(t.offset,m);const M=t.delta.map(Math.abs);ln.addTo(t.distance,M),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&s>0&&(t.velocity=[M[0]/s,M[1]/s],t.timeDelta=s)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const i=this.handler(wn(wn(wn({},t),e),{},{[this.aliasKey]:e.values}));i!==void 0&&(e.memo=i)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Nk([r,e],t){const n=Math.abs(r),i=Math.abs(e);if(n>i&&n>t)return"x";if(i>n&&i>t)return"y"}class fh extends ZT{constructor(...e){super(...e),kn(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=ln.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=ln.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const i=typeof n.axisThreshold=="object"?n.axisThreshold[jT(e)]:n.axisThreshold;t.axis=Nk(t._movement,i)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const Fk=r=>r,RS=.15,KT={enabled(r=!0){return r},eventOptions(r,e,t){return wn(wn({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[RS,RS];case!1:return[0,0];default:return ln.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return ln.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;return this.hasCustomTransform=!!n,n||Fk},threshold(r){return ln.toVector(r,0)}},kk=0,Ua=wn(wn({},KT),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=kk){return r},bounds(r={}){if(typeof r=="function")return s=>Ua.bounds(r(s));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:i=1/0}=r;return[[e,t],[n,i]]}}),PS={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class zk extends fh{constructor(...e){super(...e),kn(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),i={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=Ua.bounds(i)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const i=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(i&&i.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=$g(e),n._pointerActive=!0,this.computeValues(Zl(e)),this.computeInitial(),t.preventScrollAxis&&jT(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const i=$g(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;const s=Zl(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=ln.sub(s,t._values),this.computeValues(s)),ln.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const i=$g(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[s,o]=t._distance;if(t.tap=s<=n.tapsThreshold&&o<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[a,l]=t._delta,[c,u]=t._movement,[h,p]=n.swipe.velocity,[m,v]=n.swipe.distance,_=n.swipe.duration;if(t.elapsedTime<_){const y=Math.abs(a/t.timeDelta),g=Math.abs(l/t.timeDelta);y>h&&Math.abs(c)>m&&(t.swipe[0]=Math.sign(a)),g>p&&Math.abs(u)>v&&(t.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,Bk(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=PS[e.key];if(t){const n=this.state,i=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,i),n._keyboardActive=!0,ln.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in PS&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function Bk(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const dh=typeof window<"u"&&window.document&&window.document.createElement;function $T(){return dh&&"ontouchstart"in window}function Gk(){return $T()||dh&&window.navigator.maxTouchPoints>1}function Hk(){return dh&&"onpointerdown"in window}function Vk(){return dh&&"exitPointerLock"in window.document}function Wk(){try{return"constructor"in GestureEvent}catch{return!1}}const wr={isBrowser:dh,gesture:Wk(),touch:$T(),touchscreen:Gk(),pointer:Hk(),pointerLock:Vk()},Xk=250,jk=180,Yk=.5,qk=50,Zk=250,Kk=10,LS={mouse:0,touch:0,pen:8},$k=wn(wn({},Ua),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:i=!1}={}}){return this.pointerLock=n&&wr.pointerLock,wr.touch&&t?"touch":this.pointerLock?"mouse":wr.pointer&&!i?"pointer":wr.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?Xk:void 0,!(!wr.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:i=!0}={}}){return this.pointerButtons=n,this.keys=i,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:i=void 0}){const s=ln.toVector(r,t?n:i?1:0);return this.filterTaps=t,this.tapsThreshold=n,s},swipe({velocity:r=Yk,distance:e=qk,duration:t=Zk}={}){return{velocity:this.transform(ln.toVector(r)),distance:this.transform(ln.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return jk;case!1:return 0;default:return r}},axisThreshold(r){return r?wn(wn({},LS),r):LS},keyboardDisplacement(r=Kk){return r}});function JT(r){const[e,t]=r.overflow,[n,i]=r._delta,[s,o]=r._direction;(e<0&&n>0&&s<0||e>0&&n<0&&s>0)&&(r._movement[0]=r._movementBound[0]),(t<0&&i>0&&o<0||t>0&&i<0&&o>0)&&(r._movement[1]=r._movementBound[1])}const Jk=30,Qk=100;class ez extends ZT{constructor(...e){super(...e),kn(this,"ingKey","pinching"),kn(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const e=this.state;e._touchIds=[],e.canceled=!1,e.cancel=this.cancel.bind(this),e.turns=0}computeOffset(){const{type:e,movement:t,lastOffset:n}=this.state;e==="wheel"?this.state.offset=ln.add(t,n):this.state.offset=[(1+t[0])*n[0],t[1]+n[1]]}computeMovement(){const{offset:e,lastOffset:t}=this.state;this.state.movement=[e[0]/t[0],e[1]-t[1]]}axisIntent(){const e=this.state,[t,n]=e._movement;if(!e.axis){const i=Math.abs(t)*Jk-Math.abs(n);i<0?e.axis="angle":i>0&&(e.axis="scale")}}restrictToAxis(e){this.config.lockDirection&&(this.state.axis==="scale"?e[1]=0:this.state.axis==="angle"&&(e[0]=0))}cancel(){const e=this.state;e.canceled||setTimeout(()=>{e.canceled=!0,e._active=!1,this.compute(),this.emit()},0)}touchStart(e){this.ctrl.setEventIds(e);const t=this.state,n=this.ctrl.touchIds;if(t._active&&t._touchIds.every(s=>n.has(s))||n.size<2)return;this.start(e),t._touchIds=Array.from(n).slice(0,2);const i=MS(e,t._touchIds);i&&this.pinchStart(e,i)}pointerStart(e){if(e.buttons!=null&&e.buttons%2!==1)return;this.ctrl.setEventIds(e),e.target.setPointerCapture(e.pointerId);const t=this.state,n=t._pointerEvents,i=this.ctrl.pointerIds;if(t._active&&Array.from(n.keys()).every(o=>i.has(o))||(n.size<2&&n.set(e.pointerId,e),t._pointerEvents.size<2))return;this.start(e);const s=Ev(...Array.from(n.values()));s&&this.pinchStart(e,s)}pinchStart(e,t){const n=this.state;n.origin=t.origin,this.computeValues([t.distance,t.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const t=MS(e,this.state._touchIds);t&&this.pinchMove(e,t)}pointerMove(e){const t=this.state._pointerEvents;if(t.has(e.pointerId)&&t.set(e.pointerId,e),!this.state._active)return;const n=Ev(...Array.from(t.values()));n&&this.pinchMove(e,n)}pinchMove(e,t){const n=this.state,i=n._values[1],s=t.angle-i;let o=0;Math.abs(s)>270&&(o+=Math.sign(s)),this.computeValues([t.distance,t.angle-360*o]),n.origin=t.origin,n.turns=o,n._movement=[n._values[0]/n._initial[0]-1,n._values[1]-n._initial[1]],this.compute(e),this.emit()}touchEnd(e){this.ctrl.setEventIds(e),this.state._active&&this.state._touchIds.some(t=>!this.ctrl.touchIds.has(t))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const t=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}t._pointerEvents.has(e.pointerId)&&t._pointerEvents.delete(e.pointerId),t._active&&t._pointerEvents.size<2&&(t._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const t=this.state;t._active||(this.start(e),this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const t=this.state;this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY];const n=t._movement;t._movement=[e.scale-1,e.rotation],t._delta=ln.sub(t._movement,n),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const t=this.config.modifierKey;t&&(Array.isArray(t)?!t.find(n=>e[n]):!e[t])||(this.state._active?this.wheelChange(e):this.wheelStart(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(e){this.start(e),this.wheelChange(e)}wheelChange(e){"uv"in e||e.cancelable&&e.preventDefault();const n=this.state;n._delta=[-qT(e)[1]/Qk*n.offset[0],0],ln.addTo(n._movement,n._delta),JT(n),this.state.origin=[e.clientX,e.clientY],this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){const t=this.config.device;t&&(e(t,"start",this[t+"Start"].bind(this)),e(t,"change",this[t+"Move"].bind(this)),e(t,"end",this[t+"End"].bind(this)),e(t,"cancel",this[t+"End"].bind(this)),e("lostPointerCapture","",this[t+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const tz=wn(wn({},KT),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!wr.touch&&wr.gesture)return"gesture";if(wr.touch&&n)return"touch";if(wr.touchscreen){if(wr.pointer)return"pointer";if(wr.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const i=o=>{const a=CS(zd(t,o),{min:-1/0,max:1/0});return[a.min,a.max]},s=o=>{const a=CS(zd(n,o),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof n!="function"?[i(),s()]:o=>[i(o),s(o)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",ln.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}});class nz extends fh{constructor(...e){super(...e),kn(this,"ingKey","moving")}move(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.state._active?this.moveChange(e):this.moveStart(e),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(e){this.start(e),this.computeValues(Zl(e)),this.compute(e),this.computeInitial(),this.emit()}moveChange(e){if(!this.state._active)return;const t=Zl(e),n=this.state;n._delta=ln.sub(t,n._values),ln.addTo(n._movement,n._delta),this.computeValues(t),this.compute(e),this.emit()}moveEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}bind(e){e("pointer","change",this.move.bind(this)),e("pointer","leave",this.moveEnd.bind(this))}}const iz=wn(wn({},Ua),{},{mouseOnly:(r=!0)=>r});class rz extends fh{constructor(...e){super(...e),kn(this,"ingKey","scrolling")}scroll(e){this.state._active||this.start(e),this.scrollChange(e),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(e){e.cancelable&&e.preventDefault();const t=this.state,n=Lk(e);t._delta=ln.sub(n,t._values),ln.addTo(t._movement,t._delta),this.computeValues(n),this.compute(e),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("scroll","",this.scroll.bind(this))}}const sz=Ua;class oz extends fh{constructor(...e){super(...e),kn(this,"ingKey","wheeling")}wheel(e){this.state._active||this.start(e),this.wheelChange(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(e){const t=this.state;t._delta=qT(e),ln.addTo(t._movement,t._delta),JT(t),this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("wheel","",this.wheel.bind(this))}}const az=Ua;class lz extends fh{constructor(...e){super(...e),kn(this,"ingKey","hovering")}enter(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.start(e),this.computeValues(Zl(e)),this.compute(e),this.emit())}leave(e){if(this.config.mouseOnly&&e.pointerType!=="mouse")return;const t=this.state;if(!t._active)return;t._active=!1;const n=Zl(e);t._movement=t._delta=ln.sub(n,t._values),this.computeValues(n),this.compute(e),t.delta=t.movement,this.emit()}bind(e){e("pointer","enter",this.enter.bind(this)),e("pointer","leave",this.leave.bind(this))}}const cz=wn(wn({},Ua),{},{mouseOnly:(r=!0)=>r}),Wy=new Map,bv=new Map;function uz(r){Wy.set(r.key,r.engine),bv.set(r.key,r.resolver)}const hz={key:"drag",engine:zk,resolver:$k},fz={key:"hover",engine:lz,resolver:cz},dz={key:"move",engine:nz,resolver:iz},pz={key:"pinch",engine:ez,resolver:tz},mz={key:"scroll",engine:rz,resolver:sz},gz={key:"wheel",engine:oz,resolver:az};function vz(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,s;for(s=0;s<n.length;s++)i=n[s],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}function yz(r,e){if(r==null)return{};var t=vz(r,e),n,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);for(i=0;i<s.length;i++)n=s[i],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const _z={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=wr.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},xz=["target","eventOptions","window","enabled","transform"];function Ad(r={},e){const t={};for(const[n,i]of Object.entries(e))switch(typeof i){case"function":t[n]=i.call(t,r[n],n,r);break;case"object":t[n]=Ad(r[n],i);break;case"boolean":i&&(t[n]=r[n]);break}return t}function wz(r,e,t={}){const n=r,{target:i,eventOptions:s,window:o,enabled:a,transform:l}=n,c=yz(n,xz);if(t.shared=Ad({target:i,eventOptions:s,window:o,enabled:a,transform:l},_z),e){const u=bv.get(e);t[e]=Ad(wn({shared:t.shared},c),u)}else for(const u in c){const h=bv.get(u);h&&(t[u]=Ad(wn({shared:t.shared},c[u]),h))}return t}class QT{constructor(e,t){kn(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,i,s){const o=this._listeners,a=Ak(t,n),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},c=wn(wn({},l),s);e.addEventListener(a,i,c);const u=()=>{e.removeEventListener(a,i,c),o.delete(u)};return o.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class Sz{constructor(){kn(this,"_timeouts",new Map)}add(e,t,n=140,...i){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...i))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}let Ez=class{constructor(e){kn(this,"gestures",new Set),kn(this,"_targetEventStore",new QT(this)),kn(this,"gestureEventStores",{}),kn(this,"gestureTimeoutStores",{}),kn(this,"handlers",{}),kn(this,"config",{}),kn(this,"pointerIds",new Set),kn(this,"touchIds",new Set),kn(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),bz(this,e)}setEventIds(e){if(Ap(e))return this.touchIds=new Set(Pk(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=wz(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let i;if(!(t.target&&(i=t.target(),!i))){if(t.enabled){for(const o of this.gestures){const a=this.config[o],l=IS(n,a.eventOptions,!!i);if(a.enabled){const c=Wy.get(o);new c(this,e,o).bind(l)}}const s=IS(n,t.eventOptions,!!i);for(const o in this.nativeHandlers)s(o,"",a=>this.nativeHandlers[o](wn(wn({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const s in n)n[s]=Uk(...n[s]);if(!i)return n;for(const s in n){const{device:o,capture:a,passive:l}=Tk(s);this._targetEventStore.add(i,o,"",n[s],{capture:a,passive:l})}}}};function _l(r,e){r.gestures.add(e),r.gestureEventStores[e]=new QT(r,e),r.gestureTimeoutStores[e]=new Sz}function bz(r,e){e.drag&&_l(r,"drag"),e.wheel&&_l(r,"wheel"),e.scroll&&_l(r,"scroll"),e.move&&_l(r,"move"),e.pinch&&_l(r,"pinch"),e.hover&&_l(r,"hover")}const IS=(r,e,t)=>(n,i,s,o={},a=!1)=>{var l,c;const u=(l=o.capture)!==null&&l!==void 0?l:e.capture,h=(c=o.passive)!==null&&c!==void 0?c:e.passive;let p=a?n:bk(n,i,u);t&&h&&(p+="Passive"),r[p]=r[p]||[],r[p].push(s)},Mz=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function Tz(r){const e={},t={},n=new Set;for(let i in r)Mz.test(i)?(n.add(RegExp.lastMatch),t[i]=r[i]):e[i]=r[i];return[t,e,n]}function xl(r,e,t,n,i,s){if(!r.has(t)||!Wy.has(n))return;const o=t+"Start",a=t+"End",l=c=>{let u;return c.first&&o in e&&e[o](c),t in e&&(u=e[t](c)),c.last&&a in e&&e[a](c),u};i[n]=l,s[n]=s[n]||{}}function Az(r,e){const[t,n,i]=Tz(r),s={};return xl(i,t,"onDrag","drag",s,e),xl(i,t,"onWheel","wheel",s,e),xl(i,t,"onScroll","scroll",s,e),xl(i,t,"onPinch","pinch",s,e),xl(i,t,"onMove","move",s,e),xl(i,t,"onHover","hover",s,e),{handlers:s,config:e,nativeHandlers:n}}function Cz(r,e={},t,n){const i=Um.useMemo(()=>new Ez(r),[]);if(i.applyHandlers(r,n),i.applyConfig(e,t),Um.useEffect(i.effect.bind(i)),Um.useEffect(()=>i.clean.bind(i),[]),e.target===void 0)return i.bind.bind(i)}function Rz(r){return r.forEach(uz),function(t,n){const{handlers:i,nativeHandlers:s,config:o}=Az(t,n||{});return Cz(i,o,void 0,s)}}function Pz(r,e){return Rz([hz,pz,mz,gz,dz,fz])(r,e||{})}var Lr={},ta={},Jg,DS;function Cp(){if(DS)return Jg;DS=1;function r(e){if(typeof e!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=e}return typeof Symbol<"u"&&(r.prototype[Symbol.iterator]=function(){return this}),r.of=function(){var e=arguments,t=e.length,n=0;return new r(function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}})},r.empty=function(){var e=new r(function(){return{done:!0}});return e},r.fromSequence=function(e){var t=0,n=e.length;return new r(function(){return t>=n?{done:!0}:{done:!1,value:e[t++]}})},r.is=function(e){return e instanceof r?!0:typeof e=="object"&&e!==null&&typeof e.next=="function"},Jg=r,Jg}var nd={},US;function eA(){return US||(US=1,nd.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u",nd.SYMBOL_SUPPORT=typeof Symbol<"u"),nd}var Qg,OS;function Xy(){if(OS)return Qg;OS=1;var r=eA(),e=r.ARRAY_BUFFER_SUPPORT,t=r.SYMBOL_SUPPORT;return Qg=function(i,s){var o,a,l,c,u;if(!i)throw new Error("obliterator/forEach: invalid iterable.");if(typeof s!="function")throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(i)||e&&ArrayBuffer.isView(i)||typeof i=="string"||i.toString()==="[object Arguments]"){for(l=0,c=i.length;l<c;l++)s(i[l],l);return}if(typeof i.forEach=="function"){i.forEach(s);return}if(t&&Symbol.iterator in i&&typeof i.next!="function"&&(i=i[Symbol.iterator]()),typeof i.next=="function"){for(o=i,l=0;u=o.next(),u.done!==!0;)s(u.value,l),l++;return}for(a in i)i.hasOwnProperty(a)&&s(i[a],a)},Qg}var e0,NS;function Lz(){if(NS)return e0;NS=1;var r=Cp(),e=Xy();function t(){this.clear()}return t.prototype.clear=function(){this.items=[],this.offset=0,this.size=0},t.prototype.enqueue=function(n){return this.items.push(n),++this.size},t.prototype.dequeue=function(){if(this.size){var n=this.items[this.offset];return++this.offset*2>=this.items.length&&(this.items=this.items.slice(this.offset),this.offset=0),this.size--,n}},t.prototype.peek=function(){if(this.size)return this.items[this.offset]},t.prototype.forEach=function(n,i){i=arguments.length>1?i:this;for(var s=this.offset,o=0,a=this.items.length;s<a;s++,o++)n.call(i,this.items[s],o,this)},t.prototype.toArray=function(){return this.items.slice(this.offset)},t.prototype.values=function(){var n=this.items,i=this.offset;return new r(function(){if(i>=n.length)return{done:!0};var s=n[i];return i++,{value:s,done:!1}})},t.prototype.entries=function(){var n=this.items,i=this.offset,s=0;return new r(function(){if(i>=n.length)return{done:!0};var o=n[i];return i++,{value:[s++,o],done:!1}})},typeof Symbol<"u"&&(t.prototype[Symbol.iterator]=t.prototype.values),t.prototype.toString=function(){return this.toArray().join(",")},t.prototype.toJSON=function(){return this.toArray()},t.prototype.inspect=function(){var n=this.toArray();return Object.defineProperty(n,"constructor",{value:t,enumerable:!1}),n},typeof Symbol<"u"&&(t.prototype[Symbol.for("nodejs.util.inspect.custom")]=t.prototype.inspect),t.from=function(n){var i=new t;return e(n,function(s){i.enqueue(s)}),i},t.of=function(){return t.from(arguments)},e0=t,e0}var t0,FS;function Iz(){return FS||(FS=1,t0=function(e,t){var n=t.length;if(n!==0){var i=e.length;e.length+=n;for(var s=0;s<n;s++)e[i+s]=t[s]}}),t0}var kS;function Dz(){if(kS)return ta;kS=1;var r=Xs(),e=Lz(),t=Iz();function n(c,u,h){if(!r(c))throw new Error("graphology-shortest-path: invalid graphology instance.");if(arguments.length<3)throw new Error("graphology-shortest-path: invalid number of arguments. Expecting at least 3.");if(!c.hasNode(u))throw new Error('graphology-shortest-path: the "'+u+'" source node does not exist in the given graph.');if(!c.hasNode(h))throw new Error('graphology-shortest-path: the "'+h+'" target node does not exist in the given graph.');if(u=""+u,h=""+h,u===h)return[u];var p=c.inboundNeighbors.bind(c),m=c.outboundNeighbors.bind(c),v={},_={};v[u]=null,_[h]=null;var y=[u],g=[h],x,w,E,b,M,A,P,C,L=!1;e:for(;y.length&&g.length;)if(y.length<=g.length){for(x=y,y=[],M=0,P=x.length;M<P;M++)for(w=x[M],E=m(w),A=0,C=E.length;A<C;A++)if(b=E[A],b in v||(y.push(b),v[b]=w),b in _){L=!0;break e}}else for(x=g,g=[],M=0,P=x.length;M<P;M++)for(w=x[M],E=p(w),A=0,C=E.length;A<C;A++)if(b=E[A],b in _||(g.push(b),_[b]=w),b in v){L=!0;break e}if(!L)return null;for(var F=[];b;)F.unshift(b),b=v[b];for(b=_[F[F.length-1]];b;)F.push(b),b=_[b];return F.length?F:null}function i(c,u){if(!r(c))throw new Error("graphology-shortest-path: invalid graphology instance.");if(arguments.length<2)throw new Error("graphology-shortest-path: invalid number of arguments. Expecting at least 2.");if(!c.hasNode(u))throw new Error('graphology-shortest-path: the "'+u+'" source node does not exist in the given graph.');u=""+u;var h={},p={},m,v,_,y,g,x;for(h[u]=!0,p[u]=[u];Object.keys(h).length;){m=h,h={};for(_ in m)for(v=c.outboundNeighbors(_),g=0,x=v.length;g<x;g++)y=v[g],p[y]||(p[y]=p[_].concat(y),h[y]=!0)}return p}function s(c,u,h){if(!r(u))throw new Error("graphology-shortest-path: invalid graphology instance.");if(!u.hasNode(h))throw new Error('graphology-shortest-path: the "'+h+'" source node does not exist in the given graph.');h=""+h;var p=new Set,m={},v=0;m[h]=0;for(var _=[h],y,g,x;_.length!==0;){var w=[];for(y=0,g=_.length;y<g;y++)x=_[y],!p.has(x)&&(p.add(x),t(w,u[c](x)),m[x]=v);v++,_=w}return m}var o=s.bind(null,"outboundNeighbors"),a=s.bind(null,"neighbors");function l(c,u){u=""+u;var h=[],p={},m={},v=c.nodes(),_,y,g,x,w,E,b,M,A;for(E=0,M=v.length;E<M;E++)x=v[E],p[x]=[],m[x]=0;var P={};m[u]=1,P[u]=0;for(var C=e.of(u);C.size;)for(x=C.dequeue(),h.push(x),_=P[x],y=m[x],g=c.outboundNeighbors(x),b=0,A=g.length;b<A;b++)w=g[b],w in P||(C.enqueue(w),P[w]=_+1),P[w]===_+1&&(m[w]+=y,p[w].push(x));return[h,p,m]}return ta.bidirectional=n,ta.singleSource=i,ta.singleSourceLength=o,ta.undirectedSingleSourceLength=a,ta.brandes=l,ta}var n0={},zS;function Uz(){if(zS)return n0;zS=1;var r=function(){return!0};return n0.edgePathFromNodePath=function(e,t){var n=t.length,i,s,o,a;if(n<2)return s=t[0],a=e.multi?e.findEdge(s,s,r):e.edge(s,s),a?[a]:[];n--;var l=new Array(n);for(i=0;i<n;i++){if(s=t[i],o=t[i+1],a=e.multi?e.findOutboundEdge(s,o,r):e.edge(s,o),a===void 0)throw new Error("graphology-shortest-path: given path is impossible in given graph.");l[i]=a}return l},n0}var jc={},wl={},BS;function Oz(){if(BS)return wl;BS=1;var r=function(i,s){return i<s?-1:i>s?1:0},e=function(i,s){return i<s?1:i>s?-1:0};function t(i){return function(s,o){return i(o,s)}}function n(i){return i===2?function(s,o){return s[0]<o[0]?-1:s[0]>o[0]?1:s[1]<o[1]?-1:s[1]>o[1]?1:0}:function(s,o){for(var a=0;a<i;){if(s[a]<o[a])return-1;if(s[a]>o[a])return 1;a++}return 0}}return wl.DEFAULT_COMPARATOR=r,wl.DEFAULT_REVERSE_COMPARATOR=e,wl.reverseComparator=t,wl.createTupleComparator=n,wl}var Sl={},GS;function Nz(){if(GS)return Sl;GS=1;var r=Xy(),e=VT();function t(o){return Array.isArray(o)||e.isTypedArray(o)}function n(o){if(typeof o.length=="number")return o.length;if(typeof o.size=="number")return o.size}function i(o){var a=n(o),l=typeof a=="number"?new Array(a):[],c=0;return r(o,function(u){l[c++]=u}),l}function s(o){var a=n(o),l=typeof a=="number"?e.getPointerArray(a):Array,c=typeof a=="number"?new Array(a):[],u=typeof a=="number"?new l(a):[],h=0;return r(o,function(p){c[h]=p,u[h]=h++}),[c,u]}return Sl.isArrayLike=t,Sl.guessLength=n,Sl.toArray=i,Sl.toArrayWithIndices=s,Sl}var i0,HS;function tA(){if(HS)return i0;HS=1;var r=Xy(),e=Oz(),t=Nz(),n=e.DEFAULT_COMPARATOR,i=e.reverseComparator;function s(g,x,w,E){for(var b=x[E],M,A;E>w;){if(M=E-1>>1,A=x[M],g(b,A)<0){x[E]=A,E=M;continue}break}x[E]=b}function o(g,x,w){for(var E=x.length,b=w,M=x[w],A=2*w+1,P;A<E;)P=A+1,P<E&&g(x[A],x[P])>=0&&(A=P),x[w]=x[A],w=A,A=2*w+1;x[w]=M,s(g,x,b,w)}function a(g,x,w){x.push(w),s(g,x,0,x.length-1)}function l(g,x){var w=x.pop();if(x.length!==0){var E=x[0];return x[0]=w,o(g,x,0),E}return w}function c(g,x,w){if(x.length===0)throw new Error("mnemonist/heap.replace: cannot pop an empty heap.");var E=x[0];return x[0]=w,o(g,x,0),E}function u(g,x,w){var E;return x.length!==0&&g(x[0],w)<0&&(E=x[0],x[0]=w,w=E,o(g,x,0)),w}function h(g,x){for(var w=x.length,E=w>>1,b=E;--b>=0;)o(g,x,b)}function p(g,x){for(var w=x.length,E=0,b=new Array(w);E<w;)b[E++]=l(g,x);return b}function m(g,x,w){arguments.length===2&&(w=x,x=g,g=n);var E=i(g),b,M,A,P=1/0,C;if(x===1){if(t.isArrayLike(w)){for(b=0,M=w.length;b<M;b++)A=w[b],(P===1/0||g(A,P)<0)&&(P=A);return C=new w.constructor(1),C[0]=P,C}return r(w,function(F){(P===1/0||g(F,P)<0)&&(P=F)}),[P]}if(t.isArrayLike(w)){if(x>=w.length)return w.slice().sort(g);for(C=w.slice(0,x),h(E,C),b=x,M=w.length;b<M;b++)E(w[b],C[0])>0&&c(E,C,w[b]);return C.sort(g)}var L=t.guessLength(w);return L!==null&&L<x&&(x=L),C=new Array(x),b=0,r(w,function(F){b<x?C[b]=F:(b===x&&h(E,C),E(F,C[0])>0&&c(E,C,F)),b++}),C.length>b&&(C.length=b),C.sort(g)}function v(g,x,w){arguments.length===2&&(w=x,x=g,g=n);var E=i(g),b,M,A,P=-1/0,C;if(x===1){if(t.isArrayLike(w)){for(b=0,M=w.length;b<M;b++)A=w[b],(P===-1/0||g(A,P)>0)&&(P=A);return C=new w.constructor(1),C[0]=P,C}return r(w,function(F){(P===-1/0||g(F,P)>0)&&(P=F)}),[P]}if(t.isArrayLike(w)){if(x>=w.length)return w.slice().sort(E);for(C=w.slice(0,x),h(g,C),b=x,M=w.length;b<M;b++)g(w[b],C[0])>0&&c(g,C,w[b]);return C.sort(E)}var L=t.guessLength(w);return L!==null&&L<x&&(x=L),C=new Array(x),b=0,r(w,function(F){b<x?C[b]=F:(b===x&&h(g,C),g(F,C[0])>0&&c(g,C,F)),b++}),C.length>b&&(C.length=b),C.sort(E)}function _(g){if(this.clear(),this.comparator=g||n,typeof this.comparator!="function")throw new Error("mnemonist/Heap.constructor: given comparator should be a function.")}_.prototype.clear=function(){this.items=[],this.size=0},_.prototype.push=function(g){return a(this.comparator,this.items,g),++this.size},_.prototype.peek=function(){return this.items[0]},_.prototype.pop=function(){return this.size!==0&&this.size--,l(this.comparator,this.items)},_.prototype.replace=function(g){return c(this.comparator,this.items,g)},_.prototype.pushpop=function(g){return u(this.comparator,this.items,g)},_.prototype.consume=function(){return this.size=0,p(this.comparator,this.items)},_.prototype.toArray=function(){return p(this.comparator,this.items.slice())},_.prototype.inspect=function(){var g=this.toArray();return Object.defineProperty(g,"constructor",{value:_,enumerable:!1}),g},typeof Symbol<"u"&&(_.prototype[Symbol.for("nodejs.util.inspect.custom")]=_.prototype.inspect);function y(g){if(this.clear(),this.comparator=g||n,typeof this.comparator!="function")throw new Error("mnemonist/MaxHeap.constructor: given comparator should be a function.");this.comparator=i(this.comparator)}return y.prototype=_.prototype,_.from=function(g,x){var w=new _(x),E;return t.isArrayLike(g)?E=g.slice():E=t.toArray(g),h(w.comparator,E),w.items=E,w.size=E.length,w},y.from=function(g,x){var w=new y(x),E;return t.isArrayLike(g)?E=g.slice():E=t.toArray(g),h(w.comparator,E),w.items=E,w.size=E.length,w},_.siftUp=o,_.siftDown=s,_.push=a,_.pop=l,_.replace=c,_.pushpop=u,_.heapify=h,_.consume=p,_.nsmallest=m,_.nlargest=v,_.MinHeap=_,_.MaxHeap=y,i0=_,i0}var VS;function Fz(){if(VS)return jc;VS=1;var r=Xs(),e=Tp().createEdgeWeightGetter,t=tA(),n="weight";function i(h,p){return h[0]>p[0]?1:h[0]<p[0]?-1:h[1]>p[1]?1:h[1]<p[1]?-1:h[2]>p[2]?1:h[2]<p[2]?-1:0}function s(h,p){return h[0]>p[0]?1:h[0]<p[0]?-1:h[1]>p[1]?1:h[1]<p[1]?-1:h[2]>p[2]?1:h[2]<p[2]?-1:h[3]>p[3]?1:h[3]<p[3]?-1:0}function o(h,p,m,v){if(p=""+p,m=""+m,!r(h))throw new Error("graphology-shortest-path/dijkstra: invalid graphology instance.");if(p&&!h.hasNode(p))throw new Error('graphology-shortest-path/dijkstra: the "'+p+'" source node does not exist in the given graph.');if(m&&!h.hasNode(m))throw new Error('graphology-shortest-path/dijkstra: the "'+m+'" target node does not exist in the given graph.');if(v=e(v||n).fromMinimalEntry,p===m)return[0,[p]];var _=[{},{}],y=[{},{}],g=[new t(i),new t(i)],x=[{},{}];y[0][p]=[p],y[1][m]=[m],x[0][p]=0,x[1][m]=0;var w=[],E=1/0,b=0,M=1,A,P,C,L,F,N,I,X,q;for(g[0].push([0,b++,p]),g[1].push([0,b++,m]);g[0].size&&g[1].size;)if(M=1-M,A=g[M].pop(),L=A[0],F=A[2],!(F in _[M])){if(_[M][F]=L,F in _[1-M])return[E,w];for(P=M===1?h.inboundEdges(F):h.outboundEdges(F),X=0,q=P.length;X<q;X++){if(I=P[X],N=h.opposite(F,I),C=_[M][F]+v(I,h.getEdgeAttributes(I)),N in _[M]&&C<_[M][N])throw Error("graphology-shortest-path/dijkstra: contradictory paths found. Do some of your edges have a negative weight?");(!(N in x[M])||C<x[M][N])&&(x[M][N]=C,g[M].push([C,b++,N]),y[M][N]=y[M][F].concat(N),N in x[0]&&N in x[1]&&(L=x[0][N]+x[1][N],(w.length===0||E>L)&&(E=L,w=y[0][N].concat(y[1][N].slice(0,-1).reverse()))))}}return[1/0,null]}function a(h,p,m,v,_,y){if(!r(h))throw new Error("graphology-shortest-path/dijkstra: invalid graphology instance.");m=e(m||n).fromMinimalEntry;var g={},x={},w=new t(i),E=0,b,M,A,P,C,L,F,N,I,X,q;for(N=0,X=p.length;N<X;N++)P=p[N],x[P]=0,w.push([0,E++,P]),y&&(y[P]=[P]);for(;w.size;)if(M=w.pop(),F=M[0],P=M[2],!(P in g)){if(g[P]=F,P===_)break;for(b=h.outboundEdges(P),I=0,q=b.length;I<q;I++){if(L=b[I],C=h.opposite(P,L),A=m(L,h.getEdgeAttributes(L))+g[P],C in g&&A<g[C])throw Error("graphology-shortest-path/dijkstra: contradictory paths found. Do some of your edges have a negative weight?");(!(C in x)||A<x[C])&&(x[C]=A,w.push([A,E++,C]),y&&(y[C]=y[P].concat(C)))}}return g}function l(h,p,m){var v={};return a(h,[p],m,0,null,v),v}function c(h,p,m,v){return o(h,p,m,v)[1]}function u(h,p,m){p=""+p,m=e(m||n).fromMinimalEntry;var v=[],_={},y={},g=h.nodes(),x,w,E,b,M,A,P,C,L,F;for(L=0,F=g.length;L<F;L++)A=g[L],_[A]=[],y[A]=0;var N={};y[p]=1;var I={};I[p]=0;var X=0,q=new t(s);for(q.push([0,X++,p,p]);q.size;)if(w=q.pop(),b=w[0],E=w[2],A=w[3],!(A in N))for(y[A]+=y[E],v.push(A),N[A]=b,x=h.outboundEdges(A),L=0,F=x.length;L<F;L++)C=x[L],P=h.opposite(A,C),M=b+m(C,h.getEdgeAttributes(C)),!(P in N)&&(!(P in I)||M<I[P])?(I[P]=M,q.push([M,X++,A,P]),y[P]=0,_[P]=[A]):M===I[P]&&(y[P]+=y[A],_[P].push(A));return[v,_,y]}return jc.bidirectional=c,jc.singleSource=l,jc.brandes=u,jc}var r0={},WS;function kz(){if(WS)return r0;WS=1;var r=Xs(),e=Tp().createEdgeWeightGetter,t=tA(),n="weight";function i(o,a){return o[0]>a[0]?1:o[0]<a[0]?-1:o[1]>a[1]?1:o[1]<a[1]?-1:0}function s(o,a,l,c,u,h){if(!r(o))throw new Error("graphology-shortest-path/astar: invalid graphology instance.");if(a&&!o.hasNode(a))throw new Error('graphology-shortest-path/astar: the "'+a+'" source node does not exist in the given graph.');if(l&&!o.hasNode(l))throw new Error('graphology-shortest-path/astar: the "'+l+'" target node does not exist in the given graph.');if(c=e(c||n).fromMinimalEntry,a===l)return[a];u=u||function(){return 0},h=h||{};var p=0,m=new t(i);m.push([0,p++,a,0,null]);var v={},_={},y,g,x,w,E,b,M,A,P,C,L,F;function N(I,X,q,W){if(F=g===q?W:q,C=c(I,X),C!==null){if(L=w+C,v.hasOwnProperty(F)){if(x=v[F],A=x[0],P=x[1],A<=L)return}else P=u(F,l);h.cutoff&&L+P>h.cutoff||(v[F]=[L,P],m.push([L+P,p++,F,L,g]))}}for(;m.size!==0;){if(y=m.pop(),g=y[2],w=y[3],E=y[4],g===l){for(b=[g],M=E;M!==null;)b.push(M),M=_[M];return b.reverse(),b}_.hasOwnProperty(g)&&(_[g]===null||(A=v[g][0],A<w))||(_[g]=E,o.forEachOutboundEdge(g,N))}return null}return r0.bidirectional=s,r0}var XS;function zz(){if(XS)return Lr;XS=1;var r=Dz(),e=Uz();return Lr.unweighted=r,Lr.dijkstra=Fz(),Lr.astar=kz(),Lr.bidirectional=r.bidirectional,Lr.singleSource=r.singleSource,Lr.singleSourceLength=r.singleSourceLength,Lr.undirectedSingleSourceLength=r.undirectedSingleSourceLength,Lr.brandes=r.brandes,Lr.edgePathFromNodePath=e.edgePathFromNodePath,Lr}zz();var id={exports:{}},jS;function Bz(){if(jS)return id.exports;jS=1;var r=typeof Reflect=="object"?Reflect:null,e=r&&typeof r.apply=="function"?r.apply:function(b,M,A){return Function.prototype.apply.call(b,M,A)},t;r&&typeof r.ownKeys=="function"?t=r.ownKeys:Object.getOwnPropertySymbols?t=function(b){return Object.getOwnPropertyNames(b).concat(Object.getOwnPropertySymbols(b))}:t=function(b){return Object.getOwnPropertyNames(b)};function n(E){console&&console.warn&&console.warn(E)}var i=Number.isNaN||function(b){return b!==b};function s(){s.init.call(this)}id.exports=s,id.exports.once=g,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(E){if(typeof E!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof E)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(E){if(typeof E!="number"||E<0||i(E))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+E+".");o=E}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(b){if(typeof b!="number"||b<0||i(b))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+b+".");return this._maxListeners=b,this};function l(E){return E._maxListeners===void 0?s.defaultMaxListeners:E._maxListeners}s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(b){for(var M=[],A=1;A<arguments.length;A++)M.push(arguments[A]);var P=b==="error",C=this._events;if(C!==void 0)P=P&&C.error===void 0;else if(!P)return!1;if(P){var L;if(M.length>0&&(L=M[0]),L instanceof Error)throw L;var F=new Error("Unhandled error."+(L?" ("+L.message+")":""));throw F.context=L,F}var N=C[b];if(N===void 0)return!1;if(typeof N=="function")e(N,this,M);else for(var I=N.length,X=v(N,I),A=0;A<I;++A)e(X[A],this,M);return!0};function c(E,b,M,A){var P,C,L;if(a(M),C=E._events,C===void 0?(C=E._events=Object.create(null),E._eventsCount=0):(C.newListener!==void 0&&(E.emit("newListener",b,M.listener?M.listener:M),C=E._events),L=C[b]),L===void 0)L=C[b]=M,++E._eventsCount;else if(typeof L=="function"?L=C[b]=A?[M,L]:[L,M]:A?L.unshift(M):L.push(M),P=l(E),P>0&&L.length>P&&!L.warned){L.warned=!0;var F=new Error("Possible EventEmitter memory leak detected. "+L.length+" "+String(b)+" listeners added. Use emitter.setMaxListeners() to increase limit");F.name="MaxListenersExceededWarning",F.emitter=E,F.type=b,F.count=L.length,n(F)}return E}s.prototype.addListener=function(b,M){return c(this,b,M,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(b,M){return c(this,b,M,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(E,b,M){var A={fired:!1,wrapFn:void 0,target:E,type:b,listener:M},P=u.bind(A);return P.listener=M,A.wrapFn=P,P}s.prototype.once=function(b,M){return a(M),this.on(b,h(this,b,M)),this},s.prototype.prependOnceListener=function(b,M){return a(M),this.prependListener(b,h(this,b,M)),this},s.prototype.removeListener=function(b,M){var A,P,C,L,F;if(a(M),P=this._events,P===void 0)return this;if(A=P[b],A===void 0)return this;if(A===M||A.listener===M)--this._eventsCount===0?this._events=Object.create(null):(delete P[b],P.removeListener&&this.emit("removeListener",b,A.listener||M));else if(typeof A!="function"){for(C=-1,L=A.length-1;L>=0;L--)if(A[L]===M||A[L].listener===M){F=A[L].listener,C=L;break}if(C<0)return this;C===0?A.shift():_(A,C),A.length===1&&(P[b]=A[0]),P.removeListener!==void 0&&this.emit("removeListener",b,F||M)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(b){var M,A,P;if(A=this._events,A===void 0)return this;if(A.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):A[b]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete A[b]),this;if(arguments.length===0){var C=Object.keys(A),L;for(P=0;P<C.length;++P)L=C[P],L!=="removeListener"&&this.removeAllListeners(L);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(M=A[b],typeof M=="function")this.removeListener(b,M);else if(M!==void 0)for(P=M.length-1;P>=0;P--)this.removeListener(b,M[P]);return this};function p(E,b,M){var A=E._events;if(A===void 0)return[];var P=A[b];return P===void 0?[]:typeof P=="function"?M?[P.listener||P]:[P]:M?y(P):v(P,P.length)}s.prototype.listeners=function(b){return p(this,b,!0)},s.prototype.rawListeners=function(b){return p(this,b,!1)},s.listenerCount=function(E,b){return typeof E.listenerCount=="function"?E.listenerCount(b):m.call(E,b)},s.prototype.listenerCount=m;function m(E){var b=this._events;if(b!==void 0){var M=b[E];if(typeof M=="function")return 1;if(M!==void 0)return M.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function v(E,b){for(var M=new Array(b),A=0;A<b;++A)M[A]=E[A];return M}function _(E,b){for(;b+1<E.length;b++)E[b]=E[b+1];E.pop()}function y(E){for(var b=new Array(E.length),M=0;M<b.length;++M)b[M]=E[M].listener||E[M];return b}function g(E,b){return new Promise(function(M,A){function P(L){E.removeListener(b,C),A(L)}function C(){typeof E.removeListener=="function"&&E.removeListener("error",P),M([].slice.call(arguments))}w(E,b,C,{once:!0}),b!=="error"&&x(E,P,{once:!0})})}function x(E,b,M){typeof E.on=="function"&&w(E,"error",b,M)}function w(E,b,M,A){if(typeof E.on=="function")A.once?E.once(b,M):E.on(b,M);else if(typeof E.addEventListener=="function")E.addEventListener(b,function P(C){A.once&&E.removeEventListener(b,P),M(C)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof E)}return id.exports}var Gz=Bz(),Hz=Cp();const Mr=Hr(Hz);var s0,YS;function nA(){if(YS)return s0;YS=1;var r=Cp(),e=eA(),t=e.ARRAY_BUFFER_SUPPORT,n=e.SYMBOL_SUPPORT;function i(s){return typeof s=="string"||Array.isArray(s)||t&&ArrayBuffer.isView(s)?r.fromSequence(s):typeof s!="object"||s===null?null:n&&typeof s[Symbol.iterator]=="function"?s[Symbol.iterator]():typeof s.next=="function"?s:null}return s0=function(o){var a=i(o);if(!a)throw new Error("obliterator: target is not iterable nor a valid iterator.");return a},s0}var o0,qS;function Vz(){if(qS)return o0;qS=1;var r=nA();return o0=function(t,n){for(var i=arguments.length>1?n:1/0,s=i!==1/0?new Array(i):[],o,a=0,l=r(t);;){if(a===i)return s;if(o=l.next(),o.done)return a!==n&&(s.length=a),s;s[a++]=o.value}},o0}var Wz=Vz();const iA=Hr(Wz);var a0,ZS;function Xz(){if(ZS)return a0;ZS=1;var r=Cp(),e=nA();return a0=function(){var n=arguments,i=null,s=-1;return new r(function(){var a=null;do{if(i===null){if(s++,s>=n.length)return{done:!0};i=e(n[s])}if(a=i.next(),a.done===!0){i=null;continue}break}while(!0);return a})},a0}var jz=Xz();const zs=Hr(jz);function Yz(){const r=arguments[0];for(let e=1,t=arguments.length;e<t;e++)if(arguments[e])for(const n in arguments[e])r[n]=arguments[e][n];return r}let Vn=Yz;typeof Object.assign=="function"&&(Vn=Object.assign);function br(r,e,t,n){const i=r._nodes.get(e);let s=null;return i&&(n==="mixed"?s=i.out&&i.out[t]||i.undirected&&i.undirected[t]:n==="directed"?s=i.out&&i.out[t]:s=i.undirected&&i.undirected[t]),s}function ri(r){return typeof r=="object"&&r!==null}function rA(r){let e;for(e in r)return!1;return!0}function mr(r,e,t){Object.defineProperty(r,e,{enumerable:!1,configurable:!1,writable:!0,value:t})}function Ir(r,e,t){const n={enumerable:!0,configurable:!0};typeof t=="function"?n.get=t:(n.value=t,n.writable=!1),Object.defineProperty(r,e,n)}function KS(r){return!(!ri(r)||r.attributes&&!Array.isArray(r.attributes))}function qz(){let r=Math.floor(Math.random()*256)&255;return()=>r++}class jy extends Error{constructor(e){super(),this.name="GraphError",this.message=e}}class tt extends jy{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,tt.prototype.constructor)}}class je extends jy{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,je.prototype.constructor)}}class ft extends jy{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ft.prototype.constructor)}}function sA(r,e){this.key=r,this.attributes=e,this.clear()}sA.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function oA(r,e){this.key=r,this.attributes=e,this.clear()}oA.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function aA(r,e){this.key=r,this.attributes=e,this.clear()}aA.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function nc(r,e,t,n,i){this.key=e,this.attributes=i,this.undirected=r,this.source=t,this.target=n}nc.prototype.attach=function(){let r="out",e="in";this.undirected&&(r=e="undirected");const t=this.source.key,n=this.target.key;this.source[r][n]=this,!(this.undirected&&t===n)&&(this.target[e][t]=this)};nc.prototype.attachMulti=function(){let r="out",e="in";const t=this.source.key,n=this.target.key;this.undirected&&(r=e="undirected");const i=this.source[r],s=i[n];if(typeof s>"u"){i[n]=this,this.undirected&&t===n||(this.target[e][t]=this);return}s.previous=this,this.next=s,i[n]=this,this.target[e][t]=this};nc.prototype.detach=function(){const r=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),delete this.source[t][e],delete this.target[n][r]};nc.prototype.detachMulti=function(){const r=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][e],delete this.target[n][r]):(this.next.previous=void 0,this.source[t][e]=this.next,this.target[n][r]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const lA=0,cA=1,Zz=2,uA=3;function js(r,e,t,n,i,s,o){let a,l,c,u;if(n=""+n,t===lA){if(a=r._nodes.get(n),!a)throw new je(`Graph.${e}: could not find the "${n}" node in the graph.`);c=i,u=s}else if(t===uA){if(i=""+i,l=r._edges.get(i),!l)throw new je(`Graph.${e}: could not find the "${i}" edge in the graph.`);const h=l.source.key,p=l.target.key;if(n===h)a=l.target;else if(n===p)a=l.source;else throw new je(`Graph.${e}: the "${n}" node is not attached to the "${i}" edge (${h}, ${p}).`);c=s,u=o}else{if(l=r._edges.get(n),!l)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`);t===cA?a=l.source:a=l.target,c=i,u=s}return[a,c,u]}function Kz(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=js(this,e,t,n,i,s);return o.attributes[a]}}function $z(r,e,t){r.prototype[e]=function(n,i){const[s]=js(this,e,t,n,i);return s.attributes}}function Jz(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=js(this,e,t,n,i,s);return o.attributes.hasOwnProperty(a)}}function Qz(r,e,t){r.prototype[e]=function(n,i,s,o){const[a,l,c]=js(this,e,t,n,i,s,o);return a.attributes[l]=c,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}function eB(r,e,t){r.prototype[e]=function(n,i,s,o){const[a,l,c]=js(this,e,t,n,i,s,o);if(typeof c!="function")throw new tt(`Graph.${e}: updater should be a function.`);const u=a.attributes,h=c(u[l]);return u[l]=h,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:l}),this}}function tB(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=js(this,e,t,n,i,s);return delete o.attributes[a],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:a}),this}}function nB(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=js(this,e,t,n,i,s);if(!ri(a))throw new tt(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=a,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function iB(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=js(this,e,t,n,i,s);if(!ri(a))throw new tt(`Graph.${e}: provided attributes are not a plain object.`);return Vn(o.attributes,a),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:a}),this}}function rB(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=js(this,e,t,n,i,s);if(typeof a!="function")throw new tt(`Graph.${e}: provided updater is not a function.`);return o.attributes=a(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const sB=[{name:r=>`get${r}Attribute`,attacher:Kz},{name:r=>`get${r}Attributes`,attacher:$z},{name:r=>`has${r}Attribute`,attacher:Jz},{name:r=>`set${r}Attribute`,attacher:Qz},{name:r=>`update${r}Attribute`,attacher:eB},{name:r=>`remove${r}Attribute`,attacher:tB},{name:r=>`replace${r}Attributes`,attacher:nB},{name:r=>`merge${r}Attributes`,attacher:iB},{name:r=>`update${r}Attributes`,attacher:rB}];function oB(r){sB.forEach(function({name:e,attacher:t}){t(r,e("Node"),lA),t(r,e("Source"),cA),t(r,e("Target"),Zz),t(r,e("Opposite"),uA)})}function aB(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=br(this,o,a,t),!s)throw new je(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return s.attributes[i]}}function lB(r,e,t){r.prototype[e]=function(n){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,o=""+arguments[1];if(i=br(this,s,o,t),!i)throw new je(`Graph.${e}: could not find an edge for the given path ("${s}" - "${o}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,i=this._edges.get(n),!i)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return i.attributes}}function cB(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=br(this,o,a,t),!s)throw new je(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return s.attributes.hasOwnProperty(i)}}function uB(r,e,t){r.prototype[e]=function(n,i,s){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+n,l=""+i;if(i=arguments[2],s=arguments[3],o=br(this,a,l,t),!o)throw new je(`Graph.${e}: could not find an edge for the given path ("${a}" - "${l}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return o.attributes[i]=s,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function hB(r,e,t){r.prototype[e]=function(n,i,s){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+n,l=""+i;if(i=arguments[2],s=arguments[3],o=br(this,a,l,t),!o)throw new je(`Graph.${e}: could not find an edge for the given path ("${a}" - "${l}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof s!="function")throw new tt(`Graph.${e}: updater should be a function.`);return o.attributes[i]=s(o.attributes[i]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function fB(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=br(this,o,a,t),!s)throw new je(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return delete s.attributes[i],this.emit("edgeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:i}),this}}function dB(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=br(this,o,a,t),!s)throw new je(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!ri(i))throw new tt(`Graph.${e}: provided attributes are not a plain object.`);return s.attributes=i,this.emit("edgeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function pB(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=br(this,o,a,t),!s)throw new je(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!ri(i))throw new tt(`Graph.${e}: provided attributes are not a plain object.`);return Vn(s.attributes,i),this.emit("edgeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:i}),this}}function mB(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new ft(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ft(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=br(this,o,a,t),!s)throw new je(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new ft(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new je(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof i!="function")throw new tt(`Graph.${e}: provided updater is not a function.`);return s.attributes=i(s.attributes),this.emit("edgeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const gB=[{name:r=>`get${r}Attribute`,attacher:aB},{name:r=>`get${r}Attributes`,attacher:lB},{name:r=>`has${r}Attribute`,attacher:cB},{name:r=>`set${r}Attribute`,attacher:uB},{name:r=>`update${r}Attribute`,attacher:hB},{name:r=>`remove${r}Attribute`,attacher:fB},{name:r=>`replace${r}Attributes`,attacher:dB},{name:r=>`merge${r}Attributes`,attacher:pB},{name:r=>`update${r}Attributes`,attacher:mB}];function vB(r){gB.forEach(function({name:e,attacher:t}){t(r,e("Edge"),"mixed"),t(r,e("DirectedEdge"),"directed"),t(r,e("UndirectedEdge"),"undirected")})}const yB=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function _B(r,e,t,n){let i=!1;for(const s in e){if(s===n)continue;const o=e[s];if(i=t(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),r&&i)return o.key}}function xB(r,e,t,n){let i,s,o,a=!1;for(const l in e)if(l!==n){i=e[l];do{if(s=i.source,o=i.target,a=t(i.key,i.attributes,s.key,o.key,s.attributes,o.attributes,i.undirected),r&&a)return i.key;i=i.next}while(i!==void 0)}}function l0(r,e){const t=Object.keys(r),n=t.length;let i,s=0;return new Mr(function(){do if(i)i=i.next;else{if(s>=n)return{done:!0};const a=t[s++];if(a===e){i=void 0;continue}i=r[a]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}})}function wB(r,e,t,n){const i=e[t];if(!i)return;const s=i.source,o=i.target;if(n(i.key,i.attributes,s.key,o.key,s.attributes,o.attributes,i.undirected)&&r)return i.key}function SB(r,e,t,n){let i=e[t];if(!i)return;let s=!1;do{if(s=n(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),r&&s)return i.key;i=i.next}while(i!==void 0)}function c0(r,e){let t=r[e];return t.next!==void 0?new Mr(function(){if(!t)return{done:!0};const n={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:n}}):Mr.of({edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected})}function EB(r,e){if(r.size===0)return[];if(e==="mixed"||e===r.type)return typeof Array.from=="function"?Array.from(r._edges.keys()):iA(r._edges.keys(),r._edges.size);const t=e==="undirected"?r.undirectedSize:r.directedSize,n=new Array(t),i=e==="undirected",s=r._edges.values();let o=0,a,l;for(;a=s.next(),a.done!==!0;)l=a.value,l.undirected===i&&(n[o++]=l.key);return n}function hA(r,e,t,n){if(e.size===0)return;const i=t!=="mixed"&&t!==e.type,s=t==="undirected";let o,a,l=!1;const c=e._edges.values();for(;o=c.next(),o.done!==!0;){if(a=o.value,i&&a.undirected!==s)continue;const{key:u,attributes:h,source:p,target:m}=a;if(l=n(u,h,p.key,m.key,p.attributes,m.attributes,a.undirected),r&&l)return u}}function bB(r,e){if(r.size===0)return Mr.empty();const t=e!=="mixed"&&e!==r.type,n=e==="undirected",i=r._edges.values();return new Mr(function(){let o,a;for(;;){if(o=i.next(),o.done)return o;if(a=o.value,!(t&&a.undirected!==n))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}})}function Yy(r,e,t,n,i,s){const o=e?xB:_B;let a;if(t!=="undirected"&&(n!=="out"&&(a=o(r,i.in,s),r&&a)||n!=="in"&&(a=o(r,i.out,s,n?void 0:i.key),r&&a))||t!=="directed"&&(a=o(r,i.undirected,s),r&&a))return a}function MB(r,e,t,n){const i=[];return Yy(!1,r,e,t,n,function(s){i.push(s)}),i}function TB(r,e,t){let n=Mr.empty();return r!=="undirected"&&(e!=="out"&&typeof t.in<"u"&&(n=zs(n,l0(t.in))),e!=="in"&&typeof t.out<"u"&&(n=zs(n,l0(t.out,e?void 0:t.key)))),r!=="directed"&&typeof t.undirected<"u"&&(n=zs(n,l0(t.undirected))),n}function qy(r,e,t,n,i,s,o){const a=t?SB:wB;let l;if(e!=="undirected"&&(typeof i.in<"u"&&n!=="out"&&(l=a(r,i.in,s,o),r&&l)||typeof i.out<"u"&&n!=="in"&&(n||i.key!==s)&&(l=a(r,i.out,s,o),r&&l))||e!=="directed"&&typeof i.undirected<"u"&&(l=a(r,i.undirected,s,o),r&&l))return l}function AB(r,e,t,n,i){const s=[];return qy(!1,r,e,t,n,i,function(o){s.push(o)}),s}function CB(r,e,t,n){let i=Mr.empty();return r!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&n in t.in&&(i=zs(i,c0(t.in,n))),typeof t.out<"u"&&e!=="in"&&n in t.out&&(e||t.key!==n)&&(i=zs(i,c0(t.out,n)))),r!=="directed"&&typeof t.undirected<"u"&&n in t.undirected&&(i=zs(i,c0(t.undirected,n))),i}function RB(r,e){const{name:t,type:n,direction:i}=e;r.prototype[t]=function(s,o){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];if(!arguments.length)return EB(this,n);if(arguments.length===1){s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new je(`Graph.${t}: could not find the "${s}" node in the graph.`);return MB(this.multi,n==="mixed"?this.type:n,i,a)}if(arguments.length===2){s=""+s,o=""+o;const a=this._nodes.get(s);if(!a)throw new je(`Graph.${t}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(o))throw new je(`Graph.${t}: could not find the "${o}" target node in the graph.`);return AB(n,this.multi,i,a,o)}throw new tt(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function PB(r,e){const{name:t,type:n,direction:i}=e,s="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(c,u,h){if(!(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)){if(arguments.length===1)return h=c,hA(!1,this,n,h);if(arguments.length===2){c=""+c,h=u;const p=this._nodes.get(c);if(typeof p>"u")throw new je(`Graph.${s}: could not find the "${c}" node in the graph.`);return Yy(!1,this.multi,n==="mixed"?this.type:n,i,p,h)}if(arguments.length===3){c=""+c,u=""+u;const p=this._nodes.get(c);if(!p)throw new je(`Graph.${s}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(u))throw new je(`Graph.${s}: could not find the "${u}" target node in the graph.`);return qy(!1,n,this.multi,i,p,u,h)}throw new tt(`Graph.${s}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const o="map"+t[0].toUpperCase()+t.slice(1);r.prototype[o]=function(){const c=Array.prototype.slice.call(arguments),u=c.pop();let h;if(c.length===0){let p=0;n!=="directed"&&(p+=this.undirectedSize),n!=="undirected"&&(p+=this.directedSize),h=new Array(p);let m=0;c.push((v,_,y,g,x,w,E)=>{h[m++]=u(v,_,y,g,x,w,E)})}else h=[],c.push((p,m,v,_,y,g,x)=>{h.push(u(p,m,v,_,y,g,x))});return this[s].apply(this,c),h};const a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(){const c=Array.prototype.slice.call(arguments),u=c.pop(),h=[];return c.push((p,m,v,_,y,g,x)=>{u(p,m,v,_,y,g,x)&&h.push(p)}),this[s].apply(this,c),h};const l="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[l]=function(){let c=Array.prototype.slice.call(arguments);if(c.length<2||c.length>4)throw new tt(`Graph.${l}: invalid number of arguments (expecting 2, 3 or 4 and got ${c.length}).`);if(typeof c[c.length-1]=="function"&&typeof c[c.length-2]!="function")throw new tt(`Graph.${l}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let u,h;c.length===2?(u=c[0],h=c[1],c=[]):c.length===3?(u=c[1],h=c[2],c=[c[0]]):c.length===4&&(u=c[2],h=c[3],c=[c[0],c[1]]);let p=h;return c.push((m,v,_,y,g,x,w)=>{p=u(p,m,v,_,y,g,x,w)}),this[s].apply(this,c),p}}function LB(r,e){const{name:t,type:n,direction:i}=e,s="find"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(l,c,u){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return!1;if(arguments.length===1)return u=l,hA(!0,this,n,u);if(arguments.length===2){l=""+l,u=c;const h=this._nodes.get(l);if(typeof h>"u")throw new je(`Graph.${s}: could not find the "${l}" node in the graph.`);return Yy(!0,this.multi,n==="mixed"?this.type:n,i,h,u)}if(arguments.length===3){l=""+l,c=""+c;const h=this._nodes.get(l);if(!h)throw new je(`Graph.${s}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(c))throw new je(`Graph.${s}: could not find the "${c}" target node in the graph.`);return qy(!0,n,this.multi,i,h,c,u)}throw new tt(`Graph.${s}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const o="some"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(){const l=Array.prototype.slice.call(arguments),c=l.pop();return l.push((h,p,m,v,_,y,g)=>c(h,p,m,v,_,y,g)),!!this[s].apply(this,l)};const a="every"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[a]=function(){const l=Array.prototype.slice.call(arguments),c=l.pop();return l.push((h,p,m,v,_,y,g)=>!c(h,p,m,v,_,y,g)),!this[s].apply(this,l)}}function IB(r,e){const{name:t,type:n,direction:i}=e,s=t.slice(0,-1)+"Entries";r.prototype[s]=function(o,a){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return Mr.empty();if(!arguments.length)return bB(this,n);if(arguments.length===1){o=""+o;const l=this._nodes.get(o);if(!l)throw new je(`Graph.${s}: could not find the "${o}" node in the graph.`);return TB(n,i,l)}if(arguments.length===2){o=""+o,a=""+a;const l=this._nodes.get(o);if(!l)throw new je(`Graph.${s}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new je(`Graph.${s}: could not find the "${a}" target node in the graph.`);return CB(n,i,l,a)}throw new tt(`Graph.${s}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function DB(r){yB.forEach(e=>{RB(r,e),PB(r,e),LB(r,e),IB(r,e)})}const UB=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function Rp(){this.A=null,this.B=null}Rp.prototype.wrap=function(r){this.A===null?this.A=r:this.B===null&&(this.B=r)};Rp.prototype.has=function(r){return this.A!==null&&r in this.A||this.B!==null&&r in this.B};function Yc(r,e,t,n,i){for(const s in n){const o=n[s],a=o.source,l=o.target,c=a===t?l:a;if(e&&e.has(c.key))continue;const u=i(c.key,c.attributes);if(r&&u)return c.key}}function Zy(r,e,t,n,i){if(e!=="mixed"){if(e==="undirected")return Yc(r,null,n,n.undirected,i);if(typeof t=="string")return Yc(r,null,n,n[t],i)}const s=new Rp;let o;if(e!=="undirected"){if(t!=="out"){if(o=Yc(r,null,n,n.in,i),r&&o)return o;s.wrap(n.in)}if(t!=="in"){if(o=Yc(r,s,n,n.out,i),r&&o)return o;s.wrap(n.out)}}if(e!=="directed"&&(o=Yc(r,s,n,n.undirected,i),r&&o))return o}function OB(r,e,t){if(r!=="mixed"){if(r==="undirected")return Object.keys(t.undirected);if(typeof e=="string")return Object.keys(t[e])}const n=[];return Zy(!1,r,e,t,function(i){n.push(i)}),n}function qc(r,e,t){const n=Object.keys(t),i=n.length;let s=0;return new Mr(function(){let a=null;do{if(s>=i)return r&&r.wrap(t),{done:!0};const l=t[n[s++]],c=l.source,u=l.target;if(a=c===e?u:c,r&&r.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}})}function NB(r,e,t){if(r!=="mixed"){if(r==="undirected")return qc(null,t,t.undirected);if(typeof e=="string")return qc(null,t,t[e])}let n=Mr.empty();const i=new Rp;return r!=="undirected"&&(e!=="out"&&(n=zs(n,qc(i,t,t.in))),e!=="in"&&(n=zs(n,qc(i,t,t.out)))),r!=="directed"&&(n=zs(n,qc(i,t,t.undirected))),n}function FB(r,e){const{name:t,type:n,direction:i}=e;r.prototype[t]=function(s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];s=""+s;const o=this._nodes.get(s);if(typeof o>"u")throw new je(`Graph.${t}: could not find the "${s}" node in the graph.`);return OB(n==="mixed"?this.type:n,i,o)}}function kB(r,e){const{name:t,type:n,direction:i}=e,s="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(c,u){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;c=""+c;const h=this._nodes.get(c);if(typeof h>"u")throw new je(`Graph.${s}: could not find the "${c}" node in the graph.`);Zy(!1,n==="mixed"?this.type:n,i,h,u)};const o="map"+t[0].toUpperCase()+t.slice(1);r.prototype[o]=function(c,u){const h=[];return this[s](c,(p,m)=>{h.push(u(p,m))}),h};const a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(c,u){const h=[];return this[s](c,(p,m)=>{u(p,m)&&h.push(p)}),h};const l="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[l]=function(c,u,h){if(arguments.length<3)throw new tt(`Graph.${l}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let p=h;return this[s](c,(m,v)=>{p=u(p,m,v)}),p}}function zB(r,e){const{name:t,type:n,direction:i}=e,s=t[0].toUpperCase()+t.slice(1,-1),o="find"+s;r.prototype[o]=function(c,u){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;c=""+c;const h=this._nodes.get(c);if(typeof h>"u")throw new je(`Graph.${o}: could not find the "${c}" node in the graph.`);return Zy(!0,n==="mixed"?this.type:n,i,h,u)};const a="some"+s;r.prototype[a]=function(c,u){return!!this[o](c,u)};const l="every"+s;r.prototype[l]=function(c,u){return!this[o](c,(p,m)=>!u(p,m))}}function BB(r,e){const{name:t,type:n,direction:i}=e,s=t.slice(0,-1)+"Entries";r.prototype[s]=function(o){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return Mr.empty();o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new je(`Graph.${s}: could not find the "${o}" node in the graph.`);return NB(n==="mixed"?this.type:n,i,a)}}function GB(r){UB.forEach(e=>{FB(r,e),kB(r,e),zB(r,e),BB(r,e)})}function rd(r,e,t,n,i){const s=n._nodes.values(),o=n.type;let a,l,c,u,h,p;for(;a=s.next(),a.done!==!0;){let m=!1;if(l=a.value,o!=="undirected"){u=l.out;for(c in u){h=u[c];do p=h.target,m=!0,i(l.key,p.key,l.attributes,p.attributes,h.key,h.attributes,h.undirected),h=h.next;while(h)}}if(o!=="directed"){u=l.undirected;for(c in u)if(!(e&&l.key>c)){h=u[c];do p=h.target,p.key!==c&&(p=h.source),m=!0,i(l.key,p.key,l.attributes,p.attributes,h.key,h.attributes,h.undirected),h=h.next;while(h)}}t&&!m&&i(l.key,null,l.attributes,null,null,null,null)}}function HB(r,e){const t={key:r};return rA(e.attributes)||(t.attributes=Vn({},e.attributes)),t}function VB(r,e,t){const n={key:e,source:t.source.key,target:t.target.key};return rA(t.attributes)||(n.attributes=Vn({},t.attributes)),r==="mixed"&&t.undirected&&(n.undirected=!0),n}function WB(r){if(!ri(r))throw new tt('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in r))throw new tt("Graph.import: serialized node is missing its key.");if("attributes"in r&&(!ri(r.attributes)||r.attributes===null))throw new tt("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function XB(r){if(!ri(r))throw new tt('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in r))throw new tt("Graph.import: serialized edge is missing its source.");if(!("target"in r))throw new tt("Graph.import: serialized edge is missing its target.");if("attributes"in r&&(!ri(r.attributes)||r.attributes===null))throw new tt("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in r&&typeof r.undirected!="boolean")throw new tt("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const jB=qz(),YB=new Set(["directed","undirected","mixed"]),$S=new Set(["domain","_events","_eventsCount","_maxListeners"]),qB=[{name:r=>`${r}Edge`,generateKey:!0},{name:r=>`${r}DirectedEdge`,generateKey:!0,type:"directed"},{name:r=>`${r}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:r=>`${r}EdgeWithKey`},{name:r=>`${r}DirectedEdgeWithKey`,type:"directed"},{name:r=>`${r}UndirectedEdgeWithKey`,type:"undirected"}],ZB={allowSelfLoops:!0,multi:!1,type:"mixed"};function KB(r,e,t){if(t&&!ri(t))throw new tt(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(e=""+e,t=t||{},r._nodes.has(e))throw new ft(`Graph.addNode: the "${e}" node already exist in the graph.`);const n=new r.NodeDataClass(e,t);return r._nodes.set(e,n),r.emit("nodeAdded",{key:e,attributes:t}),n}function JS(r,e,t){const n=new r.NodeDataClass(e,t);return r._nodes.set(e,n),r.emit("nodeAdded",{key:e,attributes:t}),n}function fA(r,e,t,n,i,s,o,a){if(!n&&r.type==="undirected")throw new ft(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(n&&r.type==="directed")throw new ft(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!ri(a))throw new tt(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`);if(s=""+s,o=""+o,a=a||{},!r.allowSelfLoops&&s===o)throw new ft(`Graph.${e}: source & target are the same ("${s}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const l=r._nodes.get(s),c=r._nodes.get(o);if(!l)throw new je(`Graph.${e}: source node "${s}" not found.`);if(!c)throw new je(`Graph.${e}: target node "${o}" not found.`);const u={key:null,undirected:n,source:s,target:o,attributes:a};if(t)i=r._edgeKeyGenerator();else if(i=""+i,r._edges.has(i))throw new ft(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!r.multi&&(n?typeof l.undirected[o]<"u":typeof l.out[o]<"u"))throw new ft(`Graph.${e}: an edge linking "${s}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const h=new nc(n,i,l,c,a);r._edges.set(i,h);const p=s===o;return n?(l.undirectedDegree++,c.undirectedDegree++,p&&(l.undirectedLoops++,r._undirectedSelfLoopCount++)):(l.outDegree++,c.inDegree++,p&&(l.directedLoops++,r._directedSelfLoopCount++)),r.multi?h.attachMulti():h.attach(),n?r._undirectedSize++:r._directedSize++,u.key=i,r.emit("edgeAdded",u),i}function $B(r,e,t,n,i,s,o,a,l){if(!n&&r.type==="undirected")throw new ft(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(n&&r.type==="directed")throw new ft(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(l){if(typeof a!="function")throw new tt(`Graph.${e}: invalid updater function. Expecting a function but got "${a}"`)}else if(!ri(a))throw new tt(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`)}s=""+s,o=""+o;let c;if(l&&(c=a,a=void 0),!r.allowSelfLoops&&s===o)throw new ft(`Graph.${e}: source & target are the same ("${s}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let u=r._nodes.get(s),h=r._nodes.get(o),p,m;if(!t&&(p=r._edges.get(i),p)){if((p.source.key!==s||p.target.key!==o)&&(!n||p.source.key!==o||p.target.key!==s))throw new ft(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${s}" source & "${o}" target vs. ("${p.source.key}", "${p.target.key}").`);m=p}if(!m&&!r.multi&&u&&(m=n?u.undirected[o]:u.out[o]),m){const x=[m.key,!1,!1,!1];if(l?!c:!a)return x;if(l){const w=m.attributes;m.attributes=c(w),r.emit("edgeAttributesUpdated",{type:"replace",key:m.key,attributes:m.attributes})}else Vn(m.attributes,a),r.emit("edgeAttributesUpdated",{type:"merge",key:m.key,attributes:m.attributes,data:a});return x}a=a||{},l&&c&&(a=c(a));const v={key:null,undirected:n,source:s,target:o,attributes:a};if(t)i=r._edgeKeyGenerator();else if(i=""+i,r._edges.has(i))throw new ft(`Graph.${e}: the "${i}" edge already exists in the graph.`);let _=!1,y=!1;u||(u=JS(r,s,{}),_=!0,s===o&&(h=u,y=!0)),h||(h=JS(r,o,{}),y=!0),p=new nc(n,i,u,h,a),r._edges.set(i,p);const g=s===o;return n?(u.undirectedDegree++,h.undirectedDegree++,g&&(u.undirectedLoops++,r._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,g&&(u.directedLoops++,r._directedSelfLoopCount++)),r.multi?p.attachMulti():p.attach(),n?r._undirectedSize++:r._directedSize++,v.key=i,r.emit("edgeAdded",v),[i,!0,_,y]}function El(r,e){r._edges.delete(e.key);const{source:t,target:n,attributes:i}=e,s=e.undirected,o=t===n;s?(t.undirectedDegree--,n.undirectedDegree--,o&&(t.undirectedLoops--,r._undirectedSelfLoopCount--)):(t.outDegree--,n.inDegree--,o&&(t.directedLoops--,r._directedSelfLoopCount--)),r.multi?e.detachMulti():e.detach(),s?r._undirectedSize--:r._directedSize--,r.emit("edgeDropped",{key:e.key,attributes:i,source:t.key,target:n.key,undirected:s})}class en extends Gz.EventEmitter{constructor(e){if(super(),e=Vn({},ZB,e),typeof e.multi!="boolean")throw new tt(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!YB.has(e.type))throw new tt(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new tt(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);const t=e.type==="mixed"?sA:e.type==="directed"?oA:aA;mr(this,"NodeDataClass",t);const n="geid_"+jB()+"_";let i=0;const s=()=>{let o;do o=n+i++;while(this._edges.has(o));return o};mr(this,"_attributes",{}),mr(this,"_nodes",new Map),mr(this,"_edges",new Map),mr(this,"_directedSize",0),mr(this,"_undirectedSize",0),mr(this,"_directedSelfLoopCount",0),mr(this,"_undirectedSelfLoopCount",0),mr(this,"_edgeKeyGenerator",s),mr(this,"_options",e),$S.forEach(o=>mr(this,o,this[o])),Ir(this,"order",()=>this._nodes.size),Ir(this,"size",()=>this._edges.size),Ir(this,"directedSize",()=>this._directedSize),Ir(this,"undirectedSize",()=>this._undirectedSize),Ir(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Ir(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Ir(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Ir(this,"multi",this._options.multi),Ir(this,"type",this._options.type),Ir(this,"allowSelfLoops",this._options.allowSelfLoops),Ir(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,t){if(this.type==="undirected")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.out.hasOwnProperty(t):!1}throw new tt(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,t){if(this.type==="directed")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(t):!1}throw new tt(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,t){if(arguments.length===1){const n=""+e;return this._edges.has(n)}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?typeof n.out<"u"&&n.out.hasOwnProperty(t)||typeof n.undirected<"u"&&n.undirected.hasOwnProperty(t):!1}throw new tt(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,t){if(this.type==="undirected")return;if(e=""+e,t=""+t,this.multi)throw new ft("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const n=this._nodes.get(e);if(!n)throw new je(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new je(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const i=n.out&&n.out[t]||void 0;if(i)return i.key}undirectedEdge(e,t){if(this.type==="directed")return;if(e=""+e,t=""+t,this.multi)throw new ft("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const n=this._nodes.get(e);if(!n)throw new je(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new je(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const i=n.undirected&&n.undirected[t]||void 0;if(i)return i.key}edge(e,t){if(this.multi)throw new ft("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new je(`Graph.edge: could not find the "${t}" target node in the graph.`);const i=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(i)return i.key}areDirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in||t in n.out}areOutNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.out}areInNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in}areUndirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:t in n.undirected}areNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(t in n.in||t in n.out)||this.type!=="directed"&&t in n.undirected}areInboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.in||this.type!=="directed"&&t in n.undirected}areOutboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new je(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.out||this.type!=="directed"&&t in n.undirected}inDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree),n}outboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.outDegree),n}degree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree),n}inDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree,i+=t.directedLoops),n-i}outboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.outDegree,i+=t.directedLoops),n-i}degreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree,i+=t.directedLoops*2),n-i}source(e){e=""+e;const t=this._edges.get(e);if(!t)throw new je(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=""+e;const t=this._edges.get(e);if(!t)throw new je(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=""+e;const t=this._edges.get(e);if(!t)throw new je(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=""+e,t=""+t;const n=this._edges.get(t);if(!n)throw new je(`Graph.opposite: could not find the "${t}" edge in the graph.`);const i=n.source.key,s=n.target.key;if(e===i)return s;if(e===s)return i;throw new je(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${i}, ${s}).`)}hasExtremity(e,t){e=""+e,t=""+t;const n=this._edges.get(e);if(!n)throw new je(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===t||n.target.key===t}isUndirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new je(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new je(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=""+e;const t=this._edges.get(e);if(!t)throw new je(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return KB(this,e,t).key}mergeNode(e,t){if(t&&!ri(t))throw new tt(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=""+e,t=t||{};let n=this._nodes.get(e);return n?(t&&(Vn(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!="function")throw new tt(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=""+e;let n=this._nodes.get(e);if(n){if(t){const s=n.attributes;n.attributes=t(s),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return[e,!1]}const i=t?t({}):{};return n=new this.NodeDataClass(e,i),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new je(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!=="undirected"){for(const i in t.out){n=t.out[i];do El(this,n),n=n.next;while(n)}for(const i in t.in){n=t.in[i];do El(this,n),n=n.next;while(n)}}if(this.type!=="directed")for(const i in t.undirected){n=t.undirected[i];do El(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){const n=""+arguments[0],i=""+arguments[1];if(t=br(this,n,i,this.type),!t)throw new je(`Graph.dropEdge: could not find the "${n}" -> "${i}" edge in the graph.`)}else if(e=""+e,t=this._edges.get(e),!t)throw new je(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return El(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new ft("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new ft("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,t=""+t;const n=br(this,e,t,"directed");if(!n)throw new je(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return El(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new ft("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new ft("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const n=br(this,e,t,"undirected");if(!n)throw new je(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return El(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const e=this._nodes.values();let t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!="function")throw new tt("Graph.updateAttribute: updater should be a function.");const n=this._attributes[e];return this._attributes[e]=t(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!ri(e))throw new tt("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!ri(e))throw new tt("Graph.mergeAttributes: provided attributes are not a plain object.");return Vn(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new tt("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!="function")throw new tt("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!KS(t))throw new tt("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._nodes.values();let i,s;for(;i=n.next(),i.done!==!0;)s=i.value,s.attributes=e(s.key,s.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!="function")throw new tt("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!KS(t))throw new tt("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._edges.values();let i,s,o,a;for(;i=n.next(),i.done!==!0;)s=i.value,o=s.source,a=s.target,s.attributes=e(s.key,s.attributes,o.key,a.key,o.attributes,a.attributes,s.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new tt("Graph.forEachAdjacencyEntry: expecting a callback.");rd(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new tt("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");rd(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new tt("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");rd(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new tt("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");rd(!1,!0,!0,this,e)}nodes(){return typeof Array.from=="function"?Array.from(this._nodes.keys()):iA(this._nodes.keys(),this._nodes.size)}forEachNode(e){if(typeof e!="function")throw new tt("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new tt("Graph.findNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new tt("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let n,i;const s=new Array(this.order);let o=0;for(;n=t.next(),n.done!==!0;)i=n.value,s[o++]=e(i.key,i.attributes);return s}someNode(e){if(typeof e!="function")throw new tt("Graph.someNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new tt("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new tt("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let n,i;const s=[];for(;n=t.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)&&s.push(i.key);return s}reduceNodes(e,t){if(typeof e!="function")throw new tt("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new tt("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let n=t;const i=this._nodes.values();let s,o;for(;s=i.next(),s.done!==!0;)o=s.value,n=e(n,o.key,o.attributes);return n}nodeEntries(){const e=this._nodes.values();return new Mr(()=>{const t=e.next();if(t.done)return t;const n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}})}export(){const e=new Array(this._nodes.size);let t=0;this._nodes.forEach((i,s)=>{e[t++]=HB(s,i)});const n=new Array(this._edges.size);return t=0,this._edges.forEach((i,s)=>{n[t++]=VB(this.type,s,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(e,t=!1){if(e instanceof en)return e.forEachNode((l,c)=>{t?this.mergeNode(l,c):this.addNode(l,c)}),e.forEachEdge((l,c,u,h,p,m,v)=>{t?v?this.mergeUndirectedEdgeWithKey(l,u,h,c):this.mergeDirectedEdgeWithKey(l,u,h,c):v?this.addUndirectedEdgeWithKey(l,u,h,c):this.addDirectedEdgeWithKey(l,u,h,c)}),this;if(!ri(e))throw new tt("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!ri(e.attributes))throw new tt("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let n,i,s,o,a;if(e.nodes){if(s=e.nodes,!Array.isArray(s))throw new tt("Graph.import: invalid nodes. Expecting an array.");for(n=0,i=s.length;n<i;n++){o=s[n],WB(o);const{key:l,attributes:c}=o;t?this.mergeNode(l,c):this.addNode(l,c)}}if(e.edges){let l=!1;if(this.type==="undirected"&&(l=!0),s=e.edges,!Array.isArray(s))throw new tt("Graph.import: invalid edges. Expecting an array.");for(n=0,i=s.length;n<i;n++){a=s[n],XB(a);const{source:c,target:u,attributes:h,undirected:p=l}=a;let m;"key"in a?(m=t?p?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:p?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,m.call(this,a.key,c,u,h)):(m=t?p?this.mergeUndirectedEdge:this.mergeDirectedEdge:p?this.addUndirectedEdge:this.addDirectedEdge,m.call(this,c,u,h))}}return this}nullCopy(e){const t=new en(Vn({},this._options,e));return t.replaceAttributes(Vn({},this.getAttributes())),t}emptyCopy(e){const t=this.nullCopy(e);return this._nodes.forEach((n,i)=>{const s=Vn({},n.attributes);n=new t.NodeDataClass(i,s),t._nodes.set(i,n)}),t}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new ft(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new ft("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new ft("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(e),n=this._edges.values();let i,s;for(;i=n.next(),i.done!==!0;)s=i.value,fA(t,"copy",!1,s.undirected,s.key,s.source.key,s.target.key,Vn({},s.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const e={};this._nodes.forEach((s,o)=>{e[o]=s.attributes});const t={},n={};this._edges.forEach((s,o)=>{const a=s.undirected?"--":"->";let l="",c=s.source.key,u=s.target.key,h;s.undirected&&c>u&&(h=c,c=u,u=h);const p=`(${c})${a}(${u})`;o.startsWith("geid_")?this.multi&&(typeof n[p]>"u"?n[p]=0:n[p]++,l+=`${n[p]}. `):l+=`[${o}]: `,l+=p,t[l]=s.attributes});const i={};for(const s in this)this.hasOwnProperty(s)&&!$S.has(s)&&typeof this[s]!="function"&&typeof s!="symbol"&&(i[s]=this[s]);return i.attributes=this._attributes,i.nodes=e,i.edges=t,mr(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(en.prototype[Symbol.for("nodejs.util.inspect.custom")]=en.prototype.inspect);qB.forEach(r=>{["add","merge","update"].forEach(e=>{const t=r.name(e),n=e==="add"?fA:$B;r.generateKey?en.prototype[t]=function(i,s,o){return n(this,t,!0,(r.type||this.type)==="undirected",null,i,s,o,e==="update")}:en.prototype[t]=function(i,s,o,a){return n(this,t,!1,(r.type||this.type)==="undirected",i,s,o,a,e==="update")}})});oB(en);vB(en);DB(en);GB(en);class dA extends en{constructor(e){const t=Vn({type:"directed"},e);if("multi"in t&&t.multi!==!1)throw new tt("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new tt('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class pA extends en{constructor(e){const t=Vn({type:"undirected"},e);if("multi"in t&&t.multi!==!1)throw new tt("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new tt('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class mA extends en{constructor(e){const t=Vn({multi:!0},e);if("multi"in t&&t.multi!==!0)throw new tt("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class gA extends en{constructor(e){const t=Vn({type:"directed",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new tt("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new tt('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class vA extends en{constructor(e){const t=Vn({type:"undirected",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new tt("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new tt('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function ic(r){r.from=function(e,t){const n=Vn({},e.options,t),i=new r(n);return i.import(e),i}}ic(en);ic(dA);ic(pA);ic(mA);ic(gA);ic(vA);en.Graph=en;en.DirectedGraph=dA;en.UndirectedGraph=pA;en.MultiGraph=mA;en.MultiDirectedGraph=gA;en.MultiUndirectedGraph=vA;en.InvalidArgumentsGraphError=tt;en.NotFoundGraphError=je;en.UsageGraphError=ft;const ph=new Y,Ky=new Y,JB=new Y;function QB(r,e,t){const n=ph.setFromMatrixPosition(r.matrixWorld);n.project(e);const i=t.width/2,s=t.height/2;return[n.x*i+i,-(n.y*s)+s]}function e4(r,e){const t=ph.setFromMatrixPosition(r.matrixWorld),n=Ky.setFromMatrixPosition(e.matrixWorld),i=t.sub(n),s=e.getWorldDirection(JB);return i.angleTo(s)>Math.PI/2}function t4(r,e,t,n){const i=ph.setFromMatrixPosition(r.matrixWorld),s=i.clone();s.project(e),t.setFromCamera(s,e);const o=t.intersectObjects(n,!0);if(o.length){const a=o[0].distance;return i.distanceTo(t.ray.origin)<a}return!0}function n4(r,e){if(e instanceof Pa)return e.zoom;if(e instanceof zn){const t=ph.setFromMatrixPosition(r.matrixWorld),n=Ky.setFromMatrixPosition(e.matrixWorld),i=e.fov*Math.PI/180,s=t.distanceTo(n);return 1/(2*Math.tan(i/2)*s)}else return 1}function i4(r,e,t){if(e instanceof zn||e instanceof Pa){const n=ph.setFromMatrixPosition(r.matrixWorld),i=Ky.setFromMatrixPosition(e.matrixWorld),s=n.distanceTo(i),o=(t[1]-t[0])/(e.far-e.near),a=t[1]-o*e.far;return Math.round(o*s+a)}}const Mv=r=>Math.abs(r)<1e-10?0:r;function yA(r,e,t=""){let n="matrix3d(";for(let i=0;i!==16;i++)n+=Mv(e[i]*r.elements[i])+(i!==15?",":")");return t+n}const r4=(r=>e=>yA(e,r))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),s4=(r=>(e,t)=>yA(e,r(t),"translate(-50%,-50%)"))(r=>[1/r,1/r,1/r,1,-1/r,-1/r,-1/r,-1,1/r,1/r,1/r,1,1,1,1,1]);function o4(r){return r&&typeof r=="object"&&"current"in r}const $y=K.forwardRef(({children:r,eps:e=.001,style:t,className:n,prepend:i,center:s,fullscreen:o,portal:a,distanceFactor:l,sprite:c=!1,transform:u=!1,occlude:h,onOcclude:p,castShadow:m,receiveShadow:v,material:_,geometry:y,zIndexRange:g=[16777271,0],calculatePosition:x=QB,as:w="div",wrapperClass:E,pointerEvents:b="auto",...M},A)=>{const{gl:P,camera:C,scene:L,size:F,raycaster:N,events:I,viewport:X}=Bn(),[q]=K.useState(()=>document.createElement(w)),W=K.useRef(),O=K.useRef(null),k=K.useRef(0),G=K.useRef([0,0]),B=K.useRef(null),D=K.useRef(null),V=(a==null?void 0:a.current)||I.connected||P.domElement.parentNode,Z=K.useRef(null),ee=K.useRef(!1),ie=K.useMemo(()=>h&&h!=="blending"||Array.isArray(h)&&h.length&&o4(h[0]),[h]);K.useLayoutEffect(()=>{const Ee=P.domElement;h&&h==="blending"?(Ee.style.zIndex=`${Math.floor(g[0]/2)}`,Ee.style.position="absolute",Ee.style.pointerEvents="none"):(Ee.style.zIndex=null,Ee.style.position=null,Ee.style.pointerEvents=null)},[h]),K.useLayoutEffect(()=>{if(O.current){const Ee=W.current=q2.createRoot(q);if(L.updateMatrixWorld(),u)q.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const ae=x(O.current,C,F);q.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${ae[0]}px,${ae[1]}px,0);transform-origin:0 0;`}return V&&(i?V.prepend(q):V.appendChild(q)),()=>{V&&V.removeChild(q),Ee.unmount()}}},[V,u]),K.useLayoutEffect(()=>{E&&(q.className=E)},[E]);const ue=K.useMemo(()=>u?{position:"absolute",top:0,left:0,width:F.width,height:F.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:s?"translate3d(-50%,-50%,0)":"none",...o&&{top:-F.height/2,left:-F.width/2,width:F.width,height:F.height},...t},[t,s,o,F,u]),ce=K.useMemo(()=>({position:"absolute",pointerEvents:b}),[b]);K.useLayoutEffect(()=>{if(ee.current=!1,u){var Ee;(Ee=W.current)==null||Ee.render(K.createElement("div",{ref:B,style:ue},K.createElement("div",{ref:D,style:ce},K.createElement("div",{ref:A,className:n,style:t,children:r}))))}else{var ae;(ae=W.current)==null||ae.render(K.createElement("div",{ref:A,style:ue,className:n,children:r}))}});const le=K.useRef(!0);Ep(Ee=>{if(O.current){C.updateMatrixWorld(),O.current.updateWorldMatrix(!0,!1);const ae=u?G.current:x(O.current,C,F);if(u||Math.abs(k.current-C.zoom)>e||Math.abs(G.current[0]-ae[0])>e||Math.abs(G.current[1]-ae[1])>e){const z=e4(O.current,C);let oe=!1;ie&&(Array.isArray(h)?oe=h.map(Ie=>Ie.current):h!=="blending"&&(oe=[L]));const te=le.current;if(oe){const Ie=t4(O.current,C,N,oe);le.current=Ie&&!z}else le.current=!z;te!==le.current&&(p?p(!le.current):q.style.display=le.current?"block":"none");const se=Math.floor(g[0]/2),$=h?ie?[g[0],se]:[se-1,0]:g;if(q.style.zIndex=`${i4(O.current,C,$)}`,u){const[Ie,de]=[F.width/2,F.height/2],Se=C.projectionMatrix.elements[5]*de,{isOrthographicCamera:Le,top:ge,left:He,bottom:j,right:H}=C,ne=r4(C.matrixWorldInverse),we=Le?`scale(${Se})translate(${Mv(-(H+He)/2)}px,${Mv((ge+j)/2)}px)`:`translateZ(${Se}px)`;let be=O.current.matrixWorld;c&&(be=C.matrixWorldInverse.clone().transpose().copyPosition(be).scale(O.current.scale),be.elements[3]=be.elements[7]=be.elements[11]=0,be.elements[15]=1),q.style.width=F.width+"px",q.style.height=F.height+"px",q.style.perspective=Le?"":`${Se}px`,B.current&&D.current&&(B.current.style.transform=`${we}${ne}translate(${Ie}px,${de}px)`,D.current.style.transform=s4(be,1/((l||10)/400)))}else{const Ie=l===void 0?1:n4(O.current,C)*l;q.style.transform=`translate3d(${ae[0]}px,${ae[1]}px,0) scale(${Ie})`}G.current=ae,k.current=C.zoom}}if(!ie&&Z.current&&!ee.current)if(u){if(B.current){const ae=B.current.children[0];if(ae!=null&&ae.clientWidth&&ae!=null&&ae.clientHeight){const{isOrthographicCamera:z}=C;if(z||y)M.scale&&(Array.isArray(M.scale)?M.scale instanceof Y?Z.current.scale.copy(M.scale.clone().divideScalar(1)):Z.current.scale.set(1/M.scale[0],1/M.scale[1],1/M.scale[2]):Z.current.scale.setScalar(1/M.scale));else{const oe=(l||10)/400,te=ae.clientWidth*oe,se=ae.clientHeight*oe;Z.current.scale.set(te,se,1)}ee.current=!0}}}else{const ae=q.children[0];if(ae!=null&&ae.clientWidth&&ae!=null&&ae.clientHeight){const z=1/X.factor,oe=ae.clientWidth*z,te=ae.clientHeight*z;Z.current.scale.set(oe,te,1),ee.current=!0}Z.current.lookAt(Ee.camera.position)}});const Ae=K.useMemo(()=>({vertexShader:u?void 0:`
|
|
/*
|
|
This shader is from the THREE's SpriteMaterial.
|
|
We need to turn the backing plane into a Sprite
|
|
(make it always face the camera) if "transfrom"
|
|
is false.
|
|
*/
|
|
#include <common>
|
|
|
|
void main() {
|
|
vec2 center = vec2(0., 1.);
|
|
float rotation = 0.0;
|
|
|
|
// This is somewhat arbitrary, but it seems to work well
|
|
// Need to figure out how to derive this dynamically if it even matters
|
|
float size = 0.03;
|
|
|
|
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
vec2 scale;
|
|
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
|
|
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
|
|
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) scale *= - mvPosition.z;
|
|
|
|
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size;
|
|
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;
|
|
}
|
|
`,fragmentShader:`
|
|
void main() {
|
|
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
}
|
|
`}),[u]);return K.createElement("group",Ta({},M,{ref:O}),h&&!ie&&K.createElement("mesh",{castShadow:m,receiveShadow:v,ref:Z},y||K.createElement("planeGeometry",null),_||K.createElement("shaderMaterial",{side:vn,vertexShader:Ae.vertexShader,fragmentShader:Ae.fragmentShader})))});function ya(r,e="pointer",t="auto",n=document.body){K.useEffect(()=>{if(r)return n.style.cursor=e,()=>void(n.style.cursor=t)},[r])}let Jy=gh();const xt=r=>mh(r,Jy);let Qy=gh();xt.write=r=>mh(r,Qy);let Pp=gh();xt.onStart=r=>mh(r,Pp);let e_=gh();xt.onFrame=r=>mh(r,e_);let t_=gh();xt.onFinish=r=>mh(r,t_);let Gl=[];xt.setTimeout=(r,e)=>{let t=xt.now()+e,n=()=>{let s=Gl.findIndex(o=>o.cancel==n);~s&&Gl.splice(s,1),po-=~s?1:0},i={time:t,handler:r,cancel:n};return Gl.splice(_A(t),0,i),po+=1,xA(),i};let _A=r=>~(~Gl.findIndex(e=>e.time>r)||~Gl.length);xt.cancel=r=>{Pp.delete(r),e_.delete(r),t_.delete(r),Jy.delete(r),Qy.delete(r)};xt.sync=r=>{Tv=!0,xt.batchedUpdates(r),Tv=!1};xt.throttle=r=>{let e;function t(){try{r(...e)}finally{e=null}}function n(...i){e=i,xt.onStart(t)}return n.handler=r,n.cancel=()=>{Pp.delete(t),e=null},n};let n_=typeof window<"u"?window.requestAnimationFrame:()=>{};xt.use=r=>n_=r;xt.now=typeof performance<"u"?()=>performance.now():Date.now;xt.batchedUpdates=r=>r();xt.catch=console.error;xt.frameLoop="always";xt.advance=()=>{xt.frameLoop!=="demand"?console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"):SA()};let fo=-1,po=0,Tv=!1;function mh(r,e){Tv?(e.delete(r),r(0)):(e.add(r),xA())}function xA(){fo<0&&(fo=0,xt.frameLoop!=="demand"&&n_(wA))}function a4(){fo=-1}function wA(){~fo&&(n_(wA),xt.batchedUpdates(SA))}function SA(){let r=fo;fo=xt.now();let e=_A(fo);if(e&&(EA(Gl.splice(0,e),t=>t.handler()),po-=e),!po){a4();return}Pp.flush(),Jy.flush(r?Math.min(64,fo-r):16.667),e_.flush(),Qy.flush(),t_.flush()}function gh(){let r=new Set,e=r;return{add(t){po+=e==r&&!r.has(t)?1:0,r.add(t)},delete(t){return po-=e==r&&r.has(t)?1:0,r.delete(t)},flush(t){e.size&&(r=new Set,po-=e.size,EA(e,n=>n(t)&&r.add(n)),po+=r.size,e=r)}}}function EA(r,e){r.forEach(t=>{try{e(t)}catch(n){xt.catch(n)}})}function Av(){}const l4=(r,e,t)=>Object.defineProperty(r,e,{value:t,writable:!0,configurable:!0}),Ze={arr:Array.isArray,obj:r=>!!r&&r.constructor.name==="Object",fun:r=>typeof r=="function",str:r=>typeof r=="string",num:r=>typeof r=="number",und:r=>r===void 0};function Ds(r,e){if(Ze.arr(r)){if(!Ze.arr(e)||r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}return r===e}const Kt=(r,e)=>r.forEach(e);function Gs(r,e,t){if(Ze.arr(r)){for(let n=0;n<r.length;n++)e.call(t,r[n],`${n}`);return}for(const n in r)r.hasOwnProperty(n)&&e.call(t,r[n],n)}const Er=r=>Ze.und(r)?[]:Ze.arr(r)?r:[r];function Su(r,e){if(r.size){const t=Array.from(r);r.clear(),Kt(t,e)}}const mu=(r,...e)=>Su(r,t=>t(...e)),i_=()=>typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent);let r_,bA,_o=null,MA=!1,s_=Av;const c4=r=>{r.to&&(bA=r.to),r.now&&(xt.now=r.now),r.colors!==void 0&&(_o=r.colors),r.skipAnimation!=null&&(MA=r.skipAnimation),r.createStringInterpolator&&(r_=r.createStringInterpolator),r.requestAnimationFrame&&xt.use(r.requestAnimationFrame),r.batchedUpdates&&(xt.batchedUpdates=r.batchedUpdates),r.willAdvance&&(s_=r.willAdvance),r.frameLoop&&(xt.frameLoop=r.frameLoop)};var us=Object.freeze({__proto__:null,get createStringInterpolator(){return r_},get to(){return bA},get colors(){return _o},get skipAnimation(){return MA},get willAdvance(){return s_},assign:c4});const Eu=new Set;let Sr=[],u0=[],Bd=0;const Lp={get idle(){return!Eu.size&&!Sr.length},start(r){Bd>r.priority?(Eu.add(r),xt.onStart(u4)):(TA(r),xt(Cv))},advance:Cv,sort(r){if(Bd)xt.onFrame(()=>Lp.sort(r));else{const e=Sr.indexOf(r);~e&&(Sr.splice(e,1),AA(r))}},clear(){Sr=[],Eu.clear()}};function u4(){Eu.forEach(TA),Eu.clear(),xt(Cv)}function TA(r){Sr.includes(r)||AA(r)}function AA(r){Sr.splice(h4(Sr,e=>e.priority>r.priority),0,r)}function Cv(r){const e=u0;for(let t=0;t<Sr.length;t++){const n=Sr[t];Bd=n.priority,n.idle||(s_(n),n.advance(r),n.idle||e.push(n))}return Bd=0,u0=Sr,u0.length=0,Sr=e,Sr.length>0}function h4(r,e){const t=r.findIndex(e);return t<0?r.length:t}const f4={transparent:0,aliceblue:4042850303,antiquewhite:4209760255,aqua:16777215,aquamarine:2147472639,azure:4043309055,beige:4126530815,bisque:4293182719,black:255,blanchedalmond:4293643775,blue:65535,blueviolet:2318131967,brown:2771004159,burlywood:3736635391,burntsienna:3934150143,cadetblue:1604231423,chartreuse:2147418367,chocolate:3530104575,coral:4286533887,cornflowerblue:1687547391,cornsilk:4294499583,crimson:3692313855,cyan:16777215,darkblue:35839,darkcyan:9145343,darkgoldenrod:3095792639,darkgray:2846468607,darkgreen:6553855,darkgrey:2846468607,darkkhaki:3182914559,darkmagenta:2332068863,darkolivegreen:1433087999,darkorange:4287365375,darkorchid:2570243327,darkred:2332033279,darksalmon:3918953215,darkseagreen:2411499519,darkslateblue:1211993087,darkslategray:793726975,darkslategrey:793726975,darkturquoise:13554175,darkviolet:2483082239,deeppink:4279538687,deepskyblue:12582911,dimgray:1768516095,dimgrey:1768516095,dodgerblue:512819199,firebrick:2988581631,floralwhite:4294635775,forestgreen:579543807,fuchsia:4278255615,gainsboro:3705462015,ghostwhite:4177068031,gold:4292280575,goldenrod:3668254975,gray:2155905279,green:8388863,greenyellow:2919182335,grey:2155905279,honeydew:4043305215,hotpink:4285117695,indianred:3445382399,indigo:1258324735,ivory:4294963455,khaki:4041641215,lavender:3873897215,lavenderblush:4293981695,lawngreen:2096890111,lemonchiffon:4294626815,lightblue:2916673279,lightcoral:4034953471,lightcyan:3774873599,lightgoldenrodyellow:4210742015,lightgray:3553874943,lightgreen:2431553791,lightgrey:3553874943,lightpink:4290167295,lightsalmon:4288707327,lightseagreen:548580095,lightskyblue:2278488831,lightslategray:2005441023,lightslategrey:2005441023,lightsteelblue:2965692159,lightyellow:4294959359,lime:16711935,limegreen:852308735,linen:4210091775,magenta:4278255615,maroon:2147483903,mediumaquamarine:1724754687,mediumblue:52735,mediumorchid:3126187007,mediumpurple:2473647103,mediumseagreen:1018393087,mediumslateblue:2070474495,mediumspringgreen:16423679,mediumturquoise:1221709055,mediumvioletred:3340076543,midnightblue:421097727,mintcream:4127193855,mistyrose:4293190143,moccasin:4293178879,navajowhite:4292783615,navy:33023,oldlace:4260751103,olive:2155872511,olivedrab:1804477439,orange:4289003775,orangered:4282712319,orchid:3664828159,palegoldenrod:4008225535,palegreen:2566625535,paleturquoise:2951671551,palevioletred:3681588223,papayawhip:4293907967,peachpuff:4292524543,peru:3448061951,pink:4290825215,plum:3718307327,powderblue:2967529215,purple:2147516671,rebeccapurple:1714657791,red:4278190335,rosybrown:3163525119,royalblue:1097458175,saddlebrown:2336560127,salmon:4202722047,sandybrown:4104413439,seagreen:780883967,seashell:4294307583,sienna:2689740287,silver:3233857791,skyblue:2278484991,slateblue:1784335871,slategray:1887473919,slategrey:1887473919,snow:4294638335,springgreen:16744447,steelblue:1182971135,tan:3535047935,teal:8421631,thistle:3636451583,tomato:4284696575,turquoise:1088475391,violet:4001558271,wheat:4125012991,white:4294967295,whitesmoke:4126537215,yellow:4294902015,yellowgreen:2597139199},kr="[-+]?\\d*\\.?\\d+",Gd=kr+"%";function Ip(...r){return"\\(\\s*("+r.join(")\\s*,\\s*(")+")\\s*\\)"}const d4=new RegExp("rgb"+Ip(kr,kr,kr)),p4=new RegExp("rgba"+Ip(kr,kr,kr,kr)),m4=new RegExp("hsl"+Ip(kr,Gd,Gd)),g4=new RegExp("hsla"+Ip(kr,Gd,Gd,kr)),v4=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,y4=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,_4=/^#([0-9a-fA-F]{6})$/,x4=/^#([0-9a-fA-F]{8})$/;function w4(r){let e;return typeof r=="number"?r>>>0===r&&r>=0&&r<=4294967295?r:null:(e=_4.exec(r))?parseInt(e[1]+"ff",16)>>>0:_o&&_o[r]!==void 0?_o[r]:(e=d4.exec(r))?(bl(e[1])<<24|bl(e[2])<<16|bl(e[3])<<8|255)>>>0:(e=p4.exec(r))?(bl(e[1])<<24|bl(e[2])<<16|bl(e[3])<<8|tE(e[4]))>>>0:(e=v4.exec(r))?parseInt(e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+"ff",16)>>>0:(e=x4.exec(r))?parseInt(e[1],16)>>>0:(e=y4.exec(r))?parseInt(e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+e[4]+e[4],16)>>>0:(e=m4.exec(r))?(QS(eE(e[1]),sd(e[2]),sd(e[3]))|255)>>>0:(e=g4.exec(r))?(QS(eE(e[1]),sd(e[2]),sd(e[3]))|tE(e[4]))>>>0:null}function h0(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*(2/3-t)*6:r}function QS(r,e,t){const n=t<.5?t*(1+e):t+e-t*e,i=2*t-n,s=h0(i,n,r+1/3),o=h0(i,n,r),a=h0(i,n,r-1/3);return Math.round(s*255)<<24|Math.round(o*255)<<16|Math.round(a*255)<<8}function bl(r){const e=parseInt(r,10);return e<0?0:e>255?255:e}function eE(r){return(parseFloat(r)%360+360)%360/360}function tE(r){const e=parseFloat(r);return e<0?0:e>1?255:Math.round(e*255)}function sd(r){const e=parseFloat(r);return e<0?0:e>100?1:e/100}function nE(r){let e=w4(r);if(e===null)return r;e=e||0;let t=(e&4278190080)>>>24,n=(e&16711680)>>>16,i=(e&65280)>>>8,s=(e&255)/255;return`rgba(${t}, ${n}, ${i}, ${s})`}const qu=(r,e,t)=>{if(Ze.fun(r))return r;if(Ze.arr(r))return qu({range:r,output:e,extrapolate:t});if(Ze.str(r.output[0]))return r_(r);const n=r,i=n.output,s=n.range||[0,1],o=n.extrapolateLeft||n.extrapolate||"extend",a=n.extrapolateRight||n.extrapolate||"extend",l=n.easing||(c=>c);return c=>{const u=E4(c,s);return S4(c,s[u],s[u+1],i[u],i[u+1],l,o,a,n.map)}};function S4(r,e,t,n,i,s,o,a,l){let c=l?l(r):r;if(c<e){if(o==="identity")return c;o==="clamp"&&(c=e)}if(c>t){if(a==="identity")return c;a==="clamp"&&(c=t)}return n===i?n:e===t?r<=e?n:i:(e===-1/0?c=-c:t===1/0?c=c-e:c=(c-e)/(t-e),c=s(c),n===-1/0?c=-c:i===1/0?c=c+n:c=c*(i-n)+n,c)}function E4(r,e){for(var t=1;t<e.length-1&&!(e[t]>=r);++t);return t-1}const b4={linear:r=>r};function Rv(){return Rv=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},Rv.apply(this,arguments)}const Kl=Symbol.for("FluidValue.get"),Ca=Symbol.for("FluidValue.observers"),is=r=>!!(r&&r[Kl]),_r=r=>r&&r[Kl]?r[Kl]():r,iE=r=>r[Ca]||null;function M4(r,e){r.eventObserved?r.eventObserved(e):r(e)}function Hd(r,e){let t=r[Ca];t&&t.forEach(n=>{M4(n,e)})}class T4{constructor(e){if(this[Kl]=void 0,this[Ca]=void 0,!e&&!(e=this.get))throw Error("Unknown getter");A4(this,e)}}const A4=(r,e)=>CA(r,Kl,e);function vh(r,e){if(r[Kl]){let t=r[Ca];t||CA(r,Ca,t=new Set),t.has(e)||(t.add(e),r.observerAdded&&r.observerAdded(t.size,e))}return e}function Vd(r,e){let t=r[Ca];if(t&&t.has(e)){const n=t.size-1;n?t.delete(e):r[Ca]=null,r.observerRemoved&&r.observerRemoved(n,e)}}const CA=(r,e,t)=>Object.defineProperty(r,e,{value:t,writable:!0,configurable:!0}),Cd=/[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,C4=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi,rE=new RegExp(`(${Cd.source})(%|[a-z]+)`,"i"),R4=/rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi,Dp=/var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/,RA=r=>{const[e,t]=P4(r);if(!e||i_())return r;const n=window.getComputedStyle(document.documentElement).getPropertyValue(e);if(n)return n.trim();if(t&&t.startsWith("--")){const i=window.getComputedStyle(document.documentElement).getPropertyValue(t);return i||r}else{if(t&&Dp.test(t))return RA(t);if(t)return t}return r},P4=r=>{const e=Dp.exec(r);if(!e)return[,];const[,t,n]=e;return[t,n]};let f0;const L4=(r,e,t,n,i)=>`rgba(${Math.round(e)}, ${Math.round(t)}, ${Math.round(n)}, ${i})`,PA=r=>{f0||(f0=_o?new RegExp(`(${Object.keys(_o).join("|")})(?!\\w)`,"g"):/^\b$/);const e=r.output.map(s=>_r(s).replace(Dp,RA).replace(C4,nE).replace(f0,nE)),t=e.map(s=>s.match(Cd).map(Number)),i=t[0].map((s,o)=>t.map(a=>{if(!(o in a))throw Error('The arity of each "output" value must be equal');return a[o]})).map(s=>qu(Rv({},r,{output:s})));return s=>{var o;const a=!rE.test(e[0])&&((o=e.find(c=>rE.test(c)))==null?void 0:o.replace(Cd,""));let l=0;return e[0].replace(Cd,()=>`${i[l++](s)}${a||""}`).replace(R4,L4)}},o_="react-spring: ",LA=r=>{const e=r;let t=!1;if(typeof e!="function")throw new TypeError(`${o_}once requires a function parameter`);return(...n)=>{t||(e(...n),t=!0)}},I4=LA(console.warn);function D4(){I4(`${o_}The "interpolate" function is deprecated in v9 (use "to" instead)`)}const U4=LA(console.warn);function O4(){U4(`${o_}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`)}function Up(r){return Ze.str(r)&&(r[0]=="#"||/\d/.test(r)||!i_()&&Dp.test(r)||r in(_o||{}))}const a_=i_()?K.useEffect:K.useLayoutEffect,N4=()=>{const r=K.useRef(!1);return a_(()=>(r.current=!0,()=>{r.current=!1}),[]),r};function IA(){const r=K.useState()[1],e=N4();return()=>{e.current&&r(Math.random())}}function F4(r,e){const[t]=K.useState(()=>({inputs:e,result:r()})),n=K.useRef(),i=n.current;let s=i;return s?e&&s.inputs&&k4(e,s.inputs)||(s={inputs:e,result:r()}):s=t,K.useEffect(()=>{n.current=s,i==t&&(t.inputs=t.result=void 0)},[s]),s.result}function k4(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}const DA=r=>K.useEffect(r,z4),z4=[];function sE(r){const e=K.useRef();return K.useEffect(()=>{e.current=r}),e.current}const Zu=Symbol.for("Animated:node"),B4=r=>!!r&&r[Zu]===r,ns=r=>r&&r[Zu],l_=(r,e)=>l4(r,Zu,e),Op=r=>r&&r[Zu]&&r[Zu].getPayload();class UA{constructor(){this.payload=void 0,l_(this,this)}getPayload(){return this.payload||[]}}class rc extends UA{constructor(e){super(),this.done=!0,this.elapsedTime=void 0,this.lastPosition=void 0,this.lastVelocity=void 0,this.v0=void 0,this.durationProgress=0,this._value=e,Ze.num(this._value)&&(this.lastPosition=this._value)}static create(e){return new rc(e)}getPayload(){return[this]}getValue(){return this._value}setValue(e,t){return Ze.num(e)&&(this.lastPosition=e,t&&(e=Math.round(e/t)*t,this.done&&(this.lastPosition=e))),this._value===e?!1:(this._value=e,!0)}reset(){const{done:e}=this;this.done=!1,Ze.num(this._value)&&(this.elapsedTime=0,this.durationProgress=0,this.lastPosition=this._value,e&&(this.lastVelocity=null),this.v0=null)}}class $l extends rc{constructor(e){super(0),this._string=null,this._toString=void 0,this._toString=qu({output:[e,e]})}static create(e){return new $l(e)}getValue(){let e=this._string;return e??(this._string=this._toString(this._value))}setValue(e){if(Ze.str(e)){if(e==this._string)return!1;this._string=e,this._value=1}else if(super.setValue(e))this._string=null;else return!1;return!0}reset(e){e&&(this._toString=qu({output:[this.getValue(),e]})),this._value=0,super.reset()}}const Wd={dependencies:null};class c_ extends UA{constructor(e){super(),this.source=e,this.setValue(e)}getValue(e){const t={};return Gs(this.source,(n,i)=>{B4(n)?t[i]=n.getValue(e):is(n)?t[i]=_r(n):e||(t[i]=n)}),t}setValue(e){this.source=e,this.payload=this._makePayload(e)}reset(){this.payload&&Kt(this.payload,e=>e.reset())}_makePayload(e){if(e){const t=new Set;return Gs(e,this._addToPayload,t),Array.from(t)}}_addToPayload(e){Wd.dependencies&&is(e)&&Wd.dependencies.add(e);const t=Op(e);t&&Kt(t,n=>this.add(n))}}class u_ extends c_{constructor(e){super(e)}static create(e){return new u_(e)}getValue(){return this.source.map(e=>e.getValue())}setValue(e){const t=this.getPayload();return e.length==t.length?t.map((n,i)=>n.setValue(e[i])).some(Boolean):(super.setValue(e.map(G4)),!0)}}function G4(r){return(Up(r)?$l:rc).create(r)}function Pv(r){const e=ns(r);return e?e.constructor:Ze.arr(r)?u_:Up(r)?$l:rc}function Xd(){return Xd=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},Xd.apply(this,arguments)}const oE=(r,e)=>{const t=!Ze.fun(r)||r.prototype&&r.prototype.isReactComponent;return K.forwardRef((n,i)=>{const s=K.useRef(null),o=t&&K.useCallback(v=>{s.current=W4(i,v)},[i]),[a,l]=V4(n,e),c=IA(),u=()=>{const v=s.current;if(t&&!v)return;(v?e.applyAnimatedValues(v,a.getValue(!0)):!1)===!1&&c()},h=new H4(u,l),p=K.useRef();a_(()=>(p.current=h,Kt(l,v=>vh(v,h)),()=>{p.current&&(Kt(p.current.deps,v=>Vd(v,p.current)),xt.cancel(p.current.update))})),K.useEffect(u,[]),DA(()=>()=>{const v=p.current;Kt(v.deps,_=>Vd(_,v))});const m=e.getComponentProps(a.getValue());return K.createElement(r,Xd({},m,{ref:o}))})};class H4{constructor(e,t){this.update=e,this.deps=t}eventObserved(e){e.type=="change"&&xt.write(this.update)}}function V4(r,e){const t=new Set;return Wd.dependencies=t,r.style&&(r=Xd({},r,{style:e.createAnimatedStyle(r.style)})),r=new c_(r),Wd.dependencies=null,[r,t]}function W4(r,e){return r&&(Ze.fun(r)?r(e):r.current=e),e}const aE=Symbol.for("AnimatedComponent"),X4=(r,{applyAnimatedValues:e=()=>!1,createAnimatedStyle:t=i=>new c_(i),getComponentProps:n=i=>i}={})=>{const i={applyAnimatedValues:e,createAnimatedStyle:t,getComponentProps:n},s=o=>{const a=lE(o)||"Anonymous";return Ze.str(o)?o=s[o]||(s[o]=oE(o,i)):o=o[aE]||(o[aE]=oE(o,i)),o.displayName=`Animated(${a})`,o};return Gs(r,(o,a)=>{Ze.arr(r)&&(a=lE(o)),s[a]=s(o)}),{animated:s}},lE=r=>Ze.str(r)?r:r&&Ze.str(r.displayName)?r.displayName:Ze.fun(r)&&r.name||null;function ei(){return ei=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},ei.apply(this,arguments)}function ca(r,...e){return Ze.fun(r)?r(...e):r}const bu=(r,e)=>r===!0||!!(e&&r&&(Ze.fun(r)?r(e):Er(r).includes(e))),OA=(r,e)=>Ze.obj(r)?e&&r[e]:r,NA=(r,e)=>r.default===!0?r[e]:r.default?r.default[e]:void 0,j4=r=>r,h_=(r,e=j4)=>{let t=Y4;r.default&&r.default!==!0&&(r=r.default,t=Object.keys(r));const n={};for(const i of t){const s=e(r[i],i);Ze.und(s)||(n[i]=s)}return n},Y4=["config","onProps","onStart","onChange","onPause","onResume","onRest"],q4={config:1,from:1,to:1,ref:1,loop:1,reset:1,pause:1,cancel:1,reverse:1,immediate:1,default:1,delay:1,onProps:1,onStart:1,onChange:1,onPause:1,onResume:1,onRest:1,onResolve:1,items:1,trail:1,sort:1,expires:1,initial:1,enter:1,update:1,leave:1,children:1,onDestroyed:1,keys:1,callId:1,parentId:1};function Z4(r){const e={};let t=0;if(Gs(r,(n,i)=>{q4[i]||(e[i]=n,t++)}),t)return e}function FA(r){const e=Z4(r);if(e){const t={to:e};return Gs(r,(n,i)=>i in e||(t[i]=n)),t}return ei({},r)}function Ku(r){return r=_r(r),Ze.arr(r)?r.map(Ku):Up(r)?us.createStringInterpolator({range:[0,1],output:[r,r]})(1):r}function K4(r){for(const e in r)return!0;return!1}function Lv(r){return Ze.fun(r)||Ze.arr(r)&&Ze.obj(r[0])}function $4(r,e){var t;(t=r.ref)==null||t.delete(r),e==null||e.delete(r)}function J4(r,e){if(e&&r.ref!==e){var t;(t=r.ref)==null||t.delete(r),e.add(r),r.ref=e}}const Q4={default:{tension:170,friction:26}},Iv=ei({},Q4.default,{mass:1,damping:1,easing:b4.linear,clamp:!1});class eG{constructor(){this.tension=void 0,this.friction=void 0,this.frequency=void 0,this.damping=void 0,this.mass=void 0,this.velocity=0,this.restVelocity=void 0,this.precision=void 0,this.progress=void 0,this.duration=void 0,this.easing=void 0,this.clamp=void 0,this.bounce=void 0,this.decay=void 0,this.round=void 0,Object.assign(this,Iv)}}function tG(r,e,t){t&&(t=ei({},t),cE(t,e),e=ei({},t,e)),cE(r,e),Object.assign(r,e);for(const o in Iv)r[o]==null&&(r[o]=Iv[o]);let{mass:n,frequency:i,damping:s}=r;return Ze.und(i)||(i<.01&&(i=.01),s<0&&(s=0),r.tension=Math.pow(2*Math.PI/i,2)*n,r.friction=4*Math.PI*s*n/i),r}function cE(r,e){if(!Ze.und(e.decay))r.duration=void 0;else{const t=!Ze.und(e.tension)||!Ze.und(e.friction);(t||!Ze.und(e.frequency)||!Ze.und(e.damping)||!Ze.und(e.mass))&&(r.duration=void 0,r.decay=void 0),t&&(r.frequency=void 0)}}const uE=[];class nG{constructor(){this.changed=!1,this.values=uE,this.toValues=null,this.fromValues=uE,this.to=void 0,this.from=void 0,this.config=new eG,this.immediate=!1}}function kA(r,{key:e,props:t,defaultProps:n,state:i,actions:s}){return new Promise((o,a)=>{var l;let c,u,h=bu((l=t.cancel)!=null?l:n==null?void 0:n.cancel,e);if(h)v();else{Ze.und(t.pause)||(i.paused=bu(t.pause,e));let _=n==null?void 0:n.pause;_!==!0&&(_=i.paused||bu(_,e)),c=ca(t.delay||0,e),_?(i.resumeQueue.add(m),s.pause()):(s.resume(),m())}function p(){i.resumeQueue.add(m),i.timeouts.delete(u),u.cancel(),c=u.time-xt.now()}function m(){c>0&&!us.skipAnimation?(i.delayed=!0,u=xt.setTimeout(v,c),i.pauseQueue.add(p),i.timeouts.add(u)):v()}function v(){i.delayed&&(i.delayed=!1),i.pauseQueue.delete(p),i.timeouts.delete(u),r<=(i.cancelId||0)&&(h=!0);try{s.start(ei({},t,{callId:r,cancel:h}),o)}catch(_){a(_)}}})}const f_=(r,e)=>e.length==1?e[0]:e.some(t=>t.cancelled)?Hl(r.get()):e.every(t=>t.noop)?zA(r.get()):Fr(r.get(),e.every(t=>t.finished)),zA=r=>({value:r,noop:!0,finished:!0,cancelled:!1}),Fr=(r,e,t=!1)=>({value:r,finished:e,cancelled:t}),Hl=r=>({value:r,cancelled:!0,finished:!1});function BA(r,e,t,n){const{callId:i,parentId:s,onRest:o}=e,{asyncTo:a,promise:l}=t;return!s&&r===a&&!e.reset?l:t.promise=(async()=>{t.asyncId=i,t.asyncTo=r;const c=h_(e,(y,g)=>g==="onRest"?void 0:y);let u,h;const p=new Promise((y,g)=>(u=y,h=g)),m=y=>{const g=i<=(t.cancelId||0)&&Hl(n)||i!==t.asyncId&&Fr(n,!1);if(g)throw y.result=g,h(y),y},v=(y,g)=>{const x=new hE,w=new fE;return(async()=>{if(us.skipAnimation)throw $u(t),w.result=Fr(n,!1),h(w),w;m(x);const E=Ze.obj(y)?ei({},y):ei({},g,{to:y});E.parentId=i,Gs(c,(M,A)=>{Ze.und(E[A])&&(E[A]=M)});const b=await n.start(E);return m(x),t.paused&&await new Promise(M=>{t.resumeQueue.add(M)}),b})()};let _;if(us.skipAnimation)return $u(t),Fr(n,!1);try{let y;Ze.arr(r)?y=(async g=>{for(const x of g)await v(x)})(r):y=Promise.resolve(r(v,n.stop.bind(n))),await Promise.all([y.then(u),p]),_=Fr(n.get(),!0,!1)}catch(y){if(y instanceof hE)_=y.result;else if(y instanceof fE)_=y.result;else throw y}finally{i==t.asyncId&&(t.asyncId=s,t.asyncTo=s?a:void 0,t.promise=s?l:void 0)}return Ze.fun(o)&&xt.batchedUpdates(()=>{o(_,n,n.item)}),_})()}function $u(r,e){Su(r.timeouts,t=>t.cancel()),r.pauseQueue.clear(),r.resumeQueue.clear(),r.asyncId=r.asyncTo=r.promise=void 0,e&&(r.cancelId=e)}class hE extends Error{constructor(){super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise."),this.result=void 0}}class fE extends Error{constructor(){super("SkipAnimationSignal"),this.result=void 0}}const Dv=r=>r instanceof d_;let iG=1;class d_ extends T4{constructor(...e){super(...e),this.id=iG++,this.key=void 0,this._priority=0}get priority(){return this._priority}set priority(e){this._priority!=e&&(this._priority=e,this._onPriorityChange(e))}get(){const e=ns(this);return e&&e.getValue()}to(...e){return us.to(this,e)}interpolate(...e){return D4(),us.to(this,e)}toJSON(){return this.get()}observerAdded(e){e==1&&this._attach()}observerRemoved(e){e==0&&this._detach()}_attach(){}_detach(){}_onChange(e,t=!1){Hd(this,{type:"change",parent:this,value:e,idle:t})}_onPriorityChange(e){this.idle||Lp.sort(this),Hd(this,{type:"priority",parent:this,priority:e})}}const Ra=Symbol.for("SpringPhase"),GA=1,Uv=2,Ov=4,d0=r=>(r[Ra]&GA)>0,co=r=>(r[Ra]&Uv)>0,Zc=r=>(r[Ra]&Ov)>0,dE=(r,e)=>e?r[Ra]|=Uv|GA:r[Ra]&=~Uv,pE=(r,e)=>e?r[Ra]|=Ov:r[Ra]&=~Ov;class rG extends d_{constructor(e,t){if(super(),this.key=void 0,this.animation=new nG,this.queue=void 0,this.defaultProps={},this._state={paused:!1,delayed:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set},this._pendingCalls=new Set,this._lastCallId=0,this._lastToId=0,this._memoizedDuration=0,!Ze.und(e)||!Ze.und(t)){const n=Ze.obj(e)?ei({},e):ei({},t,{from:e});Ze.und(n.default)&&(n.default=!0),this.start(n)}}get idle(){return!(co(this)||this._state.asyncTo)||Zc(this)}get goal(){return _r(this.animation.to)}get velocity(){const e=ns(this);return e instanceof rc?e.lastVelocity||0:e.getPayload().map(t=>t.lastVelocity||0)}get hasAnimated(){return d0(this)}get isAnimating(){return co(this)}get isPaused(){return Zc(this)}get isDelayed(){return this._state.delayed}advance(e){let t=!0,n=!1;const i=this.animation;let{config:s,toValues:o}=i;const a=Op(i.to);!a&&is(i.to)&&(o=Er(_r(i.to))),i.values.forEach((u,h)=>{if(u.done)return;const p=u.constructor==$l?1:a?a[h].lastPosition:o[h];let m=i.immediate,v=p;if(!m){if(v=u.lastPosition,s.tension<=0){u.done=!0;return}let _=u.elapsedTime+=e;const y=i.fromValues[h],g=u.v0!=null?u.v0:u.v0=Ze.arr(s.velocity)?s.velocity[h]:s.velocity;let x;const w=s.precision||(y==p?.005:Math.min(1,Math.abs(p-y)*.001));if(Ze.und(s.duration))if(s.decay){const E=s.decay===!0?.998:s.decay,b=Math.exp(-(1-E)*_);v=y+g/(1-E)*(1-b),m=Math.abs(u.lastPosition-v)<=w,x=g*b}else{x=u.lastVelocity==null?g:u.lastVelocity;const E=s.restVelocity||w/10,b=s.clamp?0:s.bounce,M=!Ze.und(b),A=y==p?u.v0>0:y<p;let P,C=!1;const L=1,F=Math.ceil(e/L);for(let N=0;N<F&&(P=Math.abs(x)>E,!(!P&&(m=Math.abs(p-v)<=w,m)));++N){M&&(C=v==p||v>p==A,C&&(x=-x*b,v=p));const I=-s.tension*1e-6*(v-p),X=-s.friction*.001*x,q=(I+X)/s.mass;x=x+q*L,v=v+x*L}}else{let E=1;s.duration>0&&(this._memoizedDuration!==s.duration&&(this._memoizedDuration=s.duration,u.durationProgress>0&&(u.elapsedTime=s.duration*u.durationProgress,_=u.elapsedTime+=e)),E=(s.progress||0)+_/this._memoizedDuration,E=E>1?1:E<0?0:E,u.durationProgress=E),v=y+s.easing(E)*(p-y),x=(v-u.lastPosition)/e,m=E==1}u.lastVelocity=x,Number.isNaN(v)&&(console.warn("Got NaN while animating:",this),m=!0)}a&&!a[h].done&&(m=!1),m?u.done=!0:t=!1,u.setValue(v,s.round)&&(n=!0)});const l=ns(this),c=l.getValue();if(t){const u=_r(i.to);(c!==u||n)&&!s.decay?(l.setValue(u),this._onChange(u)):n&&s.decay&&this._onChange(c),this._stop()}else n&&this._onChange(c)}set(e){return xt.batchedUpdates(()=>{this._stop(),this._focus(e),this._set(e)}),this}pause(){this._update({pause:!0})}resume(){this._update({pause:!1})}finish(){if(co(this)){const{to:e,config:t}=this.animation;xt.batchedUpdates(()=>{this._onStart(),t.decay||this._set(e,!1),this._stop()})}return this}update(e){return(this.queue||(this.queue=[])).push(e),this}start(e,t){let n;return Ze.und(e)?(n=this.queue||[],this.queue=[]):n=[Ze.obj(e)?e:ei({},t,{to:e})],Promise.all(n.map(i=>this._update(i))).then(i=>f_(this,i))}stop(e){const{to:t}=this.animation;return this._focus(this.get()),$u(this._state,e&&this._lastCallId),xt.batchedUpdates(()=>this._stop(t,e)),this}reset(){this._update({reset:!0})}eventObserved(e){e.type=="change"?this._start():e.type=="priority"&&(this.priority=e.priority+1)}_prepareNode(e){const t=this.key||"";let{to:n,from:i}=e;n=Ze.obj(n)?n[t]:n,(n==null||Lv(n))&&(n=void 0),i=Ze.obj(i)?i[t]:i,i==null&&(i=void 0);const s={to:n,from:i};return d0(this)||(e.reverse&&([n,i]=[i,n]),i=_r(i),Ze.und(i)?ns(this)||this._set(n):this._set(i)),s}_update(e,t){let n=ei({},e);const{key:i,defaultProps:s}=this;n.default&&Object.assign(s,h_(n,(l,c)=>/^on/.test(c)?OA(l,i):l)),gE(this,n,"onProps"),$c(this,"onProps",n,this);const o=this._prepareNode(n);if(Object.isFrozen(this))throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?");const a=this._state;return kA(++this._lastCallId,{key:i,props:n,defaultProps:s,state:a,actions:{pause:()=>{Zc(this)||(pE(this,!0),mu(a.pauseQueue),$c(this,"onPause",Fr(this,Kc(this,this.animation.to)),this))},resume:()=>{Zc(this)&&(pE(this,!1),co(this)&&this._resume(),mu(a.resumeQueue),$c(this,"onResume",Fr(this,Kc(this,this.animation.to)),this))},start:this._merge.bind(this,o)}}).then(l=>{if(n.loop&&l.finished&&!(t&&l.noop)){const c=HA(n);if(c)return this._update(c,!0)}return l})}_merge(e,t,n){if(t.cancel)return this.stop(!0),n(Hl(this));const i=!Ze.und(e.to),s=!Ze.und(e.from);if(i||s)if(t.callId>this._lastToId)this._lastToId=t.callId;else return n(Hl(this));const{key:o,defaultProps:a,animation:l}=this,{to:c,from:u}=l;let{to:h=c,from:p=u}=e;s&&!i&&(!t.default||Ze.und(h))&&(h=p),t.reverse&&([h,p]=[p,h]);const m=!Ds(p,u);m&&(l.from=p),p=_r(p);const v=!Ds(h,c);v&&this._focus(h);const _=Lv(t.to),{config:y}=l,{decay:g,velocity:x}=y;(i||s)&&(y.velocity=0),t.config&&!_&&tG(y,ca(t.config,o),t.config!==a.config?ca(a.config,o):void 0);let w=ns(this);if(!w||Ze.und(h))return n(Fr(this,!0));const E=Ze.und(t.reset)?s&&!t.default:!Ze.und(p)&&bu(t.reset,o),b=E?p:this.get(),M=Ku(h),A=Ze.num(M)||Ze.arr(M)||Up(M),P=!_&&(!A||bu(a.immediate||t.immediate,o));if(v){const N=Pv(h);if(N!==w.constructor)if(P)w=this._set(M);else throw Error(`Cannot animate between ${w.constructor.name} and ${N.name}, as the "to" prop suggests`)}const C=w.constructor;let L=is(h),F=!1;if(!L){const N=E||!d0(this)&&m;(v||N)&&(F=Ds(Ku(b),M),L=!F),(!Ds(l.immediate,P)&&!P||!Ds(y.decay,g)||!Ds(y.velocity,x))&&(L=!0)}if(F&&co(this)&&(l.changed&&!E?L=!0:L||this._stop(c)),!_&&((L||is(c))&&(l.values=w.getPayload(),l.toValues=is(h)?null:C==$l?[1]:Er(M)),l.immediate!=P&&(l.immediate=P,!P&&!E&&this._set(c)),L)){const{onRest:N}=l;Kt(oG,X=>gE(this,t,X));const I=Fr(this,Kc(this,c));mu(this._pendingCalls,I),this._pendingCalls.add(n),l.changed&&xt.batchedUpdates(()=>{l.changed=!E,N==null||N(I,this),E?ca(a.onRest,I):l.onStart==null||l.onStart(I,this)})}E&&this._set(b),_?n(BA(t.to,t,this._state,this)):L?this._start():co(this)&&!v?this._pendingCalls.add(n):n(zA(b))}_focus(e){const t=this.animation;e!==t.to&&(iE(this)&&this._detach(),t.to=e,iE(this)&&this._attach())}_attach(){let e=0;const{to:t}=this.animation;is(t)&&(vh(t,this),Dv(t)&&(e=t.priority+1)),this.priority=e}_detach(){const{to:e}=this.animation;is(e)&&Vd(e,this)}_set(e,t=!0){const n=_r(e);if(!Ze.und(n)){const i=ns(this);if(!i||!Ds(n,i.getValue())){const s=Pv(n);!i||i.constructor!=s?l_(this,s.create(n)):i.setValue(n),i&&xt.batchedUpdates(()=>{this._onChange(n,t)})}}return ns(this)}_onStart(){const e=this.animation;e.changed||(e.changed=!0,$c(this,"onStart",Fr(this,Kc(this,e.to)),this))}_onChange(e,t){t||(this._onStart(),ca(this.animation.onChange,e,this)),ca(this.defaultProps.onChange,e,this),super._onChange(e,t)}_start(){const e=this.animation;ns(this).reset(_r(e.to)),e.immediate||(e.fromValues=e.values.map(t=>t.lastPosition)),co(this)||(dE(this,!0),Zc(this)||this._resume())}_resume(){us.skipAnimation?this.finish():Lp.start(this)}_stop(e,t){if(co(this)){dE(this,!1);const n=this.animation;Kt(n.values,s=>{s.done=!0}),n.toValues&&(n.onChange=n.onPause=n.onResume=void 0),Hd(this,{type:"idle",parent:this});const i=t?Hl(this.get()):Fr(this.get(),Kc(this,e??n.to));mu(this._pendingCalls,i),n.changed&&(n.changed=!1,$c(this,"onRest",i,this))}}}function Kc(r,e){const t=Ku(e),n=Ku(r.get());return Ds(n,t)}function HA(r,e=r.loop,t=r.to){let n=ca(e);if(n){const i=n!==!0&&FA(n),s=(i||r).reverse,o=!i||i.reset;return Ju(ei({},r,{loop:e,default:!1,pause:void 0,to:!s||Lv(t)?t:void 0,from:o?r.from:void 0,reset:o},i))}}function Ju(r){const{to:e,from:t}=r=FA(r),n=new Set;return Ze.obj(e)&&mE(e,n),Ze.obj(t)&&mE(t,n),r.keys=n.size?Array.from(n):null,r}function sG(r){const e=Ju(r);return Ze.und(e.default)&&(e.default=h_(e)),e}function mE(r,e){Gs(r,(t,n)=>t!=null&&e.add(n))}const oG=["onStart","onRest","onChange","onPause","onResume"];function gE(r,e,t){r.animation[t]=e[t]!==NA(e,t)?OA(e[t],r.key):void 0}function $c(r,e,...t){var n,i,s,o;(n=(i=r.animation)[e])==null||n.call(i,...t),(s=(o=r.defaultProps)[e])==null||s.call(o,...t)}const aG=["onStart","onChange","onRest"];let lG=1;class cG{constructor(e,t){this.id=lG++,this.springs={},this.queue=[],this.ref=void 0,this._flush=void 0,this._initialProps=void 0,this._lastAsyncId=0,this._active=new Set,this._changed=new Set,this._started=!1,this._item=void 0,this._state={paused:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set},this._events={onStart:new Map,onChange:new Map,onRest:new Map},this._onFrame=this._onFrame.bind(this),t&&(this._flush=t),e&&this.start(ei({default:!0},e))}get idle(){return!this._state.asyncTo&&Object.values(this.springs).every(e=>e.idle&&!e.isDelayed&&!e.isPaused)}get item(){return this._item}set item(e){this._item=e}get(){const e={};return this.each((t,n)=>e[n]=t.get()),e}set(e){for(const t in e){const n=e[t];Ze.und(n)||this.springs[t].set(n)}}update(e){return e&&this.queue.push(Ju(e)),this}start(e){let{queue:t}=this;return e?t=Er(e).map(Ju):this.queue=[],this._flush?this._flush(this,t):(YA(this,t),Nv(this,t))}stop(e,t){if(e!==!!e&&(t=e),t){const n=this.springs;Kt(Er(t),i=>n[i].stop(!!e))}else $u(this._state,this._lastAsyncId),this.each(n=>n.stop(!!e));return this}pause(e){if(Ze.und(e))this.start({pause:!0});else{const t=this.springs;Kt(Er(e),n=>t[n].pause())}return this}resume(e){if(Ze.und(e))this.start({pause:!1});else{const t=this.springs;Kt(Er(e),n=>t[n].resume())}return this}each(e){Gs(this.springs,e)}_onFrame(){const{onStart:e,onChange:t,onRest:n}=this._events,i=this._active.size>0,s=this._changed.size>0;(i&&!this._started||s&&!this._started)&&(this._started=!0,Su(e,([l,c])=>{c.value=this.get(),l(c,this,this._item)}));const o=!i&&this._started,a=s||o&&n.size?this.get():null;s&&t.size&&Su(t,([l,c])=>{c.value=a,l(c,this,this._item)}),o&&(this._started=!1,Su(n,([l,c])=>{c.value=a,l(c,this,this._item)}))}eventObserved(e){if(e.type=="change")this._changed.add(e.parent),e.idle||this._active.add(e.parent);else if(e.type=="idle")this._active.delete(e.parent);else return;xt.onFrame(this._onFrame)}}function Nv(r,e){return Promise.all(e.map(t=>VA(r,t))).then(t=>f_(r,t))}async function VA(r,e,t){const{keys:n,to:i,from:s,loop:o,onRest:a,onResolve:l}=e,c=Ze.obj(e.default)&&e.default;o&&(e.loop=!1),i===!1&&(e.to=null),s===!1&&(e.from=null);const u=Ze.arr(i)||Ze.fun(i)?i:void 0;u?(e.to=void 0,e.onRest=void 0,c&&(c.onRest=void 0)):Kt(aG,_=>{const y=e[_];if(Ze.fun(y)){const g=r._events[_];e[_]=({finished:x,cancelled:w})=>{const E=g.get(y);E?(x||(E.finished=!1),w&&(E.cancelled=!0)):g.set(y,{value:null,finished:x||!1,cancelled:w||!1})},c&&(c[_]=e[_])}});const h=r._state;e.pause===!h.paused?(h.paused=e.pause,mu(e.pause?h.pauseQueue:h.resumeQueue)):h.paused&&(e.pause=!0);const p=(n||Object.keys(r.springs)).map(_=>r.springs[_].start(e)),m=e.cancel===!0||NA(e,"cancel")===!0;(u||m&&h.asyncId)&&p.push(kA(++r._lastAsyncId,{props:e,state:h,actions:{pause:Av,resume:Av,start(_,y){m?($u(h,r._lastAsyncId),y(Hl(r))):(_.onRest=a,y(BA(u,_,h,r)))}}})),h.paused&&await new Promise(_=>{h.resumeQueue.add(_)});const v=f_(r,await Promise.all(p));if(o&&v.finished&&!(t&&v.noop)){const _=HA(e,o,i);if(_)return YA(r,[_]),VA(r,_,!0)}return l&&xt.batchedUpdates(()=>l(v,r,r.item)),v}function vE(r,e){const t=ei({},r.springs);return e&&Kt(Er(e),n=>{Ze.und(n.keys)&&(n=Ju(n)),Ze.obj(n.to)||(n=ei({},n,{to:void 0})),jA(t,n,i=>XA(i))}),WA(r,t),t}function WA(r,e){Gs(e,(t,n)=>{r.springs[n]||(r.springs[n]=t,vh(t,r))})}function XA(r,e){const t=new rG;return t.key=r,e&&vh(t,e),t}function jA(r,e,t){e.keys&&Kt(e.keys,n=>{(r[n]||(r[n]=t(n)))._prepareNode(e)})}function YA(r,e){Kt(e,t=>{jA(r.springs,t,n=>XA(n,r))})}function uG(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,s;for(s=0;s<n.length;s++)i=n[s],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}const hG=["children"],Np=r=>{let{children:e}=r,t=uG(r,hG);const n=K.useContext(jd),i=t.pause||!!n.pause,s=t.immediate||!!n.immediate;t=F4(()=>({pause:i,immediate:s}),[i,s]);const{Provider:o}=jd;return K.createElement(o,{value:t},e)},jd=fG(Np,{});Np.Provider=jd.Provider;Np.Consumer=jd.Consumer;function fG(r,e){return Object.assign(r,K.createContext(e)),r.Provider._context=r,r.Consumer._context=r,r}const dG=()=>{const r=[],e=function(i){O4();const s=[];return Kt(r,(o,a)=>{if(Ze.und(i))s.push(o.start());else{const l=t(i,o,a);l&&s.push(o.start(l))}}),s};e.current=r,e.add=function(n){r.includes(n)||r.push(n)},e.delete=function(n){const i=r.indexOf(n);~i&&r.splice(i,1)},e.pause=function(){return Kt(r,n=>n.pause(...arguments)),this},e.resume=function(){return Kt(r,n=>n.resume(...arguments)),this},e.set=function(n){Kt(r,i=>i.set(n))},e.start=function(n){const i=[];return Kt(r,(s,o)=>{if(Ze.und(n))i.push(s.start());else{const a=this._getProps(n,s,o);a&&i.push(s.start(a))}}),i},e.stop=function(){return Kt(r,n=>n.stop(...arguments)),this},e.update=function(n){return Kt(r,(i,s)=>i.update(this._getProps(n,i,s))),this};const t=function(i,s,o){return Ze.fun(i)?i(o,s):i};return e._getProps=t,e};function pG(r,e,t){const n=Ze.fun(e)&&e;n&&!t&&(t=[]);const i=K.useMemo(()=>n||arguments.length==3?dG():void 0,[]),s=K.useRef(0),o=IA(),a=K.useMemo(()=>({ctrls:[],queue:[],flush(g,x){const w=vE(g,x);return s.current>0&&!a.queue.length&&!Object.keys(w).some(b=>!g.springs[b])?Nv(g,x):new Promise(b=>{WA(g,w),a.queue.push(()=>{b(Nv(g,x))}),o()})}}),[]),l=K.useRef([...a.ctrls]),c=[],u=sE(r)||0;K.useMemo(()=>{Kt(l.current.slice(r,u),g=>{$4(g,i),g.stop(!0)}),l.current.length=r,h(u,r)},[r]),K.useMemo(()=>{h(0,Math.min(u,r))},t);function h(g,x){for(let w=g;w<x;w++){const E=l.current[w]||(l.current[w]=new cG(null,a.flush)),b=n?n(w,E):e[w];b&&(c[w]=sG(b))}}const p=l.current.map((g,x)=>vE(g,c[x])),m=K.useContext(Np),v=sE(m),_=m!==v&&K4(m);a_(()=>{s.current++,a.ctrls=l.current;const{queue:g}=a;g.length&&(a.queue=[],Kt(g,x=>x())),Kt(l.current,(x,w)=>{i==null||i.add(x),_&&x.start({default:m});const E=c[w];E&&(J4(x,E.ref),x.ref?x.queue.push(E):x.start(E))})}),DA(()=>()=>{Kt(a.ctrls,g=>g.stop(!0))});const y=p.map(g=>ei({},g));return i?[y,i]:y}function tr(r,e){const t=Ze.fun(r),[[n],i]=pG(1,t?r:[r],t?e||[]:e);return t||arguments.length==2?[n,i]:n}let yE;(function(r){r.MOUNT="mount",r.ENTER="enter",r.UPDATE="update",r.LEAVE="leave"})(yE||(yE={}));class mG extends d_{constructor(e,t){super(),this.key=void 0,this.idle=!0,this.calc=void 0,this._active=new Set,this.source=e,this.calc=qu(...t);const n=this._get(),i=Pv(n);l_(this,i.create(n))}advance(e){const t=this._get(),n=this.get();Ds(t,n)||(ns(this).setValue(t),this._onChange(t,this.idle)),!this.idle&&_E(this._active)&&p0(this)}_get(){const e=Ze.arr(this.source)?this.source.map(_r):Er(_r(this.source));return this.calc(...e)}_start(){this.idle&&!_E(this._active)&&(this.idle=!1,Kt(Op(this),e=>{e.done=!1}),us.skipAnimation?(xt.batchedUpdates(()=>this.advance()),p0(this)):Lp.start(this))}_attach(){let e=1;Kt(Er(this.source),t=>{is(t)&&vh(t,this),Dv(t)&&(t.idle||this._active.add(t),e=Math.max(e,t.priority+1))}),this.priority=e,this._start()}_detach(){Kt(Er(this.source),e=>{is(e)&&Vd(e,this)}),this._active.clear(),p0(this)}eventObserved(e){e.type=="change"?e.idle?this.advance():(this._active.add(e.parent),this._start()):e.type=="idle"?this._active.delete(e.parent):e.type=="priority"&&(this.priority=Er(this.source).reduce((t,n)=>Math.max(t,(Dv(n)?n.priority:0)+1),0))}}function gG(r){return r.idle!==!1}function _E(r){return!r.size||Array.from(r).every(gG)}function p0(r){r.idle||(r.idle=!0,Kt(Op(r),e=>{e.done=!0}),Hd(r,{type:"idle",parent:r}))}us.assign({createStringInterpolator:PA,to:(r,e)=>new mG(r,e)});const vG=["primitive"].concat(Object.keys(uT).filter(r=>/^[A-Z]/.test(r)).map(r=>r[0].toLowerCase()+r.slice(1)));us.assign({createStringInterpolator:PA,colors:f4,frameLoop:"demand"});pO(()=>{xt.advance()});const yG=X4(vG,{applyAnimatedValues:oa}),An=yG.animated,od=(r,e)=>{const t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new Tt;let c=0;if(r.forEach((u,h)=>{let p=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let m in u.attributes){if(!n.has(m))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;s[m]===void 0&&(s[m]=[]),s[m].push(u.attributes[m]),p++}if(p!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let m in u.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[m]===void 0&&(o[m]=[]),o[m].push(u.morphAttributes[m])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(u.userData),e){let m;if(u.index)m=u.index.count;else if(u.attributes.position!==void 0)m=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,m,h),c+=m}}),t){let u=0;const h=[];r.forEach(p=>{const m=p.index;for(let v=0;v<m.count;++v)h.push(m.getX(v)+u);u+=p.attributes.position.count}),l.setIndex(h)}for(let u in s){const h=xE(s[u]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,h)}for(let u in o){const h=o[u][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let p=0;p<h;++p){const m=[];for(let _=0;_<o[u].length;++_)m.push(o[u][_][p]);const v=xE(m);if(!v)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(v)}}return l},xE=r=>{let e,t,n,i=0;if(r.forEach(s=>{if(e===void 0&&(e=s.array.constructor),e!==s.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=s.itemSize),t!==s.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=s.normalized),n!==s.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=s.array.length}),e&&t){const s=new e(i);let o=0;return r.forEach(a=>{s.set(a.array,o),o+=a.array.length}),new $t(s,t,n)}},m0=new oh,g0=new Y,Ml=new Y,Dr=new Y,Ps=new Y,Qr=new Y,Ls=new Y,Is=new Y,Jc=new Y,Qc=new Y,eu=new Y,ad=new Y,tu=new Y,nu=new Y,iu=new Y;class wE{constructor(e,t,n){this.camera=e,this.scene=t,this.startPoint=new Y,this.endPoint=new Y,this.collection=[],this.deep=n||Number.MAX_VALUE}select(e,t){return this.startPoint=e||this.startPoint,this.endPoint=t||this.endPoint,this.collection=[],this.updateFrustum(this.startPoint,this.endPoint),this.searchChildInFrustum(m0,this.scene),this.collection}updateFrustum(e,t){if(e=e||this.startPoint,t=t||this.endPoint,e.x===t.x&&(t.x+=Number.EPSILON),e.y===t.y&&(t.y+=Number.EPSILON),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(),this.camera.isPerspectiveCamera){Ml.copy(e),Ml.x=Math.min(e.x,t.x),Ml.y=Math.max(e.y,t.y),t.x=Math.max(e.x,t.x),t.y=Math.min(e.y,t.y),Dr.setFromMatrixPosition(this.camera.matrixWorld),Ps.copy(Ml),Qr.set(t.x,Ml.y,0),Ls.copy(t),Is.set(Ml.x,t.y,0),Ps.unproject(this.camera),Qr.unproject(this.camera),Ls.unproject(this.camera),Is.unproject(this.camera),tu.copy(Ps).sub(Dr),nu.copy(Qr).sub(Dr),iu.copy(Ls).sub(Dr),tu.normalize(),nu.normalize(),iu.normalize(),tu.multiplyScalar(this.deep),nu.multiplyScalar(this.deep),iu.multiplyScalar(this.deep),tu.add(Dr),nu.add(Dr),iu.add(Dr);var n=m0.planes;n[0].setFromCoplanarPoints(Dr,Ps,Qr),n[1].setFromCoplanarPoints(Dr,Qr,Ls),n[2].setFromCoplanarPoints(Ls,Is,Dr),n[3].setFromCoplanarPoints(Is,Ps,Dr),n[4].setFromCoplanarPoints(Qr,Ls,Is),n[5].setFromCoplanarPoints(iu,nu,tu),n[5].normal.multiplyScalar(-1)}else if(this.camera.isOrthographicCamera){const i=Math.min(e.x,t.x),s=Math.max(e.y,t.y),o=Math.max(e.x,t.x),a=Math.min(e.y,t.y);Ps.set(i,s,-1),Qr.set(o,s,-1),Ls.set(o,a,-1),Is.set(i,a,-1),Jc.set(i,s,1),Qc.set(o,s,1),eu.set(o,a,1),ad.set(i,a,1),Ps.unproject(this.camera),Qr.unproject(this.camera),Ls.unproject(this.camera),Is.unproject(this.camera),Jc.unproject(this.camera),Qc.unproject(this.camera),eu.unproject(this.camera),ad.unproject(this.camera);var n=m0.planes;n[0].setFromCoplanarPoints(Ps,Jc,Qc),n[1].setFromCoplanarPoints(Qr,Qc,eu),n[2].setFromCoplanarPoints(eu,ad,Is),n[3].setFromCoplanarPoints(ad,Jc,Ps),n[4].setFromCoplanarPoints(Qr,Ls,Is),n[5].setFromCoplanarPoints(eu,Qc,Jc),n[5].normal.multiplyScalar(-1)}else console.error("THREE.SelectionBox: Unsupported camera type.")}searchChildInFrustum(e,t){if((t.isMesh||t.isLine||t.isPoints)&&t.material!==void 0&&(t.geometry.boundingSphere===null&&t.geometry.computeBoundingSphere(),g0.copy(t.geometry.boundingSphere.center),g0.applyMatrix4(t.matrixWorld),e.containsPoint(g0)&&this.collection.push(t)),t.children.length>0)for(let n=0;n<t.children.length;n++)this.searchChildInFrustum(e,t.children[n])}}const qA=K.forwardRef(function({children:e,follow:t=!0,lockX:n=!1,lockY:i=!1,lockZ:s=!1,...o},a){const l=K.useRef(null),c=K.useRef(null),u=new si;return Ep(({camera:h})=>{if(!t||!c.current)return;const p=c.current.rotation.clone();c.current.updateMatrix(),c.current.updateWorldMatrix(!1,!1),c.current.getWorldQuaternion(u),h.getWorldQuaternion(l.current.quaternion).premultiply(u.invert()),n&&(c.current.rotation.x=p.x),i&&(c.current.rotation.y=p.y),s&&(c.current.rotation.z=p.z)}),K.useImperativeHandle(a,()=>c.current,[]),K.createElement("group",Ta({ref:c,matrixAutoUpdate:!1,matrixWorldAutoUpdate:!1},o),K.createElement("group",{ref:l},e))});function _G(){var r=Object.create(null);function e(i,s){var o=i.id,a=i.name,l=i.dependencies;l===void 0&&(l=[]);var c=i.init;c===void 0&&(c=function(){});var u=i.getTransferables;if(u===void 0&&(u=null),!r[o])try{l=l.map(function(p){return p&&p.isWorkerModule&&(e(p,function(m){if(m instanceof Error)throw m}),p=r[p.id].value),p}),c=n("<"+a+">.init",c),u&&(u=n("<"+a+">.getTransferables",u));var h=null;typeof c=="function"?h=c.apply(void 0,l):console.error("worker module init function failed to rehydrate"),r[o]={id:o,value:h,getTransferables:u},s(h)}catch(p){p&&p.noLog||console.error(p),s(p)}}function t(i,s){var o,a=i.id,l=i.args;(!r[a]||typeof r[a].value!="function")&&s(new Error("Worker module "+a+": not found or its 'init' did not return a function"));try{var c=(o=r[a]).value.apply(o,l);c&&typeof c.then=="function"?c.then(u,function(h){return s(h instanceof Error?h:new Error(""+h))}):u(c)}catch(h){s(h)}function u(h){try{var p=r[a].getTransferables&&r[a].getTransferables(h);(!p||!Array.isArray(p)||!p.length)&&(p=void 0),s(h,p)}catch(m){console.error(m),s(m)}}}function n(i,s){var o=void 0;self.troikaDefine=function(l){return o=l};var a=URL.createObjectURL(new Blob(["/** "+i.replace(/\*/g,"")+` **/
|
|
|
|
troikaDefine(
|
|
`+s+`
|
|
)`],{type:"application/javascript"}));try{importScripts(a)}catch(l){console.error(l)}return URL.revokeObjectURL(a),delete self.troikaDefine,o}self.addEventListener("message",function(i){var s=i.data,o=s.messageId,a=s.action,l=s.data;try{a==="registerModule"&&e(l,function(c){c instanceof Error?postMessage({messageId:o,success:!1,error:c.message}):postMessage({messageId:o,success:!0,result:{isCallable:typeof c=="function"}})}),a==="callModule"&&t(l,function(c,u){c instanceof Error?postMessage({messageId:o,success:!1,error:c.message}):postMessage({messageId:o,success:!0,result:c},u||void 0)})}catch(c){postMessage({messageId:o,success:!1,error:c.stack})}})}function xG(r){var e=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return e._getInitResult().then(function(i){if(typeof i=="function")return i.apply(void 0,t);throw new Error("Worker module function was called but `init` did not return a callable function")})};return e._getInitResult=function(){var t=r.dependencies,n=r.init;t=Array.isArray(t)?t.map(function(s){return s&&s._getInitResult?s._getInitResult():s}):[];var i=Promise.all(t).then(function(s){return n.apply(null,s)});return e._getInitResult=function(){return i},i},e}var ZA=function(){var r=!1;if(typeof window<"u"&&typeof window.document<"u")try{var e=new Worker(URL.createObjectURL(new Blob([""],{type:"application/javascript"})));e.terminate(),r=!0}catch(t){console.log("Troika createWorkerModule: web workers not allowed; falling back to main thread execution. Cause: ["+t.message+"]")}return ZA=function(){return r},r},wG=0,SG=0,v0=!1,Mu=Object.create(null),Tu=Object.create(null),Fv=Object.create(null);function yh(r){if((!r||typeof r.init!="function")&&!v0)throw new Error("requires `options.init` function");var e=r.dependencies,t=r.init,n=r.getTransferables,i=r.workerId;if(!ZA())return xG(r);i==null&&(i="#default");var s="workerModule"+ ++wG,o=r.name||s,a=null;e=e&&e.map(function(c){return typeof c=="function"&&!c.workerModuleData&&(v0=!0,c=yh({workerId:i,name:"<"+o+"> function dependency: "+c.name,init:`function(){return (
|
|
`+Rd(c)+`
|
|
)}`}),v0=!1),c&&c.workerModuleData&&(c=c.workerModuleData),c});function l(){for(var c=[],u=arguments.length;u--;)c[u]=arguments[u];if(!a){a=SE(i,"registerModule",l.workerModuleData);var h=function(){a=null,Tu[i].delete(h)};(Tu[i]||(Tu[i]=new Set)).add(h)}return a.then(function(p){var m=p.isCallable;if(m)return SE(i,"callModule",{id:s,args:c});throw new Error("Worker module function was called but `init` did not return a callable function")})}return l.workerModuleData={isWorkerModule:!0,id:s,name:o,dependencies:e,init:Rd(t),getTransferables:n&&Rd(n)},l}function EG(r){Tu[r]&&Tu[r].forEach(function(e){e()}),Mu[r]&&(Mu[r].terminate(),delete Mu[r])}function Rd(r){var e=r.toString();return!/^function/.test(e)&&/^\w+\s*\(/.test(e)&&(e="function "+e),e}function bG(r){var e=Mu[r];if(!e){var t=Rd(_G);e=Mu[r]=new Worker(URL.createObjectURL(new Blob(["/** Worker Module Bootstrap: "+r.replace(/\*/g,"")+` **/
|
|
|
|
;(`+t+")()"],{type:"application/javascript"}))),e.onmessage=function(n){var i=n.data,s=i.messageId,o=Fv[s];if(!o)throw new Error("WorkerModule response with empty or unknown messageId");delete Fv[s],o(i)}}return e}function SE(r,e,t){return new Promise(function(n,i){var s=++SG;Fv[s]=function(o){o.success?n(o.result):i(new Error("Error in worker "+e+" call: "+o.error))},bG(r).postMessage({messageId:s,action:e,data:t})})}function KA(){var r=(function(e){function t(G,B,D,V,Z,ee,ie,ue){var ce=1-ie;ue.x=ce*ce*G+2*ce*ie*D+ie*ie*Z,ue.y=ce*ce*B+2*ce*ie*V+ie*ie*ee}function n(G,B,D,V,Z,ee,ie,ue,ce,le){var Ae=1-ce;le.x=Ae*Ae*Ae*G+3*Ae*Ae*ce*D+3*Ae*ce*ce*Z+ce*ce*ce*ie,le.y=Ae*Ae*Ae*B+3*Ae*Ae*ce*V+3*Ae*ce*ce*ee+ce*ce*ce*ue}function i(G,B){for(var D=/([MLQCZ])([^MLQCZ]*)/g,V,Z,ee,ie,ue;V=D.exec(G);){var ce=V[2].replace(/^\s*|\s*$/g,"").split(/[,\s]+/).map(function(le){return parseFloat(le)});switch(V[1]){case"M":ie=Z=ce[0],ue=ee=ce[1];break;case"L":(ce[0]!==ie||ce[1]!==ue)&&B("L",ie,ue,ie=ce[0],ue=ce[1]);break;case"Q":{B("Q",ie,ue,ie=ce[2],ue=ce[3],ce[0],ce[1]);break}case"C":{B("C",ie,ue,ie=ce[4],ue=ce[5],ce[0],ce[1],ce[2],ce[3]);break}case"Z":(ie!==Z||ue!==ee)&&B("L",ie,ue,Z,ee);break}}}function s(G,B,D){D===void 0&&(D=16);var V={x:0,y:0};i(G,function(Z,ee,ie,ue,ce,le,Ae,Ee,ae){switch(Z){case"L":B(ee,ie,ue,ce);break;case"Q":{for(var z=ee,oe=ie,te=1;te<D;te++)t(ee,ie,le,Ae,ue,ce,te/(D-1),V),B(z,oe,V.x,V.y),z=V.x,oe=V.y;break}case"C":{for(var se=ee,$=ie,Ie=1;Ie<D;Ie++)n(ee,ie,le,Ae,Ee,ae,ue,ce,Ie/(D-1),V),B(se,$,V.x,V.y),se=V.x,$=V.y;break}}})}var o="precision highp float;attribute vec2 aUV;varying vec2 vUV;void main(){vUV=aUV;gl_Position=vec4(mix(vec2(-1.0),vec2(1.0),aUV),0.0,1.0);}",a="precision highp float;uniform sampler2D tex;varying vec2 vUV;void main(){gl_FragColor=texture2D(tex,vUV);}",l=new WeakMap,c={premultipliedAlpha:!1,preserveDrawingBuffer:!0,antialias:!1,depth:!1};function u(G,B){var D=G.getContext?G.getContext("webgl",c):G,V=l.get(D);if(!V){let Ae=function(se){var $=ee[se];if(!$&&($=ee[se]=D.getExtension(se),!$))throw new Error(se+" not supported");return $},Ee=function(se,$){var Ie=D.createShader($);return D.shaderSource(Ie,se),D.compileShader(Ie),Ie},ae=function(se,$,Ie,de){if(!ie[se]){var Se={},Le={},ge=D.createProgram();D.attachShader(ge,Ee($,D.VERTEX_SHADER)),D.attachShader(ge,Ee(Ie,D.FRAGMENT_SHADER)),D.linkProgram(ge),ie[se]={program:ge,transaction:function(j){D.useProgram(ge),j({setUniform:function(ne,we){for(var be=[],Me=arguments.length-2;Me-- >0;)be[Me]=arguments[Me+2];var Fe=Le[we]||(Le[we]=D.getUniformLocation(ge,we));D["uniform"+ne].apply(D,[Fe].concat(be))},setAttribute:function(ne,we,be,Me,Fe){var Ue=Se[ne];Ue||(Ue=Se[ne]={buf:D.createBuffer(),loc:D.getAttribLocation(ge,ne),data:null}),D.bindBuffer(D.ARRAY_BUFFER,Ue.buf),D.vertexAttribPointer(Ue.loc,we,D.FLOAT,!1,0,0),D.enableVertexAttribArray(Ue.loc),Z?D.vertexAttribDivisor(Ue.loc,Me):Ae("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(Ue.loc,Me),Fe!==Ue.data&&(D.bufferData(D.ARRAY_BUFFER,Fe,be),Ue.data=Fe)}})}}}ie[se].transaction(de)},z=function(se,$){ce++;try{D.activeTexture(D.TEXTURE0+ce);var Ie=ue[se];Ie||(Ie=ue[se]=D.createTexture(),D.bindTexture(D.TEXTURE_2D,Ie),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_MIN_FILTER,D.NEAREST),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_MAG_FILTER,D.NEAREST)),D.bindTexture(D.TEXTURE_2D,Ie),$(Ie,ce)}finally{ce--}},oe=function(se,$,Ie){var de=D.createFramebuffer();le.push(de),D.bindFramebuffer(D.FRAMEBUFFER,de),D.activeTexture(D.TEXTURE0+$),D.bindTexture(D.TEXTURE_2D,se),D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,se,0);try{Ie(de)}finally{D.deleteFramebuffer(de),D.bindFramebuffer(D.FRAMEBUFFER,le[--le.length-1]||null)}},te=function(){ee={},ie={},ue={},ce=-1,le.length=0};var Z=typeof WebGL2RenderingContext<"u"&&D instanceof WebGL2RenderingContext,ee={},ie={},ue={},ce=-1,le=[];D.canvas.addEventListener("webglcontextlost",function(se){te(),se.preventDefault()},!1),l.set(D,V={gl:D,isWebGL2:Z,getExtension:Ae,withProgram:ae,withTexture:z,withTextureFramebuffer:oe,handleContextLoss:te})}B(V)}function h(G,B,D,V,Z,ee,ie,ue){ie===void 0&&(ie=15),ue===void 0&&(ue=null),u(G,function(ce){var le=ce.gl,Ae=ce.withProgram,Ee=ce.withTexture;Ee("copy",function(ae,z){le.texImage2D(le.TEXTURE_2D,0,le.RGBA,Z,ee,0,le.RGBA,le.UNSIGNED_BYTE,B),Ae("copy",o,a,function(oe){var te=oe.setUniform,se=oe.setAttribute;se("aUV",2,le.STATIC_DRAW,0,new Float32Array([0,0,2,0,0,2])),te("1i","image",z),le.bindFramebuffer(le.FRAMEBUFFER,ue||null),le.disable(le.BLEND),le.colorMask(ie&8,ie&4,ie&2,ie&1),le.viewport(D,V,Z,ee),le.scissor(D,V,Z,ee),le.drawArrays(le.TRIANGLES,0,3)})})})}function p(G,B,D){var V=G.width,Z=G.height;u(G,function(ee){var ie=ee.gl,ue=new Uint8Array(V*Z*4);ie.readPixels(0,0,V,Z,ie.RGBA,ie.UNSIGNED_BYTE,ue),G.width=B,G.height=D,h(ie,ue,0,0,V,Z)})}var m=Object.freeze({__proto__:null,withWebGLContext:u,renderImageData:h,resizeWebGLCanvasWithoutClearing:p});function v(G,B,D,V,Z,ee){ee===void 0&&(ee=1);var ie=new Uint8Array(G*B),ue=V[2]-V[0],ce=V[3]-V[1],le=[];s(D,function(se,$,Ie,de){le.push({x1:se,y1:$,x2:Ie,y2:de,minX:Math.min(se,Ie),minY:Math.min($,de),maxX:Math.max(se,Ie),maxY:Math.max($,de)})}),le.sort(function(se,$){return se.maxX-$.maxX});for(var Ae=0;Ae<G;Ae++)for(var Ee=0;Ee<B;Ee++){var ae=oe(V[0]+ue*(Ae+.5)/G,V[1]+ce*(Ee+.5)/B),z=Math.pow(1-Math.abs(ae)/Z,ee)/2;ae<0&&(z=1-z),z=Math.max(0,Math.min(255,Math.round(z*255))),ie[Ee*G+Ae]=z}return ie;function oe(se,$){for(var Ie=1/0,de=1/0,Se=le.length;Se--;){var Le=le[Se];if(Le.maxX+de<=se)break;if(se+de>Le.minX&&$-de<Le.maxY&&$+de>Le.minY){var ge=g(se,$,Le.x1,Le.y1,Le.x2,Le.y2);ge<Ie&&(Ie=ge,de=Math.sqrt(Ie))}}return te(se,$)&&(de=-de),de}function te(se,$){for(var Ie=0,de=le.length;de--;){var Se=le[de];if(Se.maxX<=se)break;var Le=Se.y1>$!=Se.y2>$&&se<(Se.x2-Se.x1)*($-Se.y1)/(Se.y2-Se.y1)+Se.x1;Le&&(Ie+=Se.y1<Se.y2?1:-1)}return Ie!==0}}function _(G,B,D,V,Z,ee,ie,ue,ce,le){ee===void 0&&(ee=1),ue===void 0&&(ue=0),ce===void 0&&(ce=0),le===void 0&&(le=0),y(G,B,D,V,Z,ee,ie,null,ue,ce,le)}function y(G,B,D,V,Z,ee,ie,ue,ce,le,Ae){ee===void 0&&(ee=1),ce===void 0&&(ce=0),le===void 0&&(le=0),Ae===void 0&&(Ae=0);for(var Ee=v(G,B,D,V,Z,ee),ae=new Uint8Array(Ee.length*4),z=0;z<Ee.length;z++)ae[z*4+Ae]=Ee[z];h(ie,ae,ce,le,G,B,1<<3-Ae,ue)}function g(G,B,D,V,Z,ee){var ie=Z-D,ue=ee-V,ce=ie*ie+ue*ue,le=ce?Math.max(0,Math.min(1,((G-D)*ie+(B-V)*ue)/ce)):0,Ae=G-(D+le*ie),Ee=B-(V+le*ue);return Ae*Ae+Ee*Ee}var x=Object.freeze({__proto__:null,generate:v,generateIntoCanvas:_,generateIntoFramebuffer:y}),w="precision highp float;uniform vec4 uGlyphBounds;attribute vec2 aUV;attribute vec4 aLineSegment;varying vec4 vLineSegment;varying vec2 vGlyphXY;void main(){vLineSegment=aLineSegment;vGlyphXY=mix(uGlyphBounds.xy,uGlyphBounds.zw,aUV);gl_Position=vec4(mix(vec2(-1.0),vec2(1.0),aUV),0.0,1.0);}",E="precision highp float;uniform vec4 uGlyphBounds;uniform float uMaxDistance;uniform float uExponent;varying vec4 vLineSegment;varying vec2 vGlyphXY;float absDistToSegment(vec2 point,vec2 lineA,vec2 lineB){vec2 lineDir=lineB-lineA;float lenSq=dot(lineDir,lineDir);float t=lenSq==0.0 ? 0.0 : clamp(dot(point-lineA,lineDir)/lenSq,0.0,1.0);vec2 linePt=lineA+t*lineDir;return distance(point,linePt);}void main(){vec4 seg=vLineSegment;vec2 p=vGlyphXY;float dist=absDistToSegment(p,seg.xy,seg.zw);float val=pow(1.0-clamp(dist/uMaxDistance,0.0,1.0),uExponent)*0.5;bool crossing=(seg.y>p.y!=seg.w>p.y)&&(p.x<(seg.z-seg.x)*(p.y-seg.y)/(seg.w-seg.y)+seg.x);bool crossingUp=crossing&&vLineSegment.y<vLineSegment.w;gl_FragColor=vec4(crossingUp ? 1.0/255.0 : 0.0,crossing&&!crossingUp ? 1.0/255.0 : 0.0,0.0,val);}",b="precision highp float;uniform sampler2D tex;varying vec2 vUV;void main(){vec4 color=texture2D(tex,vUV);bool inside=color.r!=color.g;float val=inside ? 1.0-color.a : color.a;gl_FragColor=vec4(val);}",M=new Float32Array([0,0,2,0,0,2]),A=null,P=!1,C={},L=new WeakMap;function F(G){if(!P&&!q(G))throw new Error("WebGL generation not supported")}function N(G,B,D,V,Z,ee,ie){if(ee===void 0&&(ee=1),ie===void 0&&(ie=null),!ie&&(ie=A,!ie)){var ue=typeof OffscreenCanvas=="function"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null;if(!ue)throw new Error("OffscreenCanvas or DOM canvas not supported");ie=A=ue.getContext("webgl",{depth:!1})}F(ie);var ce=new Uint8Array(G*B*4);u(ie,function(ae){var z=ae.gl,oe=ae.withTexture,te=ae.withTextureFramebuffer;oe("readable",function(se,$){z.texImage2D(z.TEXTURE_2D,0,z.RGBA,G,B,0,z.RGBA,z.UNSIGNED_BYTE,null),te(se,$,function(Ie){X(G,B,D,V,Z,ee,z,Ie,0,0,0),z.readPixels(0,0,G,B,z.RGBA,z.UNSIGNED_BYTE,ce)})})});for(var le=new Uint8Array(G*B),Ae=0,Ee=0;Ae<ce.length;Ae+=4)le[Ee++]=ce[Ae];return le}function I(G,B,D,V,Z,ee,ie,ue,ce,le){ee===void 0&&(ee=1),ue===void 0&&(ue=0),ce===void 0&&(ce=0),le===void 0&&(le=0),X(G,B,D,V,Z,ee,ie,null,ue,ce,le)}function X(G,B,D,V,Z,ee,ie,ue,ce,le,Ae){ee===void 0&&(ee=1),ce===void 0&&(ce=0),le===void 0&&(le=0),Ae===void 0&&(Ae=0),F(ie);var Ee=[];s(D,function(ae,z,oe,te){Ee.push(ae,z,oe,te)}),Ee=new Float32Array(Ee),u(ie,function(ae){var z=ae.gl,oe=ae.isWebGL2,te=ae.getExtension,se=ae.withProgram,$=ae.withTexture,Ie=ae.withTextureFramebuffer,de=ae.handleContextLoss;if($("rawDistances",function(Se,Le){(G!==Se._lastWidth||B!==Se._lastHeight)&&z.texImage2D(z.TEXTURE_2D,0,z.RGBA,Se._lastWidth=G,Se._lastHeight=B,0,z.RGBA,z.UNSIGNED_BYTE,null),se("main",w,E,function(ge){var He=ge.setAttribute,j=ge.setUniform,H=!oe&&te("ANGLE_instanced_arrays"),ne=!oe&&te("EXT_blend_minmax");He("aUV",2,z.STATIC_DRAW,0,M),He("aLineSegment",4,z.DYNAMIC_DRAW,1,Ee),j.apply(void 0,["4f","uGlyphBounds"].concat(V)),j("1f","uMaxDistance",Z),j("1f","uExponent",ee),Ie(Se,Le,function(we){z.enable(z.BLEND),z.colorMask(!0,!0,!0,!0),z.viewport(0,0,G,B),z.scissor(0,0,G,B),z.blendFunc(z.ONE,z.ONE),z.blendEquationSeparate(z.FUNC_ADD,oe?z.MAX:ne.MAX_EXT),z.clear(z.COLOR_BUFFER_BIT),oe?z.drawArraysInstanced(z.TRIANGLES,0,3,Ee.length/4):H.drawArraysInstancedANGLE(z.TRIANGLES,0,3,Ee.length/4)})}),se("post",o,b,function(ge){ge.setAttribute("aUV",2,z.STATIC_DRAW,0,M),ge.setUniform("1i","tex",Le),z.bindFramebuffer(z.FRAMEBUFFER,ue),z.disable(z.BLEND),z.colorMask(Ae===0,Ae===1,Ae===2,Ae===3),z.viewport(ce,le,G,B),z.scissor(ce,le,G,B),z.drawArrays(z.TRIANGLES,0,3)})}),z.isContextLost())throw de(),new Error("webgl context lost")})}function q(G){var B=!G||G===A?C:G.canvas||G,D=L.get(B);if(D===void 0){P=!0;var V=null;try{var Z=[97,106,97,61,99,137,118,80,80,118,137,99,61,97,106,97],ee=N(4,4,"M8,8L16,8L24,24L16,24Z",[0,0,32,32],24,1,G);D=ee&&Z.length===ee.length&&ee.every(function(ie,ue){return ie===Z[ue]}),D||(V="bad trial run results",console.info(Z,ee))}catch(ie){D=!1,V=ie.message}V&&console.warn("WebGL SDF generation not supported:",V),P=!1,L.set(B,D)}return D}var W=Object.freeze({__proto__:null,generate:N,generateIntoCanvas:I,generateIntoFramebuffer:X,isSupported:q});function O(G,B,D,V,Z,ee){Z===void 0&&(Z=Math.max(V[2]-V[0],V[3]-V[1])/2),ee===void 0&&(ee=1);try{return N.apply(W,arguments)}catch(ie){return console.info("WebGL SDF generation failed, falling back to JS",ie),v.apply(x,arguments)}}function k(G,B,D,V,Z,ee,ie,ue,ce,le){Z===void 0&&(Z=Math.max(V[2]-V[0],V[3]-V[1])/2),ee===void 0&&(ee=1),ue===void 0&&(ue=0),ce===void 0&&(ce=0),le===void 0&&(le=0);try{return I.apply(W,arguments)}catch(Ae){return console.info("WebGL SDF generation failed, falling back to JS",Ae),_.apply(x,arguments)}}return e.forEachPathCommand=i,e.generate=O,e.generateIntoCanvas=k,e.javascript=x,e.pathToLineSegments=s,e.webgl=W,e.webglUtils=m,Object.defineProperty(e,"__esModule",{value:!0}),e})({});return r}function MG(){var r=(function(e){var t={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",AL:"16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",LRO:"6ct",RLO:"6cu",LRE:"6cq",RLE:"6cr",PDF:"6cs",LRI:"6ee",RLI:"6ef",FSI:"6eg",PDI:"6eh"},n={},i={};n.L=1,i[1]="L",Object.keys(t).forEach(function(de,Se){n[de]=1<<Se+1,i[n[de]]=de}),Object.freeze(n);var s=n.LRI|n.RLI|n.FSI,o=n.L|n.R|n.AL,a=n.B|n.S|n.WS|n.ON|n.FSI|n.LRI|n.RLI|n.PDI,l=n.BN|n.RLE|n.LRE|n.RLO|n.LRO|n.PDF,c=n.S|n.WS|n.B|s|n.PDI|l,u=null;function h(){if(!u){u=new Map;var de=function(Le){if(t.hasOwnProperty(Le)){var ge=0;t[Le].split(",").forEach(function(He){var j=He.split("+"),H=j[0],ne=j[1];H=parseInt(H,36),ne=ne?parseInt(ne,36):0,u.set(ge+=H,n[Le]);for(var we=0;we<ne;we++)u.set(++ge,n[Le])})}};for(var Se in t)de(Se)}}function p(de){return h(),u.get(de.codePointAt(0))||n.L}function m(de){return i[p(de)]}var v={pairs:"14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function _(de,Se){var Le=36,ge=0,He=new Map,j=Se&&new Map,H;return de.split(",").forEach(function ne(we){if(we.indexOf("+")!==-1)for(var be=+we;be--;)ne(H);else{H=we;var Me=we.split(">"),Fe=Me[0],Ue=Me[1];Fe=String.fromCodePoint(ge+=parseInt(Fe,Le)),Ue=String.fromCodePoint(ge+=parseInt(Ue,Le)),He.set(Fe,Ue),Se&&j.set(Ue,Fe)}}),{map:He,reverseMap:j}}var y,g,x;function w(){if(!y){var de=_(v.pairs,!0),Se=de.map,Le=de.reverseMap;y=Se,g=Le,x=_(v.canonical,!1).map}}function E(de){return w(),y.get(de)||null}function b(de){return w(),g.get(de)||null}function M(de){return w(),x.get(de)||null}var A=n.L,P=n.R,C=n.EN,L=n.ES,F=n.ET,N=n.AN,I=n.CS,X=n.B,q=n.S,W=n.ON,O=n.BN,k=n.NSM,G=n.AL,B=n.LRO,D=n.RLO,V=n.LRE,Z=n.RLE,ee=n.PDF,ie=n.LRI,ue=n.RLI,ce=n.FSI,le=n.PDI;function Ae(de,Se){for(var Le=125,ge=new Uint32Array(de.length),He=0;He<de.length;He++)ge[He]=p(de[He]);var j=new Map;function H(Zn,bi){var Rn=ge[Zn];ge[Zn]=bi,j.set(Rn,j.get(Rn)-1),Rn&a&&j.set(a,j.get(a)-1),j.set(bi,(j.get(bi)||0)+1),bi&a&&j.set(a,(j.get(a)||0)+1)}for(var ne=new Uint8Array(de.length),we=new Map,be=[],Me=null,Fe=0;Fe<de.length;Fe++)Me||be.push(Me={start:Fe,end:de.length-1,level:Se==="rtl"?1:Se==="ltr"?0:za(Fe,!1)}),ge[Fe]&X&&(Me.end=Fe,Me=null);for(var Ue=Z|V|D|B|s|le|ee|X,xe=function(Zn){return Zn+(Zn&1?1:2)},Be=function(Zn){return Zn+(Zn&1?2:1)},$e=0;$e<be.length;$e++){Me=be[$e];var Ve=[{_level:Me.level,_override:0,_isolate:0}],Oe=void 0,We=0,nt=0,pt=0;j.clear();for(var re=Me.start;re<=Me.end;re++){var ze=ge[re];if(Oe=Ve[Ve.length-1],j.set(ze,(j.get(ze)||0)+1),ze&a&&j.set(a,(j.get(a)||0)+1),ze&Ue)if(ze&(Z|V)){ne[re]=Oe._level;var ve=(ze===Z?Be:xe)(Oe._level);ve<=Le&&!We&&!nt?Ve.push({_level:ve,_override:0,_isolate:0}):We||nt++}else if(ze&(D|B)){ne[re]=Oe._level;var Ge=(ze===D?Be:xe)(Oe._level);Ge<=Le&&!We&&!nt?Ve.push({_level:Ge,_override:ze&D?P:A,_isolate:0}):We||nt++}else if(ze&s){ze&ce&&(ze=za(re+1,!0)===1?ue:ie),ne[re]=Oe._level,Oe._override&&H(re,Oe._override);var Ye=(ze===ue?Be:xe)(Oe._level);Ye<=Le&&We===0&&nt===0?(pt++,Ve.push({_level:Ye,_override:0,_isolate:1,_isolInitIndex:re})):We++}else if(ze&le){if(We>0)We--;else if(pt>0){for(nt=0;!Ve[Ve.length-1]._isolate;)Ve.pop();var _t=Ve[Ve.length-1]._isolInitIndex;_t!=null&&(we.set(_t,re),we.set(re,_t)),Ve.pop(),pt--}Oe=Ve[Ve.length-1],ne[re]=Oe._level,Oe._override&&H(re,Oe._override)}else ze&ee?(We===0&&(nt>0?nt--:!Oe._isolate&&Ve.length>1&&(Ve.pop(),Oe=Ve[Ve.length-1])),ne[re]=Oe._level):ze&X&&(ne[re]=Me.level);else ne[re]=Oe._level,Oe._override&&ze!==O&&H(re,Oe._override)}for(var It=[],Ft=null,Ot=Me.start;Ot<=Me.end;Ot++){var Yt=ge[Ot];if(!(Yt&l)){var Nt=ne[Ot],Rt=Yt&s,li=Yt===le;Ft&&Nt===Ft._level?(Ft._end=Ot,Ft._endsWithIsolInit=Rt):It.push(Ft={_start:Ot,_end:Ot,_level:Nt,_startsWithPDI:li,_endsWithIsolInit:Rt})}}for(var jn=[],Bt=0;Bt<It.length;Bt++){var sn=It[Bt];if(!sn._startsWithPDI||sn._startsWithPDI&&!we.has(sn._start)){for(var ti=[Ft=sn],tn=void 0;Ft&&Ft._endsWithIsolInit&&(tn=we.get(Ft._end))!=null;)for(var dn=Bt+1;dn<It.length;dn++)if(It[dn]._start===tn){ti.push(Ft=It[dn]);break}for(var Gn=[],sr=0;sr<ti.length;sr++)for(var _i=ti[sr],J=_i._start;J<=_i._end;J++)Gn.push(J);for(var me=ne[Gn[0]],Re=Me.level,pe=Gn[0]-1;pe>=0;pe--)if(!(ge[pe]&l)){Re=ne[pe];break}var Pe=Gn[Gn.length-1],it=ne[Pe],lt=Me.level;if(!(ge[Pe]&s)){for(var ct=Pe+1;ct<=Me.end;ct++)if(!(ge[ct]&l)){lt=ne[ct];break}}jn.push({_seqIndices:Gn,_sosType:Math.max(Re,me)%2?P:A,_eosType:Math.max(lt,it)%2?P:A})}}for(var dt=0;dt<jn.length;dt++){var wt=jn[dt],ke=wt._seqIndices,ut=wt._sosType,Jt=wt._eosType,Gt=ne[ke[0]]&1?P:A;if(j.get(k))for(var Yn=0;Yn<ke.length;Yn++){var ci=ke[Yn];if(ge[ci]&k){for(var qt=ut,mt=Yn-1;mt>=0;mt--)if(!(ge[ke[mt]]&l)){qt=ge[ke[mt]];break}H(ci,qt&(s|le)?W:qt)}}if(j.get(C))for(var kt=0;kt<ke.length;kt++){var gt=ke[kt];if(ge[gt]&C)for(var Cn=kt-1;Cn>=-1;Cn--){var En=Cn===-1?ut:ge[ke[Cn]];if(En&o){En===G&&H(gt,N);break}}}if(j.get(G))for(var cn=0;cn<ke.length;cn++){var Ii=ke[cn];ge[Ii]&G&&H(Ii,P)}if(j.get(L)||j.get(I))for(var Qt=1;Qt<ke.length-1;Qt++){var on=ke[Qt];if(ge[on]&(L|I)){for(var xi=0,Un=0,Xr=Qt-1;Xr>=0&&(xi=ge[ke[Xr]],!!(xi&l));Xr--);for(var jr=Qt+1;jr<ke.length&&(Un=ge[ke[jr]],!!(Un&l));jr++);xi===Un&&(ge[on]===L?xi===C:xi&(C|N))&&H(on,xi)}}if(j.get(C))for(var ui=0;ui<ke.length;ui++){var Vi=ke[ui];if(ge[Vi]&C){for(var Oa=ui-1;Oa>=0&&ge[ke[Oa]]&(F|l);Oa--)H(ke[Oa],C);for(ui++;ui<ke.length&&ge[ke[ui]]&(F|l|C);ui++)ge[ke[ui]]!==C&&H(ke[ui],C)}}if(j.get(F)||j.get(L)||j.get(I))for(var Ro=0;Ro<ke.length;Ro++){var xh=ke[Ro];if(ge[xh]&(F|L|I)){H(xh,W);for(var fs=Ro-1;fs>=0&&ge[ke[fs]]&l;fs--)H(ke[fs],W);for(var ds=Ro+1;ds<ke.length&&ge[ke[ds]]&l;ds++)H(ke[ds],W)}}if(j.get(C))for(var ps=0,Po=ut;ps<ke.length;ps++){var wh=ke[ps],sc=ge[wh];sc&C?Po===A&&H(wh,A):sc&o&&(Po=sc)}if(j.get(a)){var ms=P|C|N,Na=ms|A,Yr=[];{for(var Ys=[],qr=0;qr<ke.length;qr++)if(ge[ke[qr]]&a){var Ut=de[ke[qr]],oc=void 0;if(E(Ut)!==null)if(Ys.length<63)Ys.push({char:Ut,seqIndex:qr});else break;else if((oc=b(Ut))!==null)for(var gs=Ys.length-1;gs>=0;gs--){var Fa=Ys[gs].char;if(Fa===oc||Fa===b(M(Ut))||E(M(Fa))===Ut){Yr.push([Ys[gs].seqIndex,qr]),Ys.length=gs;break}}}Yr.sort(function(Zn,bi){return Zn[0]-bi[0]})}for(var ac=0;ac<Yr.length;ac++){for(var Sh=Yr[ac],pn=Sh[0],Lo=Sh[1],Eh=!1,wi=0,lc=pn+1;lc<Lo;lc++){var Io=ke[lc];if(ge[Io]&Na){Eh=!0;var Wi=ge[Io]&ms?P:A;if(Wi===Gt){wi=Wi;break}}}if(Eh&&!wi){wi=ut;for(var cc=pn-1;cc>=0;cc--){var bh=ke[cc];if(ge[bh]&Na){var Xi=ge[bh]&ms?P:A;Xi!==Gt?wi=Xi:wi=Gt;break}}}if(wi){if(ge[ke[pn]]=ge[ke[Lo]]=wi,wi!==Gt){for(var Si=pn+1;Si<ke.length;Si++)if(!(ge[ke[Si]]&l)){p(de[ke[Si]])&k&&(ge[ke[Si]]=wi);break}}if(wi!==Gt){for(var Zr=Lo+1;Zr<ke.length;Zr++)if(!(ge[ke[Zr]]&l)){p(de[ke[Zr]])&k&&(ge[ke[Zr]]=wi);break}}}}for(var or=0;or<ke.length;or++)if(ge[ke[or]]&a){for(var uc=or,hc=or,Di=ut,Do=or-1;Do>=0;Do--)if(ge[ke[Do]]&l)uc=Do;else{Di=ge[ke[Do]]&ms?P:A;break}for(var Uo=Jt,Oo=or+1;Oo<ke.length;Oo++)if(ge[ke[Oo]]&(a|l))hc=Oo;else{Uo=ge[ke[Oo]]&ms?P:A;break}for(var Ei=uc;Ei<=hc;Ei++)ge[ke[Ei]]=Di===Uo?Di:Gt;or=hc}}}for(var qn=Me.start;qn<=Me.end;qn++){var ka=ne[qn],Tr=ge[qn];if(ka&1?Tr&(A|C|N)&&ne[qn]++:Tr&P?ne[qn]++:Tr&(N|C)&&(ne[qn]+=2),Tr&l&&(ne[qn]=qn===0?Me.level:ne[qn-1]),qn===Me.end||p(de[qn])&(q|X))for(var qs=qn;qs>=0&&p(de[qs])&c;qs--)ne[qs]=Me.level}}return{levels:ne,paragraphs:be};function za(Zn,bi){for(var Rn=Zn;Rn<de.length;Rn++){var Pn=ge[Rn];if(Pn&(P|G))return 1;if(Pn&(X|A)||bi&&Pn===le)return 0;if(Pn&s){var ji=Mh(Rn);Rn=ji===-1?de.length:ji}}return 0}function Mh(Zn){for(var bi=1,Rn=Zn+1;Rn<de.length;Rn++){var Pn=ge[Rn];if(Pn&X)break;if(Pn&le){if(--bi===0)return Rn}else Pn&s&&bi++}return-1}}var Ee="14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1",ae;function z(){if(!ae){var de=_(Ee,!0),Se=de.map,Le=de.reverseMap;Le.forEach(function(ge,He){Se.set(He,ge)}),ae=Se}}function oe(de){return z(),ae.get(de)||null}function te(de,Se,Le,ge){var He=de.length;Le=Math.max(0,Le==null?0:+Le),ge=Math.min(He-1,ge==null?He-1:+ge);for(var j=new Map,H=Le;H<=ge;H++)if(Se[H]&1){var ne=oe(de[H]);ne!==null&&j.set(H,ne)}return j}function se(de,Se,Le,ge){var He=de.length;Le=Math.max(0,Le==null?0:+Le),ge=Math.min(He-1,ge==null?He-1:+ge);var j=[];return Se.paragraphs.forEach(function(H){var ne=Math.max(Le,H.start),we=Math.min(ge,H.end);if(ne<we){for(var be=Se.levels.slice(ne,we+1),Me=we;Me>=ne&&p(de[Me])&c;Me--)be[Me]=H.level;for(var Fe=H.level,Ue=1/0,xe=0;xe<be.length;xe++){var Be=be[xe];Be>Fe&&(Fe=Be),Be<Ue&&(Ue=Be|1)}for(var $e=Fe;$e>=Ue;$e--)for(var Ve=0;Ve<be.length;Ve++)if(be[Ve]>=$e){for(var Oe=Ve;Ve+1<be.length&&be[Ve+1]>=$e;)Ve++;Ve>Oe&&j.push([Oe+ne,Ve+ne])}}}),j}function $(de,Se,Le,ge){var He=Ie(de,Se,Le,ge),j=[].concat(de);return He.forEach(function(H,ne){j[ne]=(Se.levels[H]&1?oe(de[H]):null)||de[H]}),j.join("")}function Ie(de,Se,Le,ge){for(var He=se(de,Se,Le,ge),j=[],H=0;H<de.length;H++)j[H]=H;return He.forEach(function(ne){for(var we=ne[0],be=ne[1],Me=j.slice(we,be+1),Fe=Me.length;Fe--;)j[be-Fe]=Me[Fe]}),j}return e.closingToOpeningBracket=b,e.getBidiCharType=p,e.getBidiCharTypeName=m,e.getCanonicalBracket=M,e.getEmbeddingLevels=Ae,e.getMirroredCharacter=oe,e.getMirroredCharactersMap=te,e.getReorderSegments=se,e.getReorderedIndices=Ie,e.getReorderedString=$,e.openingToClosingBracket=E,Object.defineProperty(e,"__esModule",{value:!0}),e})({});return r}const $A=/\bvoid\s+main\s*\(\s*\)\s*{/g;function kv(r){const e=/^[ \t]*#include +<([\w\d./]+)>/gm;function t(n,i){let s=bt[i];return s?kv(s):n}return r.replace(e,t)}const ii=[];for(let r=0;r<256;r++)ii[r]=(r<16?"0":"")+r.toString(16);function TG(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(ii[r&255]+ii[r>>8&255]+ii[r>>16&255]+ii[r>>24&255]+"-"+ii[e&255]+ii[e>>8&255]+"-"+ii[e>>16&15|64]+ii[e>>24&255]+"-"+ii[t&63|128]+ii[t>>8&255]+"-"+ii[t>>16&255]+ii[t>>24&255]+ii[n&255]+ii[n>>8&255]+ii[n>>16&255]+ii[n>>24&255]).toUpperCase()}const na=Object.assign||function(){let r=arguments[0];for(let e=1,t=arguments.length;e<t;e++){let n=arguments[e];if(n)for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])}return r},AG=Date.now(),EE=new WeakMap,bE=new Map;let CG=1e10;function zv(r,e){const t=IG(e);let n=EE.get(r);if(n||EE.set(r,n=Object.create(null)),n[t])return new n[t];const i=`_onBeforeCompile${t}`,s=function(c,u){r.onBeforeCompile.call(this,c,u);const h=this.customProgramCacheKey()+"|"+c.vertexShader+"|"+c.fragmentShader;let p=bE[h];if(!p){const m=RG(this,c,e,t);p=bE[h]=m}c.vertexShader=p.vertexShader,c.fragmentShader=p.fragmentShader,na(c.uniforms,this.uniforms),e.timeUniform&&(c.uniforms[e.timeUniform]={get value(){return Date.now()-AG}}),this[i]&&this[i](c)},o=function(){return a(e.chained?r:r.clone())},a=function(c){const u=Object.create(c,l);return Object.defineProperty(u,"baseMaterial",{value:r}),Object.defineProperty(u,"id",{value:CG++}),u.uuid=TG(),u.uniforms=na({},c.uniforms,e.uniforms),u.defines=na({},c.defines,e.defines),u.defines[`TROIKA_DERIVED_MATERIAL_${t}`]="",u.extensions=na({},c.extensions,e.extensions),u._listeners=void 0,u},l={constructor:{value:o},isDerivedMaterial:{value:!0},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return r.customProgramCacheKey()+"|"+t}},onBeforeCompile:{get(){return s},set(c){this[i]=c}},copy:{writable:!0,configurable:!0,value:function(c){return r.copy.call(this,c),!r.isShaderMaterial&&!r.isDerivedMaterial&&(na(this.extensions,c.extensions),na(this.defines,c.defines),na(this.uniforms,ly.clone(c.uniforms))),this}},clone:{writable:!0,configurable:!0,value:function(){const c=new r.constructor;return a(c).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let c=this._depthMaterial;return c||(c=this._depthMaterial=zv(r.isDerivedMaterial?r.getDepthMaterial():new ep({depthPacking:ty}),e),c.defines.IS_DEPTH_MATERIAL="",c.uniforms=this.uniforms),c}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let c=this._distanceMaterial;return c||(c=this._distanceMaterial=zv(r.isDerivedMaterial?r.getDistanceMaterial():new tp,e),c.defines.IS_DISTANCE_MATERIAL="",c.uniforms=this.uniforms),c}},dispose:{writable:!0,configurable:!0,value(){const{_depthMaterial:c,_distanceMaterial:u}=this;c&&c.dispose(),u&&u.dispose(),r.dispose.call(this)}}};return n[t]=o,new o}function RG(r,{vertexShader:e,fragmentShader:t},n,i){let{vertexDefs:s,vertexMainIntro:o,vertexMainOutro:a,vertexTransform:l,fragmentDefs:c,fragmentMainIntro:u,fragmentMainOutro:h,fragmentColorTransform:p,customRewriter:m,timeUniform:v}=n;if(s=s||"",o=o||"",a=a||"",c=c||"",u=u||"",h=h||"",(l||m)&&(e=kv(e)),(p||m)&&(t=t.replace(/^[ \t]*#include <((?:tonemapping|encodings|fog|premultiplied_alpha|dithering)_fragment)>/gm,`
|
|
//!BEGIN_POST_CHUNK $1
|
|
$&
|
|
//!END_POST_CHUNK
|
|
`),t=kv(t)),m){let _=m({vertexShader:e,fragmentShader:t});e=_.vertexShader,t=_.fragmentShader}if(p){let _=[];t=t.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,y=>(_.push(y),"")),h=`${p}
|
|
${_.join(`
|
|
`)}
|
|
${h}`}if(v){const _=`
|
|
uniform float ${v};
|
|
`;s=_+s,c=_+c}return l&&(e=`vec3 troika_position_${i};
|
|
vec3 troika_normal_${i};
|
|
vec2 troika_uv_${i};
|
|
${e}
|
|
`,s=`${s}
|
|
void troikaVertexTransform${i}(inout vec3 position, inout vec3 normal, inout vec2 uv) {
|
|
${l}
|
|
}
|
|
`,o=`
|
|
troika_position_${i} = vec3(position);
|
|
troika_normal_${i} = vec3(normal);
|
|
troika_uv_${i} = vec2(uv);
|
|
troikaVertexTransform${i}(troika_position_${i}, troika_normal_${i}, troika_uv_${i});
|
|
${o}
|
|
`,e=e.replace(/\b(position|normal|uv)\b/g,(_,y,g,x)=>/\battribute\s+vec[23]\s+$/.test(x.substr(0,g))?y:`troika_${y}_${i}`),r.map&&r.map.channel>0||(e=e.replace(/\bMAP_UV\b/g,`troika_uv_${i}`))),e=ME(e,i,s,o,a),t=ME(t,i,c,u,h),{vertexShader:e,fragmentShader:t}}function ME(r,e,t,n,i){return(n||i||t)&&(r=r.replace($A,`
|
|
${t}
|
|
void troikaOrigMain${e}() {`),r+=`
|
|
void main() {
|
|
${n}
|
|
troikaOrigMain${e}();
|
|
${i}
|
|
}`),r}function PG(r,e){return r==="uniforms"?void 0:typeof e=="function"?e.toString():e}let LG=0;const TE=new Map;function IG(r){const e=JSON.stringify(r,PG);let t=TE.get(e);return t==null&&TE.set(e,t=++LG),t}function DG(r,e,t){const{defaultFontURL:n}=t,i=Object.create(null),s=1/0,o=/[\u00AD\u034F\u061C\u115F-\u1160\u17B4-\u17B5\u180B-\u180E\u200B-\u200F\u202A-\u202E\u2060-\u206F\u3164\uFE00-\uFE0F\uFEFF\uFFA0\uFFF0-\uFFF8]/,a="[^\\S\\u00A0]",l=new RegExp(`${a}|[\\-\\u007C\\u00AD\\u2010\\u2012-\\u2014\\u2027\\u2056\\u2E17\\u2E40]`);function c(x,w){function E(){const b=M=>{console.error(`Failure loading font ${x}${x===n?"":"; trying fallback"}`,M),x!==n&&(x=n,E())};try{const M=new XMLHttpRequest;M.open("get",x,!0),M.responseType="arraybuffer",M.onload=function(){if(M.status>=400)b(new Error(M.statusText));else if(M.status>0)try{const A=r(M.response);w(A)}catch(A){b(A)}},M.onerror=b,M.send()}catch(M){b(M)}}E()}function u(x,w){x||(x=n);let E=i[x];E?E.pending?E.pending.push(w):w(E):(i[x]={pending:[w]},c(x,b=>{let M=i[x].pending;i[x]=b,M.forEach(A=>A(b))}))}function h({text:x="",font:w=n,sdfGlyphSize:E=64,fontSize:b=1,letterSpacing:M=0,lineHeight:A="normal",maxWidth:P=s,direction:C,textAlign:L="left",textIndent:F=0,whiteSpace:N="normal",overflowWrap:I="normal",anchorX:X=0,anchorY:q=0,includeCaretPositions:W=!1,chunkedBoundsSize:O=8192,colorRanges:k=null},G,B=!1){const D=_(),V={fontLoad:0,typesetting:0};x.indexOf("\r")>-1&&(console.info("Typesetter: got text with \\r chars; normalizing to \\n"),x=x.replace(/\r\n/g,`
|
|
`).replace(/\r/g,`
|
|
`)),b=+b,M=+M,P=+P,A=A||"normal",F=+F,u(w,Z=>{const ee=isFinite(P);let ie=null,ue=null,ce=null,le=null,Ae=null,Ee=null,ae=null,z=0,oe=0,te=N!=="nowrap";const{ascender:se,descender:$,unitsPerEm:Ie,lineGap:de,capHeight:Se,xHeight:Le}=Z;V.fontLoad=_()-D;const ge=_(),He=b/Ie;A==="normal"&&(A=(se-$+de)/Ie),A=A*b;const j=(A-(se-$)*He)/2,H=-(se*He+j),ne=Math.min(A,(se-$)*He),we=(se+$)/2*He-ne/2;let be=F,Me=new y;const Fe=[Me];Z.forEachGlyph(x,b,M,(Be,$e,Ve)=>{const Oe=x.charAt(Ve),We=Be.advanceWidth*He,nt=Me.count;let pt;if("isEmpty"in Be||(Be.isWhitespace=!!Oe&&new RegExp(a).test(Oe),Be.canBreakAfter=!!Oe&&l.test(Oe),Be.isEmpty=Be.xMin===Be.xMax||Be.yMin===Be.yMax||o.test(Oe)),!Be.isWhitespace&&!Be.isEmpty&&oe++,te&&ee&&!Be.isWhitespace&&$e+We+be>P&&nt){if(Me.glyphAt(nt-1).glyphObj.canBreakAfter)pt=new y,be=-$e;else for(let ze=nt;ze--;)if(ze===0&&I==="break-word"){pt=new y,be=-$e;break}else if(Me.glyphAt(ze).glyphObj.canBreakAfter){pt=Me.splitAt(ze+1);const ve=pt.glyphAt(0).x;be-=ve;for(let Ge=pt.count;Ge--;)pt.glyphAt(Ge).x-=ve;break}pt&&(Me.isSoftWrapped=!0,Me=pt,Fe.push(Me),z=P)}let re=Me.glyphAt(Me.count);re.glyphObj=Be,re.x=$e+be,re.width=We,re.charIndex=Ve,Oe===`
|
|
`&&(Me=new y,Fe.push(Me),be=-($e+We+M*b)+F)}),Fe.forEach(Be=>{for(let $e=Be.count;$e--;){let{glyphObj:Ve,x:Oe,width:We}=Be.glyphAt($e);if(!Ve.isWhitespace){Be.width=Oe+We,Be.width>z&&(z=Be.width);return}}});let Ue=0,xe=0;if(X&&(typeof X=="number"?Ue=-X:typeof X=="string"&&(Ue=-z*(X==="left"?0:X==="center"?.5:X==="right"?1:m(X)))),q){if(typeof q=="number")xe=-q;else if(typeof q=="string"){let Be=Fe.length*A;xe=q==="top"?0:q==="top-baseline"?-H:q==="top-cap"?-H-Se*He:q==="top-ex"?-H-Le*He:q==="middle"?Be/2:q==="bottom"?Be:q==="bottom-baseline"?Be-j+$*He:m(q)*Be}}if(!B){const Be=e.getEmbeddingLevels(x,C);ie=new Uint16Array(oe),ue=new Float32Array(oe*2),ce={},Ee=[s,s,-s,-s],ae=[];let $e=H;W&&(Ae=new Float32Array(x.length*3)),k&&(le=new Uint8Array(oe*3));let Ve=0,Oe=-1,We=-1,nt,pt;if(Fe.forEach((re,ze)=>{let{count:ve,width:Ge}=re;if(ve>0){let Ye=0;for(let Nt=ve;Nt--&&re.glyphAt(Nt).glyphObj.isWhitespace;)Ye++;let _t=0,It=0;if(L==="center")_t=(z-Ge)/2;else if(L==="right")_t=z-Ge;else if(L==="justify"&&re.isSoftWrapped){let Nt=0;for(let Rt=ve-Ye;Rt--;)re.glyphAt(Rt).glyphObj.isWhitespace&&Nt++;It=(z-Ge)/Nt}if(It||_t){let Nt=0;for(let Rt=0;Rt<ve;Rt++){let li=re.glyphAt(Rt);const jn=li.glyphObj;li.x+=_t+Nt,It!==0&&jn.isWhitespace&&Rt<ve-Ye&&(Nt+=It,li.width+=It)}}const Ft=e.getReorderSegments(x,Be,re.glyphAt(0).charIndex,re.glyphAt(re.count-1).charIndex);for(let Nt=0;Nt<Ft.length;Nt++){const[Rt,li]=Ft[Nt];let jn=1/0,Bt=-1/0;for(let sn=0;sn<ve;sn++)if(re.glyphAt(sn).charIndex>=Rt){let ti=sn,tn=sn;for(;tn<ve;tn++){let dn=re.glyphAt(tn);if(dn.charIndex>li)break;tn<ve-Ye&&(jn=Math.min(jn,dn.x),Bt=Math.max(Bt,dn.x+dn.width))}for(let dn=ti;dn<tn;dn++){const Gn=re.glyphAt(dn);Gn.x=Bt-(Gn.x+Gn.width-jn)}break}}let Ot;const Yt=Nt=>Ot=Nt;for(let Nt=0;Nt<ve;Nt++){let Rt=re.glyphAt(Nt);Ot=Rt.glyphObj;const li=Ot.index,jn=Be.levels[Rt.charIndex]&1;if(jn){const Bt=e.getMirroredCharacter(x[Rt.charIndex]);Bt&&Z.forEachGlyph(Bt,0,0,Yt)}if(W){const{charIndex:Bt}=Rt,sn=Rt.x+Ue,ti=Rt.x+Rt.width+Ue;Ae[Bt*3]=jn?ti:sn,Ae[Bt*3+1]=jn?sn:ti,Ae[Bt*3+2]=$e+we+xe;const tn=Bt-Oe;tn>1&&v(Ae,Oe,tn),Oe=Bt}if(k){const{charIndex:Bt}=Rt;for(;Bt>We;)We++,k.hasOwnProperty(We)&&(pt=k[We])}if(!Ot.isWhitespace&&!Ot.isEmpty){const Bt=Ve++;ce[li]||(ce[li]={path:Ot.path,pathBounds:[Ot.xMin,Ot.yMin,Ot.xMax,Ot.yMax]});const sn=Rt.x+Ue,ti=$e+xe;ue[Bt*2]=sn,ue[Bt*2+1]=ti;const tn=sn+Ot.xMin*He,dn=ti+Ot.yMin*He,Gn=sn+Ot.xMax*He,sr=ti+Ot.yMax*He;tn<Ee[0]&&(Ee[0]=tn),dn<Ee[1]&&(Ee[1]=dn),Gn>Ee[2]&&(Ee[2]=Gn),sr>Ee[3]&&(Ee[3]=sr),Bt%O===0&&(nt={start:Bt,end:Bt,rect:[s,s,-s,-s]},ae.push(nt)),nt.end++;const _i=nt.rect;if(tn<_i[0]&&(_i[0]=tn),dn<_i[1]&&(_i[1]=dn),Gn>_i[2]&&(_i[2]=Gn),sr>_i[3]&&(_i[3]=sr),ie[Bt]=li,k){const J=Bt*3;le[J]=pt>>16&255,le[J+1]=pt>>8&255,le[J+2]=pt&255}}}}$e-=A}),Ae){const re=x.length-Oe;re>1&&v(Ae,Oe,re)}}V.typesetting=_()-ge,G({glyphIds:ie,glyphPositions:ue,glyphData:ce,caretPositions:Ae,caretHeight:ne,glyphColors:le,chunkedBounds:ae,fontSize:b,unitsPerEm:Ie,ascender:se*He,descender:$*He,capHeight:Se*He,xHeight:Le*He,lineHeight:A,topBaseline:H,blockBounds:[Ue,xe-Fe.length*A,Ue+z,xe],visibleBounds:Ee,timings:V})})}function p(x,w){h(x,E=>{const[b,M,A,P]=E.blockBounds;w({width:A-b,height:P-M})},{})}function m(x){let w=x.match(/^([\d.]+)%$/),E=w?parseFloat(w[1]):NaN;return isNaN(E)?0:E/100}function v(x,w,E){const b=x[w*3],M=x[w*3+1],A=x[w*3+2],P=(M-b)/E;for(let C=0;C<E;C++){const L=(w+C)*3;x[L]=b+P*C,x[L+1]=b+P*(C+1),x[L+2]=A}}function _(){return(self.performance||Date).now()}function y(){this.data=[]}const g=["glyphObj","x","width","charIndex"];return y.prototype={width:0,isSoftWrapped:!1,get count(){return Math.ceil(this.data.length/g.length)},glyphAt(x){let w=y.flyweight;return w.data=this.data,w.index=x,w},splitAt(x){let w=new y;return w.data=this.data.splice(x*g.length),w}},y.flyweight=g.reduce((x,w,E,b)=>(Object.defineProperty(x,w,{get(){return this.data[this.index*g.length+E]},set(M){this.data[this.index*g.length+E]=M}}),x),{data:null,index:0}),{typeset:h,measure:p,loadFont:u}}const _a=()=>(self.performance||Date).now(),Fp=KA();let AE;function UG(r,e,t,n,i,s,o,a,l,c,u=!0){return u?NG(r,e,t,n,i,s,o,a,l,c).then(null,h=>(AE||(console.warn("WebGL SDF generation failed, falling back to JS",h),AE=!0),RE(r,e,t,n,i,s,o,a,l,c))):RE(r,e,t,n,i,s,o,a,l,c)}const Pd=[],OG=5;let Bv=0;function JA(){const r=_a();for(;Pd.length&&_a()-r<OG;)Pd.shift()();Bv=Pd.length?setTimeout(JA,0):0}const NG=(...r)=>new Promise((e,t)=>{Pd.push(()=>{const n=_a();try{Fp.webgl.generateIntoCanvas(...r),e({timing:_a()-n})}catch(i){t(i)}}),Bv||(Bv=setTimeout(JA,0))}),FG=4,kG=2e3,CE={};let zG=0;function RE(r,e,t,n,i,s,o,a,l,c){const u="TroikaTextSDFGenerator_JS_"+zG++%FG;let h=CE[u];return h||(h=CE[u]={workerModule:yh({name:u,workerId:u,dependencies:[KA,_a],init(p,m){const v=p().javascript.generate;return function(..._){const y=m();return{textureData:v(..._),timing:m()-y}}},getTransferables(p){return[p.textureData.buffer]}}),requests:0,idleTimer:null}),h.requests++,clearTimeout(h.idleTimer),h.workerModule(r,e,t,n,i,s).then(({textureData:p,timing:m})=>{const v=_a(),_=new Uint8Array(p.length*4);for(let y=0;y<p.length;y++)_[y*4+c]=p[y];return Fp.webglUtils.renderImageData(o,_,a,l,r,e,1<<3-c),m+=_a()-v,--h.requests===0&&(h.idleTimer=setTimeout(()=>{EG(u)},kG)),{timing:m}})}function BG(r){r._warm||(Fp.webgl.isSupported(r),r._warm=!0)}const GG=Fp.webglUtils.resizeWebGLCanvasWithoutClearing;/*!
|
|
Custom build of Typr.ts (https://github.com/fredli74/Typr.ts) for use in Troika text rendering.
|
|
Original MIT license applies: https://github.com/fredli74/Typr.ts/blob/master/LICENSE
|
|
*/function HG(){return typeof window>"u"&&(self.window=self),(function(r){var e={parse:function(i){var s=e._bin,o=new Uint8Array(i);if(s.readASCII(o,0,4)=="ttcf"){var a=4;s.readUshort(o,a),a+=2,s.readUshort(o,a),a+=2;var l=s.readUint(o,a);a+=4;for(var c=[],u=0;u<l;u++){var h=s.readUint(o,a);a+=4,c.push(e._readFont(o,h))}return c}return[e._readFont(o,0)]},_readFont:function(i,s){var o=e._bin,a=s;o.readFixed(i,s),s+=4;var l=o.readUshort(i,s);s+=2,o.readUshort(i,s),s+=2,o.readUshort(i,s),s+=2,o.readUshort(i,s),s+=2;for(var c=["cmap","head","hhea","maxp","hmtx","name","OS/2","post","loca","glyf","kern","CFF ","GPOS","GSUB","SVG "],u={_data:i,_offset:a},h={},p=0;p<l;p++){var m=o.readASCII(i,s,4);s+=4,o.readUint(i,s),s+=4;var v=o.readUint(i,s);s+=4;var _=o.readUint(i,s);s+=4,h[m]={offset:v,length:_}}for(p=0;p<c.length;p++){var y=c[p];h[y]&&(u[y.trim()]=e[y.trim()].parse(i,h[y].offset,h[y].length,u))}return u},_tabOffset:function(i,s,o){for(var a=e._bin,l=a.readUshort(i,o+4),c=o+12,u=0;u<l;u++){var h=a.readASCII(i,c,4);c+=4,a.readUint(i,c),c+=4;var p=a.readUint(i,c);if(c+=4,a.readUint(i,c),c+=4,h==s)return p}return 0}};e._bin={readFixed:function(i,s){return(i[s]<<8|i[s+1])+(i[s+2]<<8|i[s+3])/65540},readF2dot14:function(i,s){return e._bin.readShort(i,s)/16384},readInt:function(i,s){return e._bin._view(i).getInt32(s)},readInt8:function(i,s){return e._bin._view(i).getInt8(s)},readShort:function(i,s){return e._bin._view(i).getInt16(s)},readUshort:function(i,s){return e._bin._view(i).getUint16(s)},readUshorts:function(i,s,o){for(var a=[],l=0;l<o;l++)a.push(e._bin.readUshort(i,s+2*l));return a},readUint:function(i,s){return e._bin._view(i).getUint32(s)},readUint64:function(i,s){return 4294967296*e._bin.readUint(i,s)+e._bin.readUint(i,s+4)},readASCII:function(i,s,o){for(var a="",l=0;l<o;l++)a+=String.fromCharCode(i[s+l]);return a},readUnicode:function(i,s,o){for(var a="",l=0;l<o;l++){var c=i[s++]<<8|i[s++];a+=String.fromCharCode(c)}return a},_tdec:typeof window<"u"&&window.TextDecoder?new window.TextDecoder:null,readUTF8:function(i,s,o){var a=e._bin._tdec;return a&&s==0&&o==i.length?a.decode(i):e._bin.readASCII(i,s,o)},readBytes:function(i,s,o){for(var a=[],l=0;l<o;l++)a.push(i[s+l]);return a},readASCIIArray:function(i,s,o){for(var a=[],l=0;l<o;l++)a.push(String.fromCharCode(i[s+l]));return a},_view:function(i){return i._dataView||(i._dataView=i.buffer?new DataView(i.buffer,i.byteOffset,i.byteLength):new DataView(new Uint8Array(i).buffer))}},e._lctf={},e._lctf.parse=function(i,s,o,a,l){var c=e._bin,u={},h=s;c.readFixed(i,s),s+=4;var p=c.readUshort(i,s);s+=2;var m=c.readUshort(i,s);s+=2;var v=c.readUshort(i,s);return s+=2,u.scriptList=e._lctf.readScriptList(i,h+p),u.featureList=e._lctf.readFeatureList(i,h+m),u.lookupList=e._lctf.readLookupList(i,h+v,l),u},e._lctf.readLookupList=function(i,s,o){var a=e._bin,l=s,c=[],u=a.readUshort(i,s);s+=2;for(var h=0;h<u;h++){var p=a.readUshort(i,s);s+=2;var m=e._lctf.readLookupTable(i,l+p,o);c.push(m)}return c},e._lctf.readLookupTable=function(i,s,o){var a=e._bin,l=s,c={tabs:[]};c.ltype=a.readUshort(i,s),s+=2,c.flag=a.readUshort(i,s),s+=2;var u=a.readUshort(i,s);s+=2;for(var h=c.ltype,p=0;p<u;p++){var m=a.readUshort(i,s);s+=2;var v=o(i,h,l+m,c);c.tabs.push(v)}return c},e._lctf.numOfOnes=function(i){for(var s=0,o=0;o<32;o++)(i>>>o&1)!=0&&s++;return s},e._lctf.readClassDef=function(i,s){var o=e._bin,a=[],l=o.readUshort(i,s);if(s+=2,l==1){var c=o.readUshort(i,s);s+=2;var u=o.readUshort(i,s);s+=2;for(var h=0;h<u;h++)a.push(c+h),a.push(c+h),a.push(o.readUshort(i,s)),s+=2}if(l==2){var p=o.readUshort(i,s);for(s+=2,h=0;h<p;h++)a.push(o.readUshort(i,s)),s+=2,a.push(o.readUshort(i,s)),s+=2,a.push(o.readUshort(i,s)),s+=2}return a},e._lctf.getInterval=function(i,s){for(var o=0;o<i.length;o+=3){var a=i[o],l=i[o+1];if(i[o+2],a<=s&&s<=l)return o}return-1},e._lctf.readCoverage=function(i,s){var o=e._bin,a={};a.fmt=o.readUshort(i,s),s+=2;var l=o.readUshort(i,s);return s+=2,a.fmt==1&&(a.tab=o.readUshorts(i,s,l)),a.fmt==2&&(a.tab=o.readUshorts(i,s,3*l)),a},e._lctf.coverageIndex=function(i,s){var o=i.tab;if(i.fmt==1)return o.indexOf(s);if(i.fmt==2){var a=e._lctf.getInterval(o,s);if(a!=-1)return o[a+2]+(s-o[a])}return-1},e._lctf.readFeatureList=function(i,s){var o=e._bin,a=s,l=[],c=o.readUshort(i,s);s+=2;for(var u=0;u<c;u++){var h=o.readASCII(i,s,4);s+=4;var p=o.readUshort(i,s);s+=2;var m=e._lctf.readFeatureTable(i,a+p);m.tag=h.trim(),l.push(m)}return l},e._lctf.readFeatureTable=function(i,s){var o=e._bin,a=s,l={},c=o.readUshort(i,s);s+=2,c>0&&(l.featureParams=a+c);var u=o.readUshort(i,s);s+=2,l.tab=[];for(var h=0;h<u;h++)l.tab.push(o.readUshort(i,s+2*h));return l},e._lctf.readScriptList=function(i,s){var o=e._bin,a=s,l={},c=o.readUshort(i,s);s+=2;for(var u=0;u<c;u++){var h=o.readASCII(i,s,4);s+=4;var p=o.readUshort(i,s);s+=2,l[h.trim()]=e._lctf.readScriptTable(i,a+p)}return l},e._lctf.readScriptTable=function(i,s){var o=e._bin,a=s,l={},c=o.readUshort(i,s);s+=2,l.default=e._lctf.readLangSysTable(i,a+c);var u=o.readUshort(i,s);s+=2;for(var h=0;h<u;h++){var p=o.readASCII(i,s,4);s+=4;var m=o.readUshort(i,s);s+=2,l[p.trim()]=e._lctf.readLangSysTable(i,a+m)}return l},e._lctf.readLangSysTable=function(i,s){var o=e._bin,a={};o.readUshort(i,s),s+=2,a.reqFeature=o.readUshort(i,s),s+=2;var l=o.readUshort(i,s);return s+=2,a.features=o.readUshorts(i,s,l),a},e.CFF={},e.CFF.parse=function(i,s,o){var a=e._bin;(i=new Uint8Array(i.buffer,s,o))[s=0],i[++s],i[++s],i[++s],s++;var l=[];s=e.CFF.readIndex(i,s,l);for(var c=[],u=0;u<l.length-1;u++)c.push(a.readASCII(i,s+l[u],l[u+1]-l[u]));s+=l[l.length-1];var h=[];s=e.CFF.readIndex(i,s,h);var p=[];for(u=0;u<h.length-1;u++)p.push(e.CFF.readDict(i,s+h[u],s+h[u+1]));s+=h[h.length-1];var m=p[0],v=[];s=e.CFF.readIndex(i,s,v);var _=[];for(u=0;u<v.length-1;u++)_.push(a.readASCII(i,s+v[u],v[u+1]-v[u]));if(s+=v[v.length-1],e.CFF.readSubrs(i,s,m),m.CharStrings){s=m.CharStrings,v=[],s=e.CFF.readIndex(i,s,v);var y=[];for(u=0;u<v.length-1;u++)y.push(a.readBytes(i,s+v[u],v[u+1]-v[u]));m.CharStrings=y}if(m.ROS){s=m.FDArray;var g=[];for(s=e.CFF.readIndex(i,s,g),m.FDArray=[],u=0;u<g.length-1;u++){var x=e.CFF.readDict(i,s+g[u],s+g[u+1]);e.CFF._readFDict(i,x,_),m.FDArray.push(x)}s+=g[g.length-1],s=m.FDSelect,m.FDSelect=[];var w=i[s];if(s++,w!=3)throw w;var E=a.readUshort(i,s);for(s+=2,u=0;u<E+1;u++)m.FDSelect.push(a.readUshort(i,s),i[s+2]),s+=3}return m.Encoding&&(m.Encoding=e.CFF.readEncoding(i,m.Encoding,m.CharStrings.length)),m.charset&&(m.charset=e.CFF.readCharset(i,m.charset,m.CharStrings.length)),e.CFF._readFDict(i,m,_),m},e.CFF._readFDict=function(i,s,o){var a;for(var l in s.Private&&(a=s.Private[1],s.Private=e.CFF.readDict(i,a,a+s.Private[0]),s.Private.Subrs&&e.CFF.readSubrs(i,a+s.Private.Subrs,s.Private)),s)["FamilyName","FontName","FullName","Notice","version","Copyright"].indexOf(l)!=-1&&(s[l]=o[s[l]-426+35])},e.CFF.readSubrs=function(i,s,o){var a=e._bin,l=[];s=e.CFF.readIndex(i,s,l);var c,u=l.length;c=u<1240?107:u<33900?1131:32768,o.Bias=c,o.Subrs=[];for(var h=0;h<l.length-1;h++)o.Subrs.push(a.readBytes(i,s+l[h],l[h+1]-l[h]))},e.CFF.tableSE=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,0,111,112,113,114,0,115,116,117,118,119,120,121,122,0,123,0,124,125,126,127,128,129,130,131,0,132,133,0,134,135,136,137,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,138,0,139,0,0,0,0,140,141,142,143,0,0,0,0,0,144,0,0,0,145,0,0,146,147,148,149,0,0,0,0],e.CFF.glyphByUnicode=function(i,s){for(var o=0;o<i.charset.length;o++)if(i.charset[o]==s)return o;return-1},e.CFF.glyphBySE=function(i,s){return s<0||s>255?-1:e.CFF.glyphByUnicode(i,e.CFF.tableSE[s])},e.CFF.readEncoding=function(i,s,o){e._bin;var a=[".notdef"],l=i[s];if(s++,l!=0)throw"error: unknown encoding format: "+l;var c=i[s];s++;for(var u=0;u<c;u++)a.push(i[s+u]);return a},e.CFF.readCharset=function(i,s,o){var a=e._bin,l=[".notdef"],c=i[s];if(s++,c==0)for(var u=0;u<o;u++){var h=a.readUshort(i,s);s+=2,l.push(h)}else{if(c!=1&&c!=2)throw"error: format: "+c;for(;l.length<o;){h=a.readUshort(i,s),s+=2;var p=0;for(c==1?(p=i[s],s++):(p=a.readUshort(i,s),s+=2),u=0;u<=p;u++)l.push(h),h++}}return l},e.CFF.readIndex=function(i,s,o){var a=e._bin,l=a.readUshort(i,s)+1,c=i[s+=2];if(s++,c==1)for(var u=0;u<l;u++)o.push(i[s+u]);else if(c==2)for(u=0;u<l;u++)o.push(a.readUshort(i,s+2*u));else if(c==3)for(u=0;u<l;u++)o.push(16777215&a.readUint(i,s+3*u-1));else if(l!=1)throw"unsupported offset size: "+c+", count: "+l;return(s+=l*c)-1},e.CFF.getCharString=function(i,s,o){var a=e._bin,l=i[s],c=i[s+1];i[s+2],i[s+3],i[s+4];var u=1,h=null,p=null;l<=20&&(h=l,u=1),l==12&&(h=100*l+c,u=2),21<=l&&l<=27&&(h=l,u=1),l==28&&(p=a.readShort(i,s+1),u=3),29<=l&&l<=31&&(h=l,u=1),32<=l&&l<=246&&(p=l-139,u=1),247<=l&&l<=250&&(p=256*(l-247)+c+108,u=2),251<=l&&l<=254&&(p=256*-(l-251)-c-108,u=2),l==255&&(p=a.readInt(i,s+1)/65535,u=5),o.val=p??"o"+h,o.size=u},e.CFF.readCharString=function(i,s,o){for(var a=s+o,l=e._bin,c=[];s<a;){var u=i[s],h=i[s+1];i[s+2],i[s+3],i[s+4];var p=1,m=null,v=null;u<=20&&(m=u,p=1),u==12&&(m=100*u+h,p=2),u!=19&&u!=20||(m=u,p=2),21<=u&&u<=27&&(m=u,p=1),u==28&&(v=l.readShort(i,s+1),p=3),29<=u&&u<=31&&(m=u,p=1),32<=u&&u<=246&&(v=u-139,p=1),247<=u&&u<=250&&(v=256*(u-247)+h+108,p=2),251<=u&&u<=254&&(v=256*-(u-251)-h-108,p=2),u==255&&(v=l.readInt(i,s+1)/65535,p=5),c.push(v??"o"+m),s+=p}return c},e.CFF.readDict=function(i,s,o){for(var a=e._bin,l={},c=[];s<o;){var u=i[s],h=i[s+1];i[s+2],i[s+3],i[s+4];var p=1,m=null,v=null;if(u==28&&(v=a.readShort(i,s+1),p=3),u==29&&(v=a.readInt(i,s+1),p=5),32<=u&&u<=246&&(v=u-139,p=1),247<=u&&u<=250&&(v=256*(u-247)+h+108,p=2),251<=u&&u<=254&&(v=256*-(u-251)-h-108,p=2),u==255)throw v=a.readInt(i,s+1)/65535,p=5,"unknown number";if(u==30){var _=[];for(p=1;;){var y=i[s+p];p++;var g=y>>4,x=15&y;if(g!=15&&_.push(g),x!=15&&_.push(x),x==15)break}for(var w="",E=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"],b=0;b<_.length;b++)w+=E[_[b]];v=parseFloat(w)}u<=21&&(m=["version","Notice","FullName","FamilyName","Weight","FontBBox","BlueValues","OtherBlues","FamilyBlues","FamilyOtherBlues","StdHW","StdVW","escape","UniqueID","XUID","charset","Encoding","CharStrings","Private","Subrs","defaultWidthX","nominalWidthX"][u],p=1,u==12&&(m=["Copyright","isFixedPitch","ItalicAngle","UnderlinePosition","UnderlineThickness","PaintType","CharstringType","FontMatrix","StrokeWidth","BlueScale","BlueShift","BlueFuzz","StemSnapH","StemSnapV","ForceBold",0,0,"LanguageGroup","ExpansionFactor","initialRandomSeed","SyntheticBase","PostScript","BaseFontName","BaseFontBlend",0,0,0,0,0,0,"ROS","CIDFontVersion","CIDFontRevision","CIDFontType","CIDCount","UIDBase","FDArray","FDSelect","FontName"][h],p=2)),m!=null?(l[m]=c.length==1?c[0]:c,c=[]):c.push(v),s+=p}return l},e.cmap={},e.cmap.parse=function(i,s,o){i=new Uint8Array(i.buffer,s,o),s=0;var a=e._bin,l={};a.readUshort(i,s),s+=2;var c=a.readUshort(i,s);s+=2;var u=[];l.tables=[];for(var h=0;h<c;h++){var p=a.readUshort(i,s);s+=2;var m=a.readUshort(i,s);s+=2;var v=a.readUint(i,s);s+=4;var _="p"+p+"e"+m,y=u.indexOf(v);if(y==-1){var g;y=l.tables.length,u.push(v);var x=a.readUshort(i,v);x==0?g=e.cmap.parse0(i,v):x==4?g=e.cmap.parse4(i,v):x==6?g=e.cmap.parse6(i,v):x==12?g=e.cmap.parse12(i,v):console.debug("unknown format: "+x,p,m,v),l.tables.push(g)}if(l[_]!=null)throw"multiple tables for one platform+encoding";l[_]=y}return l},e.cmap.parse0=function(i,s){var o=e._bin,a={};a.format=o.readUshort(i,s),s+=2;var l=o.readUshort(i,s);s+=2,o.readUshort(i,s),s+=2,a.map=[];for(var c=0;c<l-6;c++)a.map.push(i[s+c]);return a},e.cmap.parse4=function(i,s){var o=e._bin,a=s,l={};l.format=o.readUshort(i,s),s+=2;var c=o.readUshort(i,s);s+=2,o.readUshort(i,s),s+=2;var u=o.readUshort(i,s);s+=2;var h=u/2;l.searchRange=o.readUshort(i,s),s+=2,l.entrySelector=o.readUshort(i,s),s+=2,l.rangeShift=o.readUshort(i,s),s+=2,l.endCount=o.readUshorts(i,s,h),s+=2*h,s+=2,l.startCount=o.readUshorts(i,s,h),s+=2*h,l.idDelta=[];for(var p=0;p<h;p++)l.idDelta.push(o.readShort(i,s)),s+=2;for(l.idRangeOffset=o.readUshorts(i,s,h),s+=2*h,l.glyphIdArray=[];s<a+c;)l.glyphIdArray.push(o.readUshort(i,s)),s+=2;return l},e.cmap.parse6=function(i,s){var o=e._bin,a={};a.format=o.readUshort(i,s),s+=2,o.readUshort(i,s),s+=2,o.readUshort(i,s),s+=2,a.firstCode=o.readUshort(i,s),s+=2;var l=o.readUshort(i,s);s+=2,a.glyphIdArray=[];for(var c=0;c<l;c++)a.glyphIdArray.push(o.readUshort(i,s)),s+=2;return a},e.cmap.parse12=function(i,s){var o=e._bin,a={};a.format=o.readUshort(i,s),s+=2,s+=2,o.readUint(i,s),s+=4,o.readUint(i,s),s+=4;var l=o.readUint(i,s);s+=4,a.groups=[];for(var c=0;c<l;c++){var u=s+12*c,h=o.readUint(i,u+0),p=o.readUint(i,u+4),m=o.readUint(i,u+8);a.groups.push([h,p,m])}return a},e.glyf={},e.glyf.parse=function(i,s,o,a){for(var l=[],c=0;c<a.maxp.numGlyphs;c++)l.push(null);return l},e.glyf._parseGlyf=function(i,s){var o=e._bin,a=i._data,l=e._tabOffset(a,"glyf",i._offset)+i.loca[s];if(i.loca[s]==i.loca[s+1])return null;var c={};if(c.noc=o.readShort(a,l),l+=2,c.xMin=o.readShort(a,l),l+=2,c.yMin=o.readShort(a,l),l+=2,c.xMax=o.readShort(a,l),l+=2,c.yMax=o.readShort(a,l),l+=2,c.xMin>=c.xMax||c.yMin>=c.yMax)return null;if(c.noc>0){c.endPts=[];for(var u=0;u<c.noc;u++)c.endPts.push(o.readUshort(a,l)),l+=2;var h=o.readUshort(a,l);if(l+=2,a.length-l<h)return null;c.instructions=o.readBytes(a,l,h),l+=h;var p=c.endPts[c.noc-1]+1;for(c.flags=[],u=0;u<p;u++){var m=a[l];if(l++,c.flags.push(m),(8&m)!=0){var v=a[l];l++;for(var _=0;_<v;_++)c.flags.push(m),u++}}for(c.xs=[],u=0;u<p;u++){var y=(2&c.flags[u])!=0,g=(16&c.flags[u])!=0;y?(c.xs.push(g?a[l]:-a[l]),l++):g?c.xs.push(0):(c.xs.push(o.readShort(a,l)),l+=2)}for(c.ys=[],u=0;u<p;u++)y=(4&c.flags[u])!=0,g=(32&c.flags[u])!=0,y?(c.ys.push(g?a[l]:-a[l]),l++):g?c.ys.push(0):(c.ys.push(o.readShort(a,l)),l+=2);var x=0,w=0;for(u=0;u<p;u++)x+=c.xs[u],w+=c.ys[u],c.xs[u]=x,c.ys[u]=w}else{var E;c.parts=[];do{E=o.readUshort(a,l),l+=2;var b={m:{a:1,b:0,c:0,d:1,tx:0,ty:0},p1:-1,p2:-1};if(c.parts.push(b),b.glyphIndex=o.readUshort(a,l),l+=2,1&E){var M=o.readShort(a,l);l+=2;var A=o.readShort(a,l);l+=2}else M=o.readInt8(a,l),l++,A=o.readInt8(a,l),l++;2&E?(b.m.tx=M,b.m.ty=A):(b.p1=M,b.p2=A),8&E?(b.m.a=b.m.d=o.readF2dot14(a,l),l+=2):64&E?(b.m.a=o.readF2dot14(a,l),l+=2,b.m.d=o.readF2dot14(a,l),l+=2):128&E&&(b.m.a=o.readF2dot14(a,l),l+=2,b.m.b=o.readF2dot14(a,l),l+=2,b.m.c=o.readF2dot14(a,l),l+=2,b.m.d=o.readF2dot14(a,l),l+=2)}while(32&E);if(256&E){var P=o.readUshort(a,l);for(l+=2,c.instr=[],u=0;u<P;u++)c.instr.push(a[l]),l++}}return c},e.GPOS={},e.GPOS.parse=function(i,s,o,a){return e._lctf.parse(i,s,o,a,e.GPOS.subt)},e.GPOS.subt=function(i,s,o,a){var l=e._bin,c=o,u={};if(u.fmt=l.readUshort(i,o),o+=2,s==1||s==2||s==3||s==7||s==8&&u.fmt<=2){var h=l.readUshort(i,o);o+=2,u.coverage=e._lctf.readCoverage(i,h+c)}if(s==1&&u.fmt==1){var p=l.readUshort(i,o);o+=2;var m=e._lctf.numOfOnes(p);p!=0&&(u.pos=e.GPOS.readValueRecord(i,o,p))}else if(s==2&&u.fmt>=1&&u.fmt<=2){p=l.readUshort(i,o),o+=2;var v=l.readUshort(i,o);o+=2,m=e._lctf.numOfOnes(p);var _=e._lctf.numOfOnes(v);if(u.fmt==1){u.pairsets=[];var y=l.readUshort(i,o);o+=2;for(var g=0;g<y;g++){var x=c+l.readUshort(i,o);o+=2;var w=l.readUshort(i,x);x+=2;for(var E=[],b=0;b<w;b++){var M=l.readUshort(i,x);x+=2,p!=0&&(N=e.GPOS.readValueRecord(i,x,p),x+=2*m),v!=0&&(I=e.GPOS.readValueRecord(i,x,v),x+=2*_),E.push({gid2:M,val1:N,val2:I})}u.pairsets.push(E)}}if(u.fmt==2){var A=l.readUshort(i,o);o+=2;var P=l.readUshort(i,o);o+=2;var C=l.readUshort(i,o);o+=2;var L=l.readUshort(i,o);for(o+=2,u.classDef1=e._lctf.readClassDef(i,c+A),u.classDef2=e._lctf.readClassDef(i,c+P),u.matrix=[],g=0;g<C;g++){var F=[];for(b=0;b<L;b++){var N=null,I=null;p!=0&&(N=e.GPOS.readValueRecord(i,o,p),o+=2*m),v!=0&&(I=e.GPOS.readValueRecord(i,o,v),o+=2*_),F.push({val1:N,val2:I})}u.matrix.push(F)}}}else{if(s==9&&u.fmt==1){var X=l.readUshort(i,o);o+=2;var q=l.readUint(i,o);if(o+=4,a.ltype==9)a.ltype=X;else if(a.ltype!=X)throw"invalid extension substitution";return e.GPOS.subt(i,a.ltype,c+q)}console.debug("unsupported GPOS table LookupType",s,"format",u.fmt)}return u},e.GPOS.readValueRecord=function(i,s,o){var a=e._bin,l=[];return l.push(1&o?a.readShort(i,s):0),s+=1&o?2:0,l.push(2&o?a.readShort(i,s):0),s+=2&o?2:0,l.push(4&o?a.readShort(i,s):0),s+=4&o?2:0,l.push(8&o?a.readShort(i,s):0),s+=8&o?2:0,l},e.GSUB={},e.GSUB.parse=function(i,s,o,a){return e._lctf.parse(i,s,o,a,e.GSUB.subt)},e.GSUB.subt=function(i,s,o,a){var l=e._bin,c=o,u={};if(u.fmt=l.readUshort(i,o),o+=2,s!=1&&s!=4&&s!=5&&s!=6)return null;if(s==1||s==4||s==5&&u.fmt<=2||s==6&&u.fmt<=2){var h=l.readUshort(i,o);o+=2,u.coverage=e._lctf.readCoverage(i,c+h)}if(s==1&&u.fmt>=1&&u.fmt<=2){if(u.fmt==1)u.delta=l.readShort(i,o),o+=2;else if(u.fmt==2){var p=l.readUshort(i,o);o+=2,u.newg=l.readUshorts(i,o,p),o+=2*u.newg.length}}else if(s==4){u.vals=[],p=l.readUshort(i,o),o+=2;for(var m=0;m<p;m++){var v=l.readUshort(i,o);o+=2,u.vals.push(e.GSUB.readLigatureSet(i,c+v))}}else if(s==5&&u.fmt==2){if(u.fmt==2){var _=l.readUshort(i,o);o+=2,u.cDef=e._lctf.readClassDef(i,c+_),u.scset=[];var y=l.readUshort(i,o);for(o+=2,m=0;m<y;m++){var g=l.readUshort(i,o);o+=2,u.scset.push(g==0?null:e.GSUB.readSubClassSet(i,c+g))}}}else if(s==6&&u.fmt==3){if(u.fmt==3){for(m=0;m<3;m++){p=l.readUshort(i,o),o+=2;for(var x=[],w=0;w<p;w++)x.push(e._lctf.readCoverage(i,c+l.readUshort(i,o+2*w)));o+=2*p,m==0&&(u.backCvg=x),m==1&&(u.inptCvg=x),m==2&&(u.ahedCvg=x)}p=l.readUshort(i,o),o+=2,u.lookupRec=e.GSUB.readSubstLookupRecords(i,o,p)}}else{if(s==7&&u.fmt==1){var E=l.readUshort(i,o);o+=2;var b=l.readUint(i,o);if(o+=4,a.ltype==9)a.ltype=E;else if(a.ltype!=E)throw"invalid extension substitution";return e.GSUB.subt(i,a.ltype,c+b)}console.debug("unsupported GSUB table LookupType",s,"format",u.fmt)}return u},e.GSUB.readSubClassSet=function(i,s){var o=e._bin.readUshort,a=s,l=[],c=o(i,s);s+=2;for(var u=0;u<c;u++){var h=o(i,s);s+=2,l.push(e.GSUB.readSubClassRule(i,a+h))}return l},e.GSUB.readSubClassRule=function(i,s){var o=e._bin.readUshort,a={},l=o(i,s),c=o(i,s+=2);s+=2,a.input=[];for(var u=0;u<l-1;u++)a.input.push(o(i,s)),s+=2;return a.substLookupRecords=e.GSUB.readSubstLookupRecords(i,s,c),a},e.GSUB.readSubstLookupRecords=function(i,s,o){for(var a=e._bin.readUshort,l=[],c=0;c<o;c++)l.push(a(i,s),a(i,s+2)),s+=4;return l},e.GSUB.readChainSubClassSet=function(i,s){var o=e._bin,a=s,l=[],c=o.readUshort(i,s);s+=2;for(var u=0;u<c;u++){var h=o.readUshort(i,s);s+=2,l.push(e.GSUB.readChainSubClassRule(i,a+h))}return l},e.GSUB.readChainSubClassRule=function(i,s){for(var o=e._bin,a={},l=["backtrack","input","lookahead"],c=0;c<l.length;c++){var u=o.readUshort(i,s);s+=2,c==1&&u--,a[l[c]]=o.readUshorts(i,s,u),s+=2*a[l[c]].length}return u=o.readUshort(i,s),s+=2,a.subst=o.readUshorts(i,s,2*u),s+=2*a.subst.length,a},e.GSUB.readLigatureSet=function(i,s){var o=e._bin,a=s,l=[],c=o.readUshort(i,s);s+=2;for(var u=0;u<c;u++){var h=o.readUshort(i,s);s+=2,l.push(e.GSUB.readLigature(i,a+h))}return l},e.GSUB.readLigature=function(i,s){var o=e._bin,a={chain:[]};a.nglyph=o.readUshort(i,s),s+=2;var l=o.readUshort(i,s);s+=2;for(var c=0;c<l-1;c++)a.chain.push(o.readUshort(i,s)),s+=2;return a},e.head={},e.head.parse=function(i,s,o){var a=e._bin,l={};return a.readFixed(i,s),s+=4,l.fontRevision=a.readFixed(i,s),s+=4,a.readUint(i,s),s+=4,a.readUint(i,s),s+=4,l.flags=a.readUshort(i,s),s+=2,l.unitsPerEm=a.readUshort(i,s),s+=2,l.created=a.readUint64(i,s),s+=8,l.modified=a.readUint64(i,s),s+=8,l.xMin=a.readShort(i,s),s+=2,l.yMin=a.readShort(i,s),s+=2,l.xMax=a.readShort(i,s),s+=2,l.yMax=a.readShort(i,s),s+=2,l.macStyle=a.readUshort(i,s),s+=2,l.lowestRecPPEM=a.readUshort(i,s),s+=2,l.fontDirectionHint=a.readShort(i,s),s+=2,l.indexToLocFormat=a.readShort(i,s),s+=2,l.glyphDataFormat=a.readShort(i,s),s+=2,l},e.hhea={},e.hhea.parse=function(i,s,o){var a=e._bin,l={};return a.readFixed(i,s),s+=4,l.ascender=a.readShort(i,s),s+=2,l.descender=a.readShort(i,s),s+=2,l.lineGap=a.readShort(i,s),s+=2,l.advanceWidthMax=a.readUshort(i,s),s+=2,l.minLeftSideBearing=a.readShort(i,s),s+=2,l.minRightSideBearing=a.readShort(i,s),s+=2,l.xMaxExtent=a.readShort(i,s),s+=2,l.caretSlopeRise=a.readShort(i,s),s+=2,l.caretSlopeRun=a.readShort(i,s),s+=2,l.caretOffset=a.readShort(i,s),s+=2,s+=8,l.metricDataFormat=a.readShort(i,s),s+=2,l.numberOfHMetrics=a.readUshort(i,s),s+=2,l},e.hmtx={},e.hmtx.parse=function(i,s,o,a){for(var l=e._bin,c={aWidth:[],lsBearing:[]},u=0,h=0,p=0;p<a.maxp.numGlyphs;p++)p<a.hhea.numberOfHMetrics&&(u=l.readUshort(i,s),s+=2,h=l.readShort(i,s),s+=2),c.aWidth.push(u),c.lsBearing.push(h);return c},e.kern={},e.kern.parse=function(i,s,o,a){var l=e._bin,c=l.readUshort(i,s);if(s+=2,c==1)return e.kern.parseV1(i,s-2,o,a);var u=l.readUshort(i,s);s+=2;for(var h={glyph1:[],rval:[]},p=0;p<u;p++){s+=2,o=l.readUshort(i,s),s+=2;var m=l.readUshort(i,s);s+=2;var v=m>>>8;if((v&=15)!=0)throw"unknown kern table format: "+v;s=e.kern.readFormat0(i,s,h)}return h},e.kern.parseV1=function(i,s,o,a){var l=e._bin;l.readFixed(i,s),s+=4;var c=l.readUint(i,s);s+=4;for(var u={glyph1:[],rval:[]},h=0;h<c;h++){l.readUint(i,s),s+=4;var p=l.readUshort(i,s);s+=2,l.readUshort(i,s),s+=2;var m=p>>>8;if((m&=15)!=0)throw"unknown kern table format: "+m;s=e.kern.readFormat0(i,s,u)}return u},e.kern.readFormat0=function(i,s,o){var a=e._bin,l=-1,c=a.readUshort(i,s);s+=2,a.readUshort(i,s),s+=2,a.readUshort(i,s),s+=2,a.readUshort(i,s),s+=2;for(var u=0;u<c;u++){var h=a.readUshort(i,s);s+=2;var p=a.readUshort(i,s);s+=2;var m=a.readShort(i,s);s+=2,h!=l&&(o.glyph1.push(h),o.rval.push({glyph2:[],vals:[]}));var v=o.rval[o.rval.length-1];v.glyph2.push(p),v.vals.push(m),l=h}return s},e.loca={},e.loca.parse=function(i,s,o,a){var l=e._bin,c=[],u=a.head.indexToLocFormat,h=a.maxp.numGlyphs+1;if(u==0)for(var p=0;p<h;p++)c.push(l.readUshort(i,s+(p<<1))<<1);if(u==1)for(p=0;p<h;p++)c.push(l.readUint(i,s+(p<<2)));return c},e.maxp={},e.maxp.parse=function(i,s,o){var a=e._bin,l={},c=a.readUint(i,s);return s+=4,l.numGlyphs=a.readUshort(i,s),s+=2,c==65536&&(l.maxPoints=a.readUshort(i,s),s+=2,l.maxContours=a.readUshort(i,s),s+=2,l.maxCompositePoints=a.readUshort(i,s),s+=2,l.maxCompositeContours=a.readUshort(i,s),s+=2,l.maxZones=a.readUshort(i,s),s+=2,l.maxTwilightPoints=a.readUshort(i,s),s+=2,l.maxStorage=a.readUshort(i,s),s+=2,l.maxFunctionDefs=a.readUshort(i,s),s+=2,l.maxInstructionDefs=a.readUshort(i,s),s+=2,l.maxStackElements=a.readUshort(i,s),s+=2,l.maxSizeOfInstructions=a.readUshort(i,s),s+=2,l.maxComponentElements=a.readUshort(i,s),s+=2,l.maxComponentDepth=a.readUshort(i,s),s+=2),l},e.name={},e.name.parse=function(i,s,o){var a=e._bin,l={};a.readUshort(i,s),s+=2;var c=a.readUshort(i,s);s+=2,a.readUshort(i,s);for(var u,h=["copyright","fontFamily","fontSubfamily","ID","fullName","version","postScriptName","trademark","manufacturer","designer","description","urlVendor","urlDesigner","licence","licenceURL","---","typoFamilyName","typoSubfamilyName","compatibleFull","sampleText","postScriptCID","wwsFamilyName","wwsSubfamilyName","lightPalette","darkPalette"],p=s+=2,m=0;m<c;m++){var v=a.readUshort(i,s);s+=2;var _=a.readUshort(i,s);s+=2;var y=a.readUshort(i,s);s+=2;var g=a.readUshort(i,s);s+=2;var x=a.readUshort(i,s);s+=2;var w=a.readUshort(i,s);s+=2;var E,b=h[g],M=p+12*c+w;if(v==0)E=a.readUnicode(i,M,x/2);else if(v==3&&_==0)E=a.readUnicode(i,M,x/2);else if(_==0)E=a.readASCII(i,M,x);else if(_==1)E=a.readUnicode(i,M,x/2);else if(_==3)E=a.readUnicode(i,M,x/2);else{if(v!=1)throw"unknown encoding "+_+", platformID: "+v;E=a.readASCII(i,M,x),console.debug("reading unknown MAC encoding "+_+" as ASCII")}var A="p"+v+","+y.toString(16);l[A]==null&&(l[A]={}),l[A][b!==void 0?b:g]=E,l[A]._lang=y}for(var P in l)if(l[P].postScriptName!=null&&l[P]._lang==1033)return l[P];for(var P in l)if(l[P].postScriptName!=null&&l[P]._lang==0)return l[P];for(var P in l)if(l[P].postScriptName!=null&&l[P]._lang==3084)return l[P];for(var P in l)if(l[P].postScriptName!=null)return l[P];for(var P in l){u=P;break}return console.debug("returning name table with languageID "+l[u]._lang),l[u]},e["OS/2"]={},e["OS/2"].parse=function(i,s,o){var a=e._bin.readUshort(i,s);s+=2;var l={};if(a==0)e["OS/2"].version0(i,s,l);else if(a==1)e["OS/2"].version1(i,s,l);else if(a==2||a==3||a==4)e["OS/2"].version2(i,s,l);else{if(a!=5)throw"unknown OS/2 table version: "+a;e["OS/2"].version5(i,s,l)}return l},e["OS/2"].version0=function(i,s,o){var a=e._bin;return o.xAvgCharWidth=a.readShort(i,s),s+=2,o.usWeightClass=a.readUshort(i,s),s+=2,o.usWidthClass=a.readUshort(i,s),s+=2,o.fsType=a.readUshort(i,s),s+=2,o.ySubscriptXSize=a.readShort(i,s),s+=2,o.ySubscriptYSize=a.readShort(i,s),s+=2,o.ySubscriptXOffset=a.readShort(i,s),s+=2,o.ySubscriptYOffset=a.readShort(i,s),s+=2,o.ySuperscriptXSize=a.readShort(i,s),s+=2,o.ySuperscriptYSize=a.readShort(i,s),s+=2,o.ySuperscriptXOffset=a.readShort(i,s),s+=2,o.ySuperscriptYOffset=a.readShort(i,s),s+=2,o.yStrikeoutSize=a.readShort(i,s),s+=2,o.yStrikeoutPosition=a.readShort(i,s),s+=2,o.sFamilyClass=a.readShort(i,s),s+=2,o.panose=a.readBytes(i,s,10),s+=10,o.ulUnicodeRange1=a.readUint(i,s),s+=4,o.ulUnicodeRange2=a.readUint(i,s),s+=4,o.ulUnicodeRange3=a.readUint(i,s),s+=4,o.ulUnicodeRange4=a.readUint(i,s),s+=4,o.achVendID=[a.readInt8(i,s),a.readInt8(i,s+1),a.readInt8(i,s+2),a.readInt8(i,s+3)],s+=4,o.fsSelection=a.readUshort(i,s),s+=2,o.usFirstCharIndex=a.readUshort(i,s),s+=2,o.usLastCharIndex=a.readUshort(i,s),s+=2,o.sTypoAscender=a.readShort(i,s),s+=2,o.sTypoDescender=a.readShort(i,s),s+=2,o.sTypoLineGap=a.readShort(i,s),s+=2,o.usWinAscent=a.readUshort(i,s),s+=2,o.usWinDescent=a.readUshort(i,s),s+=2},e["OS/2"].version1=function(i,s,o){var a=e._bin;return s=e["OS/2"].version0(i,s,o),o.ulCodePageRange1=a.readUint(i,s),s+=4,o.ulCodePageRange2=a.readUint(i,s),s+=4},e["OS/2"].version2=function(i,s,o){var a=e._bin;return s=e["OS/2"].version1(i,s,o),o.sxHeight=a.readShort(i,s),s+=2,o.sCapHeight=a.readShort(i,s),s+=2,o.usDefault=a.readUshort(i,s),s+=2,o.usBreak=a.readUshort(i,s),s+=2,o.usMaxContext=a.readUshort(i,s),s+=2},e["OS/2"].version5=function(i,s,o){var a=e._bin;return s=e["OS/2"].version2(i,s,o),o.usLowerOpticalPointSize=a.readUshort(i,s),s+=2,o.usUpperOpticalPointSize=a.readUshort(i,s),s+=2},e.post={},e.post.parse=function(i,s,o){var a=e._bin,l={};return l.version=a.readFixed(i,s),s+=4,l.italicAngle=a.readFixed(i,s),s+=4,l.underlinePosition=a.readShort(i,s),s+=2,l.underlineThickness=a.readShort(i,s),s+=2,l},e==null&&(e={}),e.U==null&&(e.U={}),e.U.codeToGlyph=function(i,s){var o=i.cmap,a=-1;if(o.p0e4!=null?a=o.p0e4:o.p3e1!=null?a=o.p3e1:o.p1e0!=null?a=o.p1e0:o.p0e3!=null&&(a=o.p0e3),a==-1)throw"no familiar platform and encoding!";var l=o.tables[a];if(l.format==0)return s>=l.map.length?0:l.map[s];if(l.format==4){for(var c=-1,u=0;u<l.endCount.length;u++)if(s<=l.endCount[u]){c=u;break}return c==-1||l.startCount[c]>s?0:65535&(l.idRangeOffset[c]!=0?l.glyphIdArray[s-l.startCount[c]+(l.idRangeOffset[c]>>1)-(l.idRangeOffset.length-c)]:s+l.idDelta[c])}if(l.format==12){if(s>l.groups[l.groups.length-1][1])return 0;for(u=0;u<l.groups.length;u++){var h=l.groups[u];if(h[0]<=s&&s<=h[1])return h[2]+(s-h[0])}return 0}throw"unknown cmap table format "+l.format},e.U.glyphToPath=function(i,s){var o={cmds:[],crds:[]};if(i.SVG&&i.SVG.entries[s]){var a=i.SVG.entries[s];return a==null?o:(typeof a=="string"&&(a=e.SVG.toPath(a),i.SVG.entries[s]=a),a)}if(i.CFF){var l={x:0,y:0,stack:[],nStems:0,haveWidth:!1,width:i.CFF.Private?i.CFF.Private.defaultWidthX:0,open:!1},c=i.CFF,u=i.CFF.Private;if(c.ROS){for(var h=0;c.FDSelect[h+2]<=s;)h+=2;u=c.FDArray[c.FDSelect[h+1]].Private}e.U._drawCFF(i.CFF.CharStrings[s],l,c,u,o)}else i.glyf&&e.U._drawGlyf(s,i,o);return o},e.U._drawGlyf=function(i,s,o){var a=s.glyf[i];a==null&&(a=s.glyf[i]=e.glyf._parseGlyf(s,i)),a!=null&&(a.noc>-1?e.U._simpleGlyph(a,o):e.U._compoGlyph(a,s,o))},e.U._simpleGlyph=function(i,s){for(var o=0;o<i.noc;o++){for(var a=o==0?0:i.endPts[o-1]+1,l=i.endPts[o],c=a;c<=l;c++){var u=c==a?l:c-1,h=c==l?a:c+1,p=1&i.flags[c],m=1&i.flags[u],v=1&i.flags[h],_=i.xs[c],y=i.ys[c];if(c==a)if(p){if(!m){e.U.P.moveTo(s,_,y);continue}e.U.P.moveTo(s,i.xs[u],i.ys[u])}else m?e.U.P.moveTo(s,i.xs[u],i.ys[u]):e.U.P.moveTo(s,(i.xs[u]+_)/2,(i.ys[u]+y)/2);p?m&&e.U.P.lineTo(s,_,y):v?e.U.P.qcurveTo(s,_,y,i.xs[h],i.ys[h]):e.U.P.qcurveTo(s,_,y,(_+i.xs[h])/2,(y+i.ys[h])/2)}e.U.P.closePath(s)}},e.U._compoGlyph=function(i,s,o){for(var a=0;a<i.parts.length;a++){var l={cmds:[],crds:[]},c=i.parts[a];e.U._drawGlyf(c.glyphIndex,s,l);for(var u=c.m,h=0;h<l.crds.length;h+=2){var p=l.crds[h],m=l.crds[h+1];o.crds.push(p*u.a+m*u.b+u.tx),o.crds.push(p*u.c+m*u.d+u.ty)}for(h=0;h<l.cmds.length;h++)o.cmds.push(l.cmds[h])}},e.U._getGlyphClass=function(i,s){var o=e._lctf.getInterval(s,i);return o==-1?0:s[o+2]},e.U.getPairAdjustment=function(i,s,o){var a=!1;if(i.GPOS)for(var l=i.GPOS,c=l.lookupList,u=l.featureList,h=[],p=0;p<u.length;p++){var m=u[p];if(m.tag=="kern"){a=!0;for(var v=0;v<m.tab.length;v++)if(!h[m.tab[v]]){h[m.tab[v]]=!0;for(var _=c[m.tab[v]],y=0;y<_.tabs.length;y++)if(_.tabs[y]!=null){var g,x=_.tabs[y];if((!x.coverage||(g=e._lctf.coverageIndex(x.coverage,s))!=-1)&&_.ltype!=1){if(_.ltype==2){var w=null;if(x.fmt==1){var E=x.pairsets[g];for(p=0;p<E.length;p++)E[p].gid2==o&&(w=E[p])}else if(x.fmt==2){var b=e.U._getGlyphClass(s,x.classDef1),M=e.U._getGlyphClass(o,x.classDef2);w=x.matrix[b][M]}if(w){var A=0;return w.val1&&w.val1[2]&&(A+=w.val1[2]),w.val2&&w.val2[0]&&(A+=w.val2[0]),A}}}}}}}if(i.kern&&!a){var P=i.kern.glyph1.indexOf(s);if(P!=-1){var C=i.kern.rval[P].glyph2.indexOf(o);if(C!=-1)return i.kern.rval[P].vals[C]}}return 0},e.U._applySubs=function(i,s,o,a){for(var l=i.length-s-1,c=0;c<o.tabs.length;c++)if(o.tabs[c]!=null){var u,h=o.tabs[c];if(!h.coverage||(u=e._lctf.coverageIndex(h.coverage,i[s]))!=-1){if(o.ltype==1)i[s],h.fmt==1?i[s]=i[s]+h.delta:i[s]=h.newg[u];else if(o.ltype==4)for(var p=h.vals[u],m=0;m<p.length;m++){var v=p[m],_=v.chain.length;if(!(_>l)){for(var y=!0,g=0,x=0;x<_;x++){for(;i[s+g+(1+x)]==-1;)g++;v.chain[x]!=i[s+g+(1+x)]&&(y=!1)}if(y){for(i[s]=v.nglyph,x=0;x<_+g;x++)i[s+x+1]=-1;break}}}else if(o.ltype==5&&h.fmt==2)for(var w=e._lctf.getInterval(h.cDef,i[s]),E=h.cDef[w+2],b=h.scset[E],M=0;M<b.length;M++){var A=b[M],P=A.input;if(!(P.length>l)){for(y=!0,x=0;x<P.length;x++){var C=e._lctf.getInterval(h.cDef,i[s+1+x]);if(w==-1&&h.cDef[C+2]!=P[x]){y=!1;break}}if(y){var L=A.substLookupRecords;for(m=0;m<L.length;m+=2)L[m],L[m+1]}}}else if(o.ltype==6&&h.fmt==3){if(!e.U._glsCovered(i,h.backCvg,s-h.backCvg.length)||!e.U._glsCovered(i,h.inptCvg,s)||!e.U._glsCovered(i,h.ahedCvg,s+h.inptCvg.length))continue;var F=h.lookupRec;for(M=0;M<F.length;M+=2){w=F[M];var N=a[F[M+1]];e.U._applySubs(i,s+w,N,a)}}}}},e.U._glsCovered=function(i,s,o){for(var a=0;a<s.length;a++)if(e._lctf.coverageIndex(s[a],i[o+a])==-1)return!1;return!0},e.U.glyphsToPath=function(i,s,o){for(var a={cmds:[],crds:[]},l=0,c=0;c<s.length;c++){var u=s[c];if(u!=-1){for(var h=c<s.length-1&&s[c+1]!=-1?s[c+1]:0,p=e.U.glyphToPath(i,u),m=0;m<p.crds.length;m+=2)a.crds.push(p.crds[m]+l),a.crds.push(p.crds[m+1]);for(o&&a.cmds.push(o),m=0;m<p.cmds.length;m++)a.cmds.push(p.cmds[m]);o&&a.cmds.push("X"),l+=i.hmtx.aWidth[u],c<s.length-1&&(l+=e.U.getPairAdjustment(i,u,h))}}return a},e.U.P={},e.U.P.moveTo=function(i,s,o){i.cmds.push("M"),i.crds.push(s,o)},e.U.P.lineTo=function(i,s,o){i.cmds.push("L"),i.crds.push(s,o)},e.U.P.curveTo=function(i,s,o,a,l,c,u){i.cmds.push("C"),i.crds.push(s,o,a,l,c,u)},e.U.P.qcurveTo=function(i,s,o,a,l){i.cmds.push("Q"),i.crds.push(s,o,a,l)},e.U.P.closePath=function(i){i.cmds.push("Z")},e.U._drawCFF=function(i,s,o,a,l){for(var c=s.stack,u=s.nStems,h=s.haveWidth,p=s.width,m=s.open,v=0,_=s.x,y=s.y,g=0,x=0,w=0,E=0,b=0,M=0,A=0,P=0,C=0,L=0,F={val:0,size:0};v<i.length;){e.CFF.getCharString(i,v,F);var N=F.val;if(v+=F.size,N=="o1"||N=="o18")c.length%2!=0&&!h&&(p=c.shift()+a.nominalWidthX),u+=c.length>>1,c.length=0,h=!0;else if(N=="o3"||N=="o23")c.length%2!=0&&!h&&(p=c.shift()+a.nominalWidthX),u+=c.length>>1,c.length=0,h=!0;else if(N=="o4")c.length>1&&!h&&(p=c.shift()+a.nominalWidthX,h=!0),m&&e.U.P.closePath(l),y+=c.pop(),e.U.P.moveTo(l,_,y),m=!0;else if(N=="o5")for(;c.length>0;)_+=c.shift(),y+=c.shift(),e.U.P.lineTo(l,_,y);else if(N=="o6"||N=="o7")for(var I=c.length,X=N=="o6",q=0;q<I;q++){var W=c.shift();X?_+=W:y+=W,X=!X,e.U.P.lineTo(l,_,y)}else if(N=="o8"||N=="o24"){I=c.length;for(var O=0;O+6<=I;)g=_+c.shift(),x=y+c.shift(),w=g+c.shift(),E=x+c.shift(),_=w+c.shift(),y=E+c.shift(),e.U.P.curveTo(l,g,x,w,E,_,y),O+=6;N=="o24"&&(_+=c.shift(),y+=c.shift(),e.U.P.lineTo(l,_,y))}else{if(N=="o11")break;if(N=="o1234"||N=="o1235"||N=="o1236"||N=="o1237")N=="o1234"&&(x=y,w=(g=_+c.shift())+c.shift(),L=E=x+c.shift(),M=E,P=y,_=(A=(b=(C=w+c.shift())+c.shift())+c.shift())+c.shift(),e.U.P.curveTo(l,g,x,w,E,C,L),e.U.P.curveTo(l,b,M,A,P,_,y)),N=="o1235"&&(g=_+c.shift(),x=y+c.shift(),w=g+c.shift(),E=x+c.shift(),C=w+c.shift(),L=E+c.shift(),b=C+c.shift(),M=L+c.shift(),A=b+c.shift(),P=M+c.shift(),_=A+c.shift(),y=P+c.shift(),c.shift(),e.U.P.curveTo(l,g,x,w,E,C,L),e.U.P.curveTo(l,b,M,A,P,_,y)),N=="o1236"&&(g=_+c.shift(),x=y+c.shift(),w=g+c.shift(),L=E=x+c.shift(),M=E,A=(b=(C=w+c.shift())+c.shift())+c.shift(),P=M+c.shift(),_=A+c.shift(),e.U.P.curveTo(l,g,x,w,E,C,L),e.U.P.curveTo(l,b,M,A,P,_,y)),N=="o1237"&&(g=_+c.shift(),x=y+c.shift(),w=g+c.shift(),E=x+c.shift(),C=w+c.shift(),L=E+c.shift(),b=C+c.shift(),M=L+c.shift(),A=b+c.shift(),P=M+c.shift(),Math.abs(A-_)>Math.abs(P-y)?_=A+c.shift():y=P+c.shift(),e.U.P.curveTo(l,g,x,w,E,C,L),e.U.P.curveTo(l,b,M,A,P,_,y));else if(N=="o14"){if(c.length>0&&!h&&(p=c.shift()+o.nominalWidthX,h=!0),c.length==4){var k=c.shift(),G=c.shift(),B=c.shift(),D=c.shift(),V=e.CFF.glyphBySE(o,B),Z=e.CFF.glyphBySE(o,D);e.U._drawCFF(o.CharStrings[V],s,o,a,l),s.x=k,s.y=G,e.U._drawCFF(o.CharStrings[Z],s,o,a,l)}m&&(e.U.P.closePath(l),m=!1)}else if(N=="o19"||N=="o20")c.length%2!=0&&!h&&(p=c.shift()+a.nominalWidthX),u+=c.length>>1,c.length=0,h=!0,v+=u+7>>3;else if(N=="o21")c.length>2&&!h&&(p=c.shift()+a.nominalWidthX,h=!0),y+=c.pop(),_+=c.pop(),m&&e.U.P.closePath(l),e.U.P.moveTo(l,_,y),m=!0;else if(N=="o22")c.length>1&&!h&&(p=c.shift()+a.nominalWidthX,h=!0),_+=c.pop(),m&&e.U.P.closePath(l),e.U.P.moveTo(l,_,y),m=!0;else if(N=="o25"){for(;c.length>6;)_+=c.shift(),y+=c.shift(),e.U.P.lineTo(l,_,y);g=_+c.shift(),x=y+c.shift(),w=g+c.shift(),E=x+c.shift(),_=w+c.shift(),y=E+c.shift(),e.U.P.curveTo(l,g,x,w,E,_,y)}else if(N=="o26")for(c.length%2&&(_+=c.shift());c.length>0;)g=_,x=y+c.shift(),_=w=g+c.shift(),y=(E=x+c.shift())+c.shift(),e.U.P.curveTo(l,g,x,w,E,_,y);else if(N=="o27")for(c.length%2&&(y+=c.shift());c.length>0;)x=y,w=(g=_+c.shift())+c.shift(),E=x+c.shift(),_=w+c.shift(),y=E,e.U.P.curveTo(l,g,x,w,E,_,y);else if(N=="o10"||N=="o29"){var ee=N=="o10"?a:o;if(c.length==0)console.debug("error: empty stack");else{var ie=c.pop(),ue=ee.Subrs[ie+ee.Bias];s.x=_,s.y=y,s.nStems=u,s.haveWidth=h,s.width=p,s.open=m,e.U._drawCFF(ue,s,o,a,l),_=s.x,y=s.y,u=s.nStems,h=s.haveWidth,p=s.width,m=s.open}}else if(N=="o30"||N=="o31"){var ce=c.length,le=(O=0,N=="o31");for(O+=ce-(I=-3&ce);O<I;)le?(x=y,w=(g=_+c.shift())+c.shift(),y=(E=x+c.shift())+c.shift(),I-O==5?(_=w+c.shift(),O++):_=w,le=!1):(g=_,x=y+c.shift(),w=g+c.shift(),E=x+c.shift(),_=w+c.shift(),I-O==5?(y=E+c.shift(),O++):y=E,le=!0),e.U.P.curveTo(l,g,x,w,E,_,y),O+=4}else{if((N+"").charAt(0)=="o")throw console.debug("Unknown operation: "+N,i),N;c.push(N)}}}s.x=_,s.y=y,s.nStems=u,s.haveWidth=h,s.width=p,s.open=m};var t=e,n={Typr:t};return r.Typr=t,r.default=n,Object.defineProperty(r,"__esModule",{value:!0}),r})({}).Typr}/*!
|
|
Custom bundle of woff2otf (https://github.com/arty-name/woff2otf) with fflate
|
|
(https://github.com/101arrowz/fflate) for use in Troika text rendering.
|
|
Original licenses apply:
|
|
- fflate: https://github.com/101arrowz/fflate/blob/master/LICENSE (MIT)
|
|
- woff2otf.js: https://github.com/arty-name/woff2otf/blob/master/woff2otf.js (Apache2)
|
|
*/function VG(){return(function(r){var e=Uint8Array,t=Uint16Array,n=Uint32Array,i=new e([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),s=new e([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),o=new e([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),a=function(N,I){for(var X=new t(31),q=0;q<31;++q)X[q]=I+=1<<N[q-1];var W=new n(X[30]);for(q=1;q<30;++q)for(var O=X[q];O<X[q+1];++O)W[O]=O-X[q]<<5|q;return[X,W]},l=a(i,2),c=l[0],u=l[1];c[28]=258,u[258]=28;for(var h=a(s,0)[0],p=new t(32768),m=0;m<32768;++m){var v=(43690&m)>>>1|(21845&m)<<1;v=(61680&(v=(52428&v)>>>2|(13107&v)<<2))>>>4|(3855&v)<<4,p[m]=((65280&v)>>>8|(255&v)<<8)>>>1}var _=function(N,I,X){for(var q=N.length,W=0,O=new t(I);W<q;++W)++O[N[W]-1];var k,G=new t(I);for(W=0;W<I;++W)G[W]=G[W-1]+O[W-1]<<1;{k=new t(1<<I);var B=15-I;for(W=0;W<q;++W)if(N[W])for(var D=W<<4|N[W],V=I-N[W],Z=G[N[W]-1]++<<V,ee=Z|(1<<V)-1;Z<=ee;++Z)k[p[Z]>>>B]=D}return k},y=new e(288);for(m=0;m<144;++m)y[m]=8;for(m=144;m<256;++m)y[m]=9;for(m=256;m<280;++m)y[m]=7;for(m=280;m<288;++m)y[m]=8;var g=new e(32);for(m=0;m<32;++m)g[m]=5;var x=_(y,9),w=_(g,5),E=function(N){for(var I=N[0],X=1;X<N.length;++X)N[X]>I&&(I=N[X]);return I},b=function(N,I,X){var q=I/8|0;return(N[q]|N[q+1]<<8)>>(7&I)&X},M=function(N,I){var X=I/8|0;return(N[X]|N[X+1]<<8|N[X+2]<<16)>>(7&I)},A=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],P=function(N,I,X){var q=new Error(I||A[N]);if(q.code=N,Error.captureStackTrace&&Error.captureStackTrace(q,P),!X)throw q;return q},C=function(N,I,X){var q=N.length;if(!q||X&&!X.l&&q<5)return I||new e(0);var W=!I||X,O=!X||X.i;X||(X={}),I||(I=new e(3*q));var k,G=function(Oe){var We=I.length;if(Oe>We){var nt=new e(Math.max(2*We,Oe));nt.set(I),I=nt}},B=X.f||0,D=X.p||0,V=X.b||0,Z=X.l,ee=X.d,ie=X.m,ue=X.n,ce=8*q;do{if(!Z){X.f=B=b(N,D,1);var le=b(N,D+1,3);if(D+=3,!le){var Ae=N[(Le=((k=D)/8|0)+(7&k&&1)+4)-4]|N[Le-3]<<8,Ee=Le+Ae;if(Ee>q){O&&P(0);break}W&&G(V+Ae),I.set(N.subarray(Le,Ee),V),X.b=V+=Ae,X.p=D=8*Ee;continue}if(le==1)Z=x,ee=w,ie=9,ue=5;else if(le==2){var ae=b(N,D,31)+257,z=b(N,D+10,15)+4,oe=ae+b(N,D+5,31)+1;D+=14;for(var te=new e(oe),se=new e(19),$=0;$<z;++$)se[o[$]]=b(N,D+3*$,7);D+=3*z;var Ie=E(se),de=(1<<Ie)-1,Se=_(se,Ie);for($=0;$<oe;){var Le,ge=Se[b(N,D,de)];if(D+=15&ge,(Le=ge>>>4)<16)te[$++]=Le;else{var He=0,j=0;for(Le==16?(j=3+b(N,D,3),D+=2,He=te[$-1]):Le==17?(j=3+b(N,D,7),D+=3):Le==18&&(j=11+b(N,D,127),D+=7);j--;)te[$++]=He}}var H=te.subarray(0,ae),ne=te.subarray(ae);ie=E(H),ue=E(ne),Z=_(H,ie),ee=_(ne,ue)}else P(1);if(D>ce){O&&P(0);break}}W&&G(V+131072);for(var we=(1<<ie)-1,be=(1<<ue)-1,Me=D;;Me=D){var Fe=(He=Z[M(N,D)&we])>>>4;if((D+=15&He)>ce){O&&P(0);break}if(He||P(2),Fe<256)I[V++]=Fe;else{if(Fe==256){Me=D,Z=null;break}var Ue=Fe-254;if(Fe>264){var xe=i[$=Fe-257];Ue=b(N,D,(1<<xe)-1)+c[$],D+=xe}var Be=ee[M(N,D)&be],$e=Be>>>4;if(Be||P(3),D+=15&Be,ne=h[$e],$e>3&&(xe=s[$e],ne+=M(N,D)&(1<<xe)-1,D+=xe),D>ce){O&&P(0);break}W&&G(V+131072);for(var Ve=V+Ue;V<Ve;V+=4)I[V]=I[V-ne],I[V+1]=I[V+1-ne],I[V+2]=I[V+2-ne],I[V+3]=I[V+3-ne];V=Ve}}X.l=Z,X.p=Me,X.b=V,Z&&(B=1,X.m=ie,X.d=ee,X.n=ue)}while(!B);return V==I.length?I:(function(Oe,We,nt){(nt==null||nt>Oe.length)&&(nt=Oe.length);var pt=new(Oe instanceof t?t:Oe instanceof n?n:e)(nt-We);return pt.set(Oe.subarray(We,nt)),pt})(I,0,V)},L=new e(0),F=typeof TextDecoder<"u"&&new TextDecoder;try{F.decode(L,{stream:!0})}catch{}return r.convert_streams=function(N){var I=new DataView(N),X=0;function q(){var ae=I.getUint16(X);return X+=2,ae}function W(){var ae=I.getUint32(X);return X+=4,ae}function O(ae){Ae.setUint16(Ee,ae),Ee+=2}function k(ae){Ae.setUint32(Ee,ae),Ee+=4}for(var G={signature:W(),flavor:W(),length:W(),numTables:q(),reserved:q(),totalSfntSize:W(),majorVersion:q(),minorVersion:q(),metaOffset:W(),metaLength:W(),metaOrigLength:W(),privOffset:W(),privLength:W()},B=0;Math.pow(2,B)<=G.numTables;)B++;B--;for(var D=16*Math.pow(2,B),V=16*G.numTables-D,Z=12,ee=[],ie=0;ie<G.numTables;ie++)ee.push({tag:W(),offset:W(),compLength:W(),origLength:W(),origChecksum:W()}),Z+=16;var ue,ce=new Uint8Array(12+16*ee.length+ee.reduce((function(ae,z){return ae+z.origLength+4}),0)),le=ce.buffer,Ae=new DataView(le),Ee=0;return k(G.flavor),O(G.numTables),O(D),O(B),O(V),ee.forEach((function(ae){k(ae.tag),k(ae.origChecksum),k(Z),k(ae.origLength),ae.outOffset=Z,(Z+=ae.origLength)%4!=0&&(Z+=4-Z%4)})),ee.forEach((function(ae){var z,oe=N.slice(ae.offset,ae.offset+ae.compLength);if(ae.compLength!=ae.origLength){var te=new Uint8Array(ae.origLength);z=new Uint8Array(oe,2),C(z,te)}else te=new Uint8Array(oe);ce.set(te,ae.outOffset);var se=0;(Z=ae.outOffset+ae.origLength)%4!=0&&(se=4-Z%4),ce.set(new Uint8Array(se).buffer,ae.outOffset+ae.origLength),ue=Z+se})),le.slice(0,ue)},Object.defineProperty(r,"__esModule",{value:!0}),r})({}).convert_streams}function WG(r,e){const t={M:2,L:2,Q:4,C:6,Z:0},n={C:"18g,ca,368,1kz",D:"17k,6,2,2+4,5+c,2+6,2+1,10+1,9+f,j+11,2+1,a,2,2+1,15+2,3,j+2,6+3,2+8,2,2,2+1,w+a,4+e,3+3,2,3+2,3+5,23+w,2f+4,3,2+9,2,b,2+3,3,1k+9,6+1,3+1,2+2,2+d,30g,p+y,1,1+1g,f+x,2,sd2+1d,jf3+4,f+3,2+4,2+2,b+3,42,2,4+2,2+1,2,3,t+1,9f+w,2,el+2,2+g,d+2,2l,2+1,5,3+1,2+1,2,3,6,16wm+1v",R:"17m+3,2,2,6+3,m,15+2,2+2,h+h,13,3+8,2,2,3+1,2,p+1,x,5+4,5,a,2,2,3,u,c+2,g+1,5,2+1,4+1,5j,6+1,2,b,2+2,f,2+1,1s+2,2,3+1,7,1ez0,2,2+1,4+4,b,4,3,b,42,2+2,4,3,2+1,2,o+3,ae,ep,x,2o+2,3+1,3,5+1,6",L:"x9u,jff,a,fd,jv",T:"4t,gj+33,7o+4,1+1,7c+18,2,2+1,2+1,2,21+a,2,1b+k,h,2u+6,3+5,3+1,2+3,y,2,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,3,7,6+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+d,1,1+1,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,ek,3+1,r+4,1e+4,6+5,2p+c,1+3,1,1+2,1+b,2db+2,3y,2p+v,ff+3,30+1,n9x,1+2,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,5s,6y+2,ea,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+9,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2,2b+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,470+8,at4+4,1o+6,t5,1s+3,2a,f5l+1,2+3,43o+2,a+7,1+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,1,gzau,v+2n,3l+6n"},i=1,s=2,o=4,a=8,l=16,c=32;let u;function h(b){if(!u){const M={R:s,L:i,D:o,C:l,U:c,T:a};u=new Map;for(let A in n){let P=0;n[A].split(",").forEach(C=>{let[L,F]=C.split("+");L=parseInt(L,36),F=F?parseInt(F,36):0,u.set(P+=L,M[A]);for(let N=F;N--;)u.set(++P,M[A])})}}return u.get(b)||c}const p=1,m=2,v=3,_=4,y=[null,"isol","init","fina","medi"];function g(b){const M=new Uint8Array(b.length);let A=c,P=p,C=-1;for(let L=0;L<b.length;L++){const F=b.codePointAt(L);let N=h(F)|0,I=p;N&a||(A&(i|o|l)?N&(s|o|l)?(I=v,(P===p||P===v)&&M[C]++):N&(i|c)&&(P===m||P===_)&&M[C]--:A&(s|c)&&(P===m||P===_)&&M[C]--,P=M[L]=I,A=N,C=L,F>65535&&L++)}return M}function x(b,M){const A=[];for(let C=0;C<M.length;C++){const L=M.codePointAt(C);L>65535&&C++,A.push(r.U.codeToGlyph(b,L))}const P=b.GSUB;if(P){const{lookupList:C,featureList:L}=P;let F;const N=/^(rlig|liga|mset|isol|init|fina|medi|half|pres|blws)$/,I=[];L.forEach(X=>{if(N.test(X.tag))for(let q=0;q<X.tab.length;q++){if(I[X.tab[q]])continue;I[X.tab[q]]=!0;const W=C[X.tab[q]],O=/^(isol|init|fina|medi)$/.test(X.tag);O&&!F&&(F=g(M));for(let k=0;k<A.length;k++)(!F||!O||y[F[k]]===X.tag)&&r.U._applySubs(A,k,W,C)}})}return A}function w(...b){for(let M=0;M<b.length;M++)if(typeof b[M]=="number")return b[M]}function E(b){const M=Object.create(null),A=b["OS/2"],P=b.hhea,C=b.head.unitsPerEm,L=w(A&&A.sTypoAscender,P&&P.ascender,C),F={unitsPerEm:C,ascender:L,descender:w(A&&A.sTypoDescender,P&&P.descender,0),capHeight:w(A&&A.sCapHeight,L),xHeight:w(A&&A.sxHeight,L),lineGap:w(A&&A.sTypoLineGap,P&&P.lineGap),forEachGlyph(N,I,X,q){let W=0;const O=1/F.unitsPerEm*I,k=x(b,N);let G=0,B=-1;return k.forEach((D,V)=>{if(D!==-1){let Z=M[D];if(!Z){const{cmds:ee,crds:ie}=r.U.glyphToPath(b,D);let ue="",ce=0;for(let z=0,oe=ee.length;z<oe;z++){const te=t[ee[z]];ue+=ee[z];for(let se=1;se<=te;se++)ue+=(se>1?",":"")+ie[ce++]}let le,Ae,Ee,ae;if(ie.length){le=Ae=1/0,Ee=ae=-1/0;for(let z=0,oe=ie.length;z<oe;z+=2){let te=ie[z],se=ie[z+1];te<le&&(le=te),se<Ae&&(Ae=se),te>Ee&&(Ee=te),se>ae&&(ae=se)}}else le=Ee=Ae=ae=0;Z=M[D]={index:D,advanceWidth:b.hmtx.aWidth[D],xMin:le,yMin:Ae,xMax:Ee,yMax:ae,path:ue,pathCommandCount:ee.length}}B!==-1&&(W+=r.U.getPairAdjustment(b,B,D)*O),q.call(null,Z,W,G),Z.advanceWidth&&(W+=Z.advanceWidth*O),X&&(W+=X*I),B=D}G+=N.codePointAt(G)>65535?2:1}),W}};return F}return function(M){const A=new Uint8Array(M,0,4),P=r._bin.readASCII(A,0,4);if(P==="wOFF")M=e(M);else if(P==="wOF2")throw new Error("woff2 fonts not supported");return E(r.parse(M)[0])}}const XG=yh({name:"Typr Font Parser",dependencies:[HG,VG,WG],init(r,e,t){const n=r(),i=e();return t(n,i)}}),kl={defaultFontURL:"https://fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4mxM.woff",sdfGlyphSize:64,sdfMargin:1/16,sdfExponent:9,textureWidth:2048},jG=new Ke;function Tl(){return(self.performance||Date).now()}const PE=Object.create(null);function QA(r,e){r=ZG({},r);const t=Tl();if(r.font=KG(r.font||kl.defaultFontURL),r.text=""+r.text,r.sdfGlyphSize=r.sdfGlyphSize||kl.sdfGlyphSize,r.colorRanges!=null){let h={};for(let p in r.colorRanges)if(r.colorRanges.hasOwnProperty(p)){let m=r.colorRanges[p];typeof m!="number"&&(m=jG.set(m).getHex()),h[p]=m}r.colorRanges=h}Object.freeze(r);const{textureWidth:n,sdfExponent:i}=kl,{sdfGlyphSize:s}=r,o=n/s*4;let a=PE[s];if(!a){const h=document.createElement("canvas");h.width=n,h.height=s*256/o,a=PE[s]={glyphCount:0,sdfGlyphSize:s,sdfCanvas:h,sdfTexture:new Sn(h,void 0,void 0,void 0,fn,fn),contextLost:!1,glyphsByFont:new Map},a.sdfTexture.generateMipmaps=!1,YG(a)}const{sdfTexture:l,sdfCanvas:c}=a;let u=a.glyphsByFont.get(r.font);u||a.glyphsByFont.set(r.font,u=new Map),JG(r).then(h=>{const{glyphIds:p,glyphPositions:m,fontSize:v,unitsPerEm:_,timings:y}=h,g=[],x=new Float32Array(p.length*4),w=v/_;let E=0,b=0;const M=Tl();p.forEach((F,N)=>{let I=u.get(F);if(!I){const{path:O,pathBounds:k}=h.glyphData[F],G=Math.max(k[2]-k[0],k[3]-k[1])/s*(kl.sdfMargin*s+.5),B=a.glyphCount++,D=[k[0]-G,k[1]-G,k[2]+G,k[3]+G];u.set(F,I={path:O,atlasIndex:B,sdfViewBox:D}),g.push(I)}const{sdfViewBox:X}=I,q=m[b++],W=m[b++];x[E++]=q+X[0]*w,x[E++]=W+X[1]*w,x[E++]=q+X[2]*w,x[E++]=W+X[3]*w,p[N]=I.atlasIndex}),y.quads=(y.quads||0)+(Tl()-M);const A=Tl();y.sdf={};const P=c.height,C=Math.ceil(a.glyphCount/o),L=Math.pow(2,Math.ceil(Math.log2(C*s)));L>P&&(console.info(`Increasing SDF texture size ${P}->${L}`),GG(c,n,L),l.dispose()),Promise.all(g.map(F=>e2(F,a,r.gpuAccelerateSDF).then(({timing:N})=>{y.sdf[F.atlasIndex]=N}))).then(()=>{g.length&&!a.contextLost&&(t2(a),l.needsUpdate=!0),y.sdfTotal=Tl()-A,y.total=Tl()-t,e(Object.freeze({parameters:r,sdfTexture:l,sdfGlyphSize:s,sdfExponent:i,glyphBounds:x,glyphAtlasIndices:p,glyphColors:h.glyphColors,caretPositions:h.caretPositions,caretHeight:h.caretHeight,chunkedBounds:h.chunkedBounds,ascender:h.ascender,descender:h.descender,lineHeight:h.lineHeight,capHeight:h.capHeight,xHeight:h.xHeight,topBaseline:h.topBaseline,blockBounds:h.blockBounds,visibleBounds:h.visibleBounds,timings:h.timings}))})}),Promise.resolve().then(()=>{a.contextLost||BG(c)})}function e2({path:r,atlasIndex:e,sdfViewBox:t},{sdfGlyphSize:n,sdfCanvas:i,contextLost:s},o){if(s)return Promise.resolve({timing:-1});const{textureWidth:a,sdfExponent:l}=kl,c=Math.max(t[2]-t[0],t[3]-t[1]),u=Math.floor(e/4),h=u%(a/n)*n,p=Math.floor(u/(a/n))*n,m=e%4;return UG(n,n,r,t,c,l,i,h,p,m,o)}function YG(r){const e=r.sdfCanvas;e.addEventListener("webglcontextlost",t=>{console.log("Context Lost",t),t.preventDefault(),r.contextLost=!0}),e.addEventListener("webglcontextrestored",t=>{console.log("Context Restored",t),r.contextLost=!1;const n=[];r.glyphsByFont.forEach(i=>{i.forEach(s=>{n.push(e2(s,r,!0))})}),Promise.all(n).then(()=>{t2(r),r.sdfTexture.needsUpdate=!0})})}function qG({font:r,characters:e,sdfGlyphSize:t},n){let i=Array.isArray(e)?e.join(`
|
|
`):""+e;QA({font:r,sdfGlyphSize:t,text:i},n)}function ZG(r,e){for(let t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}let ld;function KG(r){return ld||(ld=typeof document>"u"?{}:document.createElement("a")),ld.href=r,ld.href}function t2(r){if(typeof createImageBitmap!="function"){console.info("Safari<15: applying SDF canvas workaround");const{sdfCanvas:e,sdfTexture:t}=r,{width:n,height:i}=e,s=r.sdfCanvas.getContext("webgl");let o=t.image.data;(!o||o.length!==n*i*4)&&(o=new Uint8Array(n*i*4),t.image={width:n,height:i,data:o},t.flipY=!1,t.isDataTexture=!0),s.readPixels(0,0,n,i,s.RGBA,s.UNSIGNED_BYTE,o)}}const $G=yh({name:"Typesetter",dependencies:[kl,XG,DG,MG],init(r,e,t,n){const{defaultFontURL:i}=r;return t(e,n(),{defaultFontURL:i})}}),JG=yh({name:"Typesetter",dependencies:[$G],init(r){return function(e){return new Promise(t=>{r.typeset(e,t)})}},getTransferables(r){const e=[r.glyphPositions.buffer,r.glyphIds.buffer];return r.caretPositions&&e.push(r.caretPositions.buffer),r.glyphColors&&e.push(r.glyphColors.buffer),e}}),LE={};function QG(r){let e=LE[r];if(!e){const t=new To(1,1,r,r),n=t.clone(),i=t.attributes,s=n.attributes,o=new Tt,a=i.uv.count;for(let l=0;l<a;l++)s.position.array[l*3]*=-1,s.normal.array[l*3+2]*=-1;["position","normal","uv"].forEach(l=>{o.setAttribute(l,new st([...i[l].array,...s[l].array],i[l].itemSize))}),o.setIndex([...t.index.array,...n.index.array.map(l=>l+a)]),o.translate(.5,.5,0),e=LE[r]=o}return e}const e5="aTroikaGlyphBounds",IE="aTroikaGlyphIndex",t5="aTroikaGlyphColor";class n5 extends Cy{constructor(){super(),this.detail=1,this.curveRadius=0,this.groups=[{start:0,count:1/0,materialIndex:0},{start:0,count:1/0,materialIndex:1}],this.boundingSphere=new rr,this.boundingBox=new ir}computeBoundingSphere(){}computeBoundingBox(){}setSide(e){const t=this.getIndex().count;this.setDrawRange(e===yi?t/2:0,e===vn?t:t/2)}set detail(e){if(e!==this._detail){this._detail=e,(typeof e!="number"||e<1)&&(e=1);let t=QG(e);["position","normal","uv"].forEach(n=>{this.attributes[n]=t.attributes[n].clone()}),this.setIndex(t.getIndex().clone())}}get detail(){return this._detail}set curveRadius(e){e!==this._curveRadius&&(this._curveRadius=e,this._updateBounds())}get curveRadius(){return this._curveRadius}updateGlyphs(e,t,n,i,s){y0(this,e5,e,4),y0(this,IE,t,1),y0(this,t5,s,3),this._blockBounds=n,this._chunkedBounds=i,this.instanceCount=t.length,this._updateBounds()}_updateBounds(){const e=this._blockBounds;if(e){const{curveRadius:t,boundingBox:n}=this;if(t){const{PI:i,floor:s,min:o,max:a,sin:l,cos:c}=Math,u=i/2,h=i*2,p=Math.abs(t),m=e[0]/p,v=e[2]/p,_=s((m+u)/h)!==s((v+u)/h)?-p:o(l(m)*p,l(v)*p),y=s((m-u)/h)!==s((v-u)/h)?p:a(l(m)*p,l(v)*p),g=s((m+i)/h)!==s((v+i)/h)?p*2:a(p-c(m)*p,p-c(v)*p);n.min.set(_,e[1],t<0?-g:0),n.max.set(y,e[3],t<0?0:g)}else n.min.set(e[0],e[1],0),n.max.set(e[2],e[3],0);n.getBoundingSphere(this.boundingSphere)}}applyClipRect(e){let t=this.getAttribute(IE).count,n=this._chunkedBounds;if(n)for(let i=n.length;i--;){t=n[i].end;let s=n[i].rect;if(s[1]<e.w&&s[3]>e.y&&s[0]<e.z&&s[2]>e.x)break}this.instanceCount=t}}function y0(r,e,t,n){const i=r.getAttribute(e);t?i&&i.array.length===t.length?(i.array.set(t),i.needsUpdate=!0):(r.setAttribute(e,new Sa(t,n)),delete r._maxInstanceCount,r.dispose()):i&&r.deleteAttribute(e)}const i5=`
|
|
uniform vec2 uTroikaSDFTextureSize;
|
|
uniform float uTroikaSDFGlyphSize;
|
|
uniform vec4 uTroikaTotalBounds;
|
|
uniform vec4 uTroikaClipRect;
|
|
uniform mat3 uTroikaOrient;
|
|
uniform bool uTroikaUseGlyphColors;
|
|
uniform float uTroikaDistanceOffset;
|
|
uniform float uTroikaBlurRadius;
|
|
uniform vec2 uTroikaPositionOffset;
|
|
uniform float uTroikaCurveRadius;
|
|
attribute vec4 aTroikaGlyphBounds;
|
|
attribute float aTroikaGlyphIndex;
|
|
attribute vec3 aTroikaGlyphColor;
|
|
varying vec2 vTroikaGlyphUV;
|
|
varying vec4 vTroikaTextureUVBounds;
|
|
varying float vTroikaTextureChannel;
|
|
varying vec3 vTroikaGlyphColor;
|
|
varying vec2 vTroikaGlyphDimensions;
|
|
`,r5=`
|
|
vec4 bounds = aTroikaGlyphBounds;
|
|
bounds.xz += uTroikaPositionOffset.x;
|
|
bounds.yw -= uTroikaPositionOffset.y;
|
|
|
|
vec4 outlineBounds = vec4(
|
|
bounds.xy - uTroikaDistanceOffset - uTroikaBlurRadius,
|
|
bounds.zw + uTroikaDistanceOffset + uTroikaBlurRadius
|
|
);
|
|
vec4 clippedBounds = vec4(
|
|
clamp(outlineBounds.xy, uTroikaClipRect.xy, uTroikaClipRect.zw),
|
|
clamp(outlineBounds.zw, uTroikaClipRect.xy, uTroikaClipRect.zw)
|
|
);
|
|
|
|
vec2 clippedXY = (mix(clippedBounds.xy, clippedBounds.zw, position.xy) - bounds.xy) / (bounds.zw - bounds.xy);
|
|
|
|
position.xy = mix(bounds.xy, bounds.zw, clippedXY);
|
|
|
|
uv = (position.xy - uTroikaTotalBounds.xy) / (uTroikaTotalBounds.zw - uTroikaTotalBounds.xy);
|
|
|
|
float rad = uTroikaCurveRadius;
|
|
if (rad != 0.0) {
|
|
float angle = position.x / rad;
|
|
position.xz = vec2(sin(angle) * rad, rad - cos(angle) * rad);
|
|
normal.xz = vec2(sin(angle), cos(angle));
|
|
}
|
|
|
|
position = uTroikaOrient * position;
|
|
normal = uTroikaOrient * normal;
|
|
|
|
vTroikaGlyphUV = clippedXY.xy;
|
|
vTroikaGlyphDimensions = vec2(bounds[2] - bounds[0], bounds[3] - bounds[1]);
|
|
|
|
|
|
float txCols = uTroikaSDFTextureSize.x / uTroikaSDFGlyphSize;
|
|
vec2 txUvPerSquare = uTroikaSDFGlyphSize / uTroikaSDFTextureSize;
|
|
vec2 txStartUV = txUvPerSquare * vec2(
|
|
mod(floor(aTroikaGlyphIndex / 4.0), txCols),
|
|
floor(floor(aTroikaGlyphIndex / 4.0) / txCols)
|
|
);
|
|
vTroikaTextureUVBounds = vec4(txStartUV, vec2(txStartUV) + txUvPerSquare);
|
|
vTroikaTextureChannel = mod(aTroikaGlyphIndex, 4.0);
|
|
`,s5=`
|
|
uniform sampler2D uTroikaSDFTexture;
|
|
uniform vec2 uTroikaSDFTextureSize;
|
|
uniform float uTroikaSDFGlyphSize;
|
|
uniform float uTroikaSDFExponent;
|
|
uniform float uTroikaDistanceOffset;
|
|
uniform float uTroikaFillOpacity;
|
|
uniform float uTroikaOutlineOpacity;
|
|
uniform float uTroikaBlurRadius;
|
|
uniform vec3 uTroikaStrokeColor;
|
|
uniform float uTroikaStrokeWidth;
|
|
uniform float uTroikaStrokeOpacity;
|
|
uniform bool uTroikaSDFDebug;
|
|
varying vec2 vTroikaGlyphUV;
|
|
varying vec4 vTroikaTextureUVBounds;
|
|
varying float vTroikaTextureChannel;
|
|
varying vec2 vTroikaGlyphDimensions;
|
|
|
|
float troikaSdfValueToSignedDistance(float alpha) {
|
|
// Inverse of exponential encoding in webgl-sdf-generator
|
|
|
|
float maxDimension = max(vTroikaGlyphDimensions.x, vTroikaGlyphDimensions.y);
|
|
float absDist = (1.0 - pow(2.0 * (alpha > 0.5 ? 1.0 - alpha : alpha), 1.0 / uTroikaSDFExponent)) * maxDimension;
|
|
float signedDist = absDist * (alpha > 0.5 ? -1.0 : 1.0);
|
|
return signedDist;
|
|
}
|
|
|
|
float troikaGlyphUvToSdfValue(vec2 glyphUV) {
|
|
vec2 textureUV = mix(vTroikaTextureUVBounds.xy, vTroikaTextureUVBounds.zw, glyphUV);
|
|
vec4 rgba = texture2D(uTroikaSDFTexture, textureUV);
|
|
float ch = floor(vTroikaTextureChannel + 0.5); //NOTE: can't use round() in WebGL1
|
|
return ch == 0.0 ? rgba.r : ch == 1.0 ? rgba.g : ch == 2.0 ? rgba.b : rgba.a;
|
|
}
|
|
|
|
float troikaGlyphUvToDistance(vec2 uv) {
|
|
return troikaSdfValueToSignedDistance(troikaGlyphUvToSdfValue(uv));
|
|
}
|
|
|
|
float troikaGetAADist() {
|
|
|
|
#if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300
|
|
return length(fwidth(vTroikaGlyphUV * vTroikaGlyphDimensions)) * 0.5;
|
|
#else
|
|
return vTroikaGlyphDimensions.x / 64.0;
|
|
#endif
|
|
}
|
|
|
|
float troikaGetFragDistValue() {
|
|
vec2 clampedGlyphUV = clamp(vTroikaGlyphUV, 0.5 / uTroikaSDFGlyphSize, 1.0 - 0.5 / uTroikaSDFGlyphSize);
|
|
float distance = troikaGlyphUvToDistance(clampedGlyphUV);
|
|
|
|
// Extrapolate distance when outside bounds:
|
|
distance += clampedGlyphUV == vTroikaGlyphUV ? 0.0 :
|
|
length((vTroikaGlyphUV - clampedGlyphUV) * vTroikaGlyphDimensions);
|
|
|
|
|
|
|
|
return distance;
|
|
}
|
|
|
|
float troikaGetEdgeAlpha(float distance, float distanceOffset, float aaDist) {
|
|
#if defined(IS_DEPTH_MATERIAL) || defined(IS_DISTANCE_MATERIAL)
|
|
float alpha = step(-distanceOffset, -distance);
|
|
#else
|
|
|
|
float alpha = smoothstep(
|
|
distanceOffset + aaDist,
|
|
distanceOffset - aaDist,
|
|
distance
|
|
);
|
|
#endif
|
|
|
|
return alpha;
|
|
}
|
|
`,o5=`
|
|
float aaDist = troikaGetAADist();
|
|
float fragDistance = troikaGetFragDistValue();
|
|
float edgeAlpha = uTroikaSDFDebug ?
|
|
troikaGlyphUvToSdfValue(vTroikaGlyphUV) :
|
|
troikaGetEdgeAlpha(fragDistance, uTroikaDistanceOffset, max(aaDist, uTroikaBlurRadius));
|
|
|
|
#if !defined(IS_DEPTH_MATERIAL) && !defined(IS_DISTANCE_MATERIAL)
|
|
vec4 fillRGBA = gl_FragColor;
|
|
fillRGBA.a *= uTroikaFillOpacity;
|
|
vec4 strokeRGBA = uTroikaStrokeWidth == 0.0 ? fillRGBA : vec4(uTroikaStrokeColor, uTroikaStrokeOpacity);
|
|
if (fillRGBA.a == 0.0) fillRGBA.rgb = strokeRGBA.rgb;
|
|
gl_FragColor = mix(fillRGBA, strokeRGBA, smoothstep(
|
|
-uTroikaStrokeWidth - aaDist,
|
|
-uTroikaStrokeWidth + aaDist,
|
|
fragDistance
|
|
));
|
|
gl_FragColor.a *= edgeAlpha;
|
|
#endif
|
|
|
|
if (edgeAlpha == 0.0) {
|
|
discard;
|
|
}
|
|
`;function a5(r){const e=zv(r,{chained:!0,extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFTextureSize:{value:new De},uTroikaSDFGlyphSize:{value:0},uTroikaSDFExponent:{value:0},uTroikaTotalBounds:{value:new Xt(0,0,0,0)},uTroikaClipRect:{value:new Xt(0,0,0,0)},uTroikaDistanceOffset:{value:0},uTroikaOutlineOpacity:{value:0},uTroikaFillOpacity:{value:1},uTroikaPositionOffset:{value:new De},uTroikaCurveRadius:{value:0},uTroikaBlurRadius:{value:0},uTroikaStrokeWidth:{value:0},uTroikaStrokeColor:{value:new Ke},uTroikaStrokeOpacity:{value:1},uTroikaOrient:{value:new Ct},uTroikaUseGlyphColors:{value:!0},uTroikaSDFDebug:{value:!1}},vertexDefs:i5,vertexTransform:r5,fragmentDefs:s5,fragmentColorTransform:o5,customRewriter({vertexShader:t,fragmentShader:n}){let i=/\buniform\s+vec3\s+diffuse\b/;return i.test(n)&&(n=n.replace(i,"varying vec3 vTroikaGlyphColor").replace(/\bdiffuse\b/g,"vTroikaGlyphColor"),i.test(t)||(t=t.replace($A,`uniform vec3 diffuse;
|
|
$&
|
|
vTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse;
|
|
`))),{vertexShader:t,fragmentShader:n}}});return e.transparent=!0,Object.defineProperties(e,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),e}const p_=new Vs({color:16777215,side:vn,transparent:!0}),DE=8421504,UE=new yt,cd=new Y,_0=new Y,ru=[],l5=new Y,x0="+x+y";function OE(r){return Array.isArray(r)?r[0]:r}let n2=()=>{const r=new _n(new To(1,1),p_);return n2=()=>r,r},i2=()=>{const r=new _n(new To(1,1,32,1),p_);return i2=()=>r,r};const c5={type:"syncstart"},u5={type:"synccomplete"},r2=["font","fontSize","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],h5=r2.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");let s2=class extends _n{constructor(){const e=new n5;super(e,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.fontSize=.1,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=DE,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=x0,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(e){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(e):(this._isSyncing=!0,this.dispatchEvent(c5),QA({text:this.text,font:this.font,fontSize:this.fontSize||.1,letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF},t=>{this._isSyncing=!1,this._textRenderInfo=t,this.geometry.updateGlyphs(t.glyphBounds,t.glyphAtlasIndices,t.blockBounds,t.chunkedBounds,t.glyphColors);const n=this._queuedSyncs;n&&(this._queuedSyncs=null,this._needsSync=!0,this.sync(()=>{n.forEach(i=>i&&i())})),this.dispatchEvent(u5),e&&e()})))}onBeforeRender(e,t,n,i,s,o){this.sync(),s.isTroikaTextMaterial&&this._prepareForRender(s),s._hadOwnSide=s.hasOwnProperty("side"),this.geometry.setSide(s._actualSide=s.side),s.side=ls}onAfterRender(e,t,n,i,s,o){s._hadOwnSide?s.side=s._actualSide:delete s.side}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}get material(){let e=this._derivedMaterial;const t=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=p_.clone());if((!e||e.baseMaterial!==t)&&(e=this._derivedMaterial=a5(t),t.addEventListener("dispose",function n(){t.removeEventListener("dispose",n),e.dispose()})),this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY){let n=e._outlineMtl;return n||(n=e._outlineMtl=Object.create(e,{id:{value:e.id+.1}}),n.isTextOutlineMaterial=!0,n.depthWrite=!1,n.map=null,e.addEventListener("dispose",function i(){e.removeEventListener("dispose",i),n.dispose()})),[n,e]}else return e}set material(e){e&&e.isTroikaTextMaterial?(this._derivedMaterial=e,this._baseMaterial=e.baseMaterial):this._baseMaterial=e}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(e){this.geometry.detail=e}get curveRadius(){return this.geometry.curveRadius}set curveRadius(e){this.geometry.curveRadius=e}get customDepthMaterial(){return OE(this.material).getDepthMaterial()}get customDistanceMaterial(){return OE(this.material).getDistanceMaterial()}_prepareForRender(e){const t=e.isTextOutlineMaterial,n=e.uniforms,i=this.textRenderInfo;if(i){const{sdfTexture:a,blockBounds:l}=i;n.uTroikaSDFTexture.value=a,n.uTroikaSDFTextureSize.value.set(a.image.width,a.image.height),n.uTroikaSDFGlyphSize.value=i.sdfGlyphSize,n.uTroikaSDFExponent.value=i.sdfExponent,n.uTroikaTotalBounds.value.fromArray(l),n.uTroikaUseGlyphColors.value=!t&&!!i.glyphColors;let c=0,u=0,h=0,p,m,v,_=0,y=0;if(t){let{outlineWidth:x,outlineOffsetX:w,outlineOffsetY:E,outlineBlur:b,outlineOpacity:M}=this;c=this._parsePercent(x)||0,u=Math.max(0,this._parsePercent(b)||0),p=M,_=this._parsePercent(w)||0,y=this._parsePercent(E)||0}else h=Math.max(0,this._parsePercent(this.strokeWidth)||0),h&&(v=this.strokeColor,n.uTroikaStrokeColor.value.set(v??DE),m=this.strokeOpacity,m==null&&(m=1)),p=this.fillOpacity;n.uTroikaDistanceOffset.value=c,n.uTroikaPositionOffset.value.set(_,y),n.uTroikaBlurRadius.value=u,n.uTroikaStrokeWidth.value=h,n.uTroikaStrokeOpacity.value=m,n.uTroikaFillOpacity.value=p??1,n.uTroikaCurveRadius.value=this.curveRadius||0;let g=this.clipRect;if(g&&Array.isArray(g)&&g.length===4)n.uTroikaClipRect.value.fromArray(g);else{const x=(this.fontSize||.1)*100;n.uTroikaClipRect.value.set(l[0]-x,l[1]-x,l[2]+x,l[3]+x)}this.geometry.applyClipRect(n.uTroikaClipRect.value)}n.uTroikaSDFDebug.value=!!this.debugSDF,e.polygonOffset=!!this.depthOffset,e.polygonOffsetFactor=e.polygonOffsetUnits=this.depthOffset||0;const s=t?this.outlineColor||0:this.color;if(s==null)delete e.color;else{const a=e.hasOwnProperty("color")?e.color:e.color=new Ke;(s!==a._input||typeof s=="object")&&a.set(a._input=s)}let o=this.orientation||x0;if(o!==e._orientation){let a=n.uTroikaOrient.value;o=o.replace(/[^-+xyz]/g,"");let l=o!==x0&&o.match(/^([-+])([xyz])([-+])([xyz])$/);if(l){let[,c,u,h,p]=l;cd.set(0,0,0)[u]=c==="-"?1:-1,_0.set(0,0,0)[p]=h==="-"?-1:1,UE.lookAt(l5,cd.cross(_0),_0),a.setFromMatrix4(UE)}else a.identity();e._orientation=o}}_parsePercent(e){if(typeof e=="string"){let t=e.match(/^(-?[\d.]+)%$/),n=t?parseFloat(t[1]):NaN;e=(isNaN(n)?0:n/100)*this.fontSize}return e}localPositionToTextCoords(e,t=new De){t.copy(e);const n=this.curveRadius;return n&&(t.x=Math.atan2(e.x,Math.abs(n)-Math.abs(e.z))*Math.abs(n)),t}worldPositionToTextCoords(e,t=new De){return cd.copy(e),this.localPositionToTextCoords(this.worldToLocal(cd),t)}raycast(e,t){const{textRenderInfo:n,curveRadius:i}=this;if(n){const s=n.blockBounds,o=i?i2():n2(),a=o.geometry,{position:l,uv:c}=a.attributes;for(let u=0;u<c.count;u++){let h=s[0]+c.getX(u)*(s[2]-s[0]);const p=s[1]+c.getY(u)*(s[3]-s[1]);let m=0;i&&(m=i-Math.cos(h/i)*i,h=Math.sin(h/i)*i),l.setXYZ(u,h,p,m)}a.boundingSphere=this.geometry.boundingSphere,a.boundingBox=this.geometry.boundingBox,o.matrixWorld=this.matrixWorld,o.material.side=this.material.side,ru.length=0,o.raycast(e,ru);for(let u=0;u<ru.length;u++)ru[u].object=this,t.push(ru[u])}}copy(e){const t=this.geometry;return super.copy(e),this.geometry=t,h5.forEach(n=>{this[n]=e[n]}),this}clone(){return new this.constructor().copy(this)}};r2.forEach(r=>{const e="_private_"+r;Object.defineProperty(s2.prototype,r,{get(){return this[e]},set(t){t!==this[e]&&(this[e]=t,this._needsSync=!0)}})});const f5=K.forwardRef(({sdfGlyphSize:r=64,anchorX:e="center",anchorY:t="middle",font:n,fontSize:i=1,children:s,characters:o,onSync:a,...l},c)=>{const u=Bn(({invalidate:v})=>v),[h]=K.useState(()=>new s2),[p,m]=K.useMemo(()=>{const v=[];let _="";return K.Children.forEach(s,y=>{typeof y=="string"||typeof y=="number"?_+=y:v.push(y)}),[v,_]},[s]);return eO(()=>new Promise(v=>qG({font:n,characters:o},v)),["troika-text",n,o]),K.useLayoutEffect(()=>void h.sync(()=>{u(),a&&a(h)})),K.useEffect(()=>()=>h.dispose(),[h]),K.createElement("primitive",Ta({object:h,ref:c,font:n,text:m,anchorX:e,anchorY:t,fontSize:i,sdfGlyphSize:r},l),p)});/*!
|
|
* camera-controls
|
|
* https://github.com/yomotsu/camera-controls
|
|
* (c) 2017 @yomotsu
|
|
* Released under the MIT License.
|
|
*/const gn={LEFT:1,RIGHT:2,MIDDLE:4},_e=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,SCREEN_PAN:4,OFFSET:8,DOLLY:16,ZOOM:32,TOUCH_ROTATE:64,TOUCH_TRUCK:128,TOUCH_SCREEN_PAN:256,TOUCH_OFFSET:512,TOUCH_DOLLY:1024,TOUCH_ZOOM:2048,TOUCH_DOLLY_TRUCK:4096,TOUCH_DOLLY_SCREEN_PAN:8192,TOUCH_DOLLY_OFFSET:16384,TOUCH_DOLLY_ROTATE:32768,TOUCH_ZOOM_TRUCK:65536,TOUCH_ZOOM_OFFSET:131072,TOUCH_ZOOM_SCREEN_PAN:262144,TOUCH_ZOOM_ROTATE:524288}),Al={NONE:0,IN:1,OUT:-1};function ia(r){return r.isPerspectiveCamera}function ho(r){return r.isOrthographicCamera}const Cl=Math.PI*2,NE=Math.PI/2,o2=1e-5,su=Math.PI/180;function Ur(r,e,t){return Math.max(e,Math.min(t,r))}function an(r,e=o2){return Math.abs(r)<e}function Zt(r,e,t=o2){return an(r-e,t)}function FE(r,e){return Math.round(r/e)*e}function ou(r){return isFinite(r)?r:r<0?-Number.MAX_VALUE:Number.MAX_VALUE}function au(r){return Math.abs(r)<Number.MAX_VALUE?r:r*(1/0)}function ud(r,e,t,n,i=1/0,s){n=Math.max(1e-4,n);const o=2/n,a=o*s,l=1/(1+a+.48*a*a+.235*a*a*a);let c=r-e;const u=e,h=i*n;c=Ur(c,-h,h),e=r-c;const p=(t.value+o*c)*s;t.value=(t.value-o*p)*l;let m=e+(c+p)*l;return u-r>0==m>u&&(m=u,t.value=(m-u)/s),m}function kE(r,e,t,n,i=1/0,s,o){n=Math.max(1e-4,n);const a=2/n,l=a*s,c=1/(1+l+.48*l*l+.235*l*l*l);let u=e.x,h=e.y,p=e.z,m=r.x-u,v=r.y-h,_=r.z-p;const y=u,g=h,x=p,w=i*n,E=w*w,b=m*m+v*v+_*_;if(b>E){const q=Math.sqrt(b);m=m/q*w,v=v/q*w,_=_/q*w}u=r.x-m,h=r.y-v,p=r.z-_;const M=(t.x+a*m)*s,A=(t.y+a*v)*s,P=(t.z+a*_)*s;t.x=(t.x-a*M)*c,t.y=(t.y-a*A)*c,t.z=(t.z-a*P)*c,o.x=u+(m+M)*c,o.y=h+(v+A)*c,o.z=p+(_+P)*c;const C=y-r.x,L=g-r.y,F=x-r.z,N=o.x-y,I=o.y-g,X=o.z-x;return C*N+L*I+F*X>0&&(o.x=y,o.y=g,o.z=x,t.x=(o.x-y)/s,t.y=(o.y-g)/s,t.z=(o.z-x)/s),o}function w0(r,e){e.set(0,0),r.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=r.length,e.y/=r.length}function S0(r,e){return ho(r)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}let d5=class{constructor(){this._listeners={}}addEventListener(e,t){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[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e)}}};var E0;const p5="2.10.1",hd=1/8,m5=/Mac/.test((E0=globalThis==null?void 0:globalThis.navigator)===null||E0===void 0?void 0:E0.platform);let vt,zE,fd,b0,Fi,At,Wt,Rl,lu,es,ts,ra,BE,GE,gr,cu,Pl,HE,M0,VE,T0,A0,dd,Qn=class Gv extends d5{static install(e){vt=e.THREE,zE=Object.freeze(new vt.Vector3(0,0,0)),fd=Object.freeze(new vt.Vector3(0,1,0)),b0=Object.freeze(new vt.Vector3(0,0,1)),Fi=new vt.Vector2,At=new vt.Vector3,Wt=new vt.Vector3,Rl=new vt.Vector3,lu=new vt.Vector3,es=new vt.Vector3,ts=new vt.Vector3,ra=new vt.Vector3,BE=new vt.Vector3,GE=new vt.Vector3,gr=new vt.Spherical,cu=new vt.Spherical,Pl=new vt.Box3,HE=new vt.Box3,M0=new vt.Sphere,VE=new vt.Quaternion,T0=new vt.Quaternion,A0=new vt.Matrix4,dd=new vt.Raycaster}static get ACTION(){return _e}set verticalDragToForward(e){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=_e.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Al.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new vt.Vector3,this._focalOffsetVelocity=new vt.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,x,w,E)=>{let b,M;if(ia(this._camera)){const A=At.copy(this._camera.position).sub(this._target),P=this._camera.getEffectiveFOV()*su,C=A.length()*Math.tan(P*.5);b=this.truckSpeed*g*C/this._elementRect.height,M=this.truckSpeed*x*C/this._elementRect.height}else if(ho(this._camera)){const A=this._camera;b=this.truckSpeed*g*(A.right-A.left)/A.zoom/this._elementRect.width,M=this.truckSpeed*x*(A.top-A.bottom)/A.zoom/this._elementRect.height}else return;E?(w?this.setFocalOffset(this._focalOffsetEnd.x+b,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(b,0,!0),this.forward(-M,!0)):w?this.setFocalOffset(this._focalOffsetEnd.x+b,this._focalOffsetEnd.y+M,this._focalOffsetEnd.z,!0):this.truck(b,M,!0)},this._rotateInternal=(g,x)=>{const w=Cl*this.azimuthRotateSpeed*g/this._elementRect.height,E=Cl*this.polarRotateSpeed*x/this._elementRect.height;this.rotate(w,E,!0)},this._dollyInternal=(g,x,w)=>{const E=Math.pow(.95,-g*this.dollySpeed),b=this._sphericalEnd.radius,M=this._sphericalEnd.radius*E,A=Ur(M,this.minDistance,this.maxDistance),P=A-M;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(M,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(P,!0),this._dollyToNoClamp(A,!0)):this._dollyToNoClamp(A,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?M:A)-b,this._dollyControlCoord.set(x,w)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,x,w)=>{const E=Math.pow(.95,g*this.dollySpeed),b=this._zoom,M=this._zoom*E;this.zoomTo(M,!0),this.dollyToCursor&&(this._changedZoom+=M-b,this._dollyControlCoord.set(x,w))},typeof vt>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new vt.Quaternion().setFromUnitVectors(this._camera.up,fd),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=_e.NONE,this._target=new vt.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new vt.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new vt.Spherical().setFromVector3(At.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new vt.Vector3,new vt.Vector3,new vt.Vector3,new vt.Vector3],this._updateNearPlaneCorners(),this._boundary=new vt.Box3(new vt.Vector3(-1/0,-1/0,-1/0),new vt.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new vt.Vector2,this.mouseButtons={left:_e.ROTATE,middle:_e.DOLLY,right:_e.TRUCK,wheel:ia(this._camera)?_e.DOLLY:ho(this._camera)?_e.ZOOM:_e.NONE},this.touches={one:_e.TOUCH_ROTATE,two:ia(this._camera)?_e.TOUCH_DOLLY_TRUCK:ho(this._camera)?_e.TOUCH_ZOOM_TRUCK:_e.NONE,three:_e.TOUCH_TRUCK};const n=new vt.Vector2,i=new vt.Vector2,s=new vt.Vector2,o=g=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const E=this._domElement.getBoundingClientRect(),b=g.clientX/E.width,M=g.clientY/E.height;if(b<this._interactiveArea.left||b>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}const x=g.pointerType!=="mouse"?null:(g.buttons&gn.LEFT)===gn.LEFT?gn.LEFT:(g.buttons&gn.MIDDLE)===gn.MIDDLE?gn.MIDDLE:(g.buttons&gn.RIGHT)===gn.RIGHT?gn.RIGHT:null;if(x!==null){const E=this._findPointerByMouseButton(x);E&&this._disposePointer(E)}if((g.buttons&gn.LEFT)===gn.LEFT&&this._lockedPointer)return;const w={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:x};this._activePointers.push(w),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),this._isDragging=!0,p(g)},a=g=>{g.cancelable&&g.preventDefault();const x=g.pointerId,w=this._lockedPointer||this._findPointerById(x);if(w){if(w.clientX=g.clientX,w.clientY=g.clientY,w.deltaX=g.movementX,w.deltaY=g.movementY,this._state=0,g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(g.buttons&gn.LEFT)===gn.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&gn.MIDDLE)===gn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&gn.RIGHT)===gn.RIGHT&&(this._state=this._state|this.mouseButtons.right);m()}},l=g=>{const x=this._findPointerById(g.pointerId);if(!(x&&x===this._lockedPointer)){if(x&&this._disposePointer(x),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=_e.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=_e.NONE;v()}};let c=-1;const u=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===_e.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const M=this._domElement.getBoundingClientRect(),A=g.clientX/M.width,P=g.clientY/M.height;if(A<this._interactiveArea.left||A>this._interactiveArea.right||P<this._interactiveArea.top||P>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===_e.ROTATE||this.mouseButtons.wheel===_e.TRUCK){const M=performance.now();c-M<1e3&&this._getClientRect(this._elementRect),c=M}const x=m5?-1:-3,w=g.deltaMode===1||g.ctrlKey?g.deltaY/x:g.deltaY/(x*10),E=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,b=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case _e.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case _e.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1,!1),this._isUserControllingTruck=!0;break}case _e.SCREEN_PAN:{this._truckInternal(g.deltaX,g.deltaY,!1,!0),this._isUserControllingTruck=!0;break}case _e.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0,!1),this._isUserControllingOffset=!0;break}case _e.DOLLY:{this._dollyInternal(-w,E,b),this._isUserControllingDolly=!0;break}case _e.ZOOM:{this._zoomInternal(-w,E,b),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},h=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Gv.ACTION.NONE){const x=g instanceof PointerEvent?g.pointerId:0,w=this._findPointerById(x);w&&this._disposePointer(w),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l);return}g.preventDefault()}},p=g=>{if(!this._enabled)return;if(w0(this._activePointers,Fi),this._getClientRect(this._elementRect),n.copy(Fi),i.copy(Fi),this._activePointers.length>=2){const w=Fi.x-this._activePointers[1].clientX,E=Fi.y-this._activePointers[1].clientY,b=Math.sqrt(w*w+E*E);s.set(0,b);const M=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,A=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(M,A)}if(this._state=0,!g)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in g&&g.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(g.buttons&gn.LEFT)===gn.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&gn.MIDDLE)===gn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&gn.RIGHT)===gn.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&_e.ROTATE)===_e.ROTATE||(this._state&_e.TOUCH_ROTATE)===_e.TOUCH_ROTATE||(this._state&_e.TOUCH_DOLLY_ROTATE)===_e.TOUCH_DOLLY_ROTATE||(this._state&_e.TOUCH_ZOOM_ROTATE)===_e.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&_e.TRUCK)===_e.TRUCK||(this._state&_e.SCREEN_PAN)===_e.SCREEN_PAN||(this._state&_e.TOUCH_TRUCK)===_e.TOUCH_TRUCK||(this._state&_e.TOUCH_SCREEN_PAN)===_e.TOUCH_SCREEN_PAN||(this._state&_e.TOUCH_DOLLY_TRUCK)===_e.TOUCH_DOLLY_TRUCK||(this._state&_e.TOUCH_DOLLY_SCREEN_PAN)===_e.TOUCH_DOLLY_SCREEN_PAN||(this._state&_e.TOUCH_ZOOM_TRUCK)===_e.TOUCH_ZOOM_TRUCK||(this._state&_e.TOUCH_ZOOM_SCREEN_PAN)===_e.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&_e.DOLLY)===_e.DOLLY||(this._state&_e.TOUCH_DOLLY)===_e.TOUCH_DOLLY||(this._state&_e.TOUCH_DOLLY_TRUCK)===_e.TOUCH_DOLLY_TRUCK||(this._state&_e.TOUCH_DOLLY_SCREEN_PAN)===_e.TOUCH_DOLLY_SCREEN_PAN||(this._state&_e.TOUCH_DOLLY_OFFSET)===_e.TOUCH_DOLLY_OFFSET||(this._state&_e.TOUCH_DOLLY_ROTATE)===_e.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&_e.ZOOM)===_e.ZOOM||(this._state&_e.TOUCH_ZOOM)===_e.TOUCH_ZOOM||(this._state&_e.TOUCH_ZOOM_TRUCK)===_e.TOUCH_ZOOM_TRUCK||(this._state&_e.TOUCH_ZOOM_SCREEN_PAN)===_e.TOUCH_ZOOM_SCREEN_PAN||(this._state&_e.TOUCH_ZOOM_OFFSET)===_e.TOUCH_ZOOM_OFFSET||(this._state&_e.TOUCH_ZOOM_ROTATE)===_e.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&_e.OFFSET)===_e.OFFSET||(this._state&_e.TOUCH_OFFSET)===_e.TOUCH_OFFSET||(this._state&_e.TOUCH_DOLLY_OFFSET)===_e.TOUCH_DOLLY_OFFSET||(this._state&_e.TOUCH_ZOOM_OFFSET)===_e.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},m=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,w0(this._activePointers,Fi);const x=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,w=x?-x.deltaX:i.x-Fi.x,E=x?-x.deltaY:i.y-Fi.y;if(i.copy(Fi),((this._state&_e.ROTATE)===_e.ROTATE||(this._state&_e.TOUCH_ROTATE)===_e.TOUCH_ROTATE||(this._state&_e.TOUCH_DOLLY_ROTATE)===_e.TOUCH_DOLLY_ROTATE||(this._state&_e.TOUCH_ZOOM_ROTATE)===_e.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(w,E),this._isUserControllingRotate=!0),(this._state&_e.DOLLY)===_e.DOLLY||(this._state&_e.ZOOM)===_e.ZOOM){const b=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,M=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,A=this.dollyDragInverted?-1:1;(this._state&_e.DOLLY)===_e.DOLLY?(this._dollyInternal(A*E*hd,b,M),this._isUserControllingDolly=!0):(this._zoomInternal(A*E*hd,b,M),this._isUserControllingZoom=!0)}if((this._state&_e.TOUCH_DOLLY)===_e.TOUCH_DOLLY||(this._state&_e.TOUCH_ZOOM)===_e.TOUCH_ZOOM||(this._state&_e.TOUCH_DOLLY_TRUCK)===_e.TOUCH_DOLLY_TRUCK||(this._state&_e.TOUCH_ZOOM_TRUCK)===_e.TOUCH_ZOOM_TRUCK||(this._state&_e.TOUCH_DOLLY_SCREEN_PAN)===_e.TOUCH_DOLLY_SCREEN_PAN||(this._state&_e.TOUCH_ZOOM_SCREEN_PAN)===_e.TOUCH_ZOOM_SCREEN_PAN||(this._state&_e.TOUCH_DOLLY_OFFSET)===_e.TOUCH_DOLLY_OFFSET||(this._state&_e.TOUCH_ZOOM_OFFSET)===_e.TOUCH_ZOOM_OFFSET||(this._state&_e.TOUCH_DOLLY_ROTATE)===_e.TOUCH_DOLLY_ROTATE||(this._state&_e.TOUCH_ZOOM_ROTATE)===_e.TOUCH_ZOOM_ROTATE){const b=Fi.x-this._activePointers[1].clientX,M=Fi.y-this._activePointers[1].clientY,A=Math.sqrt(b*b+M*M),P=s.y-A;s.set(0,A);const C=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,L=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&_e.TOUCH_DOLLY)===_e.TOUCH_DOLLY||(this._state&_e.TOUCH_DOLLY_ROTATE)===_e.TOUCH_DOLLY_ROTATE||(this._state&_e.TOUCH_DOLLY_TRUCK)===_e.TOUCH_DOLLY_TRUCK||(this._state&_e.TOUCH_DOLLY_SCREEN_PAN)===_e.TOUCH_DOLLY_SCREEN_PAN||(this._state&_e.TOUCH_DOLLY_OFFSET)===_e.TOUCH_DOLLY_OFFSET?(this._dollyInternal(P*hd,C,L),this._isUserControllingDolly=!0):(this._zoomInternal(P*hd,C,L),this._isUserControllingZoom=!0)}((this._state&_e.TRUCK)===_e.TRUCK||(this._state&_e.TOUCH_TRUCK)===_e.TOUCH_TRUCK||(this._state&_e.TOUCH_DOLLY_TRUCK)===_e.TOUCH_DOLLY_TRUCK||(this._state&_e.TOUCH_ZOOM_TRUCK)===_e.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(w,E,!1,!1),this._isUserControllingTruck=!0),((this._state&_e.SCREEN_PAN)===_e.SCREEN_PAN||(this._state&_e.TOUCH_SCREEN_PAN)===_e.TOUCH_SCREEN_PAN||(this._state&_e.TOUCH_DOLLY_SCREEN_PAN)===_e.TOUCH_DOLLY_SCREEN_PAN||(this._state&_e.TOUCH_ZOOM_SCREEN_PAN)===_e.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(w,E,!1,!0),this._isUserControllingTruck=!0),((this._state&_e.OFFSET)===_e.OFFSET||(this._state&_e.TOUCH_OFFSET)===_e.TOUCH_OFFSET||(this._state&_e.TOUCH_DOLLY_OFFSET)===_e.TOUCH_DOLLY_OFFSET||(this._state&_e.TOUCH_ZOOM_OFFSET)===_e.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(w,E,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},v=()=>{w0(this._activePointers,Fi),i.copy(Fi),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",_),this._domElement.ownerDocument.addEventListener("pointerlockerror",y),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),p())},this.unlockPointer=()=>{var g,x,w;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(g=this._domElement)===null||g===void 0||g.ownerDocument.exitPointerLock(),(x=this._domElement)===null||x===void 0||x.ownerDocument.removeEventListener("pointerlockchange",_),(w=this._domElement)===null||w===void 0||w.ownerDocument.removeEventListener("pointerlockerror",y),this.cancel()};const _=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},y=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",u,{passive:!1}),this._domElement.addEventListener("contextmenu",h)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("pointercancel",l),this._domElement.removeEventListener("wheel",u,{passive:!1}),this._domElement.removeEventListener("contextmenu",h),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",_),this._domElement.ownerDocument.removeEventListener("pointerlockerror",y))},this.cancel=()=>{this._state!==_e.NONE&&(this._state=_e.NONE,this._activePointers.length=0,v())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=Ur(e.width,0,1),this._interactiveArea.height=Ur(e.height,0,1),this._interactiveArea.x=Ur(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Ur(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;const i=Ur(e,this.minAzimuthAngle,this.maxAzimuthAngle),s=Ur(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=s,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!n||Zt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Zt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(o)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Al.NONE,this._changedDolly=0,this._dollyToNoClamp(Ur(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const o=this._collisionTest(),a=Zt(o,this._spherical.radius);if(!(n>e)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,o)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const s=!t||Zt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(s)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(lu).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||Zt(this._target.x,this._targetEnd.x,this.restThreshold)&&Zt(this._target.y,this._targetEnd.y,this.restThreshold)&&Zt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Ur(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||Zt(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),es.setFromMatrixColumn(this._camera.matrix,0),ts.setFromMatrixColumn(this._camera.matrix,1),es.multiplyScalar(e),ts.multiplyScalar(-t);const i=At.copy(es).add(ts),s=Wt.copy(this._targetEnd).add(i);return this.moveTo(s.x,s.y,s.z,n)}forward(e,t=!1){At.setFromMatrixColumn(this._camera.matrix,0),At.crossVectors(this._camera.up,At),At.multiplyScalar(e);const n=Wt.copy(this._targetEnd).add(At);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return At.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+At.x,this._targetEnd.y+At.y,this._targetEnd.z+At.z,t)}moveTo(e,t,n,i=!1){this._isUserControllingTruck=!1;const s=At.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,s,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);const o=!i||Zt(this._target.x,this._targetEnd.x,this.restThreshold)&&Zt(this._target.y,this._targetEnd.y,this.restThreshold)&&Zt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,t,n,i=!1){const a=At.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,i)}fitToBox(e,t,{cover:n=!1,paddingLeft:i=0,paddingRight:s=0,paddingBottom:o=0,paddingTop:a=0}={}){const l=[],c=e.isBox3?Pl.copy(e):Pl.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const u=FE(this._sphericalEnd.theta,NE),h=FE(this._sphericalEnd.phi,NE);l.push(this.rotateTo(u,h,t));const p=At.setFromSpherical(this._sphericalEnd).normalize(),m=VE.setFromUnitVectors(p,b0),v=Zt(Math.abs(p.y),1);v&&m.multiply(T0.setFromAxisAngle(fd,u)),m.multiply(this._yAxisUpSpaceInverse);const _=HE.makeEmpty();Wt.copy(c.min).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.min).setX(c.max.x).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.min).setY(c.max.y).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.max).setZ(c.min.z).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.min).setZ(c.max.z).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.max).setY(c.min.y).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.max).setX(c.min.x).applyQuaternion(m),_.expandByPoint(Wt),Wt.copy(c.max).applyQuaternion(m),_.expandByPoint(Wt),_.min.x-=i,_.min.y-=o,_.max.x+=s,_.max.y+=a,m.setFromUnitVectors(b0,p),v&&m.premultiply(T0.invert()),m.premultiply(this._yAxisUpSpace);const y=_.getSize(At),g=_.getCenter(Wt).applyQuaternion(m);if(ia(this._camera)){const x=this.getDistanceToFitBox(y.x,y.y,y.z,n);l.push(this.moveTo(g.x,g.y,g.z,t)),l.push(this.dollyTo(x,t)),l.push(this.setFocalOffset(0,0,0,t))}else if(ho(this._camera)){const x=this._camera,w=x.right-x.left,E=x.top-x.bottom,b=n?Math.max(w/y.x,E/y.y):Math.min(w/y.x,E/y.y);l.push(this.moveTo(g.x,g.y,g.z,t)),l.push(this.zoomTo(b,t)),l.push(this.setFocalOffset(0,0,0,t))}return Promise.all(l)}fitToSphere(e,t){const n=[],s="isObject3D"in e?Gv.createBoundingSphere(e,M0):M0.copy(e);if(n.push(this.moveTo(s.center.x,s.center.y,s.center.z,t)),ia(this._camera)){const o=this.getDistanceToFitSphere(s.radius);n.push(this.dollyTo(o,t))}else if(ho(this._camera)){const o=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,l=2*s.radius,c=Math.min(o/l,a/l);n.push(this.zoomTo(c,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,i,s,o,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Al.NONE,this._changedDolly=0;const l=Wt.set(i,s,o),c=At.set(e,t,n);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(c.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const u=!a||Zt(this._target.x,this._targetEnd.x,this.restThreshold)&&Zt(this._target.y,this._targetEnd.y,this.restThreshold)&&Zt(this._target.z,this._targetEnd.z,this.restThreshold)&&Zt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Zt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Zt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerpLookAt(e,t,n,i,s,o,a,l,c,u,h,p,m,v=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Al.NONE,this._changedDolly=0;const _=At.set(i,s,o),y=Wt.set(e,t,n);gr.setFromVector3(y.sub(_).applyQuaternion(this._yAxisUpSpace));const g=Rl.set(u,h,p),x=Wt.set(a,l,c);cu.setFromVector3(x.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(_.lerp(g,m));const w=cu.theta-gr.theta,E=cu.phi-gr.phi,b=cu.radius-gr.radius;this._sphericalEnd.set(gr.radius+b*m,gr.phi+E*m,gr.theta+w*m),this.normalizeRotations(),this._needsUpdate=!0,v||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const M=!v||Zt(this._target.x,this._targetEnd.x,this.restThreshold)&&Zt(this._target.y,this._targetEnd.y,this.restThreshold)&&Zt(this._target.z,this._targetEnd.z,this.restThreshold)&&Zt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Zt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Zt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(M)}setPosition(e,t,n,i=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,i)}setTarget(e,t,n,i=!1){const s=this.getPosition(At),o=this.setLookAt(s.x,s.y,s.z,e,t,n,i);return this._sphericalEnd.phi=Ur(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),o}setFocalOffset(e,t,n,i=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,i||this._focalOffset.copy(this._focalOffsetEnd);const s=!i||Zt(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Zt(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Zt(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),es.setFromMatrixColumn(this._camera.matrixWorldInverse,0),ts.setFromMatrixColumn(this._camera.matrixWorldInverse,1),ra.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=At.set(e,t,n),s=i.distanceTo(this._camera.position),o=i.sub(this._camera.position);es.multiplyScalar(o.x),ts.multiplyScalar(o.y),ra.multiplyScalar(o.z),At.copy(es).add(ts).add(ra),At.z=At.z+s,this.dollyTo(s,!1),this.setFocalOffset(-At.x,At.y,-At.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,i){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new vt.Vector4,typeof e=="number"?this._viewport.set(e,t,n,i):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,i=!1){if(S0(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const s=e/t,o=this._camera.getEffectiveFOV()*su,a=this._camera.aspect;return((i?s>a:s<a)?t:e/a)*.5/Math.tan(o*.5)+n*.5}getDistanceToFitSphere(e){if(S0(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*su,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,i=1<this._camera.aspect?t:n;return e/Math.sin(i*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new vt.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new vt.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new vt.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new vt.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Cl,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Cl),this._spherical.theta+=Cl*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Cl)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!Zt(this._camera.up.x,this._cameraUp0.x)||!Zt(this._camera.up.y,this._cameraUp0.y)||!Zt(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const n=this.getPosition(At);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,fd),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=At.subVectors(this._target,this._camera.position).normalize(),t=Wt.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const n=this.getPosition(At);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,i=this._sphericalEnd.radius-this._spherical.radius,s=BE.subVectors(this._targetEnd,this._target),o=GE.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(an(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const h=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=ud(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,h,1/0,e),this._needsUpdate=!0}if(an(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const h=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=ud(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,h,1/0,e),this._needsUpdate=!0}if(an(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const h=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=ud(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,h,this.maxSpeed,e),this._needsUpdate=!0}if(an(s.x)&&an(s.y)&&an(s.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const h=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;kE(this._target,this._targetEnd,this._targetVelocity,h,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(an(o.x)&&an(o.y)&&an(o.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const h=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;kE(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,h,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(an(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const h=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=ud(this._zoom,this._zoomEnd,this._zoomVelocity,h,1/0,e)}if(this.dollyToCursor){if(ia(this._camera)&&this._changedDolly!==0){const h=this._spherical.radius-this._lastDistance,p=this._camera,m=this._getCameraDirection(lu),v=At.copy(m).cross(p.up).normalize();v.lengthSq()===0&&(v.x=1);const _=Wt.crossVectors(v,m),y=this._sphericalEnd.radius*Math.tan(p.getEffectiveFOV()*su*.5),x=(this._sphericalEnd.radius-h-this._sphericalEnd.radius)/this._sphericalEnd.radius,w=Rl.copy(this._targetEnd).add(v.multiplyScalar(this._dollyControlCoord.x*y*p.aspect)).add(_.multiplyScalar(this._dollyControlCoord.y*y)),E=At.copy(this._targetEnd).lerp(w,x),b=this._lastDollyDirection===Al.IN&&this._spherical.radius<=this.minDistance,M=this._lastDollyDirection===Al.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(b||M)){this._sphericalEnd.radius-=h,this._spherical.radius-=h;const P=Wt.copy(m).multiplyScalar(-h);E.add(P)}this._boundary.clampPoint(E,E);const A=Wt.subVectors(E,this._targetEnd);this._targetEnd.copy(E),this._target.add(A),this._changedDolly-=h,an(this._changedDolly)&&(this._changedDolly=0)}else if(ho(this._camera)&&this._changedZoom!==0){const h=this._zoom-this._lastZoom,p=this._camera,m=At.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(p.near+p.far)/(p.near-p.far)).unproject(p),v=Wt.set(0,0,-1).applyQuaternion(p.quaternion),_=Rl.copy(m).add(v.multiplyScalar(-m.dot(p.up))),g=-(this._zoom-h-this._zoom)/this._zoom,x=this._getCameraDirection(lu),w=this._targetEnd.dot(x),E=At.copy(this._targetEnd).lerp(_,g),b=E.dot(x),M=x.multiplyScalar(b-w);E.sub(M),this._boundary.clampPoint(E,E);const A=Wt.subVectors(E,this._targetEnd);this._targetEnd.copy(E),this._target.add(A),this._changedZoom-=h,an(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const l=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,l),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!an(this._focalOffset.x)||!an(this._focalOffset.y)||!an(this._focalOffset.z))&&(es.setFromMatrixColumn(this._camera.matrix,0),ts.setFromMatrixColumn(this._camera.matrix,1),ra.setFromMatrixColumn(this._camera.matrix,2),es.multiplyScalar(this._focalOffset.x),ts.multiplyScalar(-this._focalOffset.y),ra.multiplyScalar(this._focalOffset.z),At.copy(es).add(ts).add(ra),this._camera.position.add(At),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),At.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const u=this._needsUpdate;return u&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):u?(this.dispatchEvent({type:"update"}),an(t,this.restThreshold)&&an(n,this.restThreshold)&&an(i,this.restThreshold)&&an(s.x,this.restThreshold)&&an(s.y,this.restThreshold)&&an(s.z,this.restThreshold)&&an(o.x,this.restThreshold)&&an(o.y,this.restThreshold)&&an(o.z,this.restThreshold)&&an(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!u&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=u,this._needsUpdate=!1,u}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:ou(this.maxDistance),minZoom:this.minZoom,maxZoom:ou(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:ou(this.maxPolarAngle),minAzimuthAngle:ou(this.minAzimuthAngle),maxAzimuthAngle:ou(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:At.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=au(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=au(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=au(n.maxPolarAngle),this.minAzimuthAngle=au(n.minAzimuthAngle),this.maxAzimuthAngle=au(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),gr.setFromVector3(At.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(gr.theta,gr.phi,t),this.dollyTo(gr.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",p5),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,n){const i=t.lengthSq();if(i===0)return e;const s=Wt.copy(t).add(e),a=this._boundary.clampPoint(s,Rl).sub(s),l=a.lengthSq();if(l===0)return e.add(t);if(l===i)return e;if(n===0)return e.add(t).add(a);{const c=1+n*l/t.dot(a);return e.add(Wt.copy(t).multiplyScalar(c)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(ia(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*su,i=Math.tan(n*.5)*t,s=i*e.aspect;this._nearPlaneCorners[0].set(-s,-i,0),this._nearPlaneCorners[1].set(s,-i,0),this._nearPlaneCorners[2].set(s,i,0),this._nearPlaneCorners[3].set(-s,i,0)}else if(ho(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,i=e.right*t,s=e.top*t,o=e.bottom*t;this._nearPlaneCorners[0].set(n,s,0),this._nearPlaneCorners[1].set(i,s,0),this._nearPlaneCorners[2].set(i,o,0),this._nearPlaneCorners[3].set(n,o,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||S0(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(lu);A0.lookAt(zE,n,this._camera.up);for(let i=0;i<4;i++){const s=Wt.copy(this._nearPlaneCorners[i]);s.applyMatrix4(A0);const o=Rl.addVectors(this._target,s);dd.set(o,n),dd.far=this._spherical.radius+1;const a=dd.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance<e&&(e=a[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new vt.Sphere){const n=t,i=n.center;Pl.makeEmpty(),e.traverseVisible(o=>{o.isMesh&&Pl.expandByObject(o)}),Pl.getCenter(i);let s=0;return e.traverseVisible(o=>{if(!o.isMesh)return;const a=o;if(!a.geometry)return;const l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const u=l.attributes.position;for(let h=0,p=u.count;h<p;h++)At.fromBufferAttribute(u,h),s=Math.max(s,i.distanceToSquared(At))}),n.radius=Math.sqrt(s),n}};var uu={exports:{}},WE;function g5(){if(WE)return uu.exports;WE=1;var r={ellipse:"…",chars:[" ","-"],max:140,truncate:!0};function e(n,i,s,o){if(n<=i)return n;if(i<2)return n.slice(0,i-s.length)+s;for(var a=i-s.length,l=Math.floor(a/2),c=l,u=n.length-l,h=0;h<l;h++){var p=n.charAt(h),m=n.length-h,v=n.charAt(m);o.indexOf(p)!==-1&&(c=h),o.indexOf(v)!==-1&&(u=m)}return n.slice(0,c)+s+n.slice(u)}function t(n,i,s,o,a){if(n.length<=i)return n;for(var l=i-s.length,c=l,u=0;u<=l;u++){var h=n.charAt(u);o.indexOf(h)!==-1&&(c=u)}return!a&&c==l?"":n.slice(0,c)+s}return uu.exports=function(n,i,s){if(typeof n!="string"||n.length===0||i===0)return"";s=s||{};for(var o in r)(s[o]===null||typeof s[o]>"u")&&(s[o]=r[o]);return s.max=i||s.max,s.truncate=="middle"?e(n,s.max,s.ellipse,s.chars):t(n,s.max,s.ellipse,s.chars,s.truncate)},uu.exports.ellipsizeMiddle=e,uu.exports.ellipsize=t,uu.exports}var v5=g5();const y5=Hr(v5);/*!
|
|
* hold-event
|
|
* https://github.com/yomotsu/hold-event
|
|
* (c) 2020 @yomotsu
|
|
* Released under the MIT License.
|
|
*/var Au;(function(r){r.HOLD_START="holdStart",r.HOLD_END="holdEnd",r.HOLDING="holding"})(Au||(Au={}));class _5{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}removeEventListener(e,t){const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e)}}}class x5 extends _5{constructor(e){super(),this._enabled=!0,this._holding=!1,this._intervalId=-1,this._deltaTime=0,this._elapsedTime=0,this._lastTime=0,this._holdStart=t=>{if(!this._enabled||this._holding)return;this._deltaTime=0,this._elapsedTime=0,this._lastTime=performance.now(),this.dispatchEvent({type:Au.HOLD_START,deltaTime:this._deltaTime,elapsedTime:this._elapsedTime,originalEvent:t}),this._holding=!0;const n=()=>{this._intervalId=this.holdIntervalDelay?window.setTimeout(n,this.holdIntervalDelay):window.requestAnimationFrame(n);const i=performance.now();this._deltaTime=i-this._lastTime,this._elapsedTime+=this._deltaTime,this._lastTime=performance.now(),this.dispatchEvent({type:Au.HOLDING,deltaTime:this._deltaTime,elapsedTime:this._elapsedTime,originalEvent:t})};this._intervalId=this.holdIntervalDelay?window.setTimeout(n,this.holdIntervalDelay):window.requestAnimationFrame(n)},this._holdEnd=t=>{if(!this._enabled||!this._holding)return;const n=performance.now();this._deltaTime=n-this._lastTime,this._elapsedTime+=this._deltaTime,this._lastTime=performance.now(),this.dispatchEvent({type:Au.HOLD_END,deltaTime:this._deltaTime,elapsedTime:this._elapsedTime,originalEvent:t}),window.clearTimeout(this._intervalId),window.cancelAnimationFrame(this._intervalId),this._holding=!1},this.holdIntervalDelay=e}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this._enabled||this._holdEnd())}}class kp extends x5{constructor(e,t){super(t),this._holdStart=this._holdStart.bind(this),this._holdEnd=this._holdEnd.bind(this);const n=s=>{w5(s)||s.keyCode===e&&this._holdStart(s)},i=s=>{s.keyCode===e&&this._holdEnd(s)};document.addEventListener("keydown",n),document.addEventListener("keyup",i),window.addEventListener("blur",this._holdEnd)}}function w5(r){const e=r.target;return e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA"||e.isContentEditable}var C0={exports:{}};/*!
|
|
Copyright (c) 2018 Jed Watson.
|
|
Licensed under the MIT License (MIT), see
|
|
http://jedwatson.github.io/classnames
|
|
*/var XE;function S5(){return XE||(XE=1,(function(r){(function(){var e={}.hasOwnProperty;function t(){for(var s="",o=0;o<arguments.length;o++){var a=arguments[o];a&&(s=i(s,n(a)))}return s}function n(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return t.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var o="";for(var a in s)e.call(s,a)&&s[a]&&(o=i(o,a));return o}function i(s,o){return o?s?s+" "+o:s+o:s}r.exports?(t.default=t,r.exports=t):window.classNames=t})()})(C0)),C0.exports}S5();(function(){try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode(`._canvas_670zp_1 {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
}
|
|
._container_155l7_1 {
|
|
transform-origin: bottom right;
|
|
overflow: hidden;
|
|
position: absolute;
|
|
border: solid 1px var(--radial-menu-border);
|
|
}
|
|
|
|
._container_155l7_1._disabled_155l7_7 {
|
|
opacity: 0.6;
|
|
}
|
|
|
|
._container_155l7_1._disabled_155l7_7 ._contentContainer_155l7_10 {
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
._container_155l7_1:not(._disabled_155l7_7) ._contentContainer_155l7_10 {
|
|
cursor: pointer;
|
|
}
|
|
|
|
._container_155l7_1:not(._disabled_155l7_7) ._contentContainer_155l7_10:hover {
|
|
color: var(--radial-menu-active-color);
|
|
background: var(--radial-menu-active-background);
|
|
}
|
|
|
|
._container_155l7_1 ._contentContainer_155l7_10 {
|
|
width: 200%;
|
|
height: 200%;
|
|
transform-origin: 50% 50%;
|
|
border-radius: 50%;
|
|
outline: none;
|
|
transition: background 150ms ease-in-out;
|
|
color: var(--radial-menu-color);
|
|
}
|
|
|
|
._container_155l7_1 ._contentContainer_155l7_10 ._contentInner_155l7_35 {
|
|
position: absolute;
|
|
width: 100%;
|
|
text-align: center;
|
|
}
|
|
|
|
._container_155l7_1 ._contentContainer_155l7_10 ._contentInner_155l7_35 ._content_155l7_10 {
|
|
display: inline-block;
|
|
}
|
|
|
|
._container_155l7_1 svg {
|
|
margin: 0 auto;
|
|
fill: var(--radial-menu-active-color);
|
|
height: 25px;
|
|
width: 25px;
|
|
display: block;
|
|
}
|
|
._container_x9hyx_1 {
|
|
border-radius: 50%;
|
|
z-index: 9;
|
|
position: relative;
|
|
height: 175px;
|
|
width: 175px;
|
|
border: solid 5px var(--radial-menu-border);
|
|
overflow: hidden;
|
|
background: var(--radial-menu-background);
|
|
}
|
|
|
|
._container_x9hyx_1:before {
|
|
content: ' ';
|
|
background: var(--radial-menu-border);
|
|
border-radius: 50%;
|
|
height: 25px;
|
|
width: 25px;
|
|
position: absolute;
|
|
z-index: 9;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
}`)),document.head.appendChild(r)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var jE,YE;function a2(r,e=[]){const t=e.length;for(const n of r){const i=e.indexOf(n);if(i>-1){const s=[...e.slice(i),n].map(o=>o.data.id);throw new Error(`Invalid Graph: Circular node path detected: ${s.join(" -> ")}.`)}t>n.depth&&(n.depth=t,a2(n.out,[...e,n]))}}function l2(r,e){let t=!1;const n=r.reduce((o,a)=>({...o,[a.id]:{data:a,out:[],depth:-1,ins:[]}}),{});try{for(const o of e){const a=o.source,l=o.target;if(!n.hasOwnProperty(a))throw new Error(`Missing source Node ${a}`);if(!n.hasOwnProperty(l))throw new Error(`Missing target Node ${l}`);const c=n[a],u=n[l];u.ins.push(c),c.out.push(u)}a2(Object.values(n))}catch{t=!0}const i=Object.keys(n).map(o=>n[o].depth),s=Math.max(...i);return{invalid:t,depths:n,maxDepth:s||1}}const qE=["radialin","radialout"];function E5({nodes:r,edges:e,mode:t="lr",nodeLevelRatio:n=2}){const{depths:i,maxDepth:s,invalid:o}=l2(r,e);if(o)return null;const a=qE.includes(t)?1:5,l=r.length/s*n*a;if(t){const c=(m,v)=>_=>m?(i[_.id].depth-s/2)*l*(v?-1:1):void 0,u=c(["lr","rl"].includes(t),t==="rl"),h=c(["td","bu"].includes(t),t==="td"),p=c(["zin","zout"].includes(t),t==="zout");r.forEach(m=>{m.fx=u(m),m.fy=h(m),m.fz=p(m)})}return qE.includes(t)?KN(c=>{const u=i[c.id];return(t==="radialin"?s-u.depth:u.depth)*l}).strength(1):null}function b5(r){return new Promise((e,t)=>{let n;function i(){n?e(n):(n=r.step(),i())}i()})}function _h(r){const e=[],t=[];return r.forEachNode((n,i)=>{e.push({...i,id:n,radius:i.size||1})}),r.forEachEdge((n,i)=>{t.push({...i,id:n})}),{nodes:e,edges:t}}function M5(){const r=O=>()=>O;let t=O=>O.index,n=[],i=[],s,o,a=[100,100],l=r(1),c=r(-1),u=r(100),h=r(.1),p={},m=.1,v=.001,_=[],y=[0,0],g,x=O=>O.cluster,w="treemap",E=!0,b=.1;function M(O){if(!E)return M;w==="force"&&(g.tick(),I());for(let k=0,G=n.length,B,D=O*b;k<G;++k)B=n[k],B.vx+=(p[x(B)].x-B.x)*D,B.vy+=(p[x(B)].y-B.y)*D}function A(){n&&(w==="treemap"?X():W())}M.initialize=function(O){n=O,A()};function P(O){let k=x(O.source),G=x(O.target);return k<=G?k+"~"+G:G+"~"+k}function C(O){let k=new Map,G={};return O.forEach(function(B){k.has(x(B))||k.set(x(B),{count:0,sumforceNodeSize:0})}),O.forEach(function(B){G=k.get(x(B)),G.count=G.count+1,G.sumforceNodeSize=G.sumforceNodeSize+Math.PI*(l(B)*l(B))*1.3,k.set(x(B),G)}),k}function L(O){let k=new Map,G=[];return O.forEach(function(B){let D=P(B),V;k.has(D)?V=k.get(D):V=0,V+=1,k.set(D,V)}),k.forEach(function(B,D){let V,Z;V=D.split("~")[0],Z=D.split("~")[1],V!==void 0&&Z!==void 0&&G.push({source:V,target:Z,count:B})}),G}function F(){let O=[],k=[],G=new Map,B,D,V,Z,ee;Z=C(n),ee=L(i);for(B of Z.keys())V=Z.get(B),O.push({id:B,size:V.count,r:Math.sqrt(V.sumforceNodeSize/Math.PI)}),G.set(B,D);return ee.forEach(function(ie){let ue=G.get(ie.source),ce=G.get(ie.target);ue!==void 0&&ce!==void 0&&k.push({source:ue,target:ce,count:ie.count})}),{nodes:O,links:k}}function N(){let O=[],k,G,B;B=C(M.nodes());for(k of B.keys())G=B.get(k),O.push({id:k,size:G.count});return{id:"clustersTree",children:O}}function I(){return p.none={x:0,y:0},_.forEach(function(O){w==="treemap"?p[O.data.id]={x:O.x0+(O.x1-O.x0)/2-y[0],y:O.y0+(O.y1-O.y0)/2-y[1]}:p[O.id]={x:O.x-y[0],y:O.y-y[1]}}),p}function X(){let O=UF().size(M.size());o=Mp(N()).sum(k=>k.radius).sort(function(k,G){return G.height-k.height||G.value-k.value}),_=O(o).leaves(),I()}function q(){let O=0;n.length!==0&&i.forEach(function(k){let G,B;if(n){if(G=k.source,B=k.target,typeof k.source!="object"&&(G=n.find(D=>D.id===k.source)),typeof k.target!="object"&&(B=n.find(D=>D.id===k.target)),G===void 0||B===void 0)throw Error("Error setting links, couldnt find nodes for a link (see it on the console)");k.source=G,k.target=B,k.index=O++}})}function W(){let O;!n||!n.length||(q(),O=F(),s.size>0&&O.nodes.forEach(k=>{var G,B,D,V;k.fx=(B=(G=s.get(k.id))==null?void 0:G.position)==null?void 0:B.x,k.fy=(V=(D=s.get(k.id))==null?void 0:D.position)==null?void 0:V.y}),g=zT(O.nodes).force("x",xv(a[0]/2).strength(.1)).force("y",wv(a[1]/2).strength(.1)).force("collide",IT(k=>k.r).iterations(4)).force("charge",BT().strength(c)).force("links",DT(O.nodes.length?O.links:[]).distance(u).strength(h)),_=g.nodes(),I())}return M.template=function(O){return arguments.length?(w=O,A(),M):w},M.groupBy=function(O){return arguments.length?typeof O=="string"?(x=function(k){return k[O]},M):(x=O,M):x},M.enableGrouping=function(O){return arguments.length?(E=O,M):E},M.strength=function(O){return arguments.length?(b=O,M):b},M.getLinkStrength=function(O){return E?x(O.source)===x(O.target)?typeof m=="function"?m(O):m:typeof v=="function"?v(O):v:typeof m=="function"?m(O):m},M.id=function(O){return arguments.length?(t=O,M):t},M.size=function(O){return arguments.length?(a=O,M):a},M.linkStrengthInterCluster=function(O){return arguments.length?(v=O,M):v},M.linkStrengthIntraCluster=function(O){return arguments.length?(m=O,M):m},M.nodes=function(O){return arguments.length?(n=O,M):n},M.links=function(O){return arguments.length?(O===null?i=[]:i=O,A(),M):i},M.template=function(O){return arguments.length?(w=O,A(),M):w},M.forceNodeSize=function(O){return arguments.length?(l=typeof O=="function"?O:r(+O),A(),M):l},M.nodeSize=M.forceNodeSize,M.forceCharge=function(O){return arguments.length?(c=typeof O=="function"?O:r(+O),A(),M):c},M.forceLinkDistance=function(O){return arguments.length?(u=typeof O=="function"?O:r(+O),A(),M):u},M.forceLinkStrength=function(O){return arguments.length?(h=typeof O=="function"?O:r(+O),A(),M):h},M.offset=function(O){return arguments.length?(y=typeof O=="function"?O:r(+O),M):y},M.getFocis=I,M.setClusters=function(O){return s=O,M},M}function uo({graph:r,nodeLevelRatio:e=2,mode:t=null,dimensions:n=2,nodeStrength:i=-250,linkDistance:s=50,clusterStrength:o=.5,linkStrengthInterCluster:a=.01,linkStrengthIntraCluster:l=.5,forceLinkDistance:c=100,forceLinkStrength:u=.1,clusterType:h="force",forceCharge:p=-700,getNodePosition:m,drags:v,clusters:_,clusterAttribute:y,forceLayout:g}){const{nodes:x,edges:w}=_h(r),b=n===2&&w.length>25?i*2:i;let M,A;g==="forceDirected2d"?(M=xv(),A=wv()):(M=xv(600).strength(.05),A=wv(600).strength(.05));const P=zT().force("center",FO(0,0)).force("link",DT()).force("charge",BT().strength(b)).force("x",M).force("y",A).force("z",$N()).force("collide",IT(N=>N.radius+10)).force("dagRadial",E5({nodes:x,edges:w,mode:t,nodeLevelRatio:e})).stop();let C;if(y){let N=p;if(x!=null&&x.length){const I=Math.ceil(x.length/200);N=p*I}C=M5().setClusters(_).strength(o).template(h).groupBy(I=>I.data[y]).links(w).size([100,100]).linkStrengthInterCluster(a).linkStrengthIntraCluster(l).forceLinkDistance(c).forceLinkStrength(u).forceCharge(N).forceNodeSize(I=>I.radius)}let L=P.numDimensions(n).nodes(x);if(C&&(L=L.force("group",C)),s){let N=L.force("link");N&&(N.id(I=>I.id).links(w).distance(s),C&&(N=N.strength((C==null?void 0:C.getLinkStrength)??.1)))}const F=new Map(x.map(N=>[N.id,N]));return{step(){for(;P.alpha()>.01;)P.tick();return!0},getNodePosition(N){var I,X;if(m){const q=m(N,{graph:r,drags:v,nodes:x,edges:w});if(q)return q}return(I=v==null?void 0:v[N])!=null&&I.position?(X=v==null?void 0:v[N])==null?void 0:X.position:F.get(N)}}}function T5({graph:r,radius:e,drags:t,getNodePosition:n}){const i=FF(r,{scale:e}),{nodes:s,edges:o}=_h(r);return{step(){return!0},getNodePosition(a){var l,c;if(n){const u=n(a,{graph:r,drags:t,nodes:s,edges:o});if(u)return u}return(l=t==null?void 0:t[a])!=null&&l.position?(c=t==null?void 0:t[a])==null?void 0:c.position:i==null?void 0:i[a]}}}const A5={td:{x:"x",y:"y",factor:-1},lr:{x:"y",y:"x",factor:1}};function ZE({graph:r,drags:e,mode:t="td",nodeSeparation:n=1,nodeSize:i=[50,50],getNodePosition:s}){const{nodes:o,edges:a}=_h(r),{depths:l}=l2(o,a),c=Object.keys(l).map(_=>l[_]),u=SF().id(_=>_.data.id).parentId(_=>{var y,g,x;return(x=(g=(y=_.ins)==null?void 0:y[0])==null?void 0:g.data)==null?void 0:x.id})(c),p=RF().separation(()=>n).nodeSize(i)(Mp(u)).descendants(),m=A5[t],v=new Map(o.map(_=>{const{x:y,y:g}=p.find(x=>x.data.id===_.id);return[_.id,{..._,[m.x]:y*m.factor,[m.y]:g*m.factor,z:0}]}));return{step(){return!0},getNodePosition(_){var y,g;if(s){const x=s(_,{graph:r,drags:e,nodes:o,edges:a});if(x)return x}return(y=e==null?void 0:e[_])!=null&&y.position?(g=e==null?void 0:e[_])==null?void 0:g.position:v.get(_)}}}function C5({graph:r,margin:e,drags:t,getNodePosition:n,ratio:i,gridSize:s,maxIterations:o}){const{nodes:a,edges:l}=_h(r),c=VF(r,{maxIterations:o,inputReducer:(u,h)=>({...h,x:h.x||0,y:h.y||0}),settings:{ratio:i,margin:e,gridSize:s}});return{step(){return!0},getNodePosition(u){var h,p;if(n){const m=n(u,{graph:r,drags:t,nodes:a,edges:l});if(m)return m}return(h=t==null?void 0:t[u])!=null&&h.position?(p=t==null?void 0:t[u])==null?void 0:p.position:c==null?void 0:c[u]}}}function R5({graph:r,drags:e,iterations:t,...n}){JF.assign(r);const i=ZF(r,{iterations:t,settings:n});return{step(){return!0},getNodePosition(s){var o;return((o=e==null?void 0:e[s])==null?void 0:o.position)||(i==null?void 0:i[s])}}}function P5({graph:r,drags:e,getNodePosition:t}){const{nodes:n,edges:i}=_h(r);return{step(){return!0},getNodePosition(s){return t(s,{graph:r,drags:e,nodes:n,edges:i})}}}const L5=["forceDirected2d","treeTd2d","treeLr2d","radialOut2d","treeTd3d","treeLr3d","radialOut3d","forceDirected3d"];function I5({type:r,...e}){if(L5.includes(r)){const{nodeStrength:t,linkDistance:n,nodeLevelRatio:i}=e;if(r==="forceDirected2d")return uo({...e,dimensions:2,nodeLevelRatio:i||2,nodeStrength:t||-250,linkDistance:n,forceLayout:r});if(r==="treeTd2d")return uo({...e,mode:"td",dimensions:2,nodeLevelRatio:i||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:r});if(r==="treeLr2d")return uo({...e,mode:"lr",dimensions:2,nodeLevelRatio:i||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:r});if(r==="radialOut2d")return uo({...e,mode:"radialout",dimensions:2,nodeLevelRatio:i||5,nodeStrength:t||-500,linkDistance:n||100,forceLayout:r});if(r==="treeTd3d")return uo({...e,mode:"td",dimensions:3,nodeLevelRatio:i||2,nodeStrength:t||-500,linkDistance:n||50});if(r==="treeLr3d")return uo({...e,mode:"lr",dimensions:3,nodeLevelRatio:i||2,nodeStrength:t||-500,linkDistance:n||50,forceLayout:r});if(r==="radialOut3d")return uo({...e,mode:"radialout",dimensions:3,nodeLevelRatio:i||2,nodeStrength:t||-500,linkDistance:n||100,forceLayout:r});if(r==="forceDirected3d")return uo({...e,dimensions:3,nodeLevelRatio:i||2,nodeStrength:t||-250,linkDistance:n,forceLayout:r})}else if(r==="circular2d"){const{radius:t}=e;return T5({...e,radius:t||300})}else{if(r==="hierarchicalTd")return ZE({...e,mode:"td"});if(r==="hierarchicalLr")return ZE({...e,mode:"lr"});if(r==="nooverlap"){const{graph:t,maxIterations:n,ratio:i,margin:s,gridSize:o,...a}=e;return C5({graph:t,margin:s||10,maxIterations:n||50,ratio:i||10,gridSize:o||20,...a})}else if(r==="forceatlas2"){const{graph:t,iterations:n,gravity:i,scalingRatio:s,...o}=e;return R5({type:"forceatlas2",graph:t,...o,scalingRatio:s||100,gravity:i||10,iterations:n||50})}else if(r==="custom")return P5({...e})}throw new Error(`Layout ${r} not found.`)}function c2({nodeCount:r,nodePosition:e,labelType:t,camera:n}){return(i,s)=>{var o;if(n&&e&&((o=n==null?void 0:n.position)==null?void 0:o.z)/(n==null?void 0:n.zoom)-(e==null?void 0:e.z)>6e3)return!1;if(t==="all")return!0;if(t==="nodes"&&i==="node")return!0;if(t==="edges"&&i==="edge")return!0;if(t==="auto"&&i==="node"){if(s>7)return!0;if(n&&e&&n.position.z/n.zoom-e.z<3e3)return!0}return!1}}function u2(r,e){switch(e){case"above":return r;case"below":return-r;case"inline":case"natural":default:return 0}}function D5({graph:r}){const e=nk(r);return{ranks:e,getSizeForNode:t=>e[t]*80}}function U5({graph:r}){const e=rk.degreeCentrality(r);return{ranks:e,getSizeForNode:t=>e[t]*20}}function O5({graph:r,attribute:e,defaultSize:t}){const n=new Map;return e?r.forEachNode((i,s)=>{var o;const a=(o=s.data)==null?void 0:o[e];isNaN(a)&&console.warn(`Attribute ${a} is not a number for node ${s.id}`),n.set(i,a||0)}):console.warn("Attribute sizing configured but no attribute provided"),{getSizeForNode:i=>!e||!n?t:n.get(i)}}const KE={pagerank:D5,centrality:U5,attribute:O5,none:({defaultSize:r})=>({getSizeForNode:e=>r})};function N5({type:r,...e}){var t;const n=(t=KE[r])==null?void 0:t.call(KE,e);if(!n&&r!=="default")throw new Error(`Unknown sizing strategy: ${r}`);const{graph:i,minSize:s,maxSize:o}=e,a=new Map;let l,c;if(i.forEachNode((u,h)=>{let p;r==="default"?p=h.size||e.defaultSize:p=n.getSizeForNode(u),(l===void 0||p<l)&&(l=p),(c===void 0||p>c)&&(c=p),a.set(u,p)}),r!=="none"){const u=Z2().domain([l,c]).rangeRound([s,o]);for(const[h,p]of a)a.set(h,u(p))}return a}function F5(r,e,t){r.clear();const n=new Set;for(const i of e)try{n.has(i.id)||(r.addNode(i.id,i),n.add(i.id))}catch(s){console.error(`[Graph] Error adding node '${i.id}`,s)}for(const i of t)if(!(!n.has(i.source)||!n.has(i.target)))try{r.addEdge(i.source,i.target,i)}catch(s){console.error(`[Graph] Error adding edge '${i.source} -> ${i.target}`,s)}return r}function k5({graph:r,layout:e,sizingType:t,labelType:n,sizingAttribute:i,defaultNodeSize:s,minNodeSize:o,maxNodeSize:a,clusterAttribute:l}){const c=[],u=[],h=new Map,p=N5({graph:r,type:t,attribute:i,minSize:o,maxSize:a,defaultSize:s}),m=r.nodes().length,v=c2({nodeCount:m,labelType:n});return r.forEachNode((_,y)=>{const g=e.getNodePosition(_),{data:x,fill:w,icon:E,label:b,size:M,...A}=y,P=p.get(y.id),C=v("node",P),F=(r.inboundNeighbors(y.id)||[]).map(I=>r.getNodeAttributes(I)),N={...y,size:P,labelVisible:C,label:b,icon:E,fill:w,cluster:l?x[l]:void 0,parents:F,data:{...A,...x??{}},position:{...g,x:g.x||0,y:g.y||0,z:g.z||1}};h.set(y.id,N),c.push(N)}),r.forEachEdge((_,y)=>{const g=h.get(y.source),x=h.get(y.target);if(g&&x){const{data:w,id:E,label:b,size:M,...A}=y,P=v("edge",M);u.push({...y,id:E,label:b,labelVisible:P,size:M,data:{...A,id:E,...w||{}}})}}),{nodes:c,edges:u}}const nr={mass:10,tension:1e3,friction:300,precision:.1};function h2(r,e,t){const n=e.getLength(),i=r==="end"?n:n/2,s=r==="end"?t/2:0,o=(i-s)/n,a=e.getPointAt(o),l=e.getTangentAt(o);return[a,l]}function f2(r){return[r+6,2+r/1.5]}const R0=.7;function d2(r,e,t=0){const n=new Y(r.x,r.y||0,r.z||0),i=new Y(e.x,e.y||0,e.z||0),s=new Y().addVectors(n,i).divideScalar(2);return s.setLength(s.length()+t)}function z5(r,e,t=-1){const n=r.clone(),i=e.clone(),s=new Y().subVectors(i,n),o=s.length(),a=s.clone().normalize(),l=new Y().subVectors(i,n).divideScalar(2),c=Math.abs(a.x)%1,u=new Y(-a.y,a.x-c*a.z,c*a.y).normalize(),h=new Y().add(n).add(l).add(u.multiplyScalar(o/4).multiplyScalar(t));return[r,h,e]}function Qu(r,e,t,n,i,s){const o=$E(r,t,e),a=$E(t,r,n);return i?new lp(...z5(o,a,s)):new vy(o,a)}function eh(r){return new Y(r.position.x,r.position.y,r.position.z||0)}function $E(r,e,t){const n=r.distanceTo(e);return r.clone().add(e.clone().sub(r).multiplyScalar(t/n))}function JE(r,e){return{...r,position:{...r.position,x:r.position.x+e.x,y:r.position.y+e.y,z:r.position.z+e.z}}}function B5({edge:r,edges:e,curved:t}){let n=t,i;const s=e.filter(o=>o.target===r.target&&o.source===r.source).map(o=>o.id);if(s.length>1){n=!0;const o=s.indexOf(r.id);s.length===2?i=o===0?R0:-R0:i=(o-Math.floor(s.length/2))*R0}return{curved:n,curveOffset:i}}function th(r){let e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let a of r)e=Math.min(e,a.position.x),t=Math.max(t,a.position.x),n=Math.min(n,a.position.y),i=Math.max(i,a.position.y),s=Math.min(s,a.position.z),o=Math.max(o,a.position.z);return{height:i-n,width:t-e,minX:e,maxX:t,minY:n,maxY:i,minZ:s,maxZ:o,x:(t+e)/2,y:(i+n)/2,z:(o+s)/2}}function G5(r,e){return e?r.reduce((t,n)=>{const i=n.data[e];return i&&t.set(i,[...t.get(i)||[],n]),t},new Map):new Map}function H5({nodes:r,clusterAttribute:e}){const t=new Map;if(e){const n=G5(r,e);for(const[i,s]of n){const o=th(s);t.set(i,{label:i,nodes:s,position:o})}}return t}const m_=({sensitivity:r=7,interval:e=50,timeout:t=0,disabled:n,onPointerOver:i,onPointerOut:s})=>{const o=K.useRef(!1),a=K.useRef(null),l=K.useRef(0),c=K.useRef({x:null,y:null,px:null,py:null}),u=K.useCallback(y=>{c.current.x=y.clientX,c.current.y=y.clientY},[]),h=K.useCallback(y=>{a.current=clearTimeout(a.current);const{px:g,x,py:w,y:E}=c.current;Math.abs(g-x)+Math.abs(w-E)<r?(l.current=1,i(y)):(c.current.px=x,c.current.py=E,a.current=setTimeout(()=>h(y),e))},[e,i,r]),p=K.useCallback(()=>{clearTimeout(a.current),typeof window<"u"&&document.removeEventListener("mousemove",u,!1)},[u]),m=K.useCallback(y=>{n||(o.current=!0,p(),l.current!==1&&(c.current.px=y.pointer.x,c.current.py=y.pointer.y,typeof window<"u"&&document.addEventListener("mousemove",u,!1),a.current=setTimeout(()=>h(y),t)))},[p,h,n,u,t]),v=K.useCallback(y=>{a.current=clearTimeout(a.current),l.current=0,s(y)},[s]),_=K.useCallback(y=>{o.current=!1,p(),l.current===1&&(a.current=setTimeout(()=>v(y),t))},[p,v,t]);return{pointerOver:m,pointerOut:_}},p2=({draggable:r,set:e,position:t,bounds:n,onDragStart:i,onDragEnd:s})=>{const o=Bn(y=>y.camera),a=Bn(y=>y.raycaster),l=Bn(y=>y.size),c=Bn(y=>y.gl),{mouse2D:u,mouse3D:h,offset:p,normal:m,plane:v}=K.useMemo(()=>({mouse2D:new De,mouse3D:new Y,offset:new Y,normal:new Y,plane:new Us}),[]),_=K.useMemo(()=>c.domElement.getBoundingClientRect(),[c.domElement]);return Pz({onDragStart:({event:y})=>{const{eventObject:g,point:x}=y;g.getWorldPosition(p).sub(x),h.copy(x),i()},onDrag:({xy:y,buttons:g,cancel:x})=>{if(g!==1){x();return}const w=(y[0]-((_==null?void 0:_.left)??0))/l.width*2-1,E=-((y[1]-((_==null?void 0:_.top)??0))/l.height)*2+1;u.set(w,E),a.setFromCamera(u,o),o.getWorldDirection(m).negate(),v.setFromNormalAndCoplanarPoint(m,h),a.ray.intersectPlane(v,h);const b=new Y(t.x,t.y,t.z).copy(h).add(p);if(n){const M=new Y((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,(n.minZ+n.maxZ)/2),A=(n.maxX-n.minX)/2,P=b.clone().sub(M);P.length()>A&&(P.normalize().multiplyScalar(A),b.copy(M).add(P))}return e(b)},onDragEnd:s},{drag:{enabled:r,threshold:10}})},{Provider:V5,useStore:qe}=vk(),W5=({actives:r=[],selections:e=[],collapsedNodeIds:t=[],theme:n})=>mk(i=>({theme:{...n,edge:{...n.edge,label:{...n.edge.label,fontSize:n.edge.label.fontSize??6}}},edges:[],nodes:[],collapsedNodeIds:t,clusters:new Map,panning:!1,draggingIds:[],actives:r,edgeContextMenus:new Set,edgeMeshes:[],selections:e,hoveredNodeId:null,drags:{},graph:new en({multi:!0}),setTheme:s=>i(o=>({...o,theme:s})),setClusters:s=>i(o=>({...o,clusters:s})),setEdgeContextMenus:s=>i(o=>({...o,edgeContextMenus:s})),setEdgeMeshes:s=>i(o=>({...o,edgeMeshes:s})),setPanning:s=>i(o=>({...o,panning:s})),setDrags:s=>i(o=>({...o,drags:s})),addDraggingId:s=>i(o=>({...o,draggingIds:[...o.draggingIds,s]})),removeDraggingId:s=>i(o=>({...o,draggingIds:o.draggingIds.filter(a=>a!==s)})),setActives:s=>i(o=>({...o,actives:s})),setSelections:s=>i(o=>({...o,selections:s})),setHoveredNodeId:s=>i(o=>({...o,hoveredNodeId:s})),setNodes:s=>i(o=>({...o,nodes:s,centerPosition:th(s)})),setEdges:s=>i(o=>({...o,edges:s})),setNodePosition:(s,o)=>i(a=>{var l,c;const u=a.nodes.find(_=>_.id===s),h=eh(u),m=new Y(o.x,o.y,o.z).sub(h),v=[...a.nodes];if((l=a.selections)!=null&&l.includes(s))(c=a.selections)==null||c.forEach(_=>{const y=a.nodes.find(g=>g.id===_);if(y){const g=a.nodes.indexOf(y);v[g]=JE(y,m)}});else{const _=a.nodes.indexOf(u);v[_]=JE(u,m)}return{...a,drags:{...a.drags,[s]:u},nodes:v}}),setCollapsedNodeIds:(s=[])=>i(o=>({...o,collapsedNodeIds:s})),setClusterPosition:(s,o)=>i(a=>{const l=new Map(a.clusters),c=l.get(s);if(c){const u=c.position,h=new Y(o.x-u.x,o.y-u.y,o.z-(u.z??0)),p=[...a.nodes],m={...a.drags};p.forEach((y,g)=>{y.cluster===s&&(p[g]={...y,position:{...y.position,x:y.position.x+h.x,y:y.position.y+h.y,z:y.position.z+(h.z??0)}},m[y.id]=y)});const v=p.filter(y=>y.cluster===s),_=th(v);return l.set(s,{...c,position:_}),{...a,drags:{...m,[s]:c},clusters:l,nodes:p}}return a})}));function m2({nodeId:r,nodes:e,edges:t,currentHiddenNodes:n,currentHiddenEdges:i}){const s=[],o=[],a=n.map(m=>m.id),l=i.map(m=>m.id),c=t.filter(m=>m.source===r),u=c.map(m=>m.target);o.push(...c);for(const m of u){const v=t.filter(y=>y.target===m&&y.source!==r);let _=!1;if((v.length===0||v.length>0&&!a.includes(m)&&v.map(g=>g.id).every(g=>l.includes(g)))&&(_=!0),_){const y=e.find(x=>x.id===m);y&&s.push(y);const g=m2({nodeId:m,nodes:e,edges:t,currentHiddenEdges:o,currentHiddenNodes:s});o.push(...g.hiddenEdges),s.push(...g.hiddenNodes)}}const h=Object.values(o.reduce((m,v)=>({...m,[v.id]:v}),{})),p=Object.values(s.reduce((m,v)=>({...m,[v.id]:v}),{}));return{hiddenEdges:h,hiddenNodes:p}}const X5=({collapsedIds:r,nodes:e,edges:t})=>{const n=[],i=[];for(const c of r){const{hiddenEdges:u,hiddenNodes:h}=m2({nodeId:c,nodes:e,edges:t,currentHiddenEdges:i,currentHiddenNodes:n});n.push(...h),i.push(...u)}const s=n.map(c=>c.id),o=i.map(c=>c.id),a=e.filter(c=>!s.includes(c.id)),l=t.filter(c=>!o.includes(c.id));return{visibleNodes:a,visibleEdges:l}},j5=({layoutType:r,sizingType:e,labelType:t,sizingAttribute:n,clusterAttribute:i,selections:s,nodes:o,edges:a,actives:l,collapsedNodeIds:c,defaultNodeSize:u,maxNodeSize:h,minNodeSize:p,layoutOverrides:m,constrainDragging:v})=>{const _=qe(D=>D.graph),y=qe(D=>D.clusters),g=qe(D=>D.nodes),x=qe(D=>D.setClusters),w=qe(D=>D.collapsedNodeIds),E=qe(D=>D.setEdges),b=qe(D=>D.nodes),M=qe(D=>D.setNodes),A=qe(D=>D.setSelections),P=qe(D=>D.setActives),C=qe(D=>D.drags),L=qe(D=>D.setDrags),F=qe(D=>D.setCollapsedNodeIds),N=K.useRef(!1),I=K.useRef(null),X=Bn(D=>D.camera),q=K.useRef(C),W=K.useRef([]);K.useEffect(()=>{var D;if(!i)return;const V=g.map(ee=>ee.id),Z=o.find(ee=>!V.includes(ee.id));if(Z){const ee=Z.data[i],ie=y.get(ee),ue={...q.current};(D=ie==null?void 0:ie.nodes)==null||D.forEach(ce=>ue[ce.id]=void 0),q.current=ue,L(ue)}},[g,o,i,y,L]);const{visibleEdges:O,visibleNodes:k}=K.useMemo(()=>X5({collapsedIds:w,nodes:o,edges:a}),[w,o,a]),G=K.useCallback(D=>{const V={...q.current};D.forEach(Z=>V[Z.id]=Z),q.current=V,L(V)},[L]),B=K.useCallback(async D=>{I.current=D||I5({...m,type:r,graph:_,drags:q.current,clusters:W==null?void 0:W.current,clusterAttribute:i}),await b5(I.current);const V=k5({graph:_,layout:I.current,sizingType:e,labelType:t,sizingAttribute:n,maxNodeSize:h,minNodeSize:p,defaultNodeSize:u,clusterAttribute:i}),Z=H5({nodes:V.nodes,clusterAttribute:i});v&&Z.forEach(ee=>{var ie,ue;const ce=W.current.get(ee.label);(ce==null?void 0:ce.nodes.length)===ee.nodes.length&&(ee.position=((ue=(ie=W.current)==null?void 0:ie.get(ee.label))==null?void 0:ue.position)??ee.position)}),E(V.edges),M(V.nodes),x(Z),i&&G(V.nodes)},[m,r,i,e,t,n,h,p,u,E,M,x]);return K.useEffect(()=>{q.current=C},[C,i,B]),K.useEffect(()=>{W.current=y},[y]),K.useEffect(()=>{const D=b.map(Z=>({...Z,labelVisible:c2({nodeCount:b==null?void 0:b.length,labelType:t,camera:X,nodePosition:Z==null?void 0:Z.position})("node",Z==null?void 0:Z.size)}));D.some((Z,ee)=>Z.labelVisible!==b[ee].labelVisible)&&M(D)},[X,X.zoom,X.position.z,M,b,t]),K.useEffect(()=>{N.current&&A(s)},[s,A]),K.useEffect(()=>{N.current&&P(l)},[l,P]),K.useEffect(()=>{async function D(){N.current=!1,F5(_,k,O),await B(),requestAnimationFrame(()=>N.current=!0)}D()},[k,O]),K.useEffect(()=>{N.current&&F(c)},[c,F]),K.useEffect(()=>{N.current&&(q.current={},L({}),B())},[r,B,L]),K.useEffect(()=>{N.current&&B(I.current)},[e,n,t,B]),{updateLayout:B}},nh=({text:r,fontSize:e=7,fontUrl:t,color:n="#2A6475",opacity:i=1,stroke:s,active:o,ellipsis:a=75,rotation:l})=>{const c=a&&!o?y5(r,a):r,u=K.useMemo(()=>new Ke(n),[n]),h=K.useMemo(()=>s?new Ke(s):void 0,[s]);return Ne.jsx(qA,{position:[0,0,1],children:Ne.jsx(f5,{font:t,fontSize:e,color:u,fillOpacity:i,textAlign:"center",outlineWidth:s?1:0,outlineColor:h,depthOffset:0,maxWidth:100,overflowWrap:"break-word",rotation:l,children:c})})},Y5=({color:r="#D8E6EA",size:e=1,opacity:t=.5,animated:n,strokeWidth:i=5,innerRadius:s=4,segments:o=25})=>{const a=K.useMemo(()=>new Ke(r),[r]),{ringSize:l,ringOpacity:c}=tr({from:{ringOpacity:0,ringSize:[1e-5,1e-5,1e-5]},to:{ringOpacity:t,ringSize:[e/2,e/2,1]},config:{...nr,duration:n?void 0:0}}),u=i/10,h=s+u;return Ne.jsx(qA,{position:[0,0,1],children:Ne.jsxs(An.mesh,{scale:l,children:[Ne.jsx("ringGeometry",{attach:"geometry",args:[s,h,o]}),Ne.jsx(An.meshBasicMaterial,{attach:"material",color:a,transparent:!0,depthTest:!1,opacity:c,side:vn,fog:!0})]})})},q5=({color:r,id:e,size:t,selected:n,opacity:i=1,animated:s})=>{const{scale:o,nodeOpacity:a}=tr({from:{scale:[1e-5,1e-5,1e-5],nodeOpacity:0},to:{scale:[t,t,t],nodeOpacity:i},config:{...nr,duration:s?void 0:0}}),l=K.useMemo(()=>new Ke(r),[r]),c=qe(u=>u.theme);return Ne.jsxs(Ne.Fragment,{children:[Ne.jsxs(An.mesh,{userData:{id:e,type:"node"},scale:o,children:[Ne.jsx("sphereGeometry",{attach:"geometry",args:[1,25,25]}),Ne.jsx(An.meshPhongMaterial,{attach:"material",side:vn,transparent:!0,fog:!0,opacity:a,color:l})]}),Ne.jsx(Y5,{opacity:n?.5:0,size:t,animated:s,color:n?c.ring.activeFill:c.ring.fill})]})},g2=K.createContext({controls:null,resetControls:()=>{},zoomIn:()=>{},zoomOut:()=>{},dollyIn:()=>{},dollyOut:()=>{},panLeft:()=>{},panRight:()=>{},panUp:()=>{},panDown:()=>{},freeze:()=>{},unFreeze:()=>{}}),zp=()=>{const r=K.useContext(g2);if(r===void 0)throw new Error("`useCameraControls` hook must be used within a `ControlsProvider` component");return r};Qn.install({THREE:{MOUSE:ab,Vector2:De,Vector3:Y,Vector4:Xt,Quaternion:si,Matrix4:yt,Spherical:lT,Box3:ir,Sphere:rr,Raycaster:Uy,MathUtils:{DEG2RAD:(jE=Od)==null?void 0:jE.DEG2RAD,clamp:(YE=Od)==null?void 0:YE.clamp}}});hT({ThreeCameraControls:Qn});const Bp={ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40},QE=new kp(Bp.ARROW_LEFT,100),eb=new kp(Bp.ARROW_RIGHT,100),tb=new kp(Bp.ARROW_UP,100),nb=new kp(Bp.ARROW_DOWN,100),Z5=K.forwardRef(({mode:r="rotate",children:e,animated:t,disabled:n,minDistance:i=1e3,maxDistance:s=5e4},o)=>{const a=K.useRef(null),l=Bn(F=>F.camera),c=Bn(F=>F.gl),u=r==="orbit",h=qe(F=>F.setPanning),p=qe(F=>F.draggingIds.length>0),m=K.useRef(0),[v,_]=K.useState(!1);Ep((F,N)=>{var I,X;(I=a.current)!=null&&I.enabled&&((X=a.current)==null||X.update(N)),u&&(a.current.azimuthAngle+=20*N*Od.DEG2RAD)},-1),K.useEffect(()=>()=>{var F;return(F=a.current)==null?void 0:F.dispose()},[]);const y=K.useCallback(()=>{var F;(F=a.current)==null||F.zoom(l.zoom/2,t)},[t,l.zoom]),g=K.useCallback(()=>{var F;(F=a.current)==null||F.zoom(-l.zoom/2,t)},[t,l.zoom]),x=K.useCallback(F=>{var N;(N=a.current)==null||N.dolly(F,t)},[t]),w=K.useCallback(F=>{var N;(N=a.current)==null||N.dolly(F,t)},[t]),E=K.useCallback(F=>{var N;u||(N=a.current)==null||N.truck(-.03*F.deltaTime,0,t)},[t,u]),b=K.useCallback(F=>{var N;u||(N=a.current)==null||N.truck(.03*F.deltaTime,0,t)},[t,u]),M=K.useCallback(F=>{var N;u||(N=a.current)==null||N.truck(0,.03*F.deltaTime,t)},[t,u]),A=K.useCallback(F=>{var N;u||(N=a.current)==null||N.truck(0,-.03*F.deltaTime,t)},[t,u]),P=K.useCallback(F=>{F.code==="Space"&&(r==="rotate"?a.current.mouseButtons.left=Qn.ACTION.TRUCK:a.current.mouseButtons.left=Qn.ACTION.ROTATE)},[r]),C=K.useCallback(F=>{F.code==="Space"&&(r==="rotate"?a.current.mouseButtons.left=Qn.ACTION.ROTATE:a.current.mouseButtons.left=Qn.ACTION.TRUCK)},[r]);K.useEffect(()=>(n||(QE.addEventListener("holding",b),eb.addEventListener("holding",E),tb.addEventListener("holding",M),nb.addEventListener("holding",A),typeof window<"u"&&(window.addEventListener("keydown",P),window.addEventListener("keyup",C))),()=>{QE.removeEventListener("holding",b),eb.removeEventListener("holding",E),tb.removeEventListener("holding",M),nb.removeEventListener("holding",A),typeof window<"u"&&(window.removeEventListener("keydown",P),window.removeEventListener("keyup",C))}),[n,P,C,A,b,E,M]),K.useEffect(()=>{n?(a.current.mouseButtons.left=Qn.ACTION.NONE,a.current.mouseButtons.middle=Qn.ACTION.NONE,a.current.mouseButtons.wheel=Qn.ACTION.NONE):(a.current.mouseButtons.left=Qn.ACTION.TRUCK,a.current.mouseButtons.middle=Qn.ACTION.TRUCK,a.current.mouseButtons.wheel=Qn.ACTION.DOLLY)},[n]),K.useEffect(()=>{const F=()=>h(!0),N=()=>h(!1),I=a.current;return I&&(I.addEventListener("control",F),I.addEventListener("controlend",N)),()=>{I&&(I.removeEventListener("control",F),I.removeEventListener("controlend",N))}},[a,h]),K.useEffect(()=>{p?(a.current.mouseButtons.left=Qn.ACTION.NONE,a.current.touches.one=Qn.ACTION.NONE):r==="rotate"?(a.current.mouseButtons.left=Qn.ACTION.ROTATE,a.current.touches.one=Qn.ACTION.TOUCH_ROTATE):(a.current.touches.one=Qn.ACTION.TOUCH_TRUCK,a.current.mouseButtons.left=Qn.ACTION.TRUCK)},[p,r]);const L=K.useMemo(()=>({controls:a.current,zoomIn:()=>y(),zoomOut:()=>g(),dollyIn:(F=1e3)=>x(F),dollyOut:(F=-1e3)=>w(F),panLeft:(F=100)=>b({deltaTime:F}),panRight:(F=100)=>E({deltaTime:F}),panDown:(F=100)=>A({deltaTime:F}),panUp:(F=100)=>M({deltaTime:F}),resetControls:F=>{var N;return(N=a.current)==null?void 0:N.reset(F)},freeze:()=>{a.current.truckSpeed&&(m.current=a.current.truckSpeed),a.current.truckSpeed=0},unFreeze:()=>a.current.truckSpeed=m.current}),[y,g,b,E,A,M,a.current]);return K.useImperativeHandle(o,()=>L),Ne.jsxs(g2.Provider,{value:L,children:[Ne.jsx("threeCameraControls",{ref:F=>{a.current=F,v||_(!0)},args:[l,c.domElement],smoothTime:.1,minDistance:i,dollyToCursor:!0,maxDistance:s}),e]})});function v2(r,e){const t=e.position.z;r<t?r-=t:r+=t;const n=e.fov/e.zoom*Math.PI/180;return 2*Math.tan(n/2)*Math.abs(r)}function K5(r,e){return v2(r,e)*e.aspect}function ib(r,e){var t,n,i,s;const o=K5(1,r),a=v2(1,r),l={x0:((t=r==null?void 0:r.position)==null?void 0:t.x)-o/2,x1:((n=r==null?void 0:r.position)==null?void 0:n.x)+o/2,y0:((i=r==null?void 0:r.position)==null?void 0:i.y)-a/2,y1:((s=r==null?void 0:r.position)==null?void 0:s.y)+a/2};return(e==null?void 0:e.x)>l.x0&&(e==null?void 0:e.x)<l.x1&&(e==null?void 0:e.y)>l.y0&&(e==null?void 0:e.y)<l.y1}function rb(r,e){return e.reduce((t,n)=>Math.abs(n-r%Math.PI)<Math.abs(t-r%Math.PI)?n:t)}function $5(r,e){const t=rb(r,[0,Math.PI]),n=rb(e,[Math.PI/2,3*Math.PI/2]);return{horizontalRotation:t-r%Math.PI,verticalRotation:n-e%Math.PI}}const pd=50,J5=({animated:r,disabled:e,layoutType:t})=>{const n=qe(_=>_.nodes),[i,s]=K.useState(!1),o=Bn(_=>_.invalidate),{controls:a}=zp(),l=Bn(_=>_.camera),c=K.useRef(!1),u=K.useCallback(async(_,y)=>{const g=(y==null?void 0:y.animated)!==void 0?y==null?void 0:y.animated:!0,x=(y==null?void 0:y.centerOnlyIfNodesNotInView)!==void 0?y==null?void 0:y.centerOnlyIfNodesNotInView:!1;if(!c.current||!x||x&&(_!=null&&_.some(w=>!ib(l,w.position)))){const{x:w,y:E,z:b}=th(_);await a.setTarget(w,E,b,g),i||s(!0),o()}},[o,a,n]),h=K.useCallback(async(_,y={animated:!0,fitOnlyIfNodesNotInView:!1})=>{const{fitOnlyIfNodesNotInView:g}=y;if(!g||g&&(_!=null&&_.some(x=>!ib(l,x.position)))){const{minX:x,maxX:w,minY:E,maxY:b,minZ:M,maxZ:A}=th(_);if(!t.includes("3d")){const{horizontalRotation:P,verticalRotation:C}=$5(a==null?void 0:a.azimuthAngle,a==null?void 0:a.polarAngle);a==null||a.rotate(P,C,!0)}await(a==null?void 0:a.zoomTo(1,y==null?void 0:y.animated)),await(a==null?void 0:a.fitToBox(new ir(new Y(x,E,M),new Y(w,b,A)),y==null?void 0:y.animated,{cover:!1,paddingLeft:pd,paddingRight:pd,paddingBottom:pd,paddingTop:pd}))}},[l,a,t]),p=K.useCallback(_=>{let y=null;return _!=null&&_.length&&(y=_.reduce((g,x)=>{const w=n.find(E=>E.id===x);if(w)g.push(w);else throw new Error(`Attempted to center ${x} but it was not found in the nodes`);return g},[])),y},[n]),m=K.useCallback((_,y)=>{const g=p(_);u(g||n,{animated:r,centerOnlyIfNodesNotInView:y==null?void 0:y.centerOnlyIfNodesNotInView})},[r,u,p,n]),v=K.useCallback(async(_,y)=>{const g=p(_);await h(g||n,{animated:r,...y})},[r,h,p,n]);return K.useLayoutEffect(()=>{async function _(){a&&(n!=null&&n.length)&&(c.current||(await u(n,{animated:!1}),await h(n,{animated:!1}),c.current=!0))}_()},[a,u,n,r,l,h]),{centerNodes:u,centerNodesById:m,fitNodesInViewById:v,isCentered:i}},Q5=({image:r,id:e,size:t,opacity:n=1,animated:i})=>{const s=K.useMemo(()=>new KM().load(r),[r]),{scale:o,spriteOpacity:a}=tr({from:{scale:[1e-5,1e-5,1e-5],spriteOpacity:0},to:{scale:[t,t,t],spriteOpacity:n},config:{...nr,duration:i?void 0:0}});return Ne.jsx(An.sprite,{userData:{id:e,type:"node"},scale:o,children:Ne.jsx(An.spriteMaterial,{attach:"material",opacity:a,fog:!0,depthTest:!1,transparent:!0,side:vn,children:Ne.jsx("primitive",{attach:"map",object:s,minFilter:fn})})})},eH=({animated:r,disabled:e,id:t,draggable:n=!1,labelFontUrl:i,contextMenu:s,onClick:o,onDoubleClick:a,onPointerOver:l,onDragged:c,onPointerOut:u,onContextMenu:h,renderNode:p,constrainDragging:m})=>{var v,_,y;const g=zp(),x=qe(ne=>ne.theme),w=qe(ne=>ne.nodes.find(we=>we.id===t)),E=qe(ne=>ne.edges),b=qe(ne=>ne.draggingIds),M=qe(ne=>ne.collapsedNodeIds),A=qe(ne=>ne.addDraggingId),P=qe(ne=>ne.removeDraggingId),C=qe(ne=>ne.setHoveredNodeId),L=qe(ne=>ne.setNodePosition),F=qe(ne=>ne.setCollapsedNodeIds),N=qe(ne=>ne.collapsedNodeIds.includes(t)),I=qe(ne=>{var we;return(we=ne.actives)==null?void 0:we.includes(t)}),X=qe(ne=>{var we;return(we=ne.selections)==null?void 0:we.includes(t)}),q=qe(ne=>{var we;return((we=ne.selections)==null?void 0:we.length)>0}),W=qe(ne=>ne.centerPosition),O=qe(ne=>ne.clusters.get(w.cluster)),k=b.includes(t),G=b.length>0,{position:B,label:D,subLabel:V,size:Z=7,labelVisible:ee=!0}=w,ie=K.useRef(null),[ue,ce]=K.useState(!1),[le,Ae]=K.useState(!1),Ee=ue||X||I,ae=q?Ee?x.node.selectedOpacity:x.node.inactiveOpacity:x.node.opacity,z=K.useMemo(()=>E.filter(we=>we.source===t).length>0||N,[E,t,N]),oe=K.useCallback(()=>{z&&F(N?M.filter(ne=>ne!==t):[...M,t])},[z,M,t,N,F]),[{nodePosition:te,labelPosition:se,subLabelPosition:$}]=tr(()=>({from:{nodePosition:W?[W.x,W.y,0]:[0,0,0],labelPosition:[0,-(Z+7),2],subLabelPosition:[0,-(Z+14),2]},to:{nodePosition:B?[B.x,B.y,Ee?B.z+1:B.z]:[0,0,0],labelPosition:[0,-(Z+7),2],subLabelPosition:[0,-(Z+14),2]},config:{...nr,duration:r&&!G?void 0:0}}),[k,B,r,Z,Ee]),Ie=p2({draggable:n,position:B,bounds:m?O==null?void 0:O.position:void 0,set:ne=>L(t,ne),onDragStart:()=>{A(t),ce(!0)},onDragEnd:()=>{P(t),c==null||c(w)}});ya(ue&&!G&&o!==void 0,"pointer"),ya(ue&&n&&!k&&o===void 0,"grab"),ya(k,"grabbing");const de=Ee||k,Se=de?x.node.activeFill:w.fill||x.node.fill,{pointerOver:Le,pointerOut:ge}=m_({disabled:e||k,onPointerOver:ne=>{g.freeze(),ce(!0),l==null||l(w,ne),C(t)},onPointerOut:ne=>{g.unFreeze(),ce(!1),u==null||u(w,ne),C(null)}}),He=K.useMemo(()=>p?p({id:t,color:Se,size:Z,active:de,opacity:ae,animated:r,selected:X,node:w}):Ne.jsx(Ne.Fragment,{children:w.icon?Ne.jsx(Q5,{id:t,image:w.icon||"",size:Z+8,opacity:ae,animated:r,color:Se,node:w,active:de,selected:X}):Ne.jsx(q5,{id:t,size:Z,opacity:ae,animated:r,color:Se,node:w,active:de,selected:X})}),[p,t,Se,Z,de,ae,r,X,w]),j=K.useMemo(()=>{var ne,we,be;return ee&&(ee||X||ue)&&D&&Ne.jsxs(Ne.Fragment,{children:[Ne.jsx(An.group,{position:se,children:Ne.jsx(nh,{text:D,fontUrl:i,opacity:ae,stroke:x.node.label.stroke,active:X||ue||k||I,color:X||ue||k||I?x.node.label.activeColor:x.node.label.color})}),V&&Ne.jsx(An.group,{position:$,children:Ne.jsx(nh,{text:V,fontUrl:i,fontSize:5,opacity:ae,stroke:(ne=x.node.subLabel)==null?void 0:ne.stroke,active:X||ue||k||I,color:X||ue||k||I?(we=x.node.subLabel)==null?void 0:we.activeColor:(be=x.node.subLabel)==null?void 0:be.color})})]})},[ue,I,k,X,D,i,se,ee,ae,V,$,x.node.label.activeColor,x.node.label.color,x.node.label.stroke,(v=x.node.subLabel)==null?void 0:v.activeColor,(_=x.node.subLabel)==null?void 0:_.color,(y=x.node.subLabel)==null?void 0:y.stroke]),H=K.useMemo(()=>le&&s&&Ne.jsx($y,{prepend:!0,center:!0,children:s({data:w,canCollapse:z,isCollapsed:N,onCollapse:oe,onClose:()=>Ae(!1)})}),[le,s,w,z,N,oe]);return Ne.jsxs(An.group,{renderOrder:1,userData:{id:t,type:"node"},ref:ie,position:te,onPointerOver:Le,onPointerOut:ge,onClick:ne=>{!e&&!k&&(o==null||o(w,{canCollapse:z,isCollapsed:N},ne))},onDoubleClick:ne=>{!e&&!k&&(a==null||a(w,ne))},onContextMenu:()=>{e||(Ae(!0),h==null||h(w,{canCollapse:z,isCollapsed:N,onCollapse:oe}))},...Ie(),children:[He,H,j]})},tH=({animated:r,color:e="#D8E6EA",length:t,opacity:n=.5,position:i,rotation:s,size:o=1,onActive:a,onContextMenu:l})=>{const c=K.useMemo(()=>new Ke(e),[e]),u=K.useRef(null),h=qe(y=>y.draggingIds.length>0),p=qe(y=>y.centerPosition),[{pos:m,arrowOpacity:v}]=tr(()=>({from:{pos:p?[p.x,p.y,p.z]:[0,0,0],arrowOpacity:0},to:{pos:[i.x,i.y,i.z],arrowOpacity:n},config:{...nr,duration:r&&!h?void 0:0}}),[r,h,n,i]),_=K.useCallback(()=>{var y;const g=new Y(0,1,0);(y=u.current)==null||y.quaternion.setFromUnitVectors(g,s)},[s,u]);return K.useEffect(()=>_(),[_]),Ne.jsxs(An.mesh,{position:m,ref:u,scale:[1,1,1],onPointerOver:()=>a(!0),onPointerOut:()=>a(!1),onPointerDown:y=>{y.nativeEvent.buttons===2&&(y.stopPropagation(),l())},children:[Ne.jsx("cylinderGeometry",{args:[0,o,t,20,1,!0],attach:"geometry"}),Ne.jsx(An.meshBasicMaterial,{attach:"material",color:c,depthTest:!1,opacity:v,transparent:!0,side:vn,fog:!0})]})},nH=({curveOffset:r,animated:e,color:t="#000",curve:n,curved:i=!1,id:s,opacity:o=1,size:a=1,onContextMenu:l,onClick:c,onPointerOver:u,onPointerOut:h})=>{const p=K.useRef(null),m=qe(x=>x.draggingIds.length>0),v=K.useMemo(()=>new Ke(t),[t]),_=qe(x=>x.centerPosition),y=K.useRef(!1),{lineOpacity:g}=tr({from:{lineOpacity:0},to:{lineOpacity:o},config:{...nr,duration:e?void 0:0}});return tr(()=>{const x=n.getPoint(0),w=n.getPoint(1);return{from:{fromVertices:y.current?[w==null?void 0:w.x,w==null?void 0:w.y,(w==null?void 0:w.z)||0]:[_==null?void 0:_.x,_==null?void 0:_.y,(_==null?void 0:_.z)||0],toVertices:[x==null?void 0:x.x,x==null?void 0:x.y,(x==null?void 0:x.z)||0]},to:{fromVertices:[x==null?void 0:x.x,x==null?void 0:x.y,(x==null?void 0:x.z)||0],toVertices:[w==null?void 0:w.x,w==null?void 0:w.y,(w==null?void 0:w.z)||0]},onChange:E=>{const{fromVertices:b,toVertices:M}=E.value,A=new Y(...b),P=new Y(...M),C=Qu(A,0,P,0,i,r);p.current.copy(new ba(C,20,a/2,5,!1))},config:{...nr,duration:e&&!m?void 0:0}}},[e,m,n,a]),K.useEffect(()=>{y.current=!0},[]),Ne.jsxs("mesh",{userData:{id:s,type:"edge"},onPointerOver:u,onPointerOut:h,onClick:c,onPointerDown:x=>{x.nativeEvent.buttons===2&&(x.stopPropagation(),l())},children:[Ne.jsx("tubeGeometry",{attach:"geometry",ref:p}),Ne.jsx(An.meshBasicMaterial,{attach:"material",opacity:g,fog:!0,transparent:!0,depthTest:!1,color:v})]})},sb=3,iH=({animated:r,arrowPlacement:e="end",contextMenu:t,disabled:n,labelPlacement:i="inline",id:s,interpolation:o,labelFontUrl:a,onContextMenu:l,onClick:c,onPointerOver:u,onPointerOut:h})=>{const p=qe(oe=>oe.theme),m=qe(oe=>oe.draggingIds.length>0),[v,_]=K.useState(!1),[y,g]=K.useState(!1),x=qe(oe=>oe.edges),w=x.find(oe=>oe.id===s),{target:E,source:b,label:M,labelVisible:A=!1,size:P=1,fill:C}=w,L=qe(oe=>oe.nodes.find(te=>te.id===b)),F=qe(oe=>oe.nodes.find(te=>te.id===E)),N=(P+p.edge.label.fontSize)/2,[I,X]=K.useMemo(()=>f2(P),[P]),{curveOffset:q,curved:W}=K.useMemo(()=>B5({edge:w,edges:x,curved:o==="curved"}),[w,x,o]),[O,k,G]=K.useMemo(()=>{const oe=eh(L),te=L.size,se=eh(F),$=F.size;let Ie=Qu(oe,te,se,$,W,q);const[de,Se]=h2(e,Ie,I);return e==="end"&&(Ie=Qu(oe,te,de,0,W,q)),[Ie,de,Se]},[L,F,W,q,e,I]),B=K.useMemo(()=>{let oe=d2(L.position,F.position,u2(N,i));if(W){const te=new Y().subVectors(oe,O.getPoint(.5));switch(i){case"above":te.y=te.y-sb;break;case"below":te.y=te.y+sb;break}oe=oe.sub(te)}return oe},[L.position,F.position,N,i,W,O]),D=qe(oe=>{var te;return(te=oe.selections)==null?void 0:te.includes(s)}),V=qe(oe=>{var te;return(te=oe.selections)==null?void 0:te.length}),Z=qe(oe=>{var te;return(te=oe.actives)==null?void 0:te.includes(s)}),ee=qe(oe=>oe.centerPosition),ie=V?D||Z?p.edge.selectedOpacity:p.edge.inactiveOpacity:p.edge.opacity,[{labelPosition:ue}]=tr(()=>({from:{labelPosition:ee?[ee.x,ee.y,ee.z]:[0,0,0]},to:{labelPosition:[B.x,B.y,B.z]},config:{...nr,duration:r&&!m?void 0:0}}),[B,r,m]),ce=K.useMemo(()=>new Eo(0,0,i==="natural"?0:Math.atan((F.position.y-L.position.y)/(F.position.x-L.position.x))),[F.position.x,F.position.y,L.position.x,L.position.y,i]);ya(v&&!m&&c!==void 0,"pointer");const{pointerOver:le,pointerOut:Ae}=m_({disabled:n,onPointerOver:oe=>{_(!0),u==null||u(w,oe)},onPointerOut:oe=>{_(!1),h==null||h(w,oe)}}),Ee=K.useMemo(()=>e!=="none"&&Ne.jsx(tH,{animated:r,color:D||v||Z?p.arrow.activeFill:C||p.arrow.fill,length:I,opacity:ie,position:k,rotation:G,size:X,onActive:_,onContextMenu:()=>{n||(g(!0),l==null||l(w))}}),[C,v,r,I,e,k,G,X,n,w,Z,D,l,ie,p.arrow.activeFill,p.arrow.fill]),ae=K.useMemo(()=>A&&M&&Ne.jsx(An.group,{position:ue,onContextMenu:()=>{n||(g(!0),l==null||l(w))},onPointerOver:le,onPointerOut:Ae,children:Ne.jsx(nh,{text:M,ellipsis:15,fontUrl:a,stroke:p.edge.label.stroke,color:D||v||Z?p.edge.label.activeColor:p.edge.label.color,opacity:ie,fontSize:p.edge.label.fontSize,rotation:ce})}),[v,n,w,Z,D,M,a,ue,ce,A,l,Ae,le,ie,p.edge.label.activeColor,p.edge.label.color,p.edge.label.fontSize,p.edge.label.stroke]),z=K.useMemo(()=>y&&t&&Ne.jsx($y,{prepend:!0,center:!0,position:B,children:t({data:w,onClose:()=>g(!1)})}),[y,t,B,w]);return Ne.jsxs("group",{children:[Ne.jsx(nH,{curveOffset:q,animated:r,color:D||v||Z?p.edge.activeFill:C||p.edge.fill,curve:O,curved:W,id:s,opacity:ie,size:P,onClick:oe=>{n||c==null||c(w,oe)},onPointerOver:le,onPointerOut:Ae,onContextMenu:()=>{n||(g(!0),l==null||l(w))}}),Ee,ae,z]})},ob=new Ws(0,0,0);function rH(r,e){const t=K.useRef(),n=qe(c=>c.theme);qe(c=>{t.current=c});const i=K.useRef(new Map);K.useRef(new Ws(0,0,0));const s=K.useRef(),o=e==="curved",a=K.useCallback(c=>{const u=[],h=i.current,{nodes:p}=t.current,m=new Map(p.map(_=>[_.id,_])),v=n.edge.label.fontSize;return r!=="none"&&!s.current&&(s.current=new La(0,1,1,20,1,!0)),c.forEach(_=>{const{target:y,source:g,size:x=1}=_,w=m.get(g),E=m.get(y);if(!w||!E)return;const b=`${w.position.x},${w.position.y},${E.position.x},${E.position.y},${x}`;if(h.has(b)){u.push(h.get(b));return}const M=eh(w),A=w.size+v,P=eh(E),C=E.size+v;let L=Qu(M,A,P,C,o),F=new ba(L,20,x/2,5,!1);if(r==="none"){u.push(F),h.set(b,F);return}const[N,I]=f2(x),X=s.current.clone();X.scale(I,N,I);const[q,W]=h2(r,L,N),O=new si;if(O.setFromUnitVectors(new Y(0,1,0),W),X.applyQuaternion(O),X.translate(q.x,q.y,q.z),r&&r==="end"){const G=Qu(M,A,q,0,o);F=new ba(G,20,x/2,5,!1)}const k=od([F,X]);u.push(k),h.set(b,k)}),u},[r,o,n.edge.label.fontSize]),l=K.useCallback((c,u)=>{const h=a(c),p=a(u);return od([p.length?od(p):ob,h.length?od(h):ob],!0)},[a]);return{getGeometries:a,getGeometry:l}}function sH(r,e,t){const n=K.useRef(r);K.useEffect(()=>{n.current=r},[r]);const i=qe(h=>h.edgeContextMenus),s=qe(K.useCallback(h=>h.setEdgeContextMenus,[])),o=K.useRef(!1),a=K.useCallback(()=>{o.current=!0},[]),l=K.useRef(!1),c=K.useCallback(()=>{l.current=!0},[]),u=K.useCallback((h,p)=>{const{onClick:m,onContextMenu:v,onPointerOver:_,onPointerOut:y}=n.current;if(m&&o.current&&!t){o.current=!1;for(const g of p)m(g)}if((e||v)&&l.current&&!t){l.current=!1;const g=new Set(i);let x=!1;for(const w of p)i.has(w.id)||(g.add(w.id),x=!0,v==null||v(w));x&&s(g)}_&&p.filter(x=>!h.includes(x)).forEach(x=>{_(x)}),y&&h.filter(x=>!p.includes(x)).forEach(x=>{y(x)})},[e,t,i,s]);return{handleClick:a,handleContextMenu:c,handleIntersections:u}}function oH(r,e){const t=K.useRef(r),n=K.useRef();K.useEffect(()=>{t.current=r;const o=r.getAttribute("position");n.current=new Float32Array(o.array.length)},[r]);const i=K.useCallback(()=>{const o=t.current.getAttribute("position");return{from:new Float32Array(o.array.length),to:o.array}},[]),s=K.useCallback(o=>{const a=n.current;a.set(o);const l=new $t(a,3,!1);t.current.setAttribute("position",l),l.needsUpdate=!0},[]);tr(()=>{if(!e)return null;const o=i();return{from:{positions:o.from},to:{positions:o.to},onChange:a=>{s(a.value.positions)},config:{...nr,duration:e?void 0:0}}},[e,i,s])}function aH(r,e,t){const[{activeOpacity:n,inactiveOpacity:i}]=tr(()=>({from:{activeOpacity:0,inactiveOpacity:0},to:{activeOpacity:e?t.edge.selectedOpacity:t.edge.opacity,inactiveOpacity:e?t.edge.inactiveOpacity:t.edge.opacity},config:{...nr,duration:r?void 0:0}}),[r,e,t]);return{activeOpacity:n,inactiveOpacity:i}}const lH=({animated:r,color:e,contextMenu:t,edge:n,labelFontUrl:i,labelPlacement:s="inline",opacity:o})=>{const a=qe(L=>L.theme),{target:l,source:c,label:u,labelVisible:h=!1,size:p=1}=n,m=qe(L=>L.nodes),[v,_]=K.useMemo(()=>[m.find(L=>L.id===c),m.find(L=>L.id===l)],[m,c,l]),y=qe(L=>L.draggingIds.length>0),g=K.useMemo(()=>(p+a.edge.label.fontSize)/2,[p,a.edge.label.fontSize]),x=K.useMemo(()=>d2(v.position,_.position,u2(g,s)),[v.position,_.position,g,s]),w=qe(L=>L.edgeContextMenus),E=qe(L=>L.setEdgeContextMenus),[{labelPosition:b}]=tr(()=>({from:{labelPosition:[0,0,0]},to:{labelPosition:[x.x,x.y,x.z]},config:{...nr,duration:r&&!y?void 0:0}}),[x,r,y]),M=K.useCallback(L=>{w.delete(L),E(new Set(w))},[w,E]),A=K.useMemo(()=>s==="natural"?new Eo(0,0,0):new Eo(0,0,Math.atan2(_.position.y-v.position.y,_.position.x-v.position.x)),[s,_.position.y,_.position.x,v.position.y,v.position.x]),P=K.useMemo(()=>({prepend:!0,center:!0,position:x}),[x]),C=K.useMemo(()=>({text:u,ellipsis:15,fontUrl:i,stroke:a.edge.label.stroke,color:e,opacity:o,fontSize:a.edge.label.fontSize,rotation:A}),[u,i,a.edge.label.stroke,e,o,a.edge.label.fontSize,A]);return Ne.jsxs("group",{children:[h&&u&&Ne.jsx(An.group,{position:b,children:Ne.jsx(nh,{...C})}),t&&w.has(n.id)&&Ne.jsx($y,{...P,children:t({data:n,onClose:()=>M(n.id)})})]})},cH=({interpolation:r="linear",arrowPlacement:e="end",labelPlacement:t="inline",animated:n,contextMenu:i,disabled:s,edges:o,labelFontUrl:a,onClick:l,onContextMenu:c,onPointerOut:u,onPointerOver:h})=>{const p=qe(B=>B.theme),{getGeometries:m,getGeometry:v}=rH(e,r),_=qe(B=>B.draggingIds),y=qe(B=>B.edgeMeshes),g=qe(B=>B.setEdgeMeshes),x=qe(B=>B.actives||[]),w=qe(B=>B.selections||[]),[E,b,M,A]=K.useMemo(()=>{const B=[],D=[],V=[],Z=[];return o.forEach(ee=>{if(_.includes(ee.source)||_.includes(ee.target)){w.includes(ee.id)||x.includes(ee.id)?V.push(ee):Z.push(ee);return}w.includes(ee.id)||x.includes(ee.id)?B.push(ee):D.push(ee)}),[B,D,V,Z]},[o,x,w,_]),P=!!w.length,C=K.useMemo(()=>v(E,b),[v,E,b]),{activeOpacity:L,inactiveOpacity:F}=aH(n,P,p);oH(C,n),K.useEffect(()=>{if(_.length===0){const D=m(o).map(V=>new _n(V));g(D)}},[m,g,o,_.length]);const N=K.useRef(new _n),I=K.useRef(new _n),X=K.useCallback(B=>{if(!B.camera)return[];const D=B.intersectObjects(y);return D.length?D.map(V=>o[y.indexOf(V.object)]):[]},[y,o]),{handleClick:q,handleContextMenu:W,handleIntersections:O}=sH({onClick:l,onContextMenu:c,onPointerOut:u,onPointerOver:h},i,s),k=K.useRef([]),G=K.useRef([]);return Ep(B=>{if(N.current.geometry=C,s)return;const D=k.current;if((_.length||_.length===0&&D!==null)&&(I.current.geometry=v(M,A)),k.current=_,_.length)return;const V=G.current,Z=X(B.raycaster);O(V,Z),Z.join()!==V.join()&&(I.current.geometry=v(Z,[])),G.current=Z}),Ne.jsxs("group",{onClick:q,onContextMenu:W,children:[Ne.jsxs("mesh",{ref:N,children:[Ne.jsx(An.meshBasicMaterial,{attach:"material-0",color:p.edge.fill,depthTest:!1,fog:!0,opacity:F,side:vn,transparent:!0}),Ne.jsx(An.meshBasicMaterial,{attach:"material-1",color:p.edge.activeFill,depthTest:!1,fog:!0,opacity:L,side:vn,transparent:!0})]}),Ne.jsxs("mesh",{ref:I,children:[Ne.jsx(An.meshBasicMaterial,{attach:"material-0",color:p.edge.fill,depthTest:!1,fog:!0,opacity:F,side:vn,transparent:!0}),Ne.jsx(An.meshBasicMaterial,{attach:"material-1",color:p.edge.activeFill,depthTest:!1,fog:!0,opacity:L,side:vn,transparent:!0})]}),o.map(B=>Ne.jsx(lH,{animated:n,contextMenu:i,color:p.edge.label.color,disabled:s,edge:B,labelFontUrl:a,labelPlacement:t},B.id))]})},uH=({outerRadius:r,innerRadius:e,padding:t,normalizedFill:n,normalizedStroke:i,opacity:s,animated:o,theme:a})=>{var l;const{opacity:c}=tr({from:{opacity:0},to:{opacity:s},config:{...nr,duration:o?void 0:0}});return Ne.jsxs(Ne.Fragment,{children:[Ne.jsxs("mesh",{children:[Ne.jsx("ringGeometry",{attach:"geometry",args:[r,0,128]}),Ne.jsx(An.meshBasicMaterial,{attach:"material",color:n,transparent:!0,depthTest:!1,opacity:(l=a.cluster)!=null&&l.fill?c:0,side:vn,fog:!0})]}),Ne.jsxs("mesh",{children:[Ne.jsx("ringGeometry",{attach:"geometry",args:[r,e+t,128]}),Ne.jsx(An.meshBasicMaterial,{attach:"material",color:i,transparent:!0,depthTest:!1,opacity:c,side:vn,fog:!0})]})]})},hH=({animated:r,position:e,padding:t=40,labelFontUrl:n,disabled:i,radius:s=2,nodes:o,label:a,onClick:l,onPointerOver:c,onPointerOut:u,draggable:h=!1,onDragged:p,onRender:m})=>{var v,_,y,g,x,w,E;const b=qe(z=>z.theme),M=Math.max(e.width,e.height)/2,A=M-s+t,[P,C]=K.useState(!1),L=qe(z=>z.centerPosition),F=qe(z=>z.nodes),N=zp(),I=qe(z=>z.draggingIds),X=I.includes(a),q=I.length>0,W=qe(z=>{var oe;return(oe=z.actives)==null?void 0:oe.some(te=>o.some(se=>se.id===te))}),O=qe(z=>z.hoveredNodeId),k=qe(z=>{var oe;return(oe=z.selections)==null?void 0:oe.some(te=>o.some(se=>se.id===te))}),B=qe(z=>{var oe;return((oe=z.selections)==null?void 0:oe.length)>0})?k||P||W?(v=b.cluster)==null?void 0:v.selectedOpacity:(_=b.cluster)==null?void 0:_.inactiveOpacity:(y=b.cluster)==null?void 0:y.opacity,D=K.useMemo(()=>{var z,oe;const te=[0,-A,2],se=(oe=(z=b.cluster)==null?void 0:z.label)==null?void 0:oe.offset;return se?[te[0]-se[0],te[1]-se[1],te[2]-se[2]]:te},[A,(x=(g=b.cluster)==null?void 0:g.label)==null?void 0:x.offset]),{circlePosition:V}=tr({from:{circlePosition:[L.x,L.y,-1]},to:{circlePosition:e?[e.x,e.y,-1]:[0,0,-1]},config:{...nr,duration:r&&!q?void 0:0}}),Z=K.useMemo(()=>{var z;return new Ke((z=b.cluster)==null?void 0:z.stroke)},[(w=b.cluster)==null?void 0:w.stroke]),ee=K.useMemo(()=>{var z;return new Ke((z=b.cluster)==null?void 0:z.fill)},[(E=b.cluster)==null?void 0:E.fill]),ie=qe(z=>z.addDraggingId),ue=qe(z=>z.removeDraggingId),ce=qe(z=>z.setClusterPosition),le=p2({draggable:h&&!O,position:{x:e.x,y:e.y,z:-1},set:z=>ce(a,z),onDragStart:()=>{ie(a),C(!0)},onDragEnd:()=>{ue(a),C(!1);const z=F.filter(oe=>oe.cluster===a);p==null||p({nodes:z,label:a})}});ya(P&&!q&&l!==void 0,"pointer"),ya(P&&h&&!X&&l===void 0,"grab"),ya(X,"grabbing");const{pointerOver:Ae,pointerOut:Ee}=m_({disabled:i,onPointerOver:z=>{C(!0),N.freeze(),c==null||c({nodes:o,label:a},z)},onPointerOut:z=>{C(!1),N.unFreeze(),u==null||u({nodes:o,label:a},z)}});return K.useMemo(()=>{var z,oe,te;return b.cluster&&Ne.jsx(An.group,{userData:{id:a,type:"cluster"},position:V,onPointerOver:Ae,onPointerOut:Ee,onClick:se=>{!i&&!X&&(l==null||l({nodes:o,label:a},se))},...le(),children:m?m({label:{position:D,text:a,opacity:B,fontUrl:n},opacity:B,outerRadius:A,innerRadius:M,padding:t,theme:b}):Ne.jsxs(Ne.Fragment,{children:[Ne.jsx(uH,{outerRadius:A,innerRadius:M,padding:t,normalizedFill:ee,normalizedStroke:Z,opacity:B,animated:r,theme:b}),((z=b.cluster)==null?void 0:z.label)&&Ne.jsx(An.group,{position:D,children:Ne.jsx(nh,{text:a,opacity:B,fontUrl:n,stroke:b.cluster.label.stroke,active:!1,color:(oe=b.cluster)==null?void 0:oe.label.color,fontSize:((te=b.cluster)==null?void 0:te.label.fontSize)??12})})]})})},[b,V,Ae,Ee,A,ee,M,t,Z,D,a,B,n,i,l,o,le,X,m,r])},fH=K.forwardRef(({onNodeClick:r,onNodeDoubleClick:e,onNodeContextMenu:t,onEdgeContextMenu:n,onEdgeClick:i,onEdgePointerOver:s,onEdgePointerOut:o,onNodePointerOver:a,onNodePointerOut:l,onClusterClick:c,onNodeDragged:u,onClusterDragged:h,onClusterPointerOver:p,onClusterPointerOut:m,contextMenu:v,animated:_,disabled:y,draggable:g,constrainDragging:x=!1,edgeLabelPosition:w,edgeArrowPosition:E,edgeInterpolation:b="linear",labelFontUrl:M,renderNode:A,onRenderCluster:P,...C},L)=>{const{layoutType:F,clusterAttribute:N}=C,I=Bn(le=>le.gl),X=Bn(le=>le.scene),q=Bn(le=>le.camera),{updateLayout:W}=j5({...C,constrainDragging:x});if(N&&!(F==="forceDirected2d"||F==="forceDirected3d"))throw new Error("Clustering is only supported for the force directed layouts.");const O=qe(le=>le.graph),k=qe(le=>le.nodes),G=qe(le=>le.edges),B=qe(le=>[...le.clusters.values()]),{centerNodesById:D,fitNodesInViewById:V,isCentered:Z}=J5({animated:_,disabled:y,layoutType:F});K.useImperativeHandle(L,()=>({centerGraph:D,fitNodesInView:V,graph:O,renderScene:()=>I.render(X,q)}),[D,V,O,I,X,q]);const ee=K.useCallback(le=>{u==null||u(le),N&&W()},[N,u,W]),ie=K.useMemo(()=>k.map(le=>Ne.jsx(eH,{id:le==null?void 0:le.id,labelFontUrl:M,draggable:g,constrainDragging:x,disabled:y,animated:_,contextMenu:v,renderNode:A,onClick:r,onDoubleClick:e,onContextMenu:t,onPointerOver:a,onPointerOut:l,onDragged:ee},le==null?void 0:le.id)),[x,_,v,y,g,M,k,r,t,e,ee,l,a,A]),ue=K.useMemo(()=>_?G.map(le=>Ne.jsx(iH,{id:le.id,disabled:y,animated:_,labelFontUrl:M,labelPlacement:w,arrowPlacement:E,interpolation:b,contextMenu:v,onClick:i,onContextMenu:n,onPointerOver:s,onPointerOut:o},le.id)):Ne.jsx(cH,{edges:G,disabled:y,animated:_,labelFontUrl:M,labelPlacement:w,arrowPlacement:E,interpolation:b,contextMenu:v,onClick:i,onContextMenu:n,onPointerOver:s,onPointerOut:o}),[_,v,y,E,b,w,G,M,i,n,o,s]),ce=K.useMemo(()=>B.map(le=>Ne.jsx(hH,{animated:_,disabled:y,draggable:g,labelFontUrl:M,onClick:c,onPointerOver:p,onPointerOut:m,onDragged:h,onRender:P,...le},le.label)),[_,B,y,g,M,c,m,p,h,P]);return Z&&Ne.jsxs(K.Fragment,{children:[ue,ie,ce]})}),dH={canvas:{background:"#1E2026"},node:{fill:"#7A8C9E",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.2,label:{stroke:"#1E2026",color:"#ACBAC7",activeColor:"#1DE9AC"},subLabel:{stroke:"#1E2026",color:"#ACBAC7",activeColor:"#1DE9AC"}},lasso:{border:"1px solid #55aaff",background:"rgba(75, 160, 255, 0.1)"},ring:{fill:"#54616D",activeFill:"#1DE9AC"},edge:{fill:"#474B56",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#1E2026",color:"#ACBAC7",activeColor:"#1DE9AC",fontSize:6}},arrow:{fill:"#474B56",activeFill:"#1DE9AC"},cluster:{stroke:"#474B56",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#1E2026",color:"#ACBAC7"}}},pH={canvas:{background:"#fff"},node:{fill:"#7CA0AB",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.2,label:{color:"#2A6475",stroke:"#fff",activeColor:"#1DE9AC"},subLabel:{color:"#ddd",stroke:"transparent",activeColor:"#1DE9AC"}},lasso:{border:"1px solid #55aaff",background:"rgba(75, 160, 255, 0.1)"},ring:{fill:"#D8E6EA",activeFill:"#1DE9AC"},edge:{fill:"#D8E6EA",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475",activeColor:"#1DE9AC",fontSize:6}},arrow:{fill:"#D8E6EA",activeFill:"#1DE9AC"},cluster:{stroke:"#D8E6EA",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475"}}};function md(r,e,t){const{offsetX:n,offsetY:i}=r,{width:s,height:o}=t;e.set(n/s*2-1,-(i/o)*2+1)}function mH(r){const e=document.createElement("div");return e.style.pointerEvents="none",e.style.border=r.lasso.border,e.style.backgroundColor=r.lasso.background,e.style.position="fixed",e}const gH=({children:r,type:e="none",onLasso:t,onLassoEnd:n,disabled:i})=>{var s;const o=qe(I=>I.theme),a=Bn(I=>I.camera),l=Bn(I=>I.gl),c=Bn(I=>I.setEvents),u=Bn(I=>I.size),h=Bn(I=>I.get),p=Bn(I=>I.scene),m=zp(),v=qe(I=>I.actives),_=qe(I=>I.setActives),y=qe(I=>I.edges),g=qe(I=>I.edgeMeshes),x=K.useRef(!1),w=K.useRef(null),E=K.useRef(null),b=K.useRef(mH(o)),M=K.useRef(null),A=K.useRef(!1),P=K.useRef(h().events.enabled),C=K.useRef((s=m.controls)==null?void 0:s.enabled);K.useEffect(()=>{x.current&&(t==null||t(v)),x.current=!0},[v,t]);const L=K.useCallback(I=>{if(A.current){const[X,q,W]=M.current;W.x=Math.max(X.x,I.clientX),W.y=Math.max(X.y,I.clientY),q.x=Math.min(X.x,I.clientX),q.y=Math.min(X.y,I.clientY),b.current.style.left=`${q.x}px`,b.current.style.top=`${q.y}px`,b.current.style.width=`${W.x-q.x}px`,b.current.style.height=`${W.y-q.y}px`,md(I,w.current.endPoint,u),md(I,E.current.endPoint,u);const O=[],k=E.current.select().sort(B=>B.uuid).map(B=>y[g.indexOf(B)].id);O.push(...k);const G=w.current.select().sort(B=>B.uuid).filter(B=>{var D,V;return B.isMesh&&((D=B.userData)==null?void 0:D.id)&&(((V=B.userData)==null?void 0:V.type)===e||e==="all")}).map(B=>B.userData.id);O.push(...G),requestAnimationFrame(()=>{_(O)}),document.addEventListener("pointermove",L,{passive:!0,capture:!0,once:!0})}},[y,g,_,u,e]),F=K.useCallback(()=>{var I;A.current&&(c({enabled:P.current}),A.current=!1,(I=b.current.parentElement)==null||I.removeChild(b.current),m.controls.enabled=C.current,n==null||n(v),document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",F))},[c,m.controls,n,v,L]),N=K.useCallback(I=>{var X,q;if(I.shiftKey){P.current=h().events.enabled,C.current=(X=m.controls)==null?void 0:X.enabled,w.current=new wE(a,p);const W=new ku;g.length&&W.add(...g),E.current=new wE(a,W),M.current=[new De,new De,new De];const[O]=M.current;m.controls.enabled=!1,c({enabled:!1}),A.current=!0,(q=l.domElement.parentElement)==null||q.appendChild(b.current),b.current.style.left=`${I.clientX}px`,b.current.style.top=`${I.clientY}px`,b.current.style.width="0px",b.current.style.height="0px",O.x=I.clientX,O.y=I.clientY,md(I,w.current.startPoint,u),md(I,E.current.startPoint,u),document.addEventListener("pointermove",L,{passive:!0,capture:!0,once:!0}),document.addEventListener("pointerup",F,{passive:!0})}},[a,m.controls,g,h,l.domElement.parentElement,L,F,p,c,u]);return K.useEffect(()=>{if(!(i||e==="none"))return typeof window<"u"&&(document.addEventListener("pointerdown",N,{passive:!0}),document.addEventListener("pointermove",L,{passive:!0}),document.addEventListener("pointerup",F,{passive:!0})),()=>{typeof window<"u"&&(document.removeEventListener("pointerdown",N),document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",F))}},[e,i,N,L,F]),Ne.jsx("group",{children:r})},vH="_canvas_670zp_1",yH={canvas:vH},_H={alpha:!0,antialias:!0},xH={position:[0,0,1e3],near:5,far:5e4,fov:10},wH=K.forwardRef(({cameraMode:r="pan",layoutType:e="forceDirected2d",sizingType:t="default",labelType:n="auto",theme:i=pH,animated:s=!0,defaultNodeSize:o=7,minNodeSize:a=5,maxNodeSize:l=15,lassoType:c="none",glOptions:u={},edges:h,children:p,nodes:m,minDistance:v,maxDistance:_,onCanvasClick:y,disabled:g,onLasso:x,onLassoEnd:w,...E},b)=>{var M,A;const P=K.useRef(null),C=K.useRef(null),L=K.useRef(null);K.useImperativeHandle(b,()=>({centerGraph:(W,O)=>{var k;return(k=P.current)==null?void 0:k.centerGraph(W,O)},fitNodesInView:(W,O)=>{var k;return(k=P.current)==null?void 0:k.fitNodesInView(W,O)},zoomIn:()=>{var W;return(W=C.current)==null?void 0:W.zoomIn()},zoomOut:()=>{var W;return(W=C.current)==null?void 0:W.zoomOut()},dollyIn:W=>{var O;return(O=C.current)==null?void 0:O.dollyIn(W)},dollyOut:W=>{var O;return(O=C.current)==null?void 0:O.dollyOut(W)},panLeft:()=>{var W;return(W=C.current)==null?void 0:W.panLeft()},panRight:()=>{var W;return(W=C.current)==null?void 0:W.panRight()},panDown:()=>{var W;return(W=C.current)==null?void 0:W.panDown()},panUp:()=>{var W;return(W=C.current)==null?void 0:W.panUp()},resetControls:W=>{var O;return(O=C.current)==null?void 0:O.resetControls(W)},getControls:()=>{var W;return(W=C.current)==null?void 0:W.controls},getGraph:()=>{var W;return(W=P.current)==null?void 0:W.graph},exportCanvas:()=>(P.current.renderScene(),L.current.toDataURL()),freeze:()=>{var W;return(W=C.current)==null?void 0:W.freeze()},unFreeze:()=>{var W;return(W=C.current)==null?void 0:W.unFreeze()}}));const{selections:F,actives:N,collapsedNodeIds:I}=E,X=h.length+m.length>400?!1:s,q=K.useMemo(()=>({...u,..._H}),[u]);return Ne.jsx("div",{className:yH.canvas,children:Ne.jsx(NO,{legacy:!0,linear:!0,ref:L,flat:!0,gl:q,camera:xH,onPointerMissed:y,children:Ne.jsxs(V5,{createStore:()=>W5({selections:F,actives:N,theme:i,collapsedNodeIds:I}),children:[((M=i.canvas)==null?void 0:M.background)&&Ne.jsx("color",{attach:"background",args:[i.canvas.background]}),Ne.jsx("ambientLight",{intensity:1}),p,((A=i.canvas)==null?void 0:A.fog)&&Ne.jsx("fog",{attach:"fog",args:[i.canvas.fog,4e3,9e3]}),Ne.jsx(Z5,{mode:r,ref:C,disabled:g,minDistance:v,maxDistance:_,animated:s,children:Ne.jsx(gH,{disabled:g,type:c,onLasso:x,onLassoEnd:w,children:Ne.jsx(K.Suspense,{children:Ne.jsx(fH,{ref:P,disabled:g,animated:X,edges:h,nodes:m,layoutType:e,sizingType:t,labelType:n,defaultNodeSize:o,minNodeSize:a,maxNodeSize:l,...E})})})})]})})})}),gd={user:"#22d3ee",instruction:"#a78bfa",stable:"#6366f1",versioned:"#fbbf24",ephemeral:"#f472b6"},SH={user:"User",instruction:"Regel",stable:"Fakt",versioned:"Version",ephemeral:"Temporär"},P0=new Set(["auto","agent","hermes"]);function PH({data:r,onDelete:e}){const[t,n]=K.useState(null),i=K.useMemo(()=>{const c={};return r.edges.forEach(u=>{c[u.source]=(c[u.source]||0)+1,c[u.target]=(c[u.target]||0)+1}),c},[r]),s=K.useMemo(()=>r.nodes.map(c=>({id:c.id,label:c.content.length>26?c.content.slice(0,25)+"…":c.content,fill:gd[c.category]||"#64748b",size:6+Math.min(i[c.id]||0,6)*2})),[r,i]),o=K.useMemo(()=>r.edges.map(c=>({id:`${c.source}->${c.target}`,source:c.source,target:c.target,size:.4+c.weight})),[r]),a=t?r.nodes.find(c=>c.id===t)??null:null,l=K.useMemo(()=>{if(!t)return[];const c=new Set;return r.edges.forEach(u=>{u.source===t&&c.add(u.target),u.target===t&&c.add(u.source)}),r.nodes.filter(u=>c.has(u.id))},[t,r]);return r.nodes.length?Ne.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_280px] gap-3",children:[Ne.jsx("div",{className:"relative h-[480px] rounded-2xl border border-border/60 bg-[#070a0f] overflow-hidden",children:Ne.jsx(wH,{nodes:s,edges:o,theme:dH,layoutType:"forceDirected2d",labelType:"nodes",edgeArrowPosition:"none",draggable:!0,onNodeClick:c=>n(c.id),onCanvasClick:()=>n(null)})}),Ne.jsx("div",{className:"rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-4 min-h-[480px]",children:a?Ne.jsxs(Ne.Fragment,{children:[Ne.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[Ne.jsx("span",{className:"w-3 h-3 rounded-full",style:{background:gd[a.category],boxShadow:`0 0 0 2px ${P0.has(a.source)?"#34d399":"#475569"}`}}),Ne.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:gd[a.category]},children:SH[a.category]||a.category}),Ne.jsxs("span",{className:`ml-auto text-[10px] font-mono flex items-center gap-1 ${P0.has(a.source)?"text-emerald-400":"text-muted-foreground/70"}`,children:[P0.has(a.source)&&Ne.jsx(K2,{className:"h-2.5 w-2.5"}),a.source]})]}),Ne.jsx("div",{className:"text-sm text-foreground leading-relaxed mb-4 break-words",children:a.content}),Ne.jsxs("div",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground/70 mb-2 flex items-center gap-1",children:[Ne.jsx(Vx,{className:"h-3 w-3"})," verwandte Fakten"]}),Ne.jsx("div",{className:"flex flex-col gap-1.5 mb-4",children:l.length?l.map(c=>Ne.jsxs("button",{onClick:()=>n(c.id),className:"flex items-center gap-2 text-[11px] text-muted-foreground hover:text-foreground text-left transition-colors",children:[Ne.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:gd[c.category]}}),Ne.jsx("span",{className:"truncate",children:c.content})]},c.id)):Ne.jsx("span",{className:"text-[11px] text-muted-foreground/60",children:"—"})}),Ne.jsxs("button",{onClick:()=>{e(a.id),n(null)},className:"flex items-center gap-1.5 text-[11px] text-red-400 border border-red-500/20 rounded-lg px-2.5 py-1.5 hover:bg-red-500/5 transition-all",children:[Ne.jsx($2,{className:"h-3.5 w-3.5"})," vergessen"]})]}):Ne.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center text-muted-foreground/70 gap-2 pt-24",children:[Ne.jsx(Vx,{className:"h-6 w-6"}),Ne.jsx("div",{className:"text-xs max-w-[180px] leading-relaxed",children:"Einen Knoten wählen, um den Fakt und seine semantischen Nachbarn zu sehen."})]})})]}):Ne.jsx("div",{className:"text-xs text-muted-foreground border border-dashed border-border/60 rounded-2xl p-12 text-center",children:"Noch keine Fakten — der Graph füllt sich, sobald Hermes lernt oder du Einträge anlegst."})}export{PH as GraphView};
|