Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
milady
nirholas3399b2393c66
diff --git a/dist-lib/agent-3d.umd.cjs b/dist-lib/agent-3d.umd.cjsnew file mode 100644index 000000000..869f32770--- /dev/null+++ b/dist-lib/agent-3d.umd.cjs@@ -0,0 +1,4005 @@+(function(en,nc){typeof exports=="object"&&typeof module<"u"?nc(exports):typeof define=="function"&&define.amd?define(["exports"],nc):(en=typeof globalThis<"u"?globalThis:en||self,nc(en.Agent3D={}))})(this,(function(en){"use strict";const Tr={ROTATE:0,DOLLY:1,PAN:2},Rr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},rE=0,ip=1,aE=2,sp=1,oE=2,Oi=3,Qi=0,Sn=1,Si=2,gs=0,Nr=1,rp=2,ap=3,op=4,cE=5,qs=100,lE=101,hE=102,uE=103,dE=104,fE=200,pE=201,AE=202,gE=203,oh=204,ch=205,mE=206,bE=207,xE=208,EE=209,_E=210,yE=211,wE=212,CE=213,vE=214,lh=0,hh=1,uh=2,Fr=3,dh=4,fh=5,ph=6,Ah=7,cp=0,SE=1,IE=2,ms=0,gh=1,ME=2,BE=3,lp=4,TE=5,RE=6,NE=7,hp="attached",FE="detached",up=300,Ks=301,Dr=302,mh=303,bh=304,ic=306,Lr=1e3,ai=1001,sc=1002,In=1003,dp=1004,Qa=1005,zt=1006,rc=1007,Jn=1008,tn=1009,fp=1010,pp=1011,Ga=1012,xh=1013,Xs=1014,nn=1015,Mn=1016,Eh=1017,_h=1018,Ha=1020,Ap=35902,gp=1021,mp=1022,sn=1023,za=1026,Va=1027,Gi=1028,yh=1029,Ys=1030,wh=1031,Ch=1033,ac=33776,Wa=33777,oc=33778,qa=33779,cc=35840,vh=35841,lc=35842,Sh=35843,hc=36196,uc=37492,dc=37496,Ka=37808,Ih=37809,Mh=37810,Bh=37811,Xa=37812,Th=37813,Rh=37814,Nh=37815,Fh=37816,Dh=37817,Lh=37818,Ph=37819,kh=37820,Uh=37821,Ya=36492,Oh=36494,fc=36495,bp=36283,Qh=36284,Gh=36285,Hh=36286,xp=2200,Ep=2201,DE=2202,ja=2300,Ja=2301,zh=2302,Pr=2400,kr=2401,pc=2402,Vh=2500,LE=2501,PE=0,_p=1,Wh=2,kE=3200,UE=3201,yp=0,OE=1,oi="",Kt="srgb",rn="srgb-linear",Ac="linear",Mt="srgb",Ur=7680,wp=519,QE=512,GE=513,HE=514,Cp=515,zE=516,VE=517,WE=518,qE=519,qh=35044,vp="300 es",Hi=2e3,gc=2001;class bs{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const s=n[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,e);e.target=null}}}const wn=["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 Sp=1234567;const Za=Math.PI/180,Or=180/Math.PI;function ci(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(wn[i&255]+wn[i>>8&255]+wn[i>>16&255]+wn[i>>24&255]+"-"+wn[e&255]+wn[e>>8&255]+"-"+wn[e>>16&15|64]+wn[e>>24&255]+"-"+wn[t&63|128]+wn[t>>8&255]+"-"+wn[t>>16&255]+wn[t>>24&255]+wn[n&255]+wn[n>>8&255]+wn[n>>16&255]+wn[n>>24&255]).toLowerCase()}function at(i,e,t){return Math.max(e,Math.min(t,i))}function Kh(i,e){return(i%e+e)%e}function KE(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function XE(i,e,t){return i!==e?(t-i)/(e-i):0}function $a(i,e,t){return(1-t)*i+t*e}function YE(i,e,t,n){return $a(i,e,1-Math.exp(-t*n))}function jE(i,e=1){return e-Math.abs(Kh(i,e*2)-e)}function JE(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function ZE(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function $E(i,e){return i+Math.floor(Math.random()*(e-i+1))}function e_(i,e){return i+Math.random()*(e-i)}function t_(i){return i*(.5-Math.random())}function n_(i){i!==void 0&&(Sp=i);let e=Sp+=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 i_(i){return i*Za}function s_(i){return i*Or}function r_(i){return(i&i-1)===0&&i!==0}function a_(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function o_(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function c_(i,e,t,n,s){const r=Math.cos,a=Math.sin,o=r(t/2),c=a(t/2),l=r((e+n)/2),h=a((e+n)/2),u=r((e-n)/2),d=a((e-n)/2),f=r((n-e)/2),m=a((n-e)/2);switch(s){case"XYX":i.set(o*h,c*u,c*d,o*l);break;case"YZY":i.set(c*d,o*h,c*u,o*l);break;case"ZXZ":i.set(c*u,c*d,o*h,o*l);break;case"XZX":i.set(o*h,c*m,c*f,o*l);break;case"YXY":i.set(c*f,o*h,c*m,o*l);break;case"ZYZ":i.set(c*m,c*f,o*h,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function li(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function It(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const Ip={DEG2RAD:Za,RAD2DEG:Or,generateUUID:ci,clamp:at,euclideanModulo:Kh,mapLinear:KE,inverseLerp:XE,lerp:$a,damp:YE,pingpong:jE,smoothstep:JE,smootherstep:ZE,randInt:$E,randFloat:e_,randFloatSpread:t_,seededRandom:n_,degToRad:i_,radToDeg:s_,isPowerOfTwo:r_,ceilPowerOfTwo:a_,floorPowerOfTwo:o_,setQuaternionFromProperEuler:c_,normalize:It,denormalize:li};class Ze{constructor(e=0,t=0){Ze.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,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=at(this.x,e.x,t.x),this.y=at(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=at(this.x,e,t),this.y=at(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(at(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(at(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class rt{constructor(e,t,n,s,r,a,o,c,l){rt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l)}set(e,t,n,s,r,a,o,c,l){const h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],f=n[5],m=n[8],g=s[0],A=s[3],p=s[6],y=s[1],b=s[4],_=s[7],M=s[2],w=s[5],S=s[8];return r[0]=a*g+o*y+c*M,r[3]=a*A+o*b+c*w,r[6]=a*p+o*_+c*S,r[1]=l*g+h*y+u*M,r[4]=l*A+h*b+u*w,r[7]=l*p+h*_+u*S,r[2]=d*g+f*y+m*M,r[5]=d*A+f*b+m*w,r[8]=d*p+f*_+m*S,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,m=t*u+n*d+s*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const g=1/m;return e[0]=u*g,e[1]=(s*l-h*n)*g,e[2]=(o*n-s*a)*g,e[3]=d*g,e[4]=(h*t-s*c)*g,e[5]=(s*r-o*t)*g,e[6]=f*g,e[7]=(n*c-l*t)*g,e[8]=(a*t-n*r)*g,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-s*l,s*c,-s*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Xh.makeScale(e,t)),this}rotate(e){return this.premultiply(Xh.makeRotation(-e)),this}translate(e,t){return this.premultiply(Xh.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Xh=new rt;function Mp(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function eo(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function l_(){const i=eo("canvas");return i.style.display="block",i}const Bp={};function mc(i){i in Bp||(Bp[i]=!0,console.warn(i))}function h_(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}function u_(i){const e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function d_(i){const e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const Tp=new rt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Rp=new rt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function f_(){const i={enabled:!0,workingColorSpace:rn,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Mt&&(s.r=zi(s.r),s.g=zi(s.g),s.b=zi(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Mt&&(s.r=Qr(s.r),s.g=Qr(s.g),s.b=Qr(s.b))),s},fromWorkingColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},toWorkingColorSpace:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===oi?Ac:this.spaces[s].transfer},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[rn]:{primaries:e,whitePoint:n,transfer:Ac,toXYZ:Tp,fromXYZ:Rp,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Kt},outputColorSpaceConfig:{drawingBufferColorSpace:Kt}},[Kt]:{primaries:e,whitePoint:n,transfer:Mt,toXYZ:Tp,fromXYZ:Rp,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Kt}}}),i}const At=f_();function zi(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Qr(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Gr;class p_{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Gr===void 0&&(Gr=eo("canvas")),Gr.width=e.width,Gr.height=e.height;const s=Gr.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=Gr}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=eo("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=zi(r[a]/255)*255;return n.putImageData(s,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(zi(t[n]/255)*255):t[n]=zi(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 A_=0;class Yh{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:A_++}),this.uuid=ci(),this.data=e,this.dataReady=!0,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:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(jh(s[a].image)):r.push(jh(s[a]))}else r=jh(s);n.url=r}return t||(e.images[this.uuid]=n),n}}function jh(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?p_.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let g_=0;class an extends bs{constructor(e=an.DEFAULT_IMAGE,t=an.DEFAULT_MAPPING,n=ai,s=ai,r=zt,a=Jn,o=sn,c=tn,l=an.DEFAULT_ANISOTROPY,h=oi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:g_++}),this.uuid=ci(),this.name="",this.source=new Yh(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Ze(0,0),this.repeat=new Ze(1,1),this.center=new Ze(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new rt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isTextureArray=!1,this.pmremVersion=0}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.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isTextureArray=e.isTextureArray,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!==up)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Lr:e.x=e.x-Math.floor(e.x);break;case ai:e.x=e.x<0?0:1;break;case sc: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 Lr:e.y=e.y-Math.floor(e.y);break;case ai:e.y=e.y<0?0:1;break;case sc:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}an.DEFAULT_IMAGE=null,an.DEFAULT_MAPPING=up,an.DEFAULT_ANISOTROPY=1;class _t{constructor(e=0,t=0,n=0,s=1){_t.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("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,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r;const c=e.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],m=c[9],g=c[2],A=c[6],p=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-g)<.01&&Math.abs(m-A)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+g)<.1&&Math.abs(m+A)<.1&&Math.abs(l+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(l+1)/2,_=(f+1)/2,M=(p+1)/2,w=(h+d)/4,S=(u+g)/4,T=(m+A)/4;return b>_&&b>M?b<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(b),s=w/n,r=S/n):_>M?_<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(_),n=w/s,r=T/s):M<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(M),n=S/r,s=T/r),this.set(n,s,r,t),this}let y=Math.sqrt((A-m)*(A-m)+(u-g)*(u-g)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(A-m)/y,this.y=(u-g)/y,this.z=(d-h)/y,this.w=Math.acos((l+f+p-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=at(this.x,e.x,t.x),this.y=at(this.y,e.y,t.y),this.z=at(this.z,e.z,t.z),this.w=at(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=at(this.x,e,t),this.y=at(this.y,e,t),this.z=at(this.z,e,t),this.w=at(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(at(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class m_ extends bs{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth?n.depth:1,this.scissor=new _t(0,0,e,t),this.scissorTest=!1,this.viewport=new _t(0,0,e,t);const s={width:e,height:t,depth:this.depth};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:zt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,multiview:!1},n);const r=new an(s,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].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.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const s=Object.assign({},e.textures[t].image);this.textures[t].source=new Yh(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class js extends m_{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Np extends an{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=In,this.minFilter=In,this.wrapR=ai,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Fp extends an{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=In,this.minFilter=In,this.wrapR=ai,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Vn{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let c=n[s+0],l=n[s+1],h=n[s+2],u=n[s+3];const d=r[a+0],f=r[a+1],m=r[a+2],g=r[a+3];if(o===0){e[t+0]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=m,e[t+3]=g;return}if(u!==g||c!==d||l!==f||h!==m){let A=1-o;const p=c*d+l*f+h*m+u*g,y=p>=0?1:-1,b=1-p*p;if(b>Number.EPSILON){const M=Math.sqrt(b),w=Math.atan2(M,p*y);A=Math.sin(A*w)/M,o=Math.sin(o*w)/M}const _=o*y;if(c=c*A+d*_,l=l*A+f*_,h=h*A+m*_,u=u*A+g*_,A===1-o){const M=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=M,l*=M,h*=M,u*=M}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,s,r,a){const o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],u=r[a],d=r[a+1],f=r[a+2],m=r[a+3];return e[t]=o*m+h*u+c*f-l*d,e[t+1]=c*m+h*d+l*u-o*f,e[t+2]=l*m+h*f+o*d-c*u,e[t+3]=h*m-o*u-c*d-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(s/2),u=o(r/2),d=c(n/2),f=c(s/2),m=c(r/2);switch(a){case"XYZ":this._x=d*h*u+l*f*m,this._y=l*f*u-d*h*m,this._z=l*h*m+d*f*u,this._w=l*h*u-d*f*m;break;case"YXZ":this._x=d*h*u+l*f*m,this._y=l*f*u-d*h*m,this._z=l*h*m-d*f*u,this._w=l*h*u+d*f*m;break;case"ZXY":this._x=d*h*u-l*f*m,this._y=l*f*u+d*h*m,this._z=l*h*m+d*f*u,this._w=l*h*u-d*f*m;break;case"ZYX":this._x=d*h*u-l*f*m,this._y=l*f*u+d*h*m,this._z=l*h*m-d*f*u,this._w=l*h*u+d*f*m;break;case"YZX":this._x=d*h*u+l*f*m,this._y=l*f*u+d*h*m,this._z=l*h*m-d*f*u,this._w=l*h*u-d*f*m;break;case"XZY":this._x=d*h*u-l*f*m,this._y=l*f*u-d*h*m,this._z=l*h*m+d*f*u,this._w=l*h*u+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],h=t[6],u=t[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(r-l)*f,this._z=(a-s)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-l)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-s)/f,this._x=(r+l)/f,this._y=(c+h)/f,this._z=.25*f}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(at(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,s=e._y,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+a*o+s*l-r*c,this._y=s*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-s*o,this._w=a*h-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,s=this._y,r=this._z,a=this._w;let o=a*e._w+n*e._x+s*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=s,this._z=r,this;const c=1-o*o;if(c<=Number.EPSILON){const f=1-t;return this._w=f*a+t*this._w,this._x=f*n+t*this._x,this._y=f*s+t*this._y,this._z=f*r+t*this._z,this.normalize(),this}const l=Math.sqrt(c),h=Math.atan2(l,o),u=Math.sin((1-t)*h)/l,d=Math.sin(t*h)/l;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=s*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class H{constructor(e=0,t=0,n=0){H.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(Dp.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Dp.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*s-o*n),h=2*(o*t-r*s),u=2*(r*n-a*t);return this.x=t+c*l+a*u-o*h,this.y=n+c*h+o*l-r*u,this.z=s+c*u+r*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=at(this.x,e.x,t.x),this.y=at(this.y,e.y,t.y),this.z=at(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=at(this.x,e,t),this.y=at(this.y,e,t),this.z=at(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(at(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,s=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Jh.copy(this).projectOnVector(e),this.sub(Jh)}reflect(e){return this.sub(Jh.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(at(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Jh=new H,Dp=new Vn;class Ii{constructor(e=new H(1/0,1/0,1/0),t=new H(-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(hi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(hi.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=hi.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){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,hi):hi.fromBufferAttribute(r,a),hi.applyMatrix4(e.matrixWorld),this.expandByPoint(hi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),bc.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),bc.copy(n.boundingBox)),bc.applyMatrix4(e.matrixWorld),this.union(bc)}const s=e.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],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,hi),hi.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(to),xc.subVectors(this.max,to),Hr.subVectors(e.a,to),zr.subVectors(e.b,to),Vr.subVectors(e.c,to),xs.subVectors(zr,Hr),Es.subVectors(Vr,zr),Js.subVectors(Hr,Vr);let t=[0,-xs.z,xs.y,0,-Es.z,Es.y,0,-Js.z,Js.y,xs.z,0,-xs.x,Es.z,0,-Es.x,Js.z,0,-Js.x,-xs.y,xs.x,0,-Es.y,Es.x,0,-Js.y,Js.x,0];return!Zh(t,Hr,zr,Vr,xc)||(t=[1,0,0,0,1,0,0,0,1],!Zh(t,Hr,zr,Vr,xc))?!1:(Ec.crossVectors(xs,Es),t=[Ec.x,Ec.y,Ec.z],Zh(t,Hr,zr,Vr,xc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,hi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(hi).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:(Vi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Vi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Vi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Vi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Vi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Vi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Vi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Vi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Vi),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 Vi=[new H,new H,new H,new H,new H,new H,new H,new H],hi=new H,bc=new Ii,Hr=new H,zr=new H,Vr=new H,xs=new H,Es=new H,Js=new H,to=new H,xc=new H,Ec=new H,Zs=new H;function Zh(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Zs.fromArray(i,r);const o=s.x*Math.abs(Zs.x)+s.y*Math.abs(Zs.y)+s.z*Math.abs(Zs.z),c=e.dot(Zs),l=t.dot(Zs),h=n.dot(Zs);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const b_=new Ii,no=new H,$h=new H;class Mi{constructor(e=new H,t=-1){this.isSphere=!0,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):b_.setFromPoints(e).getCenter(n);let s=0;for(let r=0,a=e.length;r<a;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const 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;no.subVectors(e,this.center);const t=no.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(no,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):($h.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(no.copy(e.center).add($h)),this.expandByPoint(no.copy(e.center).sub($h))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Wi=new H,eu=new H,_c=new H,_s=new H,tu=new H,yc=new H,nu=new H;class io{constructor(e=new H,t=new H(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,Wi)),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=Wi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Wi.copy(this.origin).addScaledVector(this.direction,t),Wi.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){eu.copy(e).add(t).multiplyScalar(.5),_c.copy(t).sub(e).normalize(),_s.copy(this.origin).sub(eu);const r=e.distanceTo(t)*.5,a=-this.direction.dot(_c),o=_s.dot(this.direction),c=-_s.dot(_c),l=_s.lengthSq(),h=Math.abs(1-a*a);let u,d,f,m;if(h>0)if(u=a*c-o,d=a*o-c,m=r*h,u>=0)if(d>=-m)if(d<=m){const g=1/h;u*=g,d*=g,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-m?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l):d<=m?(u=0,d=Math.min(Math.max(-r,-c),r),f=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(eu).addScaledVector(_c,d),f}intersectSphere(e,t){Wi.subVectors(e.center,this.origin);const n=Wi.dot(this.direction),s=Wi.dot(Wi)-n*n,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,s=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,s=(e.min.x-d.x)*l),h>=0?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),u>=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),n>c||o>s)||((o>n||n!==n)&&(n=o),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Wi)!==null}intersectTriangle(e,t,n,s,r){tu.subVectors(t,e),yc.subVectors(n,e),nu.crossVectors(tu,yc);let a=this.direction.dot(nu),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;_s.subVectors(this.origin,e);const c=o*this.direction.dot(yc.crossVectors(_s,yc));if(c<0)return null;const l=o*this.direction.dot(tu.cross(_s));if(l<0||c+l>a)return null;const h=-o*_s.dot(nu);return h<0?null:this.at(h/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class et{constructor(e,t,n,s,r,a,o,c,l,h,u,d,f,m,g,A){et.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,s,r,a,o,c,l,h,u,d,f,m,g,A)}set(e,t,n,s,r,a,o,c,l,h,u,d,f,m,g,A){const p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=s,p[1]=r,p[5]=a,p[9]=o,p[13]=c,p[2]=l,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=m,p[11]=g,p[15]=A,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 et().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,s=1/Wr.setFromMatrixColumn(e,0).length(),r=1/Wr.setFromMatrixColumn(e,1).length(),a=1/Wr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,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,s=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){const d=a*h,f=a*u,m=o*h,g=o*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=f+m*l,t[5]=d-g*l,t[9]=-o*c,t[2]=g-d*l,t[6]=m+f*l,t[10]=a*c}else if(e.order==="YXZ"){const d=c*h,f=c*u,m=l*h,g=l*u;t[0]=d+g*o,t[4]=m*o-f,t[8]=a*l,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=f*o-m,t[6]=g+d*o,t[10]=a*c}else if(e.order==="ZXY"){const d=c*h,f=c*u,m=l*h,g=l*u;t[0]=d-g*o,t[4]=-a*u,t[8]=m+f*o,t[1]=f+m*o,t[5]=a*h,t[9]=g-d*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const d=a*h,f=a*u,m=o*h,g=o*u;t[0]=c*h,t[4]=m*l-f,t[8]=d*l+g,t[1]=c*u,t[5]=g*l+d,t[9]=f*l-m,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const d=a*c,f=a*l,m=o*c,g=o*l;t[0]=c*h,t[4]=g-d*u,t[8]=m*u+f,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-l*h,t[6]=f*u+m,t[10]=d-g*u}else if(e.order==="XZY"){const d=a*c,f=a*l,m=o*c,g=o*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+g,t[5]=a*h,t[9]=f*u-m,t[2]=m*u-f,t[6]=o*h,t[10]=g*u+d}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(x_,e,E_)}lookAt(e,t,n){const s=this.elements;return Wn.subVectors(e,t),Wn.lengthSq()===0&&(Wn.z=1),Wn.normalize(),ys.crossVectors(n,Wn),ys.lengthSq()===0&&(Math.abs(n.z)===1?Wn.x+=1e-4:Wn.z+=1e-4,Wn.normalize(),ys.crossVectors(n,Wn)),ys.normalize(),wc.crossVectors(Wn,ys),s[0]=ys.x,s[4]=wc.x,s[8]=Wn.x,s[1]=ys.y,s[5]=wc.y,s[9]=Wn.y,s[2]=ys.z,s[6]=wc.z,s[10]=Wn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],f=n[13],m=n[2],g=n[6],A=n[10],p=n[14],y=n[3],b=n[7],_=n[11],M=n[15],w=s[0],S=s[4],T=s[8],v=s[12],C=s[1],F=s[5],K=s[9],q=s[13],$=s[2],D=s[6],O=s[10],j=s[14],Q=s[3],J=s[7],ee=s[11],ae=s[15];return r[0]=a*w+o*C+c*$+l*Q,r[4]=a*S+o*F+c*D+l*J,r[8]=a*T+o*K+c*O+l*ee,r[12]=a*v+o*q+c*j+l*ae,r[1]=h*w+u*C+d*$+f*Q,r[5]=h*S+u*F+d*D+f*J,r[9]=h*T+u*K+d*O+f*ee,r[13]=h*v+u*q+d*j+f*ae,r[2]=m*w+g*C+A*$+p*Q,r[6]=m*S+g*F+A*D+p*J,r[10]=m*T+g*K+A*O+p*ee,r[14]=m*v+g*q+A*j+p*ae,r[3]=y*w+b*C+_*$+M*Q,r[7]=y*S+b*F+_*D+M*J,r[11]=y*T+b*K+_*O+M*ee,r[15]=y*v+b*q+_*j+M*ae,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],s=e[8],r=e[12],a=e[1],o=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],f=e[14],m=e[3],g=e[7],A=e[11],p=e[15];return m*(+r*c*u-s*l*u-r*o*d+n*l*d+s*o*f-n*c*f)+g*(+t*c*f-t*l*d+r*a*d-s*a*f+s*l*h-r*c*h)+A*(+t*l*u-t*o*f-r*a*u+n*a*f+r*o*h-n*l*h)+p*(-s*o*h-t*c*u+t*o*d+s*a*u-n*a*d+n*c*h)}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 s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],f=e[11],m=e[12],g=e[13],A=e[14],p=e[15],y=u*A*l-g*d*l+g*c*f-o*A*f-u*c*p+o*d*p,b=m*d*l-h*A*l-m*c*f+a*A*f+h*c*p-a*d*p,_=h*g*l-m*u*l+m*o*f-a*g*f-h*o*p+a*u*p,M=m*u*c-h*g*c-m*o*d+a*g*d+h*o*A-a*u*A,w=t*y+n*b+s*_+r*M;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/w;return e[0]=y*S,e[1]=(g*d*r-u*A*r-g*s*f+n*A*f+u*s*p-n*d*p)*S,e[2]=(o*A*r-g*c*r+g*s*l-n*A*l-o*s*p+n*c*p)*S,e[3]=(u*c*r-o*d*r-u*s*l+n*d*l+o*s*f-n*c*f)*S,e[4]=b*S,e[5]=(h*A*r-m*d*r+m*s*f-t*A*f-h*s*p+t*d*p)*S,e[6]=(m*c*r-a*A*r-m*s*l+t*A*l+a*s*p-t*c*p)*S,e[7]=(a*d*r-h*c*r+h*s*l-t*d*l-a*s*f+t*c*f)*S,e[8]=_*S,e[9]=(m*u*r-h*g*r-m*n*f+t*g*f+h*n*p-t*u*p)*S,e[10]=(a*g*r-m*o*r+m*n*l-t*g*l-a*n*p+t*o*p)*S,e[11]=(h*o*r-a*u*r-h*n*l+t*u*l+a*n*f-t*o*f)*S,e[12]=M*S,e[13]=(h*g*s-m*u*s+m*n*d-t*g*d-h*n*A+t*u*A)*S,e[14]=(m*o*s-a*g*s-m*n*c+t*g*c+a*n*A-t*o*A)*S,e[15]=(a*u*s-h*o*s+h*n*c-t*u*c-a*n*d+t*o*d)*S,this}scale(e){const t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,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],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}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),s=Math.sin(t),r=1-n,a=e.x,o=e.y,c=e.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-s*c,l*c+s*o,0,l*o+s*c,h*o+n,h*c-s*a,0,l*c-s*o,h*c+s*a,r*c*c+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,s,r,a){return this.set(1,n,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){const s=this.elements,r=t._x,a=t._y,o=t._z,c=t._w,l=r+r,h=a+a,u=o+o,d=r*l,f=r*h,m=r*u,g=a*h,A=a*u,p=o*u,y=c*l,b=c*h,_=c*u,M=n.x,w=n.y,S=n.z;return s[0]=(1-(g+p))*M,s[1]=(f+_)*M,s[2]=(m-b)*M,s[3]=0,s[4]=(f-_)*w,s[5]=(1-(d+p))*w,s[6]=(A+y)*w,s[7]=0,s[8]=(m+b)*S,s[9]=(A-y)*S,s[10]=(1-(d+g))*S,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){const s=this.elements;let r=Wr.set(s[0],s[1],s[2]).length();const a=Wr.set(s[4],s[5],s[6]).length(),o=Wr.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),e.x=s[12],e.y=s[13],e.z=s[14],ui.copy(this);const l=1/r,h=1/a,u=1/o;return ui.elements[0]*=l,ui.elements[1]*=l,ui.elements[2]*=l,ui.elements[4]*=h,ui.elements[5]*=h,ui.elements[6]*=h,ui.elements[8]*=u,ui.elements[9]*=u,ui.elements[10]*=u,t.setFromRotationMatrix(ui),n.x=r,n.y=a,n.z=o,this}makePerspective(e,t,n,s,r,a,o=Hi){const c=this.elements,l=2*r/(t-e),h=2*r/(n-s),u=(t+e)/(t-e),d=(n+s)/(n-s);let f,m;if(o===Hi)f=-(a+r)/(a-r),m=-2*a*r/(a-r);else if(o===gc)f=-a/(a-r),m=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=h,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,s,r,a,o=Hi){const c=this.elements,l=1/(t-e),h=1/(n-s),u=1/(a-r),d=(t+e)*l,f=(n+s)*h;let m,g;if(o===Hi)m=(a+r)*u,g=-2*u;else if(o===gc)m=r*u,g=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-f,c[2]=0,c[6]=0,c[10]=g,c[14]=-m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])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 Wr=new H,ui=new et,x_=new H(0,0,0),E_=new H(1,1,1),ys=new H,wc=new H,Wn=new H,Lp=new et,Pp=new Vn;class Bi{constructor(e=0,t=0,n=0,s=Bi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const s=e.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],u=s[2],d=s[6],f=s[10];switch(t){case"XYZ":this._y=Math.asin(at(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-at(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(at(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-at(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(at(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-at(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),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 Lp.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Lp,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Pp.setFromEuler(this),this.setFromQuaternion(Pp,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}}Bi.DEFAULT_ORDER="XYZ";class kp{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 __=0;const Up=new H,qr=new Vn,qi=new et,Cc=new H,so=new H,y_=new H,w_=new Vn,Op=new H(1,0,0),Qp=new H(0,1,0),Gp=new H(0,0,1),Hp={type:"added"},C_={type:"removed"},Kr={type:"childadded",child:null},iu={type:"childremoved",child:null};class Pt extends bs{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:__++}),this.uuid=ci(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pt.DEFAULT_UP.clone();const e=new H,t=new Bi,n=new Vn,s=new H(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),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:s},modelViewMatrix:{value:new et},normalMatrix:{value:new rt}}),this.matrix=new et,this.matrixWorld=new et,this.matrixAutoUpdate=Pt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new kp,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,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 qr.setFromAxisAngle(e,t),this.quaternion.multiply(qr),this}rotateOnWorldAxis(e,t){return qr.setFromAxisAngle(e,t),this.quaternion.premultiply(qr),this}rotateX(e){return this.rotateOnAxis(Op,e)}rotateY(e){return this.rotateOnAxis(Qp,e)}rotateZ(e){return this.rotateOnAxis(Gp,e)}translateOnAxis(e,t){return Up.copy(e).applyQuaternion(this.quaternion),this.position.add(Up.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Op,e)}translateY(e){return this.translateOnAxis(Qp,e)}translateZ(e){return this.translateOnAxis(Gp,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(qi.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Cc.copy(e):Cc.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),so.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?qi.lookAt(so,Cc,this.up):qi.lookAt(Cc,so,this.up),this.quaternion.setFromRotationMatrix(qi),s&&(qi.extractRotation(s.matrixWorld),qr.setFromRotationMatrix(qi),this.quaternion.premultiply(qr.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.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Hp),Kr.child=e,this.dispatchEvent(Kr),Kr.child=null):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(C_),iu.child=e,this.dispatchEvent(iu),iu.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),qi.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),qi.multiply(e.parent.matrixWorld)),e.applyMatrix4(qi),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Hp),Kr.child=e,this.dispatchEvent(Kr),Kr.child=null,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,s=this.children.length;n<s;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(so,e,y_),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(so,w_,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,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,s=t.length;n<s;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.matrixWorldAutoUpdate===!0&&(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,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].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 s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?{min:o.boundingBox.min.toArray(),max:o.boundingBox.max.toArray()}:void 0,boundingSphere:o.boundingSphere?{radius:o.boundingSphere.radius,center:o.boundingSphere.center.toArray()}:void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere={center:this.boundingSphere.center.toArray(),radius:this.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:this.boundingBox.min.toArray(),max:this.boundingBox.max.toArray()}));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(e.materials,this.material[c]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];s.animations.push(r(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),f=a(e.animations),m=a(e.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=s,n;function a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const s=e.children[n];this.add(s.clone())}return this}}Pt.DEFAULT_UP=new H(0,1,0),Pt.DEFAULT_MATRIX_AUTO_UPDATE=!0,Pt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const di=new H,Ki=new H,su=new H,Xi=new H,Xr=new H,Yr=new H,zp=new H,ru=new H,au=new H,ou=new H,cu=new _t,lu=new _t,hu=new _t;class fi{constructor(e=new H,t=new H,n=new H){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),di.subVectors(e,t),s.cross(di);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){di.subVectors(s,t),Ki.subVectors(n,t),su.subVectors(e,t);const a=di.dot(di),o=di.dot(Ki),c=di.dot(su),l=Ki.dot(Ki),h=Ki.dot(su),u=a*l-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,m=(a*h-o*c)*d;return r.set(1-f-m,m,f)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Xi)===null?!1:Xi.x>=0&&Xi.y>=0&&Xi.x+Xi.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,Xi)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Xi.x),c.addScaledVector(a,Xi.y),c.addScaledVector(o,Xi.z),c)}static getInterpolatedAttribute(e,t,n,s,r,a){return cu.setScalar(0),lu.setScalar(0),hu.setScalar(0),cu.fromBufferAttribute(e,t),lu.fromBufferAttribute(e,n),hu.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(cu,r.x),a.addScaledVector(lu,r.y),a.addScaledVector(hu,r.z),a}static isFrontFacing(e,t,n,s){return di.subVectors(n,t),Ki.subVectors(e,t),di.cross(Ki).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return di.subVectors(this.c,this.b),Ki.subVectors(this.a,this.b),di.cross(Ki).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return fi.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return fi.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return fi.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return fi.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return fi.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,s=this.b,r=this.c;let a,o;Xr.subVectors(s,n),Yr.subVectors(r,n),ru.subVectors(e,n);const c=Xr.dot(ru),l=Yr.dot(ru);if(c<=0&&l<=0)return t.copy(n);au.subVectors(e,s);const h=Xr.dot(au),u=Yr.dot(au);if(h>=0&&u<=h)return t.copy(s);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(Xr,a);ou.subVectors(e,r);const f=Xr.dot(ou),m=Yr.dot(ou);if(m>=0&&f<=m)return t.copy(r);const g=f*l-c*m;if(g<=0&&l>=0&&m<=0)return o=l/(l-m),t.copy(n).addScaledVector(Yr,o);const A=h*m-f*u;if(A<=0&&u-h>=0&&f-m>=0)return zp.subVectors(r,s),o=(u-h)/(u-h+(f-m)),t.copy(s).addScaledVector(zp,o);const p=1/(A+g+d);return a=g*p,o=d*p,t.copy(n).addScaledVector(Xr,a).addScaledVector(Yr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Vp={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},ws={h:0,s:0,l:0},vc={h:0,s:0,l:0};function uu(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}let qe=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Kt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,At.toWorkingColorSpace(this,t),this}setRGB(e,t,n,s=At.workingColorSpace){return this.r=e,this.g=t,this.b=n,At.toWorkingColorSpace(this,s),this}setHSL(e,t,n,s=At.workingColorSpace){if(e=Kh(e,1),t=at(t,0,1),n=at(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=uu(a,r,e+1/3),this.g=uu(a,r,e),this.b=uu(a,r,e-1/3)}return At.toWorkingColorSpace(this,s),this}setStyle(e,t=Kt){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Kt){const n=Vp[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=zi(e.r),this.g=zi(e.g),this.b=zi(e.b),this}copyLinearToSRGB(e){return this.r=Qr(e.r),this.g=Qr(e.g),this.b=Qr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Kt){return At.fromWorkingColorSpace(Cn.copy(this),e),Math.round(at(Cn.r*255,0,255))*65536+Math.round(at(Cn.g*255,0,255))*256+Math.round(at(Cn.b*255,0,255))}getHexString(e=Kt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=At.workingColorSpace){At.fromWorkingColorSpace(Cn.copy(this),t);const n=Cn.r,s=Cn.g,r=Cn.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(s-r)/u+(s<r?6:0);break;case s:c=(r-n)/u+2;break;case r:c=(n-s)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=At.workingColorSpace){return At.fromWorkingColorSpace(Cn.copy(this),t),e.r=Cn.r,e.g=Cn.g,e.b=Cn.b,e}getStyle(e=Kt){At.fromWorkingColorSpace(Cn.copy(this),e);const t=Cn.r,n=Cn.g,s=Cn.b;return e!==Kt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(ws),this.setHSL(ws.h+e,ws.s+t,ws.l+n)}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(ws),e.getHSL(vc);const n=$a(ws.h,vc.h,t),s=$a(ws.s,vc.s,t),r=$a(ws.l,vc.l,t);return this.setHSL(n,s,r),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,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,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 Cn=new qe;qe.NAMES=Vp;let v_=0;class Ti extends bs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:v_++}),this.uuid=ci(),this.name="",this.type="Material",this.blending=Nr,this.side=Qi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=oh,this.blendDst=ch,this.blendEquation=qs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new qe(0,0,0),this.blendAlpha=0,this.depthFunc=Fr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=wp,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ur,this.stencilZFail=Ur,this.stencilZPass=Ur,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.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!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Nr&&(n.blending=this.blending),this.side!==Qi&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==oh&&(n.blendSrc=this.blendSrc),this.blendDst!==ch&&(n.blendDst=this.blendDst),this.blendEquation!==qs&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Fr&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==wp&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ur&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ur&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ur&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Cs extends Ti{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new qe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Bi,this.combine=cp,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Yi=S_();function S_(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),s=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,s[c]=24,s[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,s[c]=-l-1,s[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,s[c]=13,s[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,s[c]=24,s[c|256]=24):(n[c]=31744,n[c|256]=64512,s[c]=13,s[c|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function I_(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=at(i,-65504,65504),Yi.floatView[0]=i;const e=Yi.uint32View[0],t=e>>23&511;return Yi.baseTable[t]+((e&8388607)>>Yi.shiftTable[t])}function M_(i){const e=i>>10;return Yi.uint32View[0]=Yi.mantissaTable[Yi.offsetTable[e]+(i&1023)]+Yi.exponentTable[e],Yi.floatView[0]}class Wp{static toHalfFloat(e){return I_(e)}static fromHalfFloat(e){return M_(e)}}const jt=new H,Sc=new Ze;let B_=0;class En{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:B_++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=qh,this.updateRanges=[],this.gpuType=nn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];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++)Sc.fromBufferAttribute(this,t),Sc.applyMatrix3(e),this.setXY(t,Sc.x,Sc.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyMatrix3(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyMatrix4(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyNormalMatrix(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.transformDirection(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=li(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=It(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=li(t,this.array)),t}setX(e,t){return this.normalized&&(t=It(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=li(t,this.array)),t}setY(e,t){return this.normalized&&(t=It(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=li(t,this.array)),t}setZ(e,t){return this.normalized&&(t=It(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=li(t,this.array)),t}setW(e,t){return this.normalized&&(t=It(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=It(t,this.array),n=It(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=It(t,this.array),n=It(n,this.array),s=It(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=It(t,this.array),n=It(n,this.array),s=It(s,this.array),r=It(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,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!==qh&&(e.usage=this.usage),e}}class qp extends En{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Kp extends En{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Bn extends En{constructor(e,t,n){super(new Float32Array(e),t,n)}}let T_=0;const Zn=new et,du=new Pt,jr=new H,qn=new Ii,ro=new Ii,fn=new H;class On extends bs{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:T_++}),this.uuid=ci(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Mp(e)?Kp:qp)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new rt().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Zn.makeRotationFromQuaternion(e),this.applyMatrix4(Zn),this}rotateX(e){return Zn.makeRotationX(e),this.applyMatrix4(Zn),this}rotateY(e){return Zn.makeRotationY(e),this.applyMatrix4(Zn),this}rotateZ(e){return Zn.makeRotationZ(e),this.applyMatrix4(Zn),this}translate(e,t,n){return Zn.makeTranslation(e,t,n),this.applyMatrix4(Zn),this}scale(e,t,n){return Zn.makeScale(e,t,n),this.applyMatrix4(Zn),this}lookAt(e){return du.lookAt(e),du.updateMatrix(),this.applyMatrix4(du.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(jr).negate(),this.translate(jr.x,jr.y,jr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let s=0,r=e.length;s<r;s++){const a=e[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Bn(n,3))}else{const n=Math.min(e.length,t.count);for(let s=0;s<n;s++){const r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ii);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new H(-1/0,-1/0,-1/0),new H(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){const r=t[n];qn.setFromBufferAttribute(r),this.morphTargetsRelative?(fn.addVectors(this.boundingBox.min,qn.min),this.boundingBox.expandByPoint(fn),fn.addVectors(this.boundingBox.max,qn.max),this.boundingBox.expandByPoint(fn)):(this.boundingBox.expandByPoint(qn.min),this.boundingBox.expandByPoint(qn.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 Mi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new H,1/0);return}if(e){const n=this.boundingSphere.center;if(qn.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];ro.setFromBufferAttribute(o),this.morphTargetsRelative?(fn.addVectors(qn.min,ro.min),qn.expandByPoint(fn),fn.addVectors(qn.max,ro.max),qn.expandByPoint(fn)):(qn.expandByPoint(ro.min),qn.expandByPoint(ro.max))}qn.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)fn.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(fn));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)fn.fromBufferAttribute(o,l),c&&(jr.fromBufferAttribute(e,l),fn.add(jr)),s=Math.max(s,n.distanceToSquared(fn))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,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=t.position,s=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new En(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],c=[];for(let T=0;T<n.count;T++)o[T]=new H,c[T]=new H;const l=new H,h=new H,u=new H,d=new Ze,f=new Ze,m=new Ze,g=new H,A=new H;function p(T,v,C){l.fromBufferAttribute(n,T),h.fromBufferAttribute(n,v),u.fromBufferAttribute(n,C),d.fromBufferAttribute(r,T),f.fromBufferAttribute(r,v),m.fromBufferAttribute(r,C),h.sub(l),u.sub(l),f.sub(d),m.sub(d);const F=1/(f.x*m.y-m.x*f.y);isFinite(F)&&(g.copy(h).multiplyScalar(m.y).addScaledVector(u,-f.y).multiplyScalar(F),A.copy(u).multiplyScalar(f.x).addScaledVector(h,-m.x).multiplyScalar(F),o[T].add(g),o[v].add(g),o[C].add(g),c[T].add(A),c[v].add(A),c[C].add(A))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let T=0,v=y.length;T<v;++T){const C=y[T],F=C.start,K=C.count;for(let q=F,$=F+K;q<$;q+=3)p(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const b=new H,_=new H,M=new H,w=new H;function S(T){M.fromBufferAttribute(s,T),w.copy(M);const v=o[T];b.copy(v),b.sub(M.multiplyScalar(M.dot(v))).normalize(),_.crossVectors(w,v);const F=_.dot(c[T])<0?-1:1;a.setXYZW(T,b.x,b.y,b.z,F)}for(let T=0,v=y.length;T<v;++T){const C=y[T],F=C.start,K=C.count;for(let q=F,$=F+K;q<$;q+=3)S(e.getX(q+0)),S(e.getX(q+1)),S(e.getX(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 En(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const s=new H,r=new H,a=new H,o=new H,c=new H,l=new H,h=new H,u=new H;if(e)for(let d=0,f=e.count;d<f;d+=3){const m=e.getX(d+0),g=e.getX(d+1),A=e.getX(d+2);s.fromBufferAttribute(t,m),r.fromBufferAttribute(t,g),a.fromBufferAttribute(t,A),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),o.fromBufferAttribute(n,m),c.fromBufferAttribute(n,g),l.fromBufferAttribute(n,A),o.add(h),c.add(h),l.add(h),n.setXYZ(m,o.x,o.y,o.z),n.setXYZ(g,c.x,c.y,c.z),n.setXYZ(A,l.x,l.y,l.z)}else for(let d=0,f=t.count;d<f;d+=3)s.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)fn.fromBufferAttribute(e,t),fn.normalize(),e.setXYZ(t,fn.x,fn.y,fn.z)}toNonIndexed(){function e(o,c){const l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h);let f=0,m=0;for(let g=0,A=c.length;g<A;g++){o.isInterleavedBufferAttribute?f=c[g]*o.data.stride+o.offset:f=c[g]*h;for(let p=0;p<h;p++)d[m++]=l[f++]}return new En(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new On,n=this.index.array,s=this.attributes;for(const o in s){const c=s[o],l=e(c,n);t.setAttribute(o,l)}const r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=e(d,n);c.push(f)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.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 c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const s={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(e.data))}h.length>0&&(s[c]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.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());const s=e.attributes;for(const l in s){const h=s[l];this.setAttribute(l,h.clone(t))}const r=e.morphAttributes;for(const l in r){const h=[],u=r[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Xp=new et,$s=new io,Ic=new Mi,Yp=new H,Mc=new H,Bc=new H,Tc=new H,fu=new H,Rc=new H,jp=new H,Nc=new H;class Jt extends Pt{constructor(e=new On,t=new Cs){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(s,e);const o=this.morphTargetInfluences;if(r&&o){Rc.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(fu.fromBufferAttribute(u,e),a?Rc.addScaledVector(fu,h):Rc.addScaledVector(fu.sub(t),h))}t.add(Rc)}return t}raycast(e,t){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Ic.copy(n.boundingSphere),Ic.applyMatrix4(r),$s.copy(e.ray).recast(e.near),!(Ic.containsPoint($s.origin)===!1&&($s.intersectSphere(Ic,Yp)===null||$s.origin.distanceToSquared(Yp)>(e.far-e.near)**2))&&(Xp.copy(r).invert(),$s.copy(e.ray).applyMatrix4(Xp),!(n.boundingBox!==null&&$s.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,$s)))}_computeIntersections(e,t,n){let s;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,g=d.length;m<g;m++){const A=d[m],p=a[A.materialIndex],y=Math.max(A.start,f.start),b=Math.min(o.count,Math.min(A.start+A.count,f.start+f.count));for(let _=y,M=b;_<M;_+=3){const w=o.getX(_),S=o.getX(_+1),T=o.getX(_+2);s=Fc(this,p,e,n,l,h,u,w,S,T),s&&(s.faceIndex=Math.floor(_/3),s.face.materialIndex=A.materialIndex,t.push(s))}}else{const m=Math.max(0,f.start),g=Math.min(o.count,f.start+f.count);for(let A=m,p=g;A<p;A+=3){const y=o.getX(A),b=o.getX(A+1),_=o.getX(A+2);s=Fc(this,a,e,n,l,h,u,y,b,_),s&&(s.faceIndex=Math.floor(A/3),t.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let m=0,g=d.length;m<g;m++){const A=d[m],p=a[A.materialIndex],y=Math.max(A.start,f.start),b=Math.min(c.count,Math.min(A.start+A.count,f.start+f.count));for(let _=y,M=b;_<M;_+=3){const w=_,S=_+1,T=_+2;s=Fc(this,p,e,n,l,h,u,w,S,T),s&&(s.faceIndex=Math.floor(_/3),s.face.materialIndex=A.materialIndex,t.push(s))}}else{const m=Math.max(0,f.start),g=Math.min(c.count,f.start+f.count);for(let A=m,p=g;A<p;A+=3){const y=A,b=A+1,_=A+2;s=Fc(this,a,e,n,l,h,u,y,b,_),s&&(s.faceIndex=Math.floor(A/3),t.push(s))}}}}function R_(i,e,t,n,s,r,a,o){let c;if(e.side===Sn?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,e.side===Qi,o),c===null)return null;Nc.copy(o),Nc.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(Nc);return l<t.near||l>t.far?null:{distance:l,point:Nc.clone(),object:i}}function Fc(i,e,t,n,s,r,a,o,c,l){i.getVertexPosition(o,Mc),i.getVertexPosition(c,Bc),i.getVertexPosition(l,Tc);const h=R_(i,e,t,n,Mc,Bc,Tc,jp);if(h){const u=new H;fi.getBarycoord(jp,Mc,Bc,Tc,u),s&&(h.uv=fi.getInterpolatedAttribute(s,o,c,l,u,new Ze)),r&&(h.uv1=fi.getInterpolatedAttribute(r,o,c,l,u,new Ze)),a&&(h.normal=fi.getInterpolatedAttribute(a,o,c,l,u,new H),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new H,materialIndex:0};fi.getNormal(Mc,Bc,Tc,d.normal),h.face=d,h.barycoord=u}return h}class Jr extends On{constructor(e=1,t=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=0;m("z","y","x",-1,-1,n,t,e,a,r,0),m("z","y","x",1,-1,n,t,-e,a,r,1),m("x","z","y",1,1,e,n,t,s,a,2),m("x","z","y",1,-1,e,n,-t,s,a,3),m("x","y","z",1,-1,e,t,n,s,r,4),m("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new Bn(l,3)),this.setAttribute("normal",new Bn(h,3)),this.setAttribute("uv",new Bn(u,2));function m(g,A,p,y,b,_,M,w,S,T,v){const C=_/S,F=M/T,K=_/2,q=M/2,$=w/2,D=S+1,O=T+1;let j=0,Q=0;const J=new H;for(let ee=0;ee<O;ee++){const ae=ee*F-q;for(let ye=0;ye<D;ye++){const Me=ye*C-K;J[g]=Me*y,J[A]=ae*b,J[p]=$,l.push(J.x,J.y,J.z),J[g]=0,J[A]=0,J[p]=w>0?1:-1,h.push(J.x,J.y,J.z),u.push(ye/S),u.push(1-ee/T),j+=1}}for(let ee=0;ee<T;ee++)for(let ae=0;ae<S;ae++){const ye=d+ae+D*ee,Me=d+ae+D*(ee+1),se=d+(ae+1)+D*(ee+1),me=d+(ae+1)+D*ee;c.push(ye,Me,me),c.push(Me,se,me),Q+=6}o.addGroup(f,Q,v),f+=Q,d+=j}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Zr(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const s=i[t][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone():Array.isArray(s)?e[t][n]=s.slice():e[t][n]=s}}return e}function Tn(i){const e={};for(let t=0;t<i.length;t++){const n=Zr(i[t]);for(const s in n)e[s]=n[s]}return e}function N_(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Jp(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:At.workingColorSpace}const F_={clone:Zr,merge:Tn};var D_=`void main() {+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );+}`,L_=`void main() {+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );+}`;class vs extends Ti{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=D_,this.fragmentShader=L_,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!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=Zr(e.uniforms),this.uniformsGroups=N_(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 s in this.uniforms){const a=this.uniforms[s].value;a&&a.isTexture?t.uniforms[s]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[s]={type:"m4",value:a.toArray()}:t.uniforms[s]={value:a}}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 s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Zp extends Pt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new et,this.projectionMatrix=new et,this.projectionMatrixInverse=new et,this.coordinateSystem=Hi}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.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)}}const Ss=new H,$p=new Ze,eA=new Ze;class vn extends Zp{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Or*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Za*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Or*2*Math.atan(Math.tan(Za*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Ss.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ss.x,Ss.y).multiplyScalar(-e/Ss.z),Ss.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ss.x,Ss.y).multiplyScalar(-e/Ss.z)}getViewSize(e,t){return this.getViewBounds(e,$p,eA),t.subVectors(eA,$p)}setViewOffset(e,t,n,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Za*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,t-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem),this.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 $r=-90,ea=1;class P_ extends Pt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new vn($r,ea,e,t);s.layers=this.layers,this.add(s);const r=new vn($r,ea,e,t);r.layers=this.layers,this.add(r);const a=new vn($r,ea,e,t);a.layers=this.layers,this.add(a);const o=new vn($r,ea,e,t);o.layers=this.layers,this.add(o);const c=new vn($r,ea,e,t);c.layers=this.layers,this.add(c);const l=new vn($r,ea,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===Hi)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===gc)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;const g=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,s),e.render(t,r),e.setRenderTarget(n,1,s),e.render(t,a),e.setRenderTarget(n,2,s),e.render(t,o),e.setRenderTarget(n,3,s),e.render(t,c),e.setRenderTarget(n,4,s),e.render(t,l),n.texture.generateMipmaps=g,e.setRenderTarget(n,5,s),e.render(t,h),e.setRenderTarget(u,d,f),e.xr.enabled=m,n.texture.needsPMREMUpdate=!0}}class tA extends an{constructor(e=[],t=Ks,n,s,r,a,o,c,l,h){super(e,t,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class k_ extends js{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new tA(s,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:zt}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 );++ }+ `},s=new Jr(5,5,5),r=new vs({name:"CubemapFromEquirect",uniforms:Zr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Sn,blending:gs});r.uniforms.tEquirect.value=t;const a=new Jt(s,r),o=t.minFilter;return t.minFilter===Jn&&(t.minFilter=zt),new P_(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(r)}}class er extends Pt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const U_={type:"move"};class pu{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new er,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 er,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new H,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new H),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new er,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new H,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new H),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 s=null,r=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const g of e.hand.values()){const A=t.getJointPose(g,n),p=this._getHandJoint(l,g);A!==null&&(p.matrix.fromArray(A.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=A.radius),p.visible=A!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,m=.005;l.inputState.pinching&&d>f+m?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=f-m&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(U_)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new er;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Au extends Pt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Bi,this.environmentIntensity=1,this.environmentRotation=new Bi,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,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),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.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class O_{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=qh,this.updateRanges=[],this.version=0,this.uuid=ci()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.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 s=0,r=this.stride;s<r;s++)this.array[e+s]=t.array[n+s];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=ci()),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=ci()),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 Rn=new H;class gu{constructor(e,t,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Rn.fromBufferAttribute(this,t),Rn.applyMatrix4(e),this.setXYZ(t,Rn.x,Rn.y,Rn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Rn.fromBufferAttribute(this,t),Rn.applyNormalMatrix(e),this.setXYZ(t,Rn.x,Rn.y,Rn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Rn.fromBufferAttribute(this,t),Rn.transformDirection(e),this.setXYZ(t,Rn.x,Rn.y,Rn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=li(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=It(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=It(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=li(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=li(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=li(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=li(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),n=It(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),n=It(n,this.array),s=It(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),n=It(n,this.array),s=It(s,this.array),r=It(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=r,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 s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return new En(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 gu(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 s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}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}}}const nA=new H,iA=new _t,sA=new _t,Q_=new H,rA=new et,Dc=new H,mu=new Mi,aA=new et,bu=new io;class G_ extends Jt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=hp,this.bindMatrix=new et,this.bindMatrixInverse=new et,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Ii),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Dc),this.boundingBox.expandByPoint(Dc)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Mi),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Dc),this.boundingSphere.expandByPoint(Dc)}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,s=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),mu.copy(this.boundingSphere),mu.applyMatrix4(s),e.ray.intersectsSphere(mu)!==!1&&(aA.copy(s).invert(),bu.copy(e.ray).applyMatrix4(aA),!(this.boundingBox!==null&&bu.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,bu)))}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 _t,t=this.geometry.attributes.skinWeight;for(let n=0,s=t.count;n<s;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===hp?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===FE?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,s=this.geometry;iA.fromBufferAttribute(s.attributes.skinIndex,e),sA.fromBufferAttribute(s.attributes.skinWeight,e),nA.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const a=sA.getComponent(r);if(a!==0){const o=iA.getComponent(r);rA.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Q_.copy(nA).applyMatrix4(rA),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class oA extends Pt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Lc extends an{constructor(e=null,t=1,n=1,s,r,a,o,c,l=In,h=In,u,d){super(null,a,o,c,l,h,s,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const cA=new et,H_=new et;class xu{constructor(e=[],t=[]){this.uuid=ci(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,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,s=this.bones.length;n<s;n++)this.boneInverses.push(new et)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new et;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,s=this.boneTexture;for(let r=0,a=e.length;r<a;r++){const o=e[r]?e[r].matrixWorld:H_;cA.multiplyMatrices(o,t[r]),cA.toArray(n,r*16)}s!==null&&(s.needsUpdate=!0)}clone(){return new xu(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Lc(t,e,e,sn,nn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const s=this.bones[t];if(s.name===e)return s}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,s=e.bones.length;n<s;n++){const r=e.bones[n];let a=t[r];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),a=new oA),this.bones.push(a),this.boneInverses.push(new et().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 s=0,r=t.length;s<r;s++){const a=t[s];e.bones.push(a.uuid);const o=n[s];e.boneInverses.push(o.toArray())}return e}}class Eu extends En{constructor(e,t,n,s=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const ta=new et,lA=new et,Pc=[],hA=new Ii,z_=new et,ao=new Jt,oo=new Mi;class uA extends Jt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Eu(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let s=0;s<n;s++)this.setMatrixAt(s,z_)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Ii),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ta),hA.copy(e.boundingBox).applyMatrix4(ta),this.boundingBox.union(hA)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Mi),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,ta),oo.copy(e.boundingSphere).applyMatrix4(ta),this.boundingSphere.union(oo)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),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)}getMorphAt(e,t){const n=t.morphTargetInfluences,s=this.morphTexture.source.data.data,r=n.length+1,a=e*r+1;for(let o=0;o<n.length;o++)n[o]=s[a+o]}raycast(e,t){const n=this.matrixWorld,s=this.count;if(ao.geometry=this.geometry,ao.material=this.material,ao.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),oo.copy(this.boundingSphere),oo.applyMatrix4(n),e.ray.intersectsSphere(oo)!==!1))for(let r=0;r<s;r++){this.getMatrixAt(r,ta),lA.multiplyMatrices(n,ta),ao.matrixWorld=lA,ao.raycast(e,Pc);for(let a=0,o=Pc.length;a<o;a++){const c=Pc[a];c.instanceId=r,c.object=this,t.push(c)}Pc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Eu(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,s=n.length+1;this.morphTexture===null&&(this.morphTexture=new Lc(new Float32Array(s*this.count),s,this.count,Gi,nn));const r=this.morphTexture.source.data.data;let a=0;for(let l=0;l<n.length;l++)a+=n[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=s*e;r[c]=o,r.set(n,c+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const _u=new H,V_=new H,W_=new rt;class Is{constructor(e=new H(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const s=_u.subVectors(n,t).cross(V_.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(_u),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}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||W_.getNormalMatrix(e),s=this.coplanarPoint(_u).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const tr=new Mi,kc=new H;class yu{constructor(e=new Is,t=new Is,n=new Is,s=new Is,r=new Is,a=new Is){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Hi){const n=this.planes,s=e.elements,r=s[0],a=s[1],o=s[2],c=s[3],l=s[4],h=s[5],u=s[6],d=s[7],f=s[8],m=s[9],g=s[10],A=s[11],p=s[12],y=s[13],b=s[14],_=s[15];if(n[0].setComponents(c-r,d-l,A-f,_-p).normalize(),n[1].setComponents(c+r,d+l,A+f,_+p).normalize(),n[2].setComponents(c+a,d+h,A+m,_+y).normalize(),n[3].setComponents(c-a,d-h,A-m,_-y).normalize(),n[4].setComponents(c-o,d-u,A-g,_-b).normalize(),t===Hi)n[5].setComponents(c+o,d+u,A+g,_+b).normalize();else if(t===gc)n[5].setComponents(o,u,g,b).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(),tr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),tr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(tr)}intersectsSprite(e){return tr.center.set(0,0,0),tr.radius=.7071067811865476,tr.applyMatrix4(e.matrixWorld),this.intersectsSphere(tr)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const s=t[n];if(kc.x=s.normal.x>0?e.max.x:e.min.x,kc.y=s.normal.y>0?e.max.y:e.min.y,kc.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(kc)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class co extends Ti{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new qe(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 Uc=new H,Oc=new H,dA=new et,lo=new io,Qc=new Mi,wu=new H,fA=new H;class Cu extends Pt{constructor(e=new On,t=new co){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let s=1,r=t.count;s<r;s++)Uc.fromBufferAttribute(t,s-1),Oc.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=Uc.distanceTo(Oc);e.setAttribute("lineDistance",new Bn(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Qc.copy(n.boundingSphere),Qc.applyMatrix4(s),Qc.radius+=r,e.ray.intersectsSphere(Qc)===!1)return;dA.copy(s).invert(),lo.copy(e.ray).applyMatrix4(dA);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const f=Math.max(0,a.start),m=Math.min(h.count,a.start+a.count);for(let g=f,A=m-1;g<A;g+=l){const p=h.getX(g),y=h.getX(g+1),b=Gc(this,e,lo,c,p,y,g);b&&t.push(b)}if(this.isLineLoop){const g=h.getX(m-1),A=h.getX(f),p=Gc(this,e,lo,c,g,A,m-1);p&&t.push(p)}}else{const f=Math.max(0,a.start),m=Math.min(d.count,a.start+a.count);for(let g=f,A=m-1;g<A;g+=l){const p=Gc(this,e,lo,c,g,g+1,g);p&&t.push(p)}if(this.isLineLoop){const g=Gc(this,e,lo,c,m-1,f,m-1);g&&t.push(g)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Gc(i,e,t,n,s,r,a){const o=i.geometry.attributes.position;if(Uc.fromBufferAttribute(o,s),Oc.fromBufferAttribute(o,r),t.distanceSqToSegment(Uc,Oc,wu,fA)>n)return;wu.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(wu);if(!(l<e.near||l>e.far))return{distance:l,point:fA.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const pA=new H,AA=new H;class Hc extends Cu{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let s=0,r=t.count;s<r;s+=2)pA.fromBufferAttribute(t,s),AA.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+pA.distanceTo(AA);e.setAttribute("lineDistance",new Bn(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class q_ extends Cu{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class vu extends Ti{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new qe(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 gA=new et,Su=new io,zc=new Mi,Vc=new H;class K_ extends Pt{constructor(e=new On,t=new vu){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,s=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),zc.copy(n.boundingSphere),zc.applyMatrix4(s),zc.radius+=r,e.ray.intersectsSphere(zc)===!1)return;gA.copy(s).invert(),Su.copy(e.ray).applyMatrix4(gA);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,u=n.attributes.position;if(l!==null){const d=Math.max(0,a.start),f=Math.min(l.count,a.start+a.count);for(let m=d,g=f;m<g;m++){const A=l.getX(m);Vc.fromBufferAttribute(u,A),mA(Vc,A,c,s,e,t,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let m=d,g=f;m<g;m++)Vc.fromBufferAttribute(u,m),mA(Vc,m,c,s,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function mA(i,e,t,n,s,r,a){const o=Su.distanceSqToPoint(i);if(o<t){const c=new H;Su.closestPointToPoint(i,c),c.applyMatrix4(n);const l=s.ray.origin.distanceTo(c);if(l<s.near||l>s.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Wc extends an{constructor(e,t,n,s,r,a,o,c,l,h,u,d){super(null,a,o,c,l,h,s,r,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class X_ extends Wc{constructor(e,t,n,s,r,a){super(e,t,n,r,a),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=ai,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Y_ extends Wc{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Ks),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class bA extends an{constructor(e,t,n=Xs,s,r,a,o=In,c=In,l,h=za){if(h!==za&&h!==Va)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super(null,s,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Yh(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class qc extends On{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};const r=e/2,a=t/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,u=e/o,d=t/c,f=[],m=[],g=[],A=[];for(let p=0;p<h;p++){const y=p*d-a;for(let b=0;b<l;b++){const _=b*u-r;m.push(_,-y,0),g.push(0,0,1),A.push(b/o),A.push(1-p/c)}}for(let p=0;p<c;p++)for(let y=0;y<o;y++){const b=y+l*p,_=y+l*(p+1),M=y+1+l*(p+1),w=y+1+l*p;f.push(b,_,w),f.push(_,M,w)}this.setIndex(f),this.setAttribute("position",new Bn(m,3)),this.setAttribute("normal",new Bn(g,3)),this.setAttribute("uv",new Bn(A,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new qc(e.width,e.height,e.widthSegments,e.heightSegments)}}class ho extends Ti{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new qe(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 qe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yp,this.normalScale=new Ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Bi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Ri extends ho{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 Ze(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return at(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 qe(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 qe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new qe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=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 dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=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.dispersion=e.dispersion,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 j_ extends Ti{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=kE,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 J_ extends Ti{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}}function Kc(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function Z_(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function $_(i){function e(s,r){return i[s]-i[r]}const t=i.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function xA(i,e,t){const n=i.length,s=new i.constructor(n);for(let r=0,a=0;a!==n;++r){const o=t[r]*e;for(let c=0;c!==e;++c)s[a++]=i[o+c]}return s}function EA(i,e,t,n){let s=1,r=i[0];for(;r!==void 0&&r[n]===void 0;)r=i[s++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(e.push(r.time),t.push(...a)),r=i[s++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=i[s++];while(r!==void 0);else do a=r[n],a!==void 0&&(e.push(r.time),t.push(a)),r=i[s++];while(r!==void 0)}class uo{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s: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,s=t[n],r=t[n-1];e:{t:{let a;n:{i:if(!(e<s)){for(let o=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=s,s=t[++n],e<s)break t}a=t.length;break n}if(!(e>=r)){const o=t[1];e<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(s=r,r=t[--n-1],e>=r)break t}a=n,n=0;break n}break e}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let a=0;a!==s;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class ey extends uo{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Pr,endingEnd:Pr}}intervalChanged_(e,t,n){const s=this.parameterPositions;let r=e-2,a=e+1,o=s[r],c=s[a];if(o===void 0)switch(this.getSettings_().endingStart){case kr:r=e,o=2*t-n;break;case pc:r=s.length-2,o=t+s[r]-s[r+1];break;default:r=e,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case kr:a=e,c=2*n-t;break;case pc:a=1,c=n+s[1]-s[0];break;default:a=e-1,c=t}const l=(n-t)*.5,h=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,n,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,m=(n-t)/(s-t),g=m*m,A=g*m,p=-d*A+2*d*g-d*m,y=(1+d)*A+(-1.5-2*d)*g+(-.5+d)*m+1,b=(-1-f)*A+(1.5+f)*g+.5*m,_=f*A-f*g;for(let M=0;M!==o;++M)r[M]=p*a[h+M]+y*a[l+M]+b*a[c+M]+_*a[u+M];return r}}class _A extends uo{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=(n-t)/(s-t),u=1-h;for(let d=0;d!==o;++d)r[d]=a[l+d]*u+a[c+d]*h;return r}}class ty extends uo{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}}class pi{constructor(e,t,n,s){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=Kc(t,this.TimeBufferType),this.values=Kc(n,this.ValueBufferType),this.setInterpolation(s||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:Kc(e.times,Array),values:Kc(e.values,Array)};const s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new ty(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new _A(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ey(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case ja:t=this.InterpolantFactoryMethodDiscrete;break;case Ja:t=this.InterpolantFactoryMethodLinear;break;case zh: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 ja;case this.InterpolantFactoryMethodLinear:return Ja;case this.InterpolantFactoryMethodSmooth:return zh}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e}return this}trim(e,t){const n=this.times,s=n.length;let r=0,a=s-1;for(;r!==s&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}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,s=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(a!==null&&a>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,a),e=!1;break}a=c}if(s!==void 0&&Z_(s))for(let o=0,c=s.length;o!==c;++o){const l=s[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===zh,r=e.length-1;let a=1;for(let o=1;o<r;++o){let c=!1;const l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(s)c=!0;else{const u=o*n,d=u-n,f=u+n;for(let m=0;m!==n;++m){const g=t[u+m];if(g!==t[d+m]||g!==t[f+m]){c=!0;break}}}if(c){if(o!==a){e[a]=e[o];const u=o*n,d=a*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++a}}if(r>0){e[a]=e[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)t[c+l]=t[o+l];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}}pi.prototype.ValueTypeName="",pi.prototype.TimeBufferType=Float32Array,pi.prototype.ValueBufferType=Float32Array,pi.prototype.DefaultInterpolation=Ja;class na extends pi{constructor(e,t,n){super(e,t,n)}}na.prototype.ValueTypeName="bool",na.prototype.ValueBufferType=Array,na.prototype.DefaultInterpolation=ja,na.prototype.InterpolantFactoryMethodLinear=void 0,na.prototype.InterpolantFactoryMethodSmooth=void 0;class yA extends pi{constructor(e,t,n,s){super(e,t,n,s)}}yA.prototype.ValueTypeName="color";class ia extends pi{constructor(e,t,n,s){super(e,t,n,s)}}ia.prototype.ValueTypeName="number";class ny extends uo{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-t)/(s-t);let l=e*o;for(let h=l+o;l!==h;l+=4)Vn.slerpFlat(r,0,a,l-o,a,l,c);return r}}class sa extends pi{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new ny(this.times,this.values,this.getValueSize(),e)}}sa.prototype.ValueTypeName="quaternion",sa.prototype.InterpolantFactoryMethodSmooth=void 0;class ra extends pi{constructor(e,t,n){super(e,t,n)}}ra.prototype.ValueTypeName="string",ra.prototype.ValueBufferType=Array,ra.prototype.DefaultInterpolation=ja,ra.prototype.InterpolantFactoryMethodLinear=void 0,ra.prototype.InterpolantFactoryMethodSmooth=void 0;class aa extends pi{constructor(e,t,n,s){super(e,t,n,s)}}aa.prototype.ValueTypeName="vector";class Iu{constructor(e="",t=-1,n=[],s=Vh){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=ci(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,s=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(sy(n[a]).scale(s));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,a=n.length;r!==a;++r)t.push(pi.toJSON(n[r]));return s}static CreateFromMorphTargetSequence(e,t,n,s){const r=t.length,a=[];for(let o=0;o<r;o++){let c=[],l=[];c.push((o+r-1)%r,o,(o+1)%r),l.push(0,1,0);const h=$_(c);c=xA(c,1,h),l=xA(l,1,h),!s&&c[0]===0&&(c.push(r),l.push(l[0])),a.push(new ia(".morphTargetInfluences["+t[o].name+"]",c,l).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const s=e;n=s.geometry&&s.geometry.animations||s.animations}for(let s=0;s<n.length;s++)if(n[s].name===t)return n[s];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const s={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){const l=e[o],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let d=s[u];d||(s[u]=d=[]),d.push(l)}}const a=[];for(const o in s)a.push(this.CreateFromMorphTargetSequence(o,s[o],t,n));return a}static parseAnimation(e,t){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,f,m,g){if(f.length!==0){const A=[],p=[];EA(f,A,p,m),A.length!==0&&g.push(new u(d,A,p))}},s=[],r=e.name||"default",a=e.fps||30,o=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let u=0;u<l.length;u++){const d=l[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const f={};let m;for(m=0;m<d.length;m++)if(d[m].morphTargets)for(let g=0;g<d[m].morphTargets.length;g++)f[d[m].morphTargets[g]]=-1;for(const g in f){const A=[],p=[];for(let y=0;y!==d[m].morphTargets.length;++y){const b=d[m];A.push(b.time),p.push(b.morphTarget===g?1:0)}s.push(new ia(".morphTargetInfluence["+g+"]",A,p))}c=f.length*a}else{const f=".bones["+t[u].name+"]";n(aa,f+".position",d,"pos",s),n(sa,f+".quaternion",d,"rot",s),n(aa,f+".scale",d,"scl",s)}}return s.length===0?null:new this(r,c,s,o)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,s=e.length;n!==s;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.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 iy(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ia;case"vector":case"vector2":case"vector3":case"vector4":return aa;case"color":return yA;case"quaternion":return sa;case"bool":case"boolean":return na;case"string":return ra}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function sy(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=iy(i.type);if(i.times===void 0){const t=[],n=[];EA(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const ji={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class wA{constructor(e,t,n){const s=this;let r=!1,a=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],m=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return m}return null}}}const ry=new wA;class Ji{constructor(e){this.manager=e!==void 0?e:ry,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(s,r){n.load(e,s,t,r)})}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}}Ji.DEFAULT_MATERIAL_NAME="__DEFAULT";const Zi={};class ay extends Error{constructor(e,t){super(e),this.response=t}}class Ms extends Ji{constructor(e){super(e),this.mimeType="",this.responseType=""}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=ji.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(Zi[e]!==void 0){Zi[e].push({onLoad:t,onProgress:n,onError:s});return}Zi[e]=[],Zi[e].push({onLoad:t,onProgress:n,onError:s});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=Zi[e],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,m=f!==0;let g=0;const A=new ReadableStream({start(p){y();function y(){u.read().then(({done:b,value:_})=>{if(b)p.close();else{g+=_.byteLength;const M=new ProgressEvent("progress",{lengthComputable:m,loaded:g,total:f});for(let w=0,S=h.length;w<S;w++){const T=h[w];T.onProgress&&T.onProgress(M)}p.enqueue(_),y()}},b=>{p.error(b)})}}});return new Response(A)}else throw new ay(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o==="")return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(m=>f.decode(m))}}}).then(l=>{ji.add(e,l);const h=Zi[e];delete Zi[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=Zi[e];if(h===void 0)throw this.manager.itemError(e),l;delete Zi[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(l)}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 oy extends Ji{constructor(e){super(e)}load(e,t,n,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=ji.get(e);if(a!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a;const o=eo("img");function c(){h(),ji.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(u){h(),s&&s(u),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(e),o.src=e,o}}class cy extends Ji{constructor(e){super(e)}load(e,t,n,s){const r=this,a=new Lc,o=new Ms(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(e,function(c){let l;try{l=r.parse(c)}catch(h){if(s!==void 0)s(h);else{console.error(h);return}}l.image!==void 0?a.image=l.image:l.data!==void 0&&(a.image.width=l.width,a.image.height=l.height,a.image.data=l.data),a.wrapS=l.wrapS!==void 0?l.wrapS:ai,a.wrapT=l.wrapT!==void 0?l.wrapT:ai,a.magFilter=l.magFilter!==void 0?l.magFilter:zt,a.minFilter=l.minFilter!==void 0?l.minFilter:zt,a.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0&&(a.colorSpace=l.colorSpace),l.flipY!==void 0&&(a.flipY=l.flipY),l.format!==void 0&&(a.format=l.format),l.type!==void 0&&(a.type=l.type),l.mipmaps!==void 0&&(a.mipmaps=l.mipmaps,a.minFilter=Jn),l.mipmapCount===1&&(a.minFilter=zt),l.generateMipmaps!==void 0&&(a.generateMipmaps=l.generateMipmaps),a.needsUpdate=!0,t&&t(a,l)},n,s),a}}class ly extends Ji{constructor(e){super(e)}load(e,t,n,s){const r=new an,a=new oy(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},n,s),r}}class fo extends Pt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new qe(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()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class hy extends fo{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new qe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Mu=new et,CA=new H,vA=new H;class Bu{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ze(512,512),this.mapType=tn,this.map=null,this.mapPass=null,this.matrix=new et,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new yu,this._frameExtents=new Ze(1,1),this._viewportCount=1,this._viewports=[new _t(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;CA.setFromMatrixPosition(e.matrixWorld),t.position.copy(CA),vA.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(vA),t.updateMatrixWorld(),Mu.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Mu),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Mu)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class uy extends Bu{constructor(){super(new vn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=Or*2*e.angle*this.focus,s=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(n!==t.fov||s!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=s,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class dy extends fo{constructor(e,t,n=0,s=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.distance=n,this.angle=s,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new uy}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 SA=new et,po=new H,Tu=new H;class fy extends Bu{constructor(){super(new vn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ze(4,2),this._viewportCount=6,this._viewports=[new _t(2,1,1,1),new _t(0,1,1,1),new _t(3,1,1,1),new _t(1,1,1,1),new _t(3,0,1,1),new _t(1,0,1,1)],this._cubeDirections=[new H(1,0,0),new H(-1,0,0),new H(0,0,1),new H(0,0,-1),new H(0,1,0),new H(0,-1,0)],this._cubeUps=[new H(0,1,0),new H(0,1,0),new H(0,1,0),new H(0,1,0),new H(0,0,1),new H(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,s=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),po.setFromMatrixPosition(e.matrixWorld),n.position.copy(po),Tu.copy(n.position),Tu.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Tu),n.updateMatrixWorld(),s.makeTranslation(-po.x,-po.y,-po.z),SA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(SA)}}class IA extends fo{constructor(e,t,n=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new fy}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 Ru extends Zp{constructor(e=-1,t=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=s+t,c=s-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,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}}class py extends Bu{constructor(){super(new Ru(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class MA extends fo{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Pt.DEFAULT_UP),this.updateMatrix(),this.target=new Pt,this.shadow=new py}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Ay extends fo{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class oa{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 gy extends Ji{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,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=ji.get(e);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(l=>{t&&t(l),r.manager.itemEnd(e)}).catch(l=>{s&&s(l)});return}return setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){return ji.add(e,l),t&&t(l),r.manager.itemEnd(e),l}).catch(function(l){s&&s(l),ji.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});ji.add(e,c),r.manager.itemStart(e)}}class my extends vn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class by{constructor(e,t,n){this.binding=e,this.valueSize=n;let s,r,a;switch(t){case"quaternion":s=this._slerp,r=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":s=this._select,r=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:s=this._lerp,r=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=s,this._mixBufferRegionAdditive=r,this._setIdentity=a,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,s=this.valueSize,r=e*s+s;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==s;++o)n[r+o]=n[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(n,r,0,o,s)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,s=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,s,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,s=e*t+t,r=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const c=t*this._origIndex;this._mixBufferRegion(n,s,c,1-r,t)}a>0&&this._mixBufferRegionAdditive(n,s,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){o.setValue(n,s);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,s=n*this._origIndex;e.getValue(t,s);for(let r=n,a=s;r!==a;++r)t[r]=t[s+r%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,s,r){if(s>=.5)for(let a=0;a!==r;++a)e[t+a]=e[n+a]}_slerp(e,t,n,s){Vn.slerpFlat(e,t,e,t,e,n,s)}_slerpAdditive(e,t,n,s,r){const a=this._workIndex*r;Vn.multiplyQuaternionsFlat(e,a,e,t,e,n),Vn.slerpFlat(e,t,e,t,e,a,s)}_lerp(e,t,n,s,r){const a=1-s;for(let o=0;o!==r;++o){const c=t+o;e[c]=e[c]*a+e[n+o]*s}}_lerpAdditive(e,t,n,s,r){for(let a=0;a!==r;++a){const o=t+a;e[o]=e[o]+e[n+a]*s}}}const Nu="\\[\\]\\.:\\/",xy=new RegExp("["+Nu+"]","g"),Fu="[^"+Nu+"]",Ey="[^"+Nu.replace("\\.","")+"]",_y=/((?:WC+[\/:])*)/.source.replace("WC",Fu),yy=/(WCOD+)?/.source.replace("WCOD",Ey),wy=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Fu),Cy=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Fu),vy=new RegExp("^"+_y+yy+wy+Cy+"$"),Sy=["material","materials","bones","map"];class Iy{constructor(e,t,n){const s=n||Ct.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].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 Ct{constructor(e,t,n){this.path=t,this.parsedPath=n||Ct.parseTrackName(t),this.node=Ct.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 Ct.Composite(e,t,n):new Ct(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(xy,"")}static parseTrackName(e){const t=vy.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]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){const r=n.nodeName.substring(s+1);Sy.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}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(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===t||o.uuid===t)return o;const c=n(o.children);if(c)return c}return null},s=n(e.children);if(s)return s}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 s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_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 s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=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,s=t.propertyName;let r=t.propertyIndex;if(e||(e=Ct.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=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 h=0;h<e.length;h++)if(e[h].name===l){l=h;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(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const a=e[s];if(a===void 0){const l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+s+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(s==="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[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Ct.Composite=Iy,Ct.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Ct.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Ct.prototype.GetterByBindingType=[Ct.prototype._getValue_direct,Ct.prototype._getValue_array,Ct.prototype._getValue_arrayElement,Ct.prototype._getValue_toArray],Ct.prototype.SetterByBindingTypeAndVersioning=[[Ct.prototype._setValue_direct,Ct.prototype._setValue_direct_setNeedsUpdate,Ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ct.prototype._setValue_array,Ct.prototype._setValue_array_setNeedsUpdate,Ct.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ct.prototype._setValue_arrayElement,Ct.prototype._setValue_arrayElement_setNeedsUpdate,Ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ct.prototype._setValue_fromArray,Ct.prototype._setValue_fromArray_setNeedsUpdate,Ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class My{constructor(e,t,n=null,s=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=s;const r=t.tracks,a=r.length,o=new Array(a),c={endingStart:Pr,endingEnd:Pr};for(let l=0;l!==a;++l){const h=r[l].createInterpolant(null);o[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Ep,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=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){const s=this._clip.duration,r=e._clip.duration,a=r/s,o=s/r;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n=!1){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 s=this._mixer,r=s.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=s._lendControlInterpolant(),this._timeScaleInterpolant=o);const c=o.parameterPositions,l=o.sampleValues;return c[0]=r,c[1]=r+n,l[0]=e/a,l[1]=t/a,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,s){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const c=(e-r)*n;c<0||n===0?t=0:(this._startTime=null,t=n*c)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case LE:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulateAdditive(o);break;case Vh:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulate(s,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const s=n.evaluate(e)[0];t*=s,e>n.parameterPositions[1]&&(this.stopFading(),s===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 s=n.evaluate(e)[0];t*=s,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 s=this.time+e,r=this._loopCount;const a=n===DE;if(e===0)return r===-1?s:a&&(r&1)===1?t-s:s;if(n===xp){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else if(s<0)s=0;else{this.time=s;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),s>=t||s<0){const o=Math.floor(s/t);s-=t*o,r+=Math.abs(o);const c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=e>0?t:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=s;if(a&&(r&1)===1)return t-s}return s}_setEndings(e,t,n){const s=this._interpolantSettings;n?(s.endingStart=kr,s.endingEnd=kr):(e?s.endingStart=this.zeroSlopeAtStart?kr:Pr:s.endingStart=pc,t?s.endingEnd=this.zeroSlopeAtEnd?kr:Pr:s.endingEnd=pc)}_scheduleFading(e,t,n){const s=this._mixer,r=s.time;let a=this._weightInterpolant;a===null&&(a=s._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,c=a.sampleValues;return o[0]=r,c[0]=t,o[1]=r+e,c[1]=n,this}}const By=new Float32Array(1);class BA extends bs{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,s=e._clip.tracks,r=s.length,a=e._propertyBindings,o=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName;let h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==r;++u){const d=s[u],f=d.name;let m=h[f];if(m!==void 0)++m.referenceCount,a[u]=m;else{if(m=a[u],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,c,f));continue}const g=t&&t._propertyBindings[u].binding.parsedPath;m=new by(Ct.create(n,f,g),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,c,f),a[u]=m}o[u].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,s=e._clip.uuid,r=this._actionsByClip[s];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,s,n)}const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const r=t[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const r=t[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}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 s=this._actions,r=this._actionsByClip;let a=r[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=s.length,s.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],s=e._cacheIndex;n._cacheIndex=s,t[s]=n,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,a=this._actionsByClip,o=a[r],c=o.knownActions,l=c[c.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,c[h]=l,c.pop(),e._byClipCacheIndex=null;const u=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete u[d],c.length===0&&delete a[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const r=t[n];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,s=this._nActiveActions++,r=t[s];e._cacheIndex=s,t[s]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,s=--this._nActiveActions,r=t[s];e._cacheIndex=s,t[s]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){const s=this._bindingsByRootAndName,r=this._bindings;let a=s[t];a===void 0&&(a={},s[t]=a),a[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,s=n.rootNode.uuid,r=n.path,a=this._bindingsByRootAndName,o=a[s],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete o[r],Object.keys(o).length===0&&delete a[s]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,s=this._nActiveBindings++,r=t[s];e._cacheIndex=s,t[s]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,s=--this._nActiveBindings,r=t[s];e._cacheIndex=s,t[s]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new _A(new Float32Array(2),new Float32Array(2),1,By),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,s=--this._nActiveControlInterpolants,r=t[s];e.__cacheIndex=s,t[s]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){const s=t||this._root,r=s.uuid;let a=typeof e=="string"?Iu.findByName(s,e):e;const o=a!==null?a.uuid:e,c=this._actionsByClip[o];let l=null;if(n===void 0&&(a!==null?n=a.blendMode:n=Vh),c!==void 0){const u=c.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;l=c.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;const h=new My(this,a,t,n);return this._bindAction(h,l),this._addInactiveAction(h,o,r),h}existingAction(e,t){const n=t||this._root,s=n.uuid,r=typeof e=="string"?Iu.findByName(n,e):e,a=r?r.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[s]||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,s=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(s,e,r,a);const o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(a);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,s=this._actionsByClip,r=s[n];if(r!==void 0){const a=r.knownActions;for(let o=0,c=a.length;o!==c;++o){const l=a[o];this._deactivateAction(l);const h=l._cacheIndex,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(l)}delete s[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const a in n){const o=n[a].actionByRoot,c=o[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const s=this._bindingsByRootAndName,r=s[t];if(r!==void 0)for(const a in r){const o=r[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class TA{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}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=at(this.phi,1e-6,Math.PI-1e-6),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(at(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const Bs=new H,Xc=new et,Du=new et;class Ty extends Hc{constructor(e){const t=RA(e),n=new On,s=[],r=[],a=new qe(0,0,1),o=new qe(0,1,0);for(let l=0;l<t.length;l++){const h=t[l];h.parent&&h.parent.isBone&&(s.push(0,0,0),s.push(0,0,0),r.push(a.r,a.g,a.b),r.push(o.r,o.g,o.b))}n.setAttribute("position",new Bn(s,3)),n.setAttribute("color",new Bn(r,3));const c=new co({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,c),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,s=n.getAttribute("position");Du.copy(this.root.matrixWorld).invert();for(let r=0,a=0;r<t.length;r++){const o=t[r];o.parent&&o.parent.isBone&&(Xc.multiplyMatrices(Du,o.matrixWorld),Bs.setFromMatrixPosition(Xc),s.setXYZ(a,Bs.x,Bs.y,Bs.z),Xc.multiplyMatrices(Du,o.parent.matrixWorld),Bs.setFromMatrixPosition(Xc),s.setXYZ(a+1,Bs.x,Bs.y,Bs.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function RA(i){const e=[];i.isBone===!0&&e.push(i);for(let t=0;t<i.children.length;t++)e.push(...RA(i.children[t]));return e}class Ry extends Hc{constructor(e=10,t=10,n=4473924,s=8947848){n=new qe(n),s=new qe(s);const r=t/2,a=e/t,o=e/2,c=[],l=[];for(let d=0,f=0,m=-o;d<=t;d++,m+=a){c.push(-o,0,m,o,0,m),c.push(m,0,-o,m,0,o);const g=d===r?n:s;g.toArray(l,f),f+=3,g.toArray(l,f),f+=3,g.toArray(l,f),f+=3,g.toArray(l,f),f+=3}const h=new On;h.setAttribute("position",new Bn(c,3)),h.setAttribute("color",new Bn(l,3));const u=new co({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class NA extends Hc{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],s=new On;s.setAttribute("position",new Bn(t,3)),s.setAttribute("color",new Bn(n,3));const r=new co({vertexColors:!0,toneMapped:!1});super(s,r),this.type="AxesHelper"}setColors(e,t,n){const s=new qe,r=this.geometry.attributes.color.array;return s.set(e),s.toArray(r,0),s.toArray(r,3),s.set(t),s.toArray(r,6),s.toArray(r,9),s.set(n),s.toArray(r,12),s.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ny extends bs{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function FA(i,e,t,n){const s=Fy(n);switch(t){case gp:return i*e;case Gi:return i*e/s.components*s.byteLength;case yh:return i*e/s.components*s.byteLength;case Ys:return i*e*2/s.components*s.byteLength;case wh:return i*e*2/s.components*s.byteLength;case mp:return i*e*3/s.components*s.byteLength;case sn:return i*e*4/s.components*s.byteLength;case Ch:return i*e*4/s.components*s.byteLength;case ac:case Wa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case oc:case qa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case vh:case Sh:return Math.max(i,16)*Math.max(e,8)/4;case cc:case lc:return Math.max(i,8)*Math.max(e,8)/2;case hc:case uc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case dc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ka:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ih:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Mh:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Bh:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Xa:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Th:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Rh:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Nh:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Fh:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Dh:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Lh:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Ph:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case kh:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Uh:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Ya:case Oh:case fc:return Math.ceil(i/4)*Math.ceil(e/4)*16;case bp:case Qh:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Gh:case Hh:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Fy(i){switch(i){case tn:case fp:return{byteLength:1,components:1};case Ga:case pp:case Mn:return{byteLength:2,components:1};case Eh:case _h:return{byteLength:2,components:4};case Xs:case xh:case nn:return{byteLength:4,components:1};case Ap:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"176"}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="176");function DA(){let i=null,e=!1,t=null,n=null;function s(r,a){t(r,a),n=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function Dy(i){const e=new WeakMap;function t(o,c){const l=o.array,h=o.usage,u=l.byteLength,d=i.createBuffer();i.bindBuffer(c,d),i.bufferData(c,l,h),o.onUploadCallback();let f;if(l instanceof Float32Array)f=i.FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=i.SHORT;else if(l instanceof Uint32Array)f=i.UNSIGNED_INT;else if(l instanceof Int32Array)f=i.INT;else if(l instanceof Int8Array)f=i.BYTE;else if(l instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,c,l){const h=c.array,u=c.updateRanges;if(i.bindBuffer(l,o),u.length===0)i.bufferSubData(l,0,h);else{u.sort((f,m)=>f.start-m.start);let d=0;for(let f=1;f<u.length;f++){const m=u[d],g=u[f];g.start<=m.start+m.count+1?m.count=Math.max(m.count,g.start+g.count-m.start):(++d,u[d]=g)}u.length=d+1;for(let f=0,m=u.length;f<m;f++){const g=u[f];i.bufferSubData(l,g.start*h.BYTES_PER_ELEMENT,h,g.start,g.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const l=e.get(o);if(l===void 0)e.set(o,t(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,o,c),l.version=o.version}}return{get:s,remove:r,update:a}}var Ly=`#ifdef USE_ALPHAHASH+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;+#endif`,Py=`#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`,ky=`#ifdef USE_ALPHAMAP+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;+#endif`,Uy=`#ifdef USE_ALPHAMAP+ uniform sampler2D alphaMap;+#endif`,Oy=`#ifdef USE_ALPHATEST+ #ifdef ALPHA_TO_COVERAGE+ diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );+ if ( diffuseColor.a == 0.0 ) discard;+ #else+ if ( diffuseColor.a < alphaTest ) discard;+ #endif+#endif`,Qy=`#ifdef USE_ALPHATEST+ uniform float alphaTest;+#endif`,Gy=`#ifdef USE_AOMAP+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;+ reflectedLight.indirectDiffuse *= ambientOcclusion;+ #if defined( USE_CLEARCOAT )+ clearcoatSpecularIndirect *= ambientOcclusion;+ #endif+ #if defined( USE_SHEEN )+ sheenSpecularIndirect *= ambientOcclusion;+ #endif+ #if defined( USE_ENVMAP ) && defined( STANDARD )+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );+ #endif+#endif`,Hy=`#ifdef USE_AOMAP+ uniform sampler2D aoMap;+ uniform float aoMapIntensity;+#endif`,zy=`#ifdef USE_BATCHING+ #if ! defined( GL_ANGLE_multi_draw )+ #define gl_DrawID _gl_DrawID+ uniform int _gl_DrawID;+ #endif+ uniform highp sampler2D batchingTexture;+ uniform highp usampler2D batchingIdTexture;+ mat4 getBatchingMatrix( const in float i ) {+ int size = textureSize( batchingTexture, 0 ).x;+ int j = int( i ) * 4;+ int x = j % size;+ int y = j / size;+ vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );+ vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );+ vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );+ vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );+ return mat4( v1, v2, v3, v4 );+ }+ float getIndirectIndex( const in int i ) {+ int size = textureSize( batchingIdTexture, 0 ).x;+ int x = i % size;+ int y = i / size;+ return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );+ }+#endif+#ifdef USE_BATCHING_COLOR+ uniform sampler2D batchingColorTexture;+ vec3 getBatchingColor( const in float i ) {+ int size = textureSize( batchingColorTexture, 0 ).x;+ int j = int( i );+ int x = j % size;+ int y = j / size;+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;+ }+#endif`,Vy=`#ifdef USE_BATCHING+ mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );+#endif`,Wy=`vec3 transformed = vec3( position );+#ifdef USE_ALPHAHASH+ vPosition = vec3( position );+#endif`,qy=`vec3 objectNormal = vec3( normal );+#ifdef USE_TANGENT+ vec3 objectTangent = vec3( tangent.xyz );+#endif`,Ky=`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`,Xy=`#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 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`,Yy=`#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 = normalize( dFdx( surf_pos.xyz ) );+ vec3 vSigmaY = normalize( 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`,jy=`#if NUM_CLIPPING_PLANES > 0+ vec4 plane;+ #ifdef ALPHA_TO_COVERAGE+ float distanceToPlane, distanceGradient;+ float clipOpacity = 1.0;+ #pragma unroll_loop_start+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {+ plane = clippingPlanes[ i ];+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;+ distanceGradient = fwidth( distanceToPlane ) / 2.0;+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );+ if ( clipOpacity == 0.0 ) discard;+ }+ #pragma unroll_loop_end+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES+ float unionClipOpacity = 1.0;+ #pragma unroll_loop_start+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {+ plane = clippingPlanes[ i ];+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;+ distanceGradient = fwidth( distanceToPlane ) / 2.0;+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );+ }+ #pragma unroll_loop_end+ clipOpacity *= 1.0 - unionClipOpacity;+ #endif+ diffuseColor.a *= clipOpacity;+ if ( diffuseColor.a == 0.0 ) discard;+ #else+ #pragma unroll_loop_start+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {+ plane = clippingPlanes[ i ];+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;+ }+ #pragma unroll_loop_end+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES+ bool clipped = true;+ #pragma unroll_loop_start+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {+ plane = clippingPlanes[ i ];+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;+ }+ #pragma unroll_loop_end+ if ( clipped ) discard;+ #endif+ #endif+#endif`,Jy=`#if NUM_CLIPPING_PLANES > 0+ varying vec3 vClipPosition;+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];+#endif`,Zy=`#if NUM_CLIPPING_PLANES > 0+ varying vec3 vClipPosition;+#endif`,$y=`#if NUM_CLIPPING_PLANES > 0+ vClipPosition = - mvPosition.xyz;+#endif`,ew=`#if defined( USE_COLOR_ALPHA )+ diffuseColor *= vColor;+#elif defined( USE_COLOR )+ diffuseColor.rgb *= vColor;+#endif`,tw=`#if defined( USE_COLOR_ALPHA )+ varying vec4 vColor;+#elif defined( USE_COLOR )+ varying vec3 vColor;+#endif`,nw=`#if defined( USE_COLOR_ALPHA )+ varying vec4 vColor;+#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )+ varying vec3 vColor;+#endif`,iw=`#if defined( USE_COLOR_ALPHA )+ vColor = vec4( 1.0 );+#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )+ vColor = vec3( 1.0 );+#endif+#ifdef USE_COLOR+ vColor *= color;+#endif+#ifdef USE_INSTANCING_COLOR+ vColor.xyz *= instanceColor.xyz;+#endif+#ifdef USE_BATCHING_COLOR+ vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );+ vColor.xyz *= batchingColor.xyz;+#endif`,sw=`#define PI 3.141592653589793+#define PI2 6.283185307179586+#define PI_HALF 1.5707963267948966+#define RECIPROCAL_PI 0.3183098861837907+#define RECIPROCAL_PI2 0.15915494309189535+#define EPSILON 1e-6+#ifndef saturate+#define saturate( a ) clamp( a, 0.0, 1.0 )+#endif+#define whiteComplement( a ) ( 1.0 - saturate( a ) )+float pow2( const in float x ) { return x*x; }+vec3 pow2( const in vec3 x ) { return x*x; }+float pow3( const in float x ) { return x*x*x; }+float pow4( const in float x ) { float x2 = x*x; return x2*x2; }+float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }+float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }+highp float rand( const in vec2 uv ) {+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );+ return fract( sin( sn ) * c );+}+#ifdef HIGH_PRECISION+ float precisionSafeLength( vec3 v ) { return length( v ); }+#else+ float precisionSafeLength( vec3 v ) {+ float maxComponent = max3( abs( v ) );+ return length( v / maxComponent ) * maxComponent;+ }+#endif+struct IncidentLight {+ vec3 color;+ vec3 direction;+ bool visible;+};+struct ReflectedLight {+ vec3 directDiffuse;+ vec3 directSpecular;+ vec3 indirectDiffuse;+ vec3 indirectSpecular;+};+#ifdef USE_ALPHAHASH+ varying vec3 vPosition;+#endif+vec3 transformDirection( in vec3 dir, in mat4 matrix ) {+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );+}+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;+}+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`,rw=`#ifdef ENVMAP_TYPE_CUBE_UV+ #define cubeUV_minMipLevel 4.0+ #define cubeUV_minTileSize 16.0+ float getFace( vec3 direction ) {+ vec3 absDirection = abs( direction );+ float face = - 1.0;+ if ( absDirection.x > absDirection.z ) {+ if ( absDirection.x > absDirection.y )+ face = direction.x > 0.0 ? 0.0 : 3.0;+ else+ face = direction.y > 0.0 ? 1.0 : 4.0;+ } else {+ if ( absDirection.z > absDirection.y )+ face = direction.z > 0.0 ? 2.0 : 5.0;+ else+ face = direction.y > 0.0 ? 1.0 : 4.0;+ }+ return face;+ }+ vec2 getUV( vec3 direction, float face ) {+ vec2 uv;+ if ( face == 0.0 ) {+ uv = vec2( direction.z, direction.y ) / abs( direction.x );+ } else if ( face == 1.0 ) {+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );+ } else if ( face == 2.0 ) {+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );+ } else if ( face == 3.0 ) {+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );+ } else if ( face == 4.0 ) {+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );+ } else {+ uv = vec2( direction.x, direction.y ) / abs( direction.z );+ }+ return 0.5 * ( uv + 1.0 );+ }+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {+ float face = getFace( direction );+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );+ mipInt = max( mipInt, cubeUV_minMipLevel );+ float faceSize = exp2( mipInt );+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;+ if ( face > 2.0 ) {+ uv.y += faceSize;+ face -= 3.0;+ }+ uv.x += face * faceSize;+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );+ uv.x *= CUBEUV_TEXEL_WIDTH;+ uv.y *= CUBEUV_TEXEL_HEIGHT;+ #ifdef texture2DGradEXT+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;+ #else+ return texture2D( envMap, uv ).rgb;+ #endif+ }+ #define cubeUV_r0 1.0+ #define cubeUV_m0 - 2.0+ #define cubeUV_r1 0.8+ #define cubeUV_m1 - 1.0+ #define cubeUV_r4 0.4+ #define cubeUV_m4 2.0+ #define cubeUV_r5 0.305+ #define cubeUV_m5 3.0+ #define cubeUV_r6 0.21+ #define cubeUV_m6 4.0+ float roughnessToMip( float roughness ) {+ float mip = 0.0;+ if ( roughness >= cubeUV_r1 ) {+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;+ } else if ( roughness >= cubeUV_r4 ) {+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;+ } else if ( roughness >= cubeUV_r5 ) {+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;+ } else if ( roughness >= cubeUV_r6 ) {+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;+ } else {+ mip = - 2.0 * log2( 1.16 * roughness ); }+ return mip;+ }+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );+ float mipF = fract( mip );+ float mipInt = floor( mip );+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );+ if ( mipF == 0.0 ) {+ return vec4( color0, 1.0 );+ } else {+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );+ return vec4( mix( color0, color1, mipF ), 1.0 );+ }+ }+#endif`,aw=`vec3 transformedNormal = objectNormal;+#ifdef USE_TANGENT+ vec3 transformedTangent = objectTangent;+#endif+#ifdef USE_BATCHING+ mat3 bm = mat3( batchingMatrix );+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );+ transformedNormal = bm * transformedNormal;+ #ifdef USE_TANGENT+ transformedTangent = bm * transformedTangent;+ #endif+#endif+#ifdef USE_INSTANCING+ mat3 im = mat3( instanceMatrix );+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );+ transformedNormal = im * transformedNormal;+ #ifdef USE_TANGENT+ transformedTangent = im * transformedTangent;+ #endif+#endif+transformedNormal = normalMatrix * transformedNormal;+#ifdef FLIP_SIDED+ transformedNormal = - transformedNormal;+#endif+#ifdef USE_TANGENT+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;+ #ifdef FLIP_SIDED+ transformedTangent = - transformedTangent;+ #endif+#endif`,ow=`#ifdef USE_DISPLACEMENTMAP+ uniform sampler2D displacementMap;+ uniform float displacementScale;+ uniform float displacementBias;+#endif`,cw=`#ifdef USE_DISPLACEMENTMAP+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );+#endif`,lw=`#ifdef USE_EMISSIVEMAP+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );+ #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE+ emissiveColor = sRGBTransferEOTF( emissiveColor );+ #endif+ totalEmissiveRadiance *= emissiveColor.rgb;+#endif`,hw=`#ifdef USE_EMISSIVEMAP+ uniform sampler2D emissiveMap;+#endif`,uw="gl_FragColor = linearToOutputTexel( gl_FragColor );",dw=`vec4 LinearTransferOETF( in vec4 value ) {+ return value;+}+vec4 sRGBTransferEOTF( in vec4 value ) {+ return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );+}+vec4 sRGBTransferOETF( in vec4 value ) {+ return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );+}`,fw=`#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, envMapRotation * 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`,pw=`#ifdef USE_ENVMAP+ uniform float envMapIntensity;+ uniform float flipEnvMap;+ uniform mat3 envMapRotation;+ #ifdef ENVMAP_TYPE_CUBE+ uniform samplerCube envMap;+ #else+ uniform sampler2D envMap;+ #endif++#endif`,Aw=`#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`,gw=`#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`,mw=`#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`,bw=`#ifdef USE_FOG+ vFogDepth = - mvPosition.z;+#endif`,xw=`#ifdef USE_FOG+ varying float vFogDepth;+#endif`,Ew=`#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`,_w=`#ifdef USE_FOG+ uniform vec3 fogColor;+ varying float vFogDepth;+ #ifdef FOG_EXP2+ uniform float fogDensity;+ #else+ uniform float fogNear;+ uniform float fogFar;+ #endif+#endif`,yw=`#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+}`,ww=`#ifdef USE_LIGHTMAP+ uniform sampler2D lightMap;+ uniform float lightMapIntensity;+#endif`,Cw=`LambertMaterial material;+material.diffuseColor = diffuseColor.rgb;+material.specularStrength = specularStrength;`,vw=`varying vec3 vViewPosition;+struct LambertMaterial {+ vec3 diffuseColor;+ float specularStrength;+};+void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );+ vec3 irradiance = dotNL * directLight.color;+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+#define RE_Direct RE_Direct_Lambert+#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Sw=`uniform bool receiveShadow;+uniform vec3 ambientLightColor;+#if defined( USE_LIGHT_PROBES )+ uniform vec3 lightProbe[ 9 ];+#endif+vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {+ float x = normal.x, y = normal.y, z = normal.z;+ vec3 result = shCoefficients[ 0 ] * 0.886227;+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );+ return result;+}+vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {+ vec3 worldNormal = 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 ) {+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );+ if ( cutoffDistance > 0.0 ) {+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );+ }+ return distanceFalloff;+}+float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {+ return smoothstep( coneCosine, penumbraCosine, angleCosine );+}+#if NUM_DIR_LIGHTS > 0+ struct DirectionalLight {+ vec3 direction;+ vec3 color;+ };+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {+ light.color = directionalLight.color;+ light.direction = directionalLight.direction;+ light.visible = true;+ }+#endif+#if NUM_POINT_LIGHTS > 0+ struct PointLight {+ vec3 position;+ vec3 color;+ float distance;+ float decay;+ };+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {+ vec3 lVector = pointLight.position - geometryPosition;+ light.direction = normalize( lVector );+ float lightDistance = length( lVector );+ light.color = pointLight.color;+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );+ light.visible = ( light.color != vec3( 0.0 ) );+ }+#endif+#if NUM_SPOT_LIGHTS > 0+ struct SpotLight {+ vec3 position;+ vec3 direction;+ vec3 color;+ float distance;+ float decay;+ float coneCos;+ float penumbraCos;+ };+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {+ vec3 lVector = spotLight.position - geometryPosition;+ light.direction = normalize( lVector );+ float angleCos = dot( light.direction, spotLight.direction );+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );+ if ( spotAttenuation > 0.0 ) {+ float lightDistance = length( lVector );+ light.color = spotLight.color * spotAttenuation;+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );+ light.visible = ( light.color != vec3( 0.0 ) );+ } else {+ light.color = vec3( 0.0 );+ light.visible = false;+ }+ }+#endif+#if NUM_RECT_AREA_LIGHTS > 0+ struct RectAreaLight {+ vec3 color;+ vec3 position;+ vec3 halfWidth;+ vec3 halfHeight;+ };+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];+#endif+#if NUM_HEMI_LIGHTS > 0+ struct HemisphereLight {+ vec3 direction;+ vec3 skyColor;+ vec3 groundColor;+ };+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {+ float dotNL = dot( normal, hemiLight.direction );+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );+ return irradiance;+ }+#endif`,Iw=`#ifdef USE_ENVMAP+ vec3 getIBLIrradiance( const in vec3 normal ) {+ #ifdef ENVMAP_TYPE_CUBE_UV+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );+ return PI * envMapColor.rgb * envMapIntensity;+ #else+ return vec3( 0.0 );+ #endif+ }+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {+ #ifdef ENVMAP_TYPE_CUBE_UV+ vec3 reflectVec = reflect( - viewDir, normal );+ reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );+ return envMapColor.rgb * envMapIntensity;+ #else+ return vec3( 0.0 );+ #endif+ }+ #ifdef USE_ANISOTROPY+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {+ #ifdef ENVMAP_TYPE_CUBE_UV+ vec3 bentNormal = cross( bitangent, viewDir );+ bentNormal = normalize( cross( bentNormal, bitangent ) );+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );+ return getIBLRadiance( viewDir, bentNormal, roughness );+ #else+ return vec3( 0.0 );+ #endif+ }+ #endif+#endif`,Mw=`ToonMaterial material;+material.diffuseColor = diffuseColor.rgb;`,Bw=`varying vec3 vViewPosition;+struct ToonMaterial {+ vec3 diffuseColor;+};+void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+#define RE_Direct RE_Direct_Toon+#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Tw=`BlinnPhongMaterial material;+material.diffuseColor = diffuseColor.rgb;+material.specularColor = specular;+material.specularShininess = shininess;+material.specularStrength = specularStrength;`,Rw=`varying vec3 vViewPosition;+struct BlinnPhongMaterial {+ vec3 diffuseColor;+ vec3 specularColor;+ float specularShininess;+ float specularStrength;+};+void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );+ vec3 irradiance = dotNL * directLight.color;+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;+}+void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+#define RE_Direct RE_Direct_BlinnPhong+#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Nw=`PhysicalMaterial material;+material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );+vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );+float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );+material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;+material.roughness = min( material.roughness, 1.0 );+#ifdef IOR+ material.ior = ior;+ #ifdef USE_SPECULAR+ float specularIntensityFactor = specularIntensity;+ vec3 specularColorFactor = specularColor;+ #ifdef USE_SPECULAR_COLORMAP+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;+ #endif+ #ifdef USE_SPECULAR_INTENSITYMAP+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;+ #endif+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );+ #else+ float specularIntensityFactor = 1.0;+ vec3 specularColorFactor = vec3( 1.0 );+ material.specularF90 = 1.0;+ #endif+ material.specularColor = 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_DISPERSION+ material.dispersion = dispersion;+#endif+#ifdef USE_IRIDESCENCE+ material.iridescence = iridescence;+ material.iridescenceIOR = iridescenceIOR;+ #ifdef USE_IRIDESCENCEMAP+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;+ #endif+ #ifdef USE_IRIDESCENCE_THICKNESSMAP+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;+ #else+ material.iridescenceThickness = iridescenceThicknessMaximum;+ #endif+#endif+#ifdef USE_SHEEN+ material.sheenColor = sheenColor;+ #ifdef USE_SHEEN_COLORMAP+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;+ #endif+ material.sheenRoughness = clamp( sheenRoughness, 0.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 );+ if( material.anisotropy == 0.0 ) {+ anisotropyV = vec2( 1.0, 0.0 );+ } else {+ anisotropyV /= material.anisotropy;+ material.anisotropy = saturate( material.anisotropy );+ }+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;+#endif`,Fw=`struct PhysicalMaterial {+ vec3 diffuseColor;+ float roughness;+ vec3 specularColor;+ float specularF90;+ float dispersion;+ #ifdef USE_CLEARCOAT+ float clearcoat;+ float clearcoatRoughness;+ vec3 clearcoatF0;+ float clearcoatF90;+ #endif+ #ifdef USE_IRIDESCENCE+ float iridescence;+ float iridescenceIOR;+ float iridescenceThickness;+ vec3 iridescenceFresnel;+ vec3 iridescenceF0;+ #endif+ #ifdef USE_SHEEN+ vec3 sheenColor;+ float sheenRoughness;+ #endif+ #ifdef IOR+ float ior;+ #endif+ #ifdef USE_TRANSMISSION+ float transmission;+ float transmissionAlpha;+ float thickness;+ float attenuationDistance;+ vec3 attenuationColor;+ #endif+ #ifdef USE_ANISOTROPY+ float anisotropy;+ float alphaT;+ vec3 anisotropyT;+ vec3 anisotropyB;+ #endif+};+vec3 clearcoatSpecularDirect = vec3( 0.0 );+vec3 clearcoatSpecularIndirect = vec3( 0.0 );+vec3 sheenSpecularDirect = vec3( 0.0 );+vec3 sheenSpecularIndirect = vec3(0.0 );+vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );+ float x2 = x * x;+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );+}+float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {+ float a2 = pow2( alpha );+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );+ return 0.5 / max( gv + gl, EPSILON );+}+float D_GGX( const in float alpha, const in float dotNH ) {+ float a2 = pow2( alpha );+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;+ return RECIPROCAL_PI * a2 / pow2( denom );+}+#ifdef USE_ANISOTROPY+ float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );+ 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {+ vec3 normal = geometryNormal;+ vec3 viewDir = geometryViewDir;+ vec3 position = geometryPosition;+ vec3 lightPos = rectAreaLight.position;+ vec3 halfWidth = rectAreaLight.halfWidth;+ vec3 halfHeight = rectAreaLight.halfHeight;+ vec3 lightColor = rectAreaLight.color;+ float roughness = material.roughness;+ vec3 rectCoords[ 4 ];+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;+ vec2 uv = LTC_Uv( normal, viewDir, roughness );+ vec4 t1 = texture2D( ltc_1, uv );+ vec4 t2 = texture2D( ltc_2, uv );+ mat3 mInv = mat3(+ vec3( t1.x, 0, t1.y ),+ vec3( 0, 1, 0 ),+ vec3( t1.z, 0, t1.w )+ );+ vec3 fresnel = ( material.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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );+ vec3 irradiance = dotNL * directLight.color;+ #ifdef USE_CLEARCOAT+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );+ vec3 ccIrradiance = dotNLcc * directLight.color;+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );+ #endif+ #ifdef USE_SHEEN+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );+ #endif+ reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );+}+void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {+ 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {+ #ifdef USE_CLEARCOAT+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );+ #endif+ #ifdef USE_SHEEN+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );+ #endif+ vec3 singleScattering = vec3( 0.0 );+ vec3 multiScattering = vec3( 0.0 );+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;+ #ifdef USE_IRIDESCENCE+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );+ #else+ computeMultiscattering( geometryNormal, geometryViewDir, 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 );+}`,Dw=`+vec3 geometryPosition = - vViewPosition;+vec3 geometryNormal = normal;+vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );+vec3 geometryClearcoatNormal = vec3( 0.0 );+#ifdef USE_CLEARCOAT+ geometryClearcoatNormal = clearcoatNormal;+#endif+#ifdef USE_IRIDESCENCE+ float dotNVi = saturate( dot( normal, geometryViewDir ) );+ if ( material.iridescenceThickness == 0.0 ) {+ material.iridescence = 0.0;+ } else {+ material.iridescence = saturate( material.iridescence );+ }+ if ( material.iridescence > 0.0 ) {+ material.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, geometryPosition, 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.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;+ #endif+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+ }+ #pragma unroll_loop_end+#endif+#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )+ SpotLight spotLight;+ vec4 spotColor;+ vec3 spotLightCoord;+ bool inSpotLightMap;+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0+ SpotLightShadow spotLightShadow;+ #endif+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {+ spotLight = spotLights[ i ];+ getSpotLightInfo( spotLight, geometryPosition, directLight );+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS+ #else+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )+ #endif+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;+ #endif+ #undef SPOT_LIGHT_MAP_INDEX+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )+ spotLightShadow = spotLightShadows[ i ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+ }+ #pragma unroll_loop_end+#endif+#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )+ DirectionalLight directionalLight;+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0+ DirectionalLightShadow directionalLightShadow;+ #endif+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {+ directionalLight = directionalLights[ i ];+ getDirectionalLightInfo( directionalLight, directLight );+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )+ directionalLightShadow = directionalLightShadows[ i ];+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;+ #endif+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+ }+ #pragma unroll_loop_end+#endif+#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )+ RectAreaLight rectAreaLight;+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {+ rectAreaLight = rectAreaLights[ i ];+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+ }+ #pragma unroll_loop_end+#endif+#if defined( RE_IndirectDiffuse )+ vec3 iblIrradiance = vec3( 0.0 );+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );+ #if defined( USE_LIGHT_PROBES )+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );+ #endif+ #if ( NUM_HEMI_LIGHTS > 0 )+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );+ }+ #pragma unroll_loop_end+ #endif+#endif+#if defined( RE_IndirectSpecular )+ vec3 radiance = vec3( 0.0 );+ vec3 clearcoatRadiance = vec3( 0.0 );+#endif`,Lw=`#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( geometryNormal );+ #endif+#endif+#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )+ #ifdef USE_ANISOTROPY+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );+ #else+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );+ #endif+ #ifdef USE_CLEARCOAT+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );+ #endif+#endif`,Pw=`#if defined( RE_IndirectDiffuse )+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+#endif+#if defined( RE_IndirectSpecular )+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );+#endif`,kw=`#if defined( USE_LOGDEPTHBUF )+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;+#endif`,Uw=`#if defined( USE_LOGDEPTHBUF )+ uniform float logDepthBufFC;+ varying float vFragDepth;+ varying float vIsPerspective;+#endif`,Ow=`#ifdef USE_LOGDEPTHBUF+ varying float vFragDepth;+ varying float vIsPerspective;+#endif`,Qw=`#ifdef USE_LOGDEPTHBUF+ vFragDepth = 1.0 + gl_Position.w;+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );+#endif`,Gw=`#ifdef USE_MAP+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );+ #ifdef DECODE_VIDEO_TEXTURE+ sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );+ #endif+ diffuseColor *= sampledDiffuseColor;+#endif`,Hw=`#ifdef USE_MAP+ uniform sampler2D map;+#endif`,zw=`#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`,Vw=`#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`,Ww=`float metalnessFactor = metalness;+#ifdef USE_METALNESSMAP+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );+ metalnessFactor *= texelMetalness.b;+#endif`,qw=`#ifdef USE_METALNESSMAP+ uniform sampler2D metalnessMap;+#endif`,Kw=`#ifdef USE_INSTANCING_MORPH+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;+ }+#endif`,Xw=`#if defined( USE_MORPHCOLORS )+ vColor *= morphTargetBaseInfluence;+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {+ #if defined( USE_COLOR_ALPHA )+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];+ #elif defined( USE_COLOR )+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];+ #endif+ }+#endif`,Yw=`#ifdef USE_MORPHNORMALS+ objectNormal *= morphTargetBaseInfluence;+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];+ }+#endif`,jw=`#ifdef USE_MORPHTARGETS+ #ifndef USE_INSTANCING_MORPH+ uniform float morphTargetBaseInfluence;+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];+ #endif+ uniform sampler2DArray morphTargetsTexture;+ uniform ivec2 morphTargetsTextureSize;+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;+ int y = texelIndex / morphTargetsTextureSize.x;+ int x = texelIndex - y * morphTargetsTextureSize.x;+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );+ return texelFetch( morphTargetsTexture, morphUV, 0 );+ }+#endif`,Jw=`#ifdef USE_MORPHTARGETS+ transformed *= morphTargetBaseInfluence;+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];+ }+#endif`,Zw=`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 nonPerturbedNormal = normal;`,$w=`#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`,eC=`#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif`,tC=`#ifndef FLAT_SHADED+ varying vec3 vNormal;+ #ifdef USE_TANGENT+ varying vec3 vTangent;+ varying vec3 vBitangent;+ #endif+#endif`,nC=`#ifndef FLAT_SHADED+ vNormal = normalize( transformedNormal );+ #ifdef USE_TANGENT+ vTangent = normalize( transformedTangent );+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );+ #endif+#endif`,iC=`#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`,sC=`#ifdef USE_CLEARCOAT+ vec3 clearcoatNormal = nonPerturbedNormal;+#endif`,rC=`#ifdef USE_CLEARCOAT_NORMALMAP+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;+ clearcoatMapN.xy *= clearcoatNormalScale;+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );+#endif`,aC=`#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`,oC=`#ifdef USE_IRIDESCENCEMAP+ uniform sampler2D iridescenceMap;+#endif+#ifdef USE_IRIDESCENCE_THICKNESSMAP+ uniform sampler2D iridescenceThicknessMap;+#endif`,cC=`#ifdef OPAQUE+diffuseColor.a = 1.0;+#endif+#ifdef USE_TRANSMISSION+diffuseColor.a *= material.transmissionAlpha;+#endif+gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,lC=`vec3 packNormalToRGB( const in vec3 normal ) {+ return normalize( normal ) * 0.5 + 0.5;+}+vec3 unpackRGBToNormal( const in vec3 rgb ) {+ return 2.0 * rgb.xyz - 1.0;+}+const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;+const float Inv255 = 1. / 255.;+const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );+const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );+const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );+const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );+vec4 packDepthToRGBA( const in float v ) {+ if( v <= 0.0 )+ return vec4( 0., 0., 0., 0. );+ if( v >= 1.0 )+ return vec4( 1., 1., 1., 1. );+ float vuf;+ float af = modf( v * PackFactors.a, vuf );+ float bf = modf( vuf * ShiftRight8, vuf );+ float gf = modf( vuf * ShiftRight8, vuf );+ return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );+}+vec3 packDepthToRGB( const in float v ) {+ if( v <= 0.0 )+ return vec3( 0., 0., 0. );+ if( v >= 1.0 )+ return vec3( 1., 1., 1. );+ float vuf;+ float bf = modf( v * PackFactors.b, vuf );+ float gf = modf( vuf * ShiftRight8, vuf );+ return vec3( vuf * Inv255, gf * PackUpscale, bf );+}+vec2 packDepthToRG( const in float v ) {+ if( v <= 0.0 )+ return vec2( 0., 0. );+ if( v >= 1.0 )+ return vec2( 1., 1. );+ float vuf;+ float gf = modf( v * 256., vuf );+ return vec2( vuf * Inv255, gf );+}+float unpackRGBAToDepth( const in vec4 v ) {+ return dot( v, UnpackFactors4 );+}+float unpackRGBToDepth( const in vec3 v ) {+ return dot( v, UnpackFactors3 );+}+float unpackRGToDepth( const in vec2 v ) {+ return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;+}+vec4 pack2HalfToRGBA( const in vec2 v ) {+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );+}+vec2 unpackRGBATo2Half( const in vec4 v ) {+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );+}+float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {+ return ( viewZ + near ) / ( near - far );+}+float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {+ 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 );+}`,hC=`#ifdef PREMULTIPLIED_ALPHA+ gl_FragColor.rgb *= gl_FragColor.a;+#endif`,uC=`vec4 mvPosition = vec4( transformed, 1.0 );+#ifdef USE_BATCHING+ mvPosition = batchingMatrix * mvPosition;+#endif+#ifdef USE_INSTANCING+ mvPosition = instanceMatrix * mvPosition;+#endif+mvPosition = modelViewMatrix * mvPosition;+gl_Position = projectionMatrix * mvPosition;`,dC=`#ifdef DITHERING+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );+#endif`,fC=`#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`,pC=`float roughnessFactor = roughness;+#ifdef USE_ROUGHNESSMAP+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );+ roughnessFactor *= texelRoughness.g;+#endif`,AC=`#ifdef USE_ROUGHNESSMAP+ uniform sampler2D roughnessMap;+#endif`,gC=`#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 shadowIntensity;+ 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 shadowIntensity;+ 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 shadowIntensity;+ 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 shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {+ float shadow = 1.0;+ shadowCoord.xyz /= shadowCoord.w;+ shadowCoord.z += shadowBias;+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;+ if ( frustumTest ) {+ #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 mix( 1.0, shadow, shadowIntensity );+ }+ 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 shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {+ float shadow = 1.0;+ vec3 lightToPosition = shadowCoord.xyz;++ float lightToPositionLength = length( lightToPosition );+ if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {+ float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;+ vec3 bd3D = normalize( lightToPosition );+ vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )+ vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;+ shadow = (+ 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+ shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );+ #endif+ }+ return mix( 1.0, shadow, shadowIntensity );+ }+#endif`,mC=`#if NUM_SPOT_LIGHT_COORDS > 0+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];+#endif+#ifdef USE_SHADOWMAP+ #if NUM_DIR_LIGHT_SHADOWS > 0+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];+ struct DirectionalLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];+ #endif+ #if NUM_SPOT_LIGHT_SHADOWS > 0+ struct SpotLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ };+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];+ #endif+ #if NUM_POINT_LIGHT_SHADOWS > 0+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];+ struct PointLightShadow {+ float shadowIntensity;+ float shadowBias;+ float shadowNormalBias;+ float shadowRadius;+ vec2 shadowMapSize;+ float shadowCameraNear;+ float shadowCameraFar;+ };+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];+ #endif+#endif`,bC=`#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`,xC=`float getShadowMask() {+ float shadow = 1.0;+ #ifdef USE_SHADOWMAP+ #if NUM_DIR_LIGHT_SHADOWS > 0+ DirectionalLightShadow directionalLight;+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {+ directionalLight = directionalLightShadows[ i ];+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;+ }+ #pragma unroll_loop_end+ #endif+ #if NUM_SPOT_LIGHT_SHADOWS > 0+ SpotLightShadow spotLight;+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {+ spotLight = spotLightShadows[ i ];+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;+ }+ #pragma unroll_loop_end+ #endif+ #if NUM_POINT_LIGHT_SHADOWS > 0+ PointLightShadow pointLight;+ #pragma unroll_loop_start+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {+ pointLight = pointLightShadows[ i ];+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;+ }+ #pragma unroll_loop_end+ #endif+ #endif+ return shadow;+}`,EC=`#ifdef USE_SKINNING+ mat4 boneMatX = getBoneMatrix( skinIndex.x );+ mat4 boneMatY = getBoneMatrix( skinIndex.y );+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );+ mat4 boneMatW = getBoneMatrix( skinIndex.w );+#endif`,_C=`#ifdef USE_SKINNING+ uniform mat4 bindMatrix;+ uniform mat4 bindMatrixInverse;+ uniform highp sampler2D boneTexture;+ mat4 getBoneMatrix( const in float i ) {+ int size = textureSize( boneTexture, 0 ).x;+ int j = int( i ) * 4;+ int x = j % size;+ int y = j / size;+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );+ return mat4( v1, v2, v3, v4 );+ }+#endif`,yC=`#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`,wC=`#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`,CC=`float specularStrength;+#ifdef USE_SPECULARMAP+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );+ specularStrength = texelSpecular.r;+#else+ specularStrength = 1.0;+#endif`,vC=`#ifdef USE_SPECULARMAP+ uniform sampler2D specularMap;+#endif`,SC=`#if defined( TONE_MAPPING )+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );+#endif`,IC=`#ifndef saturate+#define saturate( a ) clamp( a, 0.0, 1.0 )+#endif+uniform float toneMappingExposure;+vec3 LinearToneMapping( vec3 color ) {+ return saturate( toneMappingExposure * color );+}+vec3 ReinhardToneMapping( vec3 color ) {+ color *= toneMappingExposure;+ return saturate( color / ( vec3( 1.0 ) + color ) );+}+vec3 CineonToneMapping( vec3 color ) {+ color *= toneMappingExposure;+ color = max( vec3( 0.0 ), color - 0.004 );+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );+}+vec3 RRTAndODTFit( vec3 v ) {+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;+ return a / b;+}+vec3 ACESFilmicToneMapping( vec3 color ) {+ const mat3 ACESInputMat = mat3(+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),+ vec3( 0.04823, 0.01566, 0.83777 )+ );+ const mat3 ACESOutputMat = mat3(+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),+ vec3( -0.07367, -0.00605, 1.07602 )+ );+ color *= toneMappingExposure / 0.6;+ color = ACESInputMat * color;+ color = RRTAndODTFit( color );+ color = ACESOutputMat * color;+ return saturate( color );+}+const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(+ vec3( 1.6605, - 0.1246, - 0.0182 ),+ vec3( - 0.5876, 1.1329, - 0.1006 ),+ vec3( - 0.0728, - 0.0083, 1.1187 )+);+const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(+ vec3( 0.6274, 0.0691, 0.0164 ),+ vec3( 0.3293, 0.9195, 0.0880 ),+ vec3( 0.0433, 0.0113, 0.8956 )+);+vec3 agxDefaultContrastApprox( vec3 x ) {+ vec3 x2 = x * x;+ vec3 x4 = x2 * x2;+ return + 15.5 * x4 * x2+ - 40.14 * x4 * x+ + 31.96 * x4+ - 6.868 * x2 * x+ + 0.4298 * x2+ + 0.1191 * x+ - 0.00232;+}+vec3 AgXToneMapping( vec3 color ) {+ const mat3 AgXInsetMatrix = mat3(+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )+ );+ const mat3 AgXOutsetMatrix = mat3(+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )+ );+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;+ color *= toneMappingExposure;+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;+ color = AgXInsetMatrix * color;+ color = max( color, 1e-10 ); color = log2( color );+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );+ color = clamp( color, 0.0, 1.0 );+ color = agxDefaultContrastApprox( color );+ color = AgXOutsetMatrix * color;+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;+ color = clamp( color, 0.0, 1.0 );+ return color;+}+vec3 NeutralToneMapping( vec3 color ) {+ const float StartCompression = 0.8 - 0.04;+ const float Desaturation = 0.15;+ color *= toneMappingExposure;+ float x = min( color.r, min( color.g, color.b ) );+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;+ color -= offset;+ float peak = max( color.r, max( color.g, color.b ) );+ if ( peak < StartCompression ) return color;+ float d = 1. - StartCompression;+ float newPeak = 1. - d * d / ( peak + d - StartCompression );+ color *= newPeak / peak;+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );+ return mix( color, vec3( newPeak ), g );+}+vec3 CustomToneMapping( vec3 color ) { return color; }`,MC=`#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.dispersion, material.ior, material.thickness,+ material.attenuationColor, material.attenuationDistance );+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );+#endif`,BC=`#ifdef USE_TRANSMISSION+ uniform float transmission;+ uniform float thickness;+ uniform float attenuationDistance;+ uniform vec3 attenuationColor;+ #ifdef USE_TRANSMISSIONMAP+ uniform sampler2D transmissionMap;+ #endif+ #ifdef USE_THICKNESSMAP+ uniform sampler2D thicknessMap;+ #endif+ uniform vec2 transmissionSamplerSize;+ uniform sampler2D transmissionSamplerMap;+ uniform mat4 modelMatrix;+ uniform mat4 projectionMatrix;+ varying vec3 vWorldPosition;+ float w0( float a ) {+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );+ }+ float w1( float a ) {+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );+ }+ float w2( float a ){+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );+ }+ float w3( float a ) {+ return ( 1.0 / 6.0 ) * ( a * a * a );+ }+ float g0( float a ) {+ return w0( a ) + w1( a );+ }+ float g1( float a ) {+ return w2( a ) + w3( a );+ }+ float h0( float a ) {+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );+ }+ float h1( float a ) {+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );+ }+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {+ uv = uv * texelSize.zw + 0.5;+ vec2 iuv = floor( uv );+ vec2 fuv = fract( uv );+ float g0x = g0( fuv.x );+ float g1x = g1( fuv.x );+ float h0x = h0( fuv.x );+ float h1x = h1( fuv.x );+ float h0y = h0( fuv.y );+ float h1y = h1( fuv.y );+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) ++ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );+ }+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );+ vec2 fLodSizeInv = 1.0 / fLodSize;+ vec2 cLodSizeInv = 1.0 / cLodSize;+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );+ return mix( fSample, cSample, fract( lod ) );+ }+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );+ vec3 modelScale;+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );+ return normalize( refractionVector ) * thickness * modelScale;+ }+ float applyIorToRoughness( const in float roughness, const in float ior ) {+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );+ }+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );+ }+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {+ if ( isinf( attenuationDistance ) ) {+ return vec3( 1.0 );+ } else {+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;+ }+ }+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,+ const in vec3 attenuationColor, const in float attenuationDistance ) {+ vec4 transmittedLight;+ vec3 transmittance;+ #ifdef USE_DISPERSION+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );+ for ( int i = 0; i < 3; i ++ ) {+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );+ vec3 refractedRayExit = position + transmissionRay;+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;+ refractionCoords += 1.0;+ refractionCoords /= 2.0;+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );+ transmittedLight[ i ] = transmissionSample[ i ];+ transmittedLight.a += transmissionSample.a;+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];+ }+ transmittedLight.a /= 3.0;+ #else+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );+ vec3 refractedRayExit = position + transmissionRay;+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;+ refractionCoords += 1.0;+ refractionCoords /= 2.0;+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );+ #endif+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );+ }+#endif`,TC=`#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`,RC=`#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`,NC=`#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`,FC=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0+ vec4 worldPosition = vec4( transformed, 1.0 );+ #ifdef USE_BATCHING+ worldPosition = batchingMatrix * worldPosition;+ #endif+ #ifdef USE_INSTANCING+ worldPosition = instanceMatrix * worldPosition;+ #endif+ worldPosition = modelMatrix * worldPosition;+#endif`;const ot={alphahash_fragment:Ly,alphahash_pars_fragment:Py,alphamap_fragment:ky,alphamap_pars_fragment:Uy,alphatest_fragment:Oy,alphatest_pars_fragment:Qy,aomap_fragment:Gy,aomap_pars_fragment:Hy,batching_pars_vertex:zy,batching_vertex:Vy,begin_vertex:Wy,beginnormal_vertex:qy,bsdfs:Ky,iridescence_fragment:Xy,bumpmap_pars_fragment:Yy,clipping_planes_fragment:jy,clipping_planes_pars_fragment:Jy,clipping_planes_pars_vertex:Zy,clipping_planes_vertex:$y,color_fragment:ew,color_pars_fragment:tw,color_pars_vertex:nw,color_vertex:iw,common:sw,cube_uv_reflection_fragment:rw,defaultnormal_vertex:aw,displacementmap_pars_vertex:ow,displacementmap_vertex:cw,emissivemap_fragment:lw,emissivemap_pars_fragment:hw,colorspace_fragment:uw,colorspace_pars_fragment:dw,envmap_fragment:fw,envmap_common_pars_fragment:pw,envmap_pars_fragment:Aw,envmap_pars_vertex:gw,envmap_physical_pars_fragment:Iw,envmap_vertex:mw,fog_vertex:bw,fog_pars_vertex:xw,fog_fragment:Ew,fog_pars_fragment:_w,gradientmap_pars_fragment:yw,lightmap_pars_fragment:ww,lights_lambert_fragment:Cw,lights_lambert_pars_fragment:vw,lights_pars_begin:Sw,lights_toon_fragment:Mw,lights_toon_pars_fragment:Bw,lights_phong_fragment:Tw,lights_phong_pars_fragment:Rw,lights_physical_fragment:Nw,lights_physical_pars_fragment:Fw,lights_fragment_begin:Dw,lights_fragment_maps:Lw,lights_fragment_end:Pw,logdepthbuf_fragment:kw,logdepthbuf_pars_fragment:Uw,logdepthbuf_pars_vertex:Ow,logdepthbuf_vertex:Qw,map_fragment:Gw,map_pars_fragment:Hw,map_particle_fragment:zw,map_particle_pars_fragment:Vw,metalnessmap_fragment:Ww,metalnessmap_pars_fragment:qw,morphinstance_vertex:Kw,morphcolor_vertex:Xw,morphnormal_vertex:Yw,morphtarget_pars_vertex:jw,morphtarget_vertex:Jw,normal_fragment_begin:Zw,normal_fragment_maps:$w,normal_pars_fragment:eC,normal_pars_vertex:tC,normal_vertex:nC,normalmap_pars_fragment:iC,clearcoat_normal_fragment_begin:sC,clearcoat_normal_fragment_maps:rC,clearcoat_pars_fragment:aC,iridescence_pars_fragment:oC,opaque_fragment:cC,packing:lC,premultiplied_alpha_fragment:hC,project_vertex:uC,dithering_fragment:dC,dithering_pars_fragment:fC,roughnessmap_fragment:pC,roughnessmap_pars_fragment:AC,shadowmap_pars_fragment:gC,shadowmap_pars_vertex:mC,shadowmap_vertex:bC,shadowmask_pars_fragment:xC,skinbase_vertex:EC,skinning_pars_vertex:_C,skinning_vertex:yC,skinnormal_vertex:wC,specularmap_fragment:CC,specularmap_pars_fragment:vC,tonemapping_fragment:SC,tonemapping_pars_fragment:IC,transmission_fragment:MC,transmission_pars_fragment:BC,uv_pars_fragment:TC,uv_pars_vertex:RC,uv_vertex:NC,worldpos_vertex:FC,background_vert:`varying vec2 vUv;+uniform mat3 uvTransform;+void main() {+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;+ gl_Position = vec4( position.xy, 1.0, 1.0 );+}`,background_frag:`uniform sampler2D t2D;+uniform float backgroundIntensity;+varying vec2 vUv;+void main() {+ vec4 texColor = texture2D( t2D, vUv );+ #ifdef DECODE_VIDEO_TEXTURE+ texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );+ #endif+ texColor.rgb *= backgroundIntensity;+ gl_FragColor = texColor;+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+}`,backgroundCube_vert:`varying vec3 vWorldDirection;+#include <common>+void main() {+ vWorldDirection = transformDirection( position, modelMatrix );+ #include <begin_vertex>+ #include <project_vertex>+ gl_Position.z = gl_Position.w;+}`,backgroundCube_frag:`#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;+uniform mat3 backgroundRotation;+varying vec3 vWorldDirection;+#include <cube_uv_reflection_fragment>+void main() {+ #ifdef ENVMAP_TYPE_CUBE+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );+ #elif defined( ENVMAP_TYPE_CUBE_UV )+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );+ #else+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );+ #endif+ texColor.rgb *= backgroundIntensity;+ gl_FragColor = texColor;+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+}`,cube_vert:`varying vec3 vWorldDirection;+#include <common>+void main() {+ vWorldDirection = transformDirection( position, modelMatrix );+ #include <begin_vertex>+ #include <project_vertex>+ gl_Position.z = gl_Position.w;+}`,cube_frag:`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>+}`,depth_vert:`#include <common>+#include <batching_pars_vertex>+#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 <batching_vertex>+ #include <skinbase_vertex>+ #include <morphinstance_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;+}`,depth_frag:`#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() {+ vec4 diffuseColor = vec4( 1.0 );+ #include <clipping_planes_fragment>+ #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 );+ #elif DEPTH_PACKING == 3202+ gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );+ #elif DEPTH_PACKING == 3203+ gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );+ #endif+}`,distanceRGBA_vert:`#define DISTANCE+varying vec3 vWorldPosition;+#include <common>+#include <batching_pars_vertex>+#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 <batching_vertex>+ #include <skinbase_vertex>+ #include <morphinstance_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;+}`,distanceRGBA_frag:`#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 () {+ vec4 diffuseColor = vec4( 1.0 );+ #include <clipping_planes_fragment>+ #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 );+}`,equirect_vert:`varying vec3 vWorldDirection;+#include <common>+void main() {+ vWorldDirection = transformDirection( position, modelMatrix );+ #include <begin_vertex>+ #include <project_vertex>+}`,equirect_frag:`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>+}`,linedashed_vert:`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 <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <begin_vertex>+ #include <morphtarget_vertex>+ #include <project_vertex>+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ #include <fog_vertex>+}`,linedashed_frag:`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() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ if ( mod( vLineDistance, totalSize ) > dashSize ) {+ discard;+ }+ vec3 outgoingLight = vec3( 0.0 );+ #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>+}`,meshbasic_vert:`#include <common>+#include <batching_pars_vertex>+#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 <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_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>+}`,meshbasic_frag:`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() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ #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>+}`,meshlambert_vert:`#define LAMBERT+varying vec3 vViewPosition;+#include <common>+#include <batching_pars_vertex>+#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 <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_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>+}`,meshlambert_frag:`#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() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ 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>+}`,meshmatcap_vert:`#define MATCAP+varying vec3 vViewPosition;+#include <common>+#include <batching_pars_vertex>+#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 <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_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;+}`,meshmatcap_frag:`#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() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ #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>+}`,meshnormal_vert:`#define NORMAL+#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )+ varying vec3 vViewPosition;+#endif+#include <common>+#include <batching_pars_vertex>+#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 <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphinstance_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+}`,meshnormal_frag:`#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() {+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );+ #include <clipping_planes_fragment>+ #include <logdepthbuf_fragment>+ #include <normal_fragment_begin>+ #include <normal_fragment_maps>+ gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );+ #ifdef OPAQUE+ gl_FragColor.a = 1.0;+ #endif+}`,meshphong_vert:`#define PHONG+varying vec3 vViewPosition;+#include <common>+#include <batching_pars_vertex>+#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 <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphinstance_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>+}`,meshphong_frag:`#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() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ 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>+}`,meshphysical_vert:`#define STANDARD+varying vec3 vViewPosition;+#ifdef USE_TRANSMISSION+ varying vec3 vWorldPosition;+#endif+#include <common>+#include <batching_pars_vertex>+#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 <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_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+}`,meshphysical_frag:`#define STANDARD+#ifdef PHYSICAL+ #define IOR+ #define USE_SPECULAR+#endif+uniform vec3 diffuse;+uniform vec3 emissive;+uniform float roughness;+uniform float metalness;+uniform float opacity;+#ifdef IOR+ uniform float ior;+#endif+#ifdef USE_SPECULAR+ uniform float specularIntensity;+ uniform vec3 specularColor;+ #ifdef USE_SPECULAR_COLORMAP+ uniform sampler2D specularColorMap;+ #endif+ #ifdef USE_SPECULAR_INTENSITYMAP+ uniform sampler2D specularIntensityMap;+ #endif+#endif+#ifdef USE_CLEARCOAT+ uniform float clearcoat;+ uniform float clearcoatRoughness;+#endif+#ifdef USE_DISPERSION+ uniform float dispersion;+#endif+#ifdef USE_IRIDESCENCE+ uniform float iridescence;+ uniform float iridescenceIOR;+ uniform float iridescenceThicknessMinimum;+ uniform float iridescenceThicknessMaximum;+#endif+#ifdef USE_SHEEN+ uniform vec3 sheenColor;+ uniform float sheenRoughness;+ #ifdef USE_SHEEN_COLORMAP+ uniform sampler2D sheenColorMap;+ #endif+ #ifdef USE_SHEEN_ROUGHNESSMAP+ uniform sampler2D sheenRoughnessMap;+ #endif+#endif+#ifdef USE_ANISOTROPY+ uniform vec2 anisotropyVector;+ #ifdef USE_ANISOTROPYMAP+ uniform sampler2D anisotropyMap;+ #endif+#endif+varying vec3 vViewPosition;+#include <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() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ 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 + sheenSpecularDirect + sheenSpecularIndirect;+ #endif+ #ifdef USE_CLEARCOAT+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;+ #endif+ #include <opaque_fragment>+ #include <tonemapping_fragment>+ #include <colorspace_fragment>+ #include <fog_fragment>+ #include <premultiplied_alpha_fragment>+ #include <dithering_fragment>+}`,meshtoon_vert:`#define TOON+varying vec3 vViewPosition;+#include <common>+#include <batching_pars_vertex>+#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 <morphinstance_vertex>+ #include <morphcolor_vertex>+ #include <batching_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>+}`,meshtoon_frag:`#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() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ 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>+}`,points_vert:`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 <morphinstance_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>+}`,points_frag:`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() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ vec3 outgoingLight = vec3( 0.0 );+ #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>+}`,shadow_vert:`#include <common>+#include <batching_pars_vertex>+#include <fog_pars_vertex>+#include <morphtarget_pars_vertex>+#include <skinning_pars_vertex>+#include <logdepthbuf_pars_vertex>+#include <shadowmap_pars_vertex>+void main() {+ #include <batching_vertex>+ #include <beginnormal_vertex>+ #include <morphinstance_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>+}`,shadow_frag:`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>+}`,sprite_vert:`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[ 3 ];+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );+ #ifndef USE_SIZEATTENUATION+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );+ if ( isPerspective ) scale *= - mvPosition.z;+ #endif+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;+ vec2 rotatedPosition;+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;+ mvPosition.xy += rotatedPosition;+ gl_Position = projectionMatrix * mvPosition;+ #include <logdepthbuf_vertex>+ #include <clipping_planes_vertex>+ #include <fog_vertex>+}`,sprite_frag:`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() {+ vec4 diffuseColor = vec4( diffuse, opacity );+ #include <clipping_planes_fragment>+ vec3 outgoingLight = vec3( 0.0 );+ #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>+}`},we={common:{diffuse:{value:new qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new rt},alphaMap:{value:null},alphaMapTransform:{value:new rt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new rt}},envmap:{envMap:{value:null},envMapRotation:{value:new rt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new rt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new rt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new rt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new rt},normalScale:{value:new Ze(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new rt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new rt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new rt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new rt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,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 qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new rt},alphaTest:{value:0},uvTransform:{value:new rt}},sprite:{diffuse:{value:new qe(16777215)},opacity:{value:1},center:{value:new Ze(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new rt},alphaMap:{value:null},alphaMapTransform:{value:new rt},alphaTest:{value:0}}},Ni={basic:{uniforms:Tn([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.fog]),vertexShader:ot.meshbasic_vert,fragmentShader:ot.meshbasic_frag},lambert:{uniforms:Tn([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.fog,we.lights,{emissive:{value:new qe(0)}}]),vertexShader:ot.meshlambert_vert,fragmentShader:ot.meshlambert_frag},phong:{uniforms:Tn([we.common,we.specularmap,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.fog,we.lights,{emissive:{value:new qe(0)},specular:{value:new qe(1118481)},shininess:{value:30}}]),vertexShader:ot.meshphong_vert,fragmentShader:ot.meshphong_frag},standard:{uniforms:Tn([we.common,we.envmap,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.roughnessmap,we.metalnessmap,we.fog,we.lights,{emissive:{value:new qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ot.meshphysical_vert,fragmentShader:ot.meshphysical_frag},toon:{uniforms:Tn([we.common,we.aomap,we.lightmap,we.emissivemap,we.bumpmap,we.normalmap,we.displacementmap,we.gradientmap,we.fog,we.lights,{emissive:{value:new qe(0)}}]),vertexShader:ot.meshtoon_vert,fragmentShader:ot.meshtoon_frag},matcap:{uniforms:Tn([we.common,we.bumpmap,we.normalmap,we.displacementmap,we.fog,{matcap:{value:null}}]),vertexShader:ot.meshmatcap_vert,fragmentShader:ot.meshmatcap_frag},points:{uniforms:Tn([we.points,we.fog]),vertexShader:ot.points_vert,fragmentShader:ot.points_frag},dashed:{uniforms:Tn([we.common,we.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ot.linedashed_vert,fragmentShader:ot.linedashed_frag},depth:{uniforms:Tn([we.common,we.displacementmap]),vertexShader:ot.depth_vert,fragmentShader:ot.depth_frag},normal:{uniforms:Tn([we.common,we.bumpmap,we.normalmap,we.displacementmap,{opacity:{value:1}}]),vertexShader:ot.meshnormal_vert,fragmentShader:ot.meshnormal_frag},sprite:{uniforms:Tn([we.sprite,we.fog]),vertexShader:ot.sprite_vert,fragmentShader:ot.sprite_frag},background:{uniforms:{uvTransform:{value:new rt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ot.background_vert,fragmentShader:ot.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new rt}},vertexShader:ot.backgroundCube_vert,fragmentShader:ot.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ot.cube_vert,fragmentShader:ot.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ot.equirect_vert,fragmentShader:ot.equirect_frag},distanceRGBA:{uniforms:Tn([we.common,we.displacementmap,{referencePosition:{value:new H},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ot.distanceRGBA_vert,fragmentShader:ot.distanceRGBA_frag},shadow:{uniforms:Tn([we.lights,we.fog,{color:{value:new qe(0)},opacity:{value:1}}]),vertexShader:ot.shadow_vert,fragmentShader:ot.shadow_frag}};Ni.physical={uniforms:Tn([Ni.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new rt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new rt},clearcoatNormalScale:{value:new Ze(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new rt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new rt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new rt},sheen:{value:0},sheenColor:{value:new qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new rt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new rt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new rt},transmissionSamplerSize:{value:new Ze},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new rt},attenuationDistance:{value:0},attenuationColor:{value:new qe(0)},specularColor:{value:new qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new rt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new rt},anisotropyVector:{value:new Ze},anisotropyMap:{value:null},anisotropyMapTransform:{value:new rt}}]),vertexShader:ot.meshphysical_vert,fragmentShader:ot.meshphysical_frag};const Yc={r:0,b:0,g:0},nr=new Bi,DC=new et;function LC(i,e,t,n,s,r,a){const o=new qe(0);let c=r===!0?0:1,l,h,u=null,d=0,f=null;function m(b){let _=b.isScene===!0?b.background:null;return _&&_.isTexture&&(_=(b.backgroundBlurriness>0?t:e).get(_)),_}function g(b){let _=!1;const M=m(b);M===null?p(o,c):M&&M.isColor&&(p(M,1),_=!0);const w=i.xr.getEnvironmentBlendMode();w==="additive"?n.buffers.color.setClear(0,0,0,1,a):w==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||_)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function A(b,_){const M=m(_);M&&(M.isCubeTexture||M.mapping===ic)?(h===void 0&&(h=new Jt(new Jr(1,1,1),new vs({name:"BackgroundCubeMaterial",uniforms:Zr(Ni.backgroundCube.uniforms),vertexShader:Ni.backgroundCube.vertexShader,fragmentShader:Ni.backgroundCube.fragmentShader,side:Sn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(w,S,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),nr.copy(_.backgroundRotation),nr.x*=-1,nr.y*=-1,nr.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(nr.y*=-1,nr.z*=-1),h.material.uniforms.envMap.value=M,h.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(DC.makeRotationFromEuler(nr)),h.material.toneMapped=At.getTransfer(M.colorSpace)!==Mt,(u!==M||d!==M.version||f!==i.toneMapping)&&(h.material.needsUpdate=!0,u=M,d=M.version,f=i.toneMapping),h.layers.enableAll(),b.unshift(h,h.geometry,h.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new Jt(new qc(2,2),new vs({name:"BackgroundMaterial",uniforms:Zr(Ni.background.uniforms),vertexShader:Ni.background.vertexShader,fragmentShader:Ni.background.fragmentShader,side:Qi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.toneMapped=At.getTransfer(M.colorSpace)!==Mt,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(u!==M||d!==M.version||f!==i.toneMapping)&&(l.material.needsUpdate=!0,u=M,d=M.version,f=i.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function p(b,_){b.getRGB(Yc,Jp(i)),n.buffers.color.setClear(Yc.r,Yc.g,Yc.b,_,a)}function y(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(b,_=1){o.set(b),c=_,p(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(b){c=b,p(o,c)},render:g,addToRenderList:A,dispose:y}}function PC(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let r=s,a=!1;function o(C,F,K,q,$){let D=!1;const O=u(q,K,F);r!==O&&(r=O,l(r.object)),D=f(C,q,K,$),D&&m(C,q,K,$),$!==null&&e.update($,i.ELEMENT_ARRAY_BUFFER),(D||a)&&(a=!1,_(C,F,K,q),$!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get($).buffer))}function c(){return i.createVertexArray()}function l(C){return i.bindVertexArray(C)}function h(C){return i.deleteVertexArray(C)}function u(C,F,K){const q=K.wireframe===!0;let $=n[C.id];$===void 0&&($={},n[C.id]=$);let D=$[F.id];D===void 0&&(D={},$[F.id]=D);let O=D[q];return O===void 0&&(O=d(c()),D[q]=O),O}function d(C){const F=[],K=[],q=[];for(let $=0;$<t;$++)F[$]=0,K[$]=0,q[$]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:K,attributeDivisors:q,object:C,attributes:{},index:null}}function f(C,F,K,q){const $=r.attributes,D=F.attributes;let O=0;const j=K.getAttributes();for(const Q in j)if(j[Q].location>=0){const ee=$[Q];let ae=D[Q];if(ae===void 0&&(Q==="instanceMatrix"&&C.instanceMatrix&&(ae=C.instanceMatrix),Q==="instanceColor"&&C.instanceColor&&(ae=C.instanceColor)),ee===void 0||ee.attribute!==ae||ae&&ee.data!==ae.data)return!0;O++}return r.attributesNum!==O||r.index!==q}function m(C,F,K,q){const $={},D=F.attributes;let O=0;const j=K.getAttributes();for(const Q in j)if(j[Q].location>=0){let ee=D[Q];ee===void 0&&(Q==="instanceMatrix"&&C.instanceMatrix&&(ee=C.instanceMatrix),Q==="instanceColor"&&C.instanceColor&&(ee=C.instanceColor));const ae={};ae.attribute=ee,ee&&ee.data&&(ae.data=ee.data),$[Q]=ae,O++}r.attributes=$,r.attributesNum=O,r.index=q}function g(){const C=r.newAttributes;for(let F=0,K=C.length;F<K;F++)C[F]=0}function A(C){p(C,0)}function p(C,F){const K=r.newAttributes,q=r.enabledAttributes,$=r.attributeDivisors;K[C]=1,q[C]===0&&(i.enableVertexAttribArray(C),q[C]=1),$[C]!==F&&(i.vertexAttribDivisor(C,F),$[C]=F)}function y(){const C=r.newAttributes,F=r.enabledAttributes;for(let K=0,q=F.length;K<q;K++)F[K]!==C[K]&&(i.disableVertexAttribArray(K),F[K]=0)}function b(C,F,K,q,$,D,O){O===!0?i.vertexAttribIPointer(C,F,K,$,D):i.vertexAttribPointer(C,F,K,q,$,D)}function _(C,F,K,q){g();const $=q.attributes,D=K.getAttributes(),O=F.defaultAttributeValues;for(const j in D){const Q=D[j];if(Q.location>=0){let J=$[j];if(J===void 0&&(j==="instanceMatrix"&&C.instanceMatrix&&(J=C.instanceMatrix),j==="instanceColor"&&C.instanceColor&&(J=C.instanceColor)),J!==void 0){const ee=J.normalized,ae=J.itemSize,ye=e.get(J);if(ye===void 0)continue;const Me=ye.buffer,se=ye.type,me=ye.bytesPerElement,be=se===i.INT||se===i.UNSIGNED_INT||J.gpuType===xh;if(J.isInterleavedBufferAttribute){const xe=J.data,Pe=xe.stride,$e=J.offset;if(xe.isInstancedInterleavedBuffer){for(let Qe=0;Qe<Q.locationSize;Qe++)p(Q.location+Qe,xe.meshPerAttribute);C.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let Qe=0;Qe<Q.locationSize;Qe++)A(Q.location+Qe);i.bindBuffer(i.ARRAY_BUFFER,Me);for(let Qe=0;Qe<Q.locationSize;Qe++)b(Q.location+Qe,ae/Q.locationSize,se,ee,Pe*me,($e+ae/Q.locationSize*Qe)*me,be)}else{if(J.isInstancedBufferAttribute){for(let xe=0;xe<Q.locationSize;xe++)p(Q.location+xe,J.meshPerAttribute);C.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let xe=0;xe<Q.locationSize;xe++)A(Q.location+xe);i.bindBuffer(i.ARRAY_BUFFER,Me);for(let xe=0;xe<Q.locationSize;xe++)b(Q.location+xe,ae/Q.locationSize,se,ee,ae*me,ae/Q.locationSize*xe*me,be)}}else if(O!==void 0){const ee=O[j];if(ee!==void 0)switch(ee.length){case 2:i.vertexAttrib2fv(Q.location,ee);break;case 3:i.vertexAttrib3fv(Q.location,ee);break;case 4:i.vertexAttrib4fv(Q.location,ee);break;default:i.vertexAttrib1fv(Q.location,ee)}}}}y()}function M(){T();for(const C in n){const F=n[C];for(const K in F){const q=F[K];for(const $ in q)h(q[$].object),delete q[$];delete F[K]}delete n[C]}}function w(C){if(n[C.id]===void 0)return;const F=n[C.id];for(const K in F){const q=F[K];for(const $ in q)h(q[$].object),delete q[$];delete F[K]}delete n[C.id]}function S(C){for(const F in n){const K=n[F];if(K[C.id]===void 0)continue;const q=K[C.id];for(const $ in q)h(q[$].object),delete q[$];delete K[C.id]}}function T(){v(),a=!0,r!==s&&(r=s,l(r.object))}function v(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:T,resetDefaultState:v,dispose:M,releaseStatesOfGeometry:w,releaseStatesOfProgram:S,initAttributes:g,enableAttribute:A,disableUnusedAttributes:y}}function kC(i,e,t){let n;function s(l){n=l}function r(l,h){i.drawArrays(n,l,h),t.update(h,n,1)}function a(l,h,u){u!==0&&(i.drawArraysInstanced(n,l,h,u),t.update(h,n,u))}function o(l,h,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,h,0,u);let f=0;for(let m=0;m<u;m++)f+=h[m];t.update(f,n,1)}function c(l,h,u,d){if(u===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let m=0;m<l.length;m++)a(l[m],h[m],d[m]);else{f.multiDrawArraysInstancedWEBGL(n,l,0,h,0,d,0,u);let m=0;for(let g=0;g<u;g++)m+=h[g]*d[g];t.update(m,n,1)}}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=c}function UC(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){const S=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(S.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(S){return!(S!==sn&&n.convert(S)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(S){const T=S===Mn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(S!==tn&&n.convert(S)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&S!==nn&&!T)}function c(S){if(S==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";S="mediump"}return S==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const h=c(l);h!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),m=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_TEXTURE_SIZE),A=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),y=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),b=i.getParameter(i.MAX_VARYING_VECTORS),_=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),M=m>0,w=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reverseDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:g,maxCubemapSize:A,maxAttributes:p,maxVertexUniforms:y,maxVaryings:b,maxFragmentUniforms:_,vertexTextures:M,maxSamples:w}}function OC(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new Is,o=new rt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||s;return s=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,f){const m=u.clippingPlanes,g=u.clipIntersection,A=u.clipShadows,p=i.get(u);if(!s||m===null||m.length===0||r&&!A)r?h(null):l();else{const y=r?0:n,b=y*4;let _=p.clippingState||null;c.value=_,_=h(m,d,b,f);for(let M=0;M!==b;++M)_[M]=t[M];p.clippingState=_,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=y}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,f,m){const g=u!==null?u.length:0;let A=null;if(g!==0){if(A=c.value,m!==!0||A===null){const p=f+g*4,y=d.matrixWorldInverse;o.getNormalMatrix(y),(A===null||A.length<p)&&(A=new Float32Array(p));for(let b=0,_=f;b!==g;++b,_+=4)a.copy(u[b]).applyMatrix4(y,o),a.normal.toArray(A,_),A[_+3]=a.constant}c.value=A,c.needsUpdate=!0}return e.numPlanes=g,e.numIntersection=0,A}}function QC(i){let e=new WeakMap;function t(a,o){return o===mh?a.mapping=Ks:o===bh&&(a.mapping=Dr),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===mh||o===bh)if(e.has(a)){const c=e.get(a).texture;return t(c,a.mapping)}else{const c=a.image;if(c&&c.height>0){const l=new k_(c.height);return l.fromEquirectangularTexture(i,a),e.set(a,l),a.addEventListener("dispose",s),t(l.texture,a.mapping)}else return null}}return a}function s(a){const o=a.target;o.removeEventListener("dispose",s);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}const ca=4,LA=[.125,.215,.35,.446,.526,.582],ir=20,Lu=new Ru,PA=new qe;let Pu=null,ku=0,Uu=0,Ou=!1;const sr=(1+Math.sqrt(5))/2,la=1/sr,kA=[new H(-sr,la,0),new H(sr,la,0),new H(-la,0,sr),new H(la,0,sr),new H(0,sr,-la),new H(0,sr,la),new H(-1,1,-1),new H(1,1,-1),new H(-1,1,1),new H(1,1,1)],GC=new H;class Qu{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,s=100,r={}){const{size:a=256,position:o=GC}=r;Pu=this._renderer.getRenderTarget(),ku=this._renderer.getActiveCubeFace(),Uu=this._renderer.getActiveMipmapLevel(),Ou=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,s,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=QA(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=OA(),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(Pu,ku,Uu),this._renderer.xr.enabled=Ou,e.scissorTest=!1,jc(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Ks||e.mapping===Dr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Pu=this._renderer.getRenderTarget(),ku=this._renderer.getActiveCubeFace(),Uu=this._renderer.getActiveMipmapLevel(),Ou=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;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:zt,minFilter:zt,generateMipmaps:!1,type:Mn,format:sn,colorSpace:rn,depthBuffer:!1},s=UA(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=UA(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=HC(r)),this._blurMaterial=zC(r,e,t)}return s}_compileMaterial(e){const t=new Jt(this._lodPlanes[0],e);this._renderer.compile(t,Lu)}_sceneToCubeUV(e,t,n,s,r){const c=new vn(90,1,t,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(PA),u.toneMapping=ms,u.autoClear=!1;const m=new Cs({name:"PMREM.Background",side:Sn,depthWrite:!1,depthTest:!1}),g=new Jt(new Jr,m);let A=!1;const p=e.background;p?p.isColor&&(m.color.copy(p),e.background=null,A=!0):(m.color.copy(PA),A=!0);for(let y=0;y<6;y++){const b=y%3;b===0?(c.up.set(0,l[y],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[y],r.y,r.z)):b===1?(c.up.set(0,0,l[y]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[y],r.z)):(c.up.set(0,l[y],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[y]));const _=this._cubeSize;jc(s,b*_,y>2?_:0,_,_),u.setRenderTarget(s),A&&u.render(g,c),u.render(e,c)}g.geometry.dispose(),g.material.dispose(),u.toneMapping=f,u.autoClear=d,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===Ks||e.mapping===Dr;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=QA()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=OA());const r=s?this._cubemapMaterial:this._equirectMaterial,a=new Jt(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;jc(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,Lu)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodPlanes.length;for(let r=1;r<s;r++){const a=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),o=kA[(s-r-1)%kA.length];this._blur(e,r-1,r,a,o)}t.autoClear=n}_blur(e,t,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",r),this._halfBlur(a,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new Jt(this._lodPlanes[s],l),d=l.uniforms,f=this._sizeLods[n]-1,m=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*ir-1),g=r/m,A=isFinite(r)?1+Math.floor(h*g):ir;A>ir&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${A} samples when the maximum is set to ${ir}`);const p=[];let y=0;for(let S=0;S<ir;++S){const T=S/g,v=Math.exp(-T*T/2);p.push(v),S===0?y+=v:S<A&&(y+=2*v)}for(let S=0;S<p.length;S++)p[S]=p[S]/y;d.envMap.value=e.texture,d.samples.value=A,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:b}=this;d.dTheta.value=m,d.mipInt.value=b-n;const _=this._sizeLods[s],M=3*_*(s>b-ca?s-b+ca:0),w=4*(this._cubeSize-_);jc(t,M,w,3*_,2*_),c.setRenderTarget(t),c.render(u,Lu)}}function HC(i){const e=[],t=[],n=[];let s=i;const r=i-ca+1+LA.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);t.push(o);let c=1/o;a>i-ca?c=LA[a-i+ca-1]:a===0&&(c=0),n.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,m=6,g=3,A=2,p=1,y=new Float32Array(g*m*f),b=new Float32Array(A*m*f),_=new Float32Array(p*m*f);for(let w=0;w<f;w++){const S=w%3*2/3-1,T=w>2?0:-1,v=[S,T,0,S+2/3,T,0,S+2/3,T+1,0,S,T,0,S+2/3,T+1,0,S,T+1,0];y.set(v,g*m*w),b.set(d,A*m*w);const C=[w,w,w,w,w,w];_.set(C,p*m*w)}const M=new On;M.setAttribute("position",new En(y,g)),M.setAttribute("uv",new En(b,A)),M.setAttribute("faceIndex",new En(_,p)),e.push(M),s>ca&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function UA(i,e,t){const n=new js(i,e,t);return n.texture.mapping=ic,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function jc(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function zC(i,e,t){const n=new Float32Array(ir),s=new H(0,1,0);return new vs({name:"SphericalGaussianBlur",defines:{n:ir,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Gu(),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:gs,depthTest:!1,depthWrite:!1})}function OA(){return new vs({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Gu(),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:gs,depthTest:!1,depthWrite:!1})}function QA(){return new vs({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Gu(),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:gs,depthTest:!1,depthWrite:!1})}function Gu(){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 VC(i){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const c=o.mapping,l=c===mh||c===bh,h=c===Ks||c===Dr;if(l||h){let u=e.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new Qu(i)),u=l?t.fromEquirectangular(o,u):t.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),u.texture;if(u!==void 0)return u.texture;{const f=o.image;return l&&f&&f.height>0||h&&f&&s(f)?(t===null&&(t=new Qu(i)),u=l?t.fromEquirectangular(o):t.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,e.set(o,u),o.addEventListener("dispose",r),u.texture):null}}}return o}function s(o){let c=0;const l=6;for(let h=0;h<l;h++)o[h]!==void 0&&c++;return c===l}function r(o){const c=o.target;c.removeEventListener("dispose",r);const l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function WC(i){const e={};function t(n){if(e[n]!==void 0)return e[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const s=t(n);return s===null&&mc("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function qC(i,e,t,n){const s={},r=new WeakMap;function a(u){const d=u.target;d.index!==null&&e.remove(d.index);for(const m in d.attributes)e.remove(d.attributes[m]);d.removeEventListener("dispose",a),delete s[d.id];const f=r.get(d);f&&(e.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(u,d){return s[d.id]===!0||(d.addEventListener("dispose",a),s[d.id]=!0,t.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)e.update(d[f],i.ARRAY_BUFFER)}function l(u){const d=[],f=u.index,m=u.attributes.position;let g=0;if(f!==null){const y=f.array;g=f.version;for(let b=0,_=y.length;b<_;b+=3){const M=y[b+0],w=y[b+1],S=y[b+2];d.push(M,w,w,S,S,M)}}else if(m!==void 0){const y=m.array;g=m.version;for(let b=0,_=y.length/3-1;b<_;b+=3){const M=b+0,w=b+1,S=b+2;d.push(M,w,w,S,S,M)}}else return;const A=new(Mp(d)?Kp:qp)(d,1);A.version=g;const p=r.get(u);p&&e.remove(p),r.set(u,A)}function h(u){const d=r.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&l(u)}else l(u);return r.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function KC(i,e,t){let n;function s(d){n=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function c(d,f){i.drawElements(n,f,r,d*a),t.update(f,n,1)}function l(d,f,m){m!==0&&(i.drawElementsInstanced(n,f,r,d*a,m),t.update(f,n,m))}function h(d,f,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,f,0,r,d,0,m);let A=0;for(let p=0;p<m;p++)A+=f[p];t.update(A,n,1)}function u(d,f,m,g){if(m===0)return;const A=e.get("WEBGL_multi_draw");if(A===null)for(let p=0;p<d.length;p++)l(d[p]/a,f[p],g[p]);else{A.multiDrawElementsInstancedWEBGL(n,f,0,r,d,0,g,0,m);let p=0;for(let y=0;y<m;y++)p+=f[y]*g[y];t.update(p,n,1)}}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function XC(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(r/3);break;case i.LINES:t.lines+=o*(r/2);break;case i.LINE_STRIP:t.lines+=o*(r-1);break;case i.LINE_LOOP:t.lines+=o*r;break;case i.POINTS:t.points+=o*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function YC(i,e,t){const n=new WeakMap,s=new _t;function r(a,o,c){const l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let v=function(){S.dispose(),n.delete(o),o.removeEventListener("dispose",v)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,m=o.morphAttributes.normal!==void 0,g=o.morphAttributes.color!==void 0,A=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],y=o.morphAttributes.color||[];let b=0;f===!0&&(b=1),m===!0&&(b=2),g===!0&&(b=3);let _=o.attributes.position.count*b,M=1;_>e.maxTextureSize&&(M=Math.ceil(_/e.maxTextureSize),_=e.maxTextureSize);const w=new Float32Array(_*M*4*u),S=new Np(w,_,M,u);S.type=nn,S.needsUpdate=!0;const T=b*4;for(let C=0;C<u;C++){const F=A[C],K=p[C],q=y[C],$=_*M*4*C;for(let D=0;D<F.count;D++){const O=D*T;f===!0&&(s.fromBufferAttribute(F,D),w[$+O+0]=s.x,w[$+O+1]=s.y,w[$+O+2]=s.z,w[$+O+3]=0),m===!0&&(s.fromBufferAttribute(K,D),w[$+O+4]=s.x,w[$+O+5]=s.y,w[$+O+6]=s.z,w[$+O+7]=0),g===!0&&(s.fromBufferAttribute(q,D),w[$+O+8]=s.x,w[$+O+9]=s.y,w[$+O+10]=s.z,w[$+O+11]=q.itemSize===4?s.w:1)}}d={count:u,texture:S,size:new Ze(_,M)},n.set(o,d),o.addEventListener("dispose",v)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let f=0;for(let g=0;g<l.length;g++)f+=l[g];const m=o.morphTargetsRelative?1:1-f;c.getUniforms().setValue(i,"morphTargetBaseInfluence",m),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function jC(i,e,t,n){let s=new WeakMap;function r(c){const l=n.render.frame,h=c.geometry,u=e.get(c,h);if(s.get(u)!==l&&(e.update(u),s.set(u,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),s.get(c)!==l&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),s.set(c,l))),c.isSkinnedMesh){const d=c.skeleton;s.get(d)!==l&&(d.update(),s.set(d,l))}return u}function a(){s=new WeakMap}function o(c){const l=c.target;l.removeEventListener("dispose",o),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:r,dispose:a}}const GA=new an,HA=new bA(1,1),zA=new Np,VA=new Fp,WA=new tA,qA=[],KA=[],XA=new Float32Array(16),YA=new Float32Array(9),jA=new Float32Array(4);function ha(i,e,t){const n=i[0];if(n<=0||n>0)return i;const s=e*t;let r=qA[s];if(r===void 0&&(r=new Float32Array(s),qA[s]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(r,o)}return r}function on(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function cn(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Jc(i,e){let t=KA[e];t===void 0&&(t=new Int32Array(e),KA[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function JC(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function ZC(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(on(t,e))return;i.uniform2fv(this.addr,e),cn(t,e)}}function $C(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.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)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(on(t,e))return;i.uniform3fv(this.addr,e),cn(t,e)}}function ev(i,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)&&(i.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(on(t,e))return;i.uniform4fv(this.addr,e),cn(t,e)}}function tv(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(on(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),cn(t,e)}else{if(on(t,n))return;jA.set(n),i.uniformMatrix2fv(this.addr,!1,jA),cn(t,n)}}function nv(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(on(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),cn(t,e)}else{if(on(t,n))return;YA.set(n),i.uniformMatrix3fv(this.addr,!1,YA),cn(t,n)}}function iv(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(on(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),cn(t,e)}else{if(on(t,n))return;XA.set(n),i.uniformMatrix4fv(this.addr,!1,XA),cn(t,n)}}function sv(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function rv(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(on(t,e))return;i.uniform2iv(this.addr,e),cn(t,e)}}function av(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(on(t,e))return;i.uniform3iv(this.addr,e),cn(t,e)}}function ov(i,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)&&(i.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(on(t,e))return;i.uniform4iv(this.addr,e),cn(t,e)}}function cv(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function lv(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(on(t,e))return;i.uniform2uiv(this.addr,e),cn(t,e)}}function hv(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(on(t,e))return;i.uniform3uiv(this.addr,e),cn(t,e)}}function uv(i,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)&&(i.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(on(t,e))return;i.uniform4uiv(this.addr,e),cn(t,e)}}function dv(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(HA.compareFunction=Cp,r=HA):r=GA,t.setTexture2D(e||r,s)}function fv(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||VA,s)}function pv(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||WA,s)}function Av(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||zA,s)}function gv(i){switch(i){case 5126:return JC;case 35664:return ZC;case 35665:return $C;case 35666:return ev;case 35674:return tv;case 35675:return nv;case 35676:return iv;case 5124:case 35670:return sv;case 35667:case 35671:return rv;case 35668:case 35672:return av;case 35669:case 35673:return ov;case 5125:return cv;case 36294:return lv;case 36295:return hv;case 36296:return uv;case 35678:case 36198:case 36298:case 36306:case 35682:return dv;case 35679:case 36299:case 36307:return fv;case 35680:case 36300:case 36308:case 36293:return pv;case 36289:case 36303:case 36311:case 36292:return Av}}function mv(i,e){i.uniform1fv(this.addr,e)}function bv(i,e){const t=ha(e,this.size,2);i.uniform2fv(this.addr,t)}function xv(i,e){const t=ha(e,this.size,3);i.uniform3fv(this.addr,t)}function Ev(i,e){const t=ha(e,this.size,4);i.uniform4fv(this.addr,t)}function _v(i,e){const t=ha(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function yv(i,e){const t=ha(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function wv(i,e){const t=ha(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Cv(i,e){i.uniform1iv(this.addr,e)}function vv(i,e){i.uniform2iv(this.addr,e)}function Sv(i,e){i.uniform3iv(this.addr,e)}function Iv(i,e){i.uniform4iv(this.addr,e)}function Mv(i,e){i.uniform1uiv(this.addr,e)}function Bv(i,e){i.uniform2uiv(this.addr,e)}function Tv(i,e){i.uniform3uiv(this.addr,e)}function Rv(i,e){i.uniform4uiv(this.addr,e)}function Nv(i,e,t){const n=this.cache,s=e.length,r=Jc(t,s);on(n,r)||(i.uniform1iv(this.addr,r),cn(n,r));for(let a=0;a!==s;++a)t.setTexture2D(e[a]||GA,r[a])}function Fv(i,e,t){const n=this.cache,s=e.length,r=Jc(t,s);on(n,r)||(i.uniform1iv(this.addr,r),cn(n,r));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||VA,r[a])}function Dv(i,e,t){const n=this.cache,s=e.length,r=Jc(t,s);on(n,r)||(i.uniform1iv(this.addr,r),cn(n,r));for(let a=0;a!==s;++a)t.setTextureCube(e[a]||WA,r[a])}function Lv(i,e,t){const n=this.cache,s=e.length,r=Jc(t,s);on(n,r)||(i.uniform1iv(this.addr,r),cn(n,r));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||zA,r[a])}function Pv(i){switch(i){case 5126:return mv;case 35664:return bv;case 35665:return xv;case 35666:return Ev;case 35674:return _v;case 35675:return yv;case 35676:return wv;case 5124:case 35670:return Cv;case 35667:case 35671:return vv;case 35668:case 35672:return Sv;case 35669:case 35673:return Iv;case 5125:return Mv;case 36294:return Bv;case 36295:return Tv;case 36296:return Rv;case 35678:case 36198:case 36298:case 36306:case 35682:return Nv;case 35679:case 36299:case 36307:return Fv;case 35680:case 36300:case 36308:case 36293:return Dv;case 36289:case 36303:case 36311:case 36292:return Lv}}class kv{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=gv(t.type)}}class Uv{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Pv(t.type)}}class Ov{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const s=this.seq;for(let r=0,a=s.length;r!==a;++r){const o=s[r];o.setValue(e,t[o.id],n)}}}const Hu=/(\w+)(\])?(\[|\.)?/g;function JA(i,e){i.seq.push(e),i.map[e.id]=e}function Qv(i,e,t){const n=i.name,s=n.length;for(Hu.lastIndex=0;;){const r=Hu.exec(n),a=Hu.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){JA(t,l===void 0?new kv(o,i,e):new Uv(o,i,e));break}else{let u=t.map[o];u===void 0&&(u=new Ov(o),JA(t,u)),t=u}}}class Zc{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){const r=e.getActiveUniform(t,s),a=e.getUniformLocation(t,r.name);Qv(r,a,this)}}setValue(e,t,n,s){const r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){const s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,s)}}static seqWithValue(e,t){const n=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&n.push(a)}return n}}function ZA(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Gv=37297;let Hv=0;function zv(i,e){const t=i.split(`+`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a<r;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`+`)}const $A=new rt;function Vv(i){At._getMatrix($A,At.workingColorSpace,i);const e=`mat3( ${$A.elements.map(t=>t.toFixed(4))} )`;switch(At.getTransfer(i)){case Ac:return[e,"LinearTransferOETF"];case Mt:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function eg(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),s=i.getShaderInfoLog(e).trim();if(n&&s==="")return"";const r=/ERROR: 0:(\d+)/.exec(s);if(r){const a=parseInt(r[1]);return t.toUpperCase()+`++`+s+`++`+zv(i.getShaderSource(e),a)}else return s}function Wv(i,e){const t=Vv(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`+`)}function qv(i,e){let t;switch(e){case gh:t="Linear";break;case ME:t="Reinhard";break;case BE:t="Cineon";break;case lp:t="ACESFilmic";break;case RE:t="AgX";break;case NE:t="Neutral";break;case TE:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const $c=new H;function Kv(){At.getLuminanceCoefficients($c);const i=$c.x.toFixed(4),e=$c.y.toFixed(4),t=$c.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`+`)}function Xv(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ao).join(`+`)}function Yv(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`+`)}function jv(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const r=i.getActiveAttrib(e,s),a=r.name;let o=1;r.type===i.FLOAT_MAT2&&(o=2),r.type===i.FLOAT_MAT3&&(o=3),r.type===i.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function Ao(i){return i!==""}function tg(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.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 ng(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Jv=/^[ \t]*#include +<([\w\d./]+)>/gm;function zu(i){return i.replace(Jv,$v)}const Zv=new Map;function $v(i,e){let t=ot[e];if(t===void 0){const n=Zv.get(e);if(n!==void 0)t=ot[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 zu(t)}const eS=/#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 ig(i){return i.replace(eS,tS)}function tS(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function sg(i){let e=`precision ${i.precision} float;+ precision ${i.precision} int;+ precision ${i.precision} sampler2D;+ precision ${i.precision} samplerCube;+ precision ${i.precision} sampler3D;+ precision ${i.precision} sampler2DArray;+ precision ${i.precision} sampler2DShadow;+ precision ${i.precision} samplerCubeShadow;+ precision ${i.precision} sampler2DArrayShadow;+ precision ${i.precision} isampler2D;+ precision ${i.precision} isampler3D;+ precision ${i.precision} isamplerCube;+ precision ${i.precision} isampler2DArray;+ precision ${i.precision} usampler2D;+ precision ${i.precision} usampler3D;+ precision ${i.precision} usamplerCube;+ precision ${i.precision} usampler2DArray;+ `;return i.precision==="highp"?e+=`+#define HIGH_PRECISION`:i.precision==="mediump"?e+=`+#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`+#define LOW_PRECISION`),e}function nS(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===sp?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===oE?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===Oi&&(e="SHADOWMAP_TYPE_VSM"),e}function iS(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Ks:case Dr:e="ENVMAP_TYPE_CUBE";break;case ic:e="ENVMAP_TYPE_CUBE_UV";break}return e}function sS(i){let e="ENVMAP_MODE_REFLECTION";return i.envMap&&i.envMapMode===Dr&&(e="ENVMAP_MODE_REFRACTION"),e}function rS(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case cp:e="ENVMAP_BLENDING_MULTIPLY";break;case SE:e="ENVMAP_BLENDING_MIX";break;case IE:e="ENVMAP_BLENDING_ADD";break}return e}function aS(i){const e=i.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 oS(i,e,t,n){const s=i.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const c=nS(t),l=iS(t),h=sS(t),u=rS(t),d=aS(t),f=Xv(t),m=Yv(r),g=s.createProgram();let A,p,y=t.glslVersion?"#version "+t.glslVersion+`+`:"";t.isRawShaderMaterial?(A=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(Ao).join(`+`),A.length>0&&(A+=`+`),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(Ao).join(`+`),p.length>0&&(p+=`+`)):(A=[sg(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`+`].filter(Ao).join(`+`),p=[sg(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.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.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#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 "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==ms?"#define TONE_MAPPING":"",t.toneMapping!==ms?ot.tonemapping_pars_fragment:"",t.toneMapping!==ms?qv("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ot.colorspace_pars_fragment,Wv("linearToOutputTexel",t.outputColorSpace),Kv(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`+`].filter(Ao).join(`+`)),a=zu(a),a=tg(a,t),a=ng(a,t),o=zu(o),o=tg(o,t),o=ng(o,t),a=ig(a),o=ig(o),t.isRawShaderMaterial!==!0&&(y=`#version 300 es+`,A=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`+`)+`+`+A,p=["#define varying in",t.glslVersion===vp?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===vp?"":"#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(`+`)+`+`+p);const b=y+A+a,_=y+p+o,M=ZA(s,s.VERTEX_SHADER,b),w=ZA(s,s.FRAGMENT_SHADER,_);s.attachShader(g,M),s.attachShader(g,w),t.index0AttributeName!==void 0?s.bindAttribLocation(g,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(g,0,"position"),s.linkProgram(g);function S(F){if(i.debug.checkShaderErrors){const K=s.getProgramInfoLog(g).trim(),q=s.getShaderInfoLog(M).trim(),$=s.getShaderInfoLog(w).trim();let D=!0,O=!0;if(s.getProgramParameter(g,s.LINK_STATUS)===!1)if(D=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,g,M,w);else{const j=eg(s,M,"vertex"),Q=eg(s,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(g,s.VALIDATE_STATUS)+`++Material Name: `+F.name+`+Material Type: `+F.type+`++Program Info Log: `+K+`+`+j+`+`+Q)}else K!==""?console.warn("THREE.WebGLProgram: Program Info Log:",K):(q===""||$==="")&&(O=!1);O&&(F.diagnostics={runnable:D,programLog:K,vertexShader:{log:q,prefix:A},fragmentShader:{log:$,prefix:p}})}s.deleteShader(M),s.deleteShader(w),T=new Zc(s,g),v=jv(s,g)}let T;this.getUniforms=function(){return T===void 0&&S(this),T};let v;this.getAttributes=function(){return v===void 0&&S(this),v};let C=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return C===!1&&(C=s.getProgramParameter(g,Gv)),C},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(g),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Hv++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=M,this.fragmentShader=w,this}let cS=0;class lS{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,s=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.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 hS(e),t.set(e,n)),n}}class hS{constructor(e){this.id=cS++,this.code=e,this.usedTimes=0}}function uS(i,e,t,n,s,r,a){const o=new kp,c=new lS,l=new Set,h=[],u=s.logarithmicDepthBuffer,d=s.vertexTextures;let f=s.precision;const m={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 g(v){return l.add(v),v===0?"uv":`uv${v}`}function A(v,C,F,K,q){const $=K.fog,D=q.geometry,O=v.isMeshStandardMaterial?K.environment:null,j=(v.isMeshStandardMaterial?t:e).get(v.envMap||O),Q=j&&j.mapping===ic?j.image.height:null,J=m[v.type];v.precision!==null&&(f=s.getMaxPrecision(v.precision),f!==v.precision&&console.warn("THREE.WebGLProgram.getParameters:",v.precision,"not supported, using",f,"instead."));const ee=D.morphAttributes.position||D.morphAttributes.normal||D.morphAttributes.color,ae=ee!==void 0?ee.length:0;let ye=0;D.morphAttributes.position!==void 0&&(ye=1),D.morphAttributes.normal!==void 0&&(ye=2),D.morphAttributes.color!==void 0&&(ye=3);let Me,se,me,be;if(J){const yt=Ni[J];Me=yt.vertexShader,se=yt.fragmentShader}else Me=v.vertexShader,se=v.fragmentShader,c.update(v),me=c.getVertexShaderID(v),be=c.getFragmentShaderID(v);const xe=i.getRenderTarget(),Pe=i.state.buffers.depth.getReversed(),$e=q.isInstancedMesh===!0,Qe=q.isBatchedMesh===!0,St=!!v.map,ut=!!v.matcap,Je=!!j,G=!!v.aoMap,mn=!!v.lightMap,dt=!!v.bumpMap,pt=!!v.normalMap,ze=!!v.displacementMap,Rt=!!v.emissiveMap,Ge=!!v.metalnessMap,L=!!v.roughnessMap,I=v.anisotropy>0,Z=v.clearcoat>0,le=v.dispersion>0,Ae=v.iridescence>0,oe=v.sheen>0,Ue=v.transmission>0,Ce=I&&!!v.anisotropyMap,Ve=Z&&!!v.clearcoatMap,je=Z&&!!v.clearcoatNormalMap,Ee=Z&&!!v.clearcoatRoughnessMap,Ne=Ae&&!!v.iridescenceMap,ke=Ae&&!!v.iridescenceThicknessMap,Oe=oe&&!!v.sheenColorMap,Te=oe&&!!v.sheenRoughnessMap,tt=!!v.specularMap,We=!!v.specularColorMap,nt=!!v.specularIntensityMap,W=Ue&&!!v.transmissionMap,ne=Ue&&!!v.thicknessMap,re=!!v.gradientMap,de=!!v.alphaMap,Ie=v.alphaTest>0,Se=!!v.alphaHash,it=!!v.extensions;let Ot=ms;v.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(Ot=i.toneMapping);const bn={shaderID:J,shaderType:v.type,shaderName:v.name,vertexShader:Me,fragmentShader:se,defines:v.defines,customVertexShaderID:me,customFragmentShaderID:be,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:f,batching:Qe,batchingColor:Qe&&q._colorsTexture!==null,instancing:$e,instancingColor:$e&&q.instanceColor!==null,instancingMorph:$e&&q.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:xe===null?i.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:rn,alphaToCoverage:!!v.alphaToCoverage,map:St,matcap:ut,envMap:Je,envMapMode:Je&&j.mapping,envMapCubeUVHeight:Q,aoMap:G,lightMap:mn,bumpMap:dt,normalMap:pt,displacementMap:d&&ze,emissiveMap:Rt,normalMapObjectSpace:pt&&v.normalMapType===OE,normalMapTangentSpace:pt&&v.normalMapType===yp,metalnessMap:Ge,roughnessMap:L,anisotropy:I,anisotropyMap:Ce,clearcoat:Z,clearcoatMap:Ve,clearcoatNormalMap:je,clearcoatRoughnessMap:Ee,dispersion:le,iridescence:Ae,iridescenceMap:Ne,iridescenceThicknessMap:ke,sheen:oe,sheenColorMap:Oe,sheenRoughnessMap:Te,specularMap:tt,specularColorMap:We,specularIntensityMap:nt,transmission:Ue,transmissionMap:W,thicknessMap:ne,gradientMap:re,opaque:v.transparent===!1&&v.blending===Nr&&v.alphaToCoverage===!1,alphaMap:de,alphaTest:Ie,alphaHash:Se,combine:v.combine,mapUv:St&&g(v.map.channel),aoMapUv:G&&g(v.aoMap.channel),lightMapUv:mn&&g(v.lightMap.channel),bumpMapUv:dt&&g(v.bumpMap.channel),normalMapUv:pt&&g(v.normalMap.channel),displacementMapUv:ze&&g(v.displacementMap.channel),emissiveMapUv:Rt&&g(v.emissiveMap.channel),metalnessMapUv:Ge&&g(v.metalnessMap.channel),roughnessMapUv:L&&g(v.roughnessMap.channel),anisotropyMapUv:Ce&&g(v.anisotropyMap.channel),clearcoatMapUv:Ve&&g(v.clearcoatMap.channel),clearcoatNormalMapUv:je&&g(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ee&&g(v.clearcoatRoughnessMap.channel),iridescenceMapUv:Ne&&g(v.iridescenceMap.channel),iridescenceThicknessMapUv:ke&&g(v.iridescenceThicknessMap.channel),sheenColorMapUv:Oe&&g(v.sheenColorMap.channel),sheenRoughnessMapUv:Te&&g(v.sheenRoughnessMap.channel),specularMapUv:tt&&g(v.specularMap.channel),specularColorMapUv:We&&g(v.specularColorMap.channel),specularIntensityMapUv:nt&&g(v.specularIntensityMap.channel),transmissionMapUv:W&&g(v.transmissionMap.channel),thicknessMapUv:ne&&g(v.thicknessMap.channel),alphaMapUv:de&&g(v.alphaMap.channel),vertexTangents:!!D.attributes.tangent&&(pt||I),vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!D.attributes.color&&D.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!D.attributes.uv&&(St||de),fog:!!$,useFog:v.fog===!0,fogExp2:!!$&&$.isFogExp2,flatShading:v.flatShading===!0,sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:Pe,skinning:q.isSkinnedMesh===!0,morphTargets:D.morphAttributes.position!==void 0,morphNormals:D.morphAttributes.normal!==void 0,morphColors:D.morphAttributes.color!==void 0,morphTargetsCount:ae,morphTextureStride:ye,numDirLights:C.directional.length,numPointLights:C.point.length,numSpotLights:C.spot.length,numSpotLightMaps:C.spotLightMap.length,numRectAreaLights:C.rectArea.length,numHemiLights:C.hemi.length,numDirLightShadows:C.directionalShadowMap.length,numPointLightShadows:C.pointShadowMap.length,numSpotLightShadows:C.spotShadowMap.length,numSpotLightShadowsWithMaps:C.numSpotLightShadowsWithMaps,numLightProbes:C.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&F.length>0,shadowMapType:i.shadowMap.type,toneMapping:Ot,decodeVideoTexture:St&&v.map.isVideoTexture===!0&&At.getTransfer(v.map.colorSpace)===Mt,decodeVideoTextureEmissive:Rt&&v.emissiveMap.isVideoTexture===!0&&At.getTransfer(v.emissiveMap.colorSpace)===Mt,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===Si,flipSided:v.side===Sn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:it&&v.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(it&&v.extensions.multiDraw===!0||Qe)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return bn.vertexUv1s=l.has(1),bn.vertexUv2s=l.has(2),bn.vertexUv3s=l.has(3),l.clear(),bn}function p(v){const C=[];if(v.shaderID?C.push(v.shaderID):(C.push(v.customVertexShaderID),C.push(v.customFragmentShaderID)),v.defines!==void 0)for(const F in v.defines)C.push(F),C.push(v.defines[F]);return v.isRawShaderMaterial===!1&&(y(C,v),b(C,v),C.push(i.outputColorSpace)),C.push(v.customProgramCacheKey),C.join()}function y(v,C){v.push(C.precision),v.push(C.outputColorSpace),v.push(C.envMapMode),v.push(C.envMapCubeUVHeight),v.push(C.mapUv),v.push(C.alphaMapUv),v.push(C.lightMapUv),v.push(C.aoMapUv),v.push(C.bumpMapUv),v.push(C.normalMapUv),v.push(C.displacementMapUv),v.push(C.emissiveMapUv),v.push(C.metalnessMapUv),v.push(C.roughnessMapUv),v.push(C.anisotropyMapUv),v.push(C.clearcoatMapUv),v.push(C.clearcoatNormalMapUv),v.push(C.clearcoatRoughnessMapUv),v.push(C.iridescenceMapUv),v.push(C.iridescenceThicknessMapUv),v.push(C.sheenColorMapUv),v.push(C.sheenRoughnessMapUv),v.push(C.specularMapUv),v.push(C.specularColorMapUv),v.push(C.specularIntensityMapUv),v.push(C.transmissionMapUv),v.push(C.thicknessMapUv),v.push(C.combine),v.push(C.fogExp2),v.push(C.sizeAttenuation),v.push(C.morphTargetsCount),v.push(C.morphAttributeCount),v.push(C.numDirLights),v.push(C.numPointLights),v.push(C.numSpotLights),v.push(C.numSpotLightMaps),v.push(C.numHemiLights),v.push(C.numRectAreaLights),v.push(C.numDirLightShadows),v.push(C.numPointLightShadows),v.push(C.numSpotLightShadows),v.push(C.numSpotLightShadowsWithMaps),v.push(C.numLightProbes),v.push(C.shadowMapType),v.push(C.toneMapping),v.push(C.numClippingPlanes),v.push(C.numClipIntersection),v.push(C.depthPacking)}function b(v,C){o.disableAll(),C.supportsVertexTextures&&o.enable(0),C.instancing&&o.enable(1),C.instancingColor&&o.enable(2),C.instancingMorph&&o.enable(3),C.matcap&&o.enable(4),C.envMap&&o.enable(5),C.normalMapObjectSpace&&o.enable(6),C.normalMapTangentSpace&&o.enable(7),C.clearcoat&&o.enable(8),C.iridescence&&o.enable(9),C.alphaTest&&o.enable(10),C.vertexColors&&o.enable(11),C.vertexAlphas&&o.enable(12),C.vertexUv1s&&o.enable(13),C.vertexUv2s&&o.enable(14),C.vertexUv3s&&o.enable(15),C.vertexTangents&&o.enable(16),C.anisotropy&&o.enable(17),C.alphaHash&&o.enable(18),C.batching&&o.enable(19),C.dispersion&&o.enable(20),C.batchingColor&&o.enable(21),v.push(o.mask),o.disableAll(),C.fog&&o.enable(0),C.useFog&&o.enable(1),C.flatShading&&o.enable(2),C.logarithmicDepthBuffer&&o.enable(3),C.reverseDepthBuffer&&o.enable(4),C.skinning&&o.enable(5),C.morphTargets&&o.enable(6),C.morphNormals&&o.enable(7),C.morphColors&&o.enable(8),C.premultipliedAlpha&&o.enable(9),C.shadowMapEnabled&&o.enable(10),C.doubleSided&&o.enable(11),C.flipSided&&o.enable(12),C.useDepthPacking&&o.enable(13),C.dithering&&o.enable(14),C.transmission&&o.enable(15),C.sheen&&o.enable(16),C.opaque&&o.enable(17),C.pointsUvs&&o.enable(18),C.decodeVideoTexture&&o.enable(19),C.decodeVideoTextureEmissive&&o.enable(20),C.alphaToCoverage&&o.enable(21),v.push(o.mask)}function _(v){const C=m[v.type];let F;if(C){const K=Ni[C];F=F_.clone(K.uniforms)}else F=v.uniforms;return F}function M(v,C){let F;for(let K=0,q=h.length;K<q;K++){const $=h[K];if($.cacheKey===C){F=$,++F.usedTimes;break}}return F===void 0&&(F=new oS(i,C,v,r),h.push(F)),F}function w(v){if(--v.usedTimes===0){const C=h.indexOf(v);h[C]=h[h.length-1],h.pop(),v.destroy()}}function S(v){c.remove(v)}function T(){c.dispose()}return{getParameters:A,getProgramCacheKey:p,getUniforms:_,acquireProgram:M,releaseProgram:w,releaseShaderCache:S,programs:h,dispose:T}}function dS(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function fS(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function rg(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function ag(){const i=[];let e=0;const t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(u,d,f,m,g,A){let p=i[e];return p===void 0?(p={id:u.id,object:u,geometry:d,material:f,groupOrder:m,renderOrder:u.renderOrder,z:g,group:A},i[e]=p):(p.id=u.id,p.object=u,p.geometry=d,p.material=f,p.groupOrder=m,p.renderOrder=u.renderOrder,p.z=g,p.group=A),e++,p}function o(u,d,f,m,g,A){const p=a(u,d,f,m,g,A);f.transmission>0?n.push(p):f.transparent===!0?s.push(p):t.push(p)}function c(u,d,f,m,g,A){const p=a(u,d,f,m,g,A);f.transmission>0?n.unshift(p):f.transparent===!0?s.unshift(p):t.unshift(p)}function l(u,d){t.length>1&&t.sort(u||fS),n.length>1&&n.sort(d||rg),s.length>1&&s.sort(d||rg)}function h(){for(let u=e,d=i.length;u<d;u++){const f=i[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:o,unshift:c,finish:h,sort:l}}function pS(){let i=new WeakMap;function e(n,s){const r=i.get(n);let a;return r===void 0?(a=new ag,i.set(n,[a])):s>=r.length?(a=new ag,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function AS(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new H,color:new qe};break;case"SpotLight":t={position:new H,direction:new H,color:new qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new H,color:new qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new H,skyColor:new qe,groundColor:new qe};break;case"RectAreaLight":t={color:new qe,position:new H,halfWidth:new H,halfHeight:new H};break}return i[e.id]=t,t}}}function gS(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ze};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ze};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ze,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let mS=0;function bS(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function xS(i){const e=new AS,t=gS(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new H);const s=new H,r=new et,a=new et;function o(l){let h=0,u=0,d=0;for(let v=0;v<9;v++)n.probe[v].set(0,0,0);let f=0,m=0,g=0,A=0,p=0,y=0,b=0,_=0,M=0,w=0,S=0;l.sort(bS);for(let v=0,C=l.length;v<C;v++){const F=l[v],K=F.color,q=F.intensity,$=F.distance,D=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)h+=K.r*q,u+=K.g*q,d+=K.b*q;else if(F.isLightProbe){for(let O=0;O<9;O++)n.probe[O].addScaledVector(F.sh.coefficients[O],q);S++}else if(F.isDirectionalLight){const O=e.get(F);if(O.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const j=F.shadow,Q=t.get(F);Q.shadowIntensity=j.intensity,Q.shadowBias=j.bias,Q.shadowNormalBias=j.normalBias,Q.shadowRadius=j.radius,Q.shadowMapSize=j.mapSize,n.directionalShadow[f]=Q,n.directionalShadowMap[f]=D,n.directionalShadowMatrix[f]=F.shadow.matrix,y++}n.directional[f]=O,f++}else if(F.isSpotLight){const O=e.get(F);O.position.setFromMatrixPosition(F.matrixWorld),O.color.copy(K).multiplyScalar(q),O.distance=$,O.coneCos=Math.cos(F.angle),O.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),O.decay=F.decay,n.spot[g]=O;const j=F.shadow;if(F.map&&(n.spotLightMap[M]=F.map,M++,j.updateMatrices(F),F.castShadow&&w++),n.spotLightMatrix[g]=j.matrix,F.castShadow){const Q=t.get(F);Q.shadowIntensity=j.intensity,Q.shadowBias=j.bias,Q.shadowNormalBias=j.normalBias,Q.shadowRadius=j.radius,Q.shadowMapSize=j.mapSize,n.spotShadow[g]=Q,n.spotShadowMap[g]=D,_++}g++}else if(F.isRectAreaLight){const O=e.get(F);O.color.copy(K).multiplyScalar(q),O.halfWidth.set(F.width*.5,0,0),O.halfHeight.set(0,F.height*.5,0),n.rectArea[A]=O,A++}else if(F.isPointLight){const O=e.get(F);if(O.color.copy(F.color).multiplyScalar(F.intensity),O.distance=F.distance,O.decay=F.decay,F.castShadow){const j=F.shadow,Q=t.get(F);Q.shadowIntensity=j.intensity,Q.shadowBias=j.bias,Q.shadowNormalBias=j.normalBias,Q.shadowRadius=j.radius,Q.shadowMapSize=j.mapSize,Q.shadowCameraNear=j.camera.near,Q.shadowCameraFar=j.camera.far,n.pointShadow[m]=Q,n.pointShadowMap[m]=D,n.pointShadowMatrix[m]=F.shadow.matrix,b++}n.point[m]=O,m++}else if(F.isHemisphereLight){const O=e.get(F);O.skyColor.copy(F.color).multiplyScalar(q),O.groundColor.copy(F.groundColor).multiplyScalar(q),n.hemi[p]=O,p++}}A>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=we.LTC_FLOAT_1,n.rectAreaLTC2=we.LTC_FLOAT_2):(n.rectAreaLTC1=we.LTC_HALF_1,n.rectAreaLTC2=we.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const T=n.hash;(T.directionalLength!==f||T.pointLength!==m||T.spotLength!==g||T.rectAreaLength!==A||T.hemiLength!==p||T.numDirectionalShadows!==y||T.numPointShadows!==b||T.numSpotShadows!==_||T.numSpotMaps!==M||T.numLightProbes!==S)&&(n.directional.length=f,n.spot.length=g,n.rectArea.length=A,n.point.length=m,n.hemi.length=p,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=b,n.pointShadowMap.length=b,n.spotShadow.length=_,n.spotShadowMap.length=_,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=b,n.spotLightMatrix.length=_+M-w,n.spotLightMap.length=M,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=S,T.directionalLength=f,T.pointLength=m,T.spotLength=g,T.rectAreaLength=A,T.hemiLength=p,T.numDirectionalShadows=y,T.numPointShadows=b,T.numSpotShadows=_,T.numSpotMaps=M,T.numLightProbes=S,n.version=mS++)}function c(l,h){let u=0,d=0,f=0,m=0,g=0;const A=h.matrixWorldInverse;for(let p=0,y=l.length;p<y;p++){const b=l[p];if(b.isDirectionalLight){const _=n.directional[u];_.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),_.direction.sub(s),_.direction.transformDirection(A),u++}else if(b.isSpotLight){const _=n.spot[f];_.position.setFromMatrixPosition(b.matrixWorld),_.position.applyMatrix4(A),_.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),_.direction.sub(s),_.direction.transformDirection(A),f++}else if(b.isRectAreaLight){const _=n.rectArea[m];_.position.setFromMatrixPosition(b.matrixWorld),_.position.applyMatrix4(A),a.identity(),r.copy(b.matrixWorld),r.premultiply(A),a.extractRotation(r),_.halfWidth.set(b.width*.5,0,0),_.halfHeight.set(0,b.height*.5,0),_.halfWidth.applyMatrix4(a),_.halfHeight.applyMatrix4(a),m++}else if(b.isPointLight){const _=n.point[d];_.position.setFromMatrixPosition(b.matrixWorld),_.position.applyMatrix4(A),d++}else if(b.isHemisphereLight){const _=n.hemi[g];_.direction.setFromMatrixPosition(b.matrixWorld),_.direction.transformDirection(A),g++}}}return{setup:o,setupView:c,state:n}}function og(i){const e=new xS(i),t=[],n=[];function s(h){l.camera=h,t.length=0,n.length=0}function r(h){t.push(h)}function a(h){n.push(h)}function o(){e.setup(t)}function c(h){e.setupView(t,h)}const l={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:s,state:l,setupLights:o,setupLightsView:c,pushLight:r,pushShadow:a}}function ES(i){let e=new WeakMap;function t(s,r=0){const a=e.get(s);let o;return a===void 0?(o=new og(i),e.set(s,[o])):r>=a.length?(o=new og(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const _S=`void main() {+ gl_Position = vec4( position, 1.0 );+}`,yS=`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 wS(i,e,t){let n=new yu;const s=new Ze,r=new Ze,a=new _t,o=new j_({depthPacking:UE}),c=new J_,l={},h=t.maxTextureSize,u={[Qi]:Sn,[Sn]:Qi,[Si]:Si},d=new vs({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ze},radius:{value:4}},vertexShader:_S,fragmentShader:yS}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const m=new On;m.setAttribute("position",new En(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const g=new Jt(m,d),A=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=sp;let p=this.type;this.render=function(w,S,T){if(A.enabled===!1||A.autoUpdate===!1&&A.needsUpdate===!1||w.length===0)return;const v=i.getRenderTarget(),C=i.getActiveCubeFace(),F=i.getActiveMipmapLevel(),K=i.state;K.setBlending(gs),K.buffers.color.setClear(1,1,1,1),K.buffers.depth.setTest(!0),K.setScissorTest(!1);const q=p!==Oi&&this.type===Oi,$=p===Oi&&this.type!==Oi;for(let D=0,O=w.length;D<O;D++){const j=w[D],Q=j.shadow;if(Q===void 0){console.warn("THREE.WebGLShadowMap:",j,"has no shadow.");continue}if(Q.autoUpdate===!1&&Q.needsUpdate===!1)continue;s.copy(Q.mapSize);const J=Q.getFrameExtents();if(s.multiply(J),r.copy(Q.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/J.x),s.x=r.x*J.x,Q.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/J.y),s.y=r.y*J.y,Q.mapSize.y=r.y)),Q.map===null||q===!0||$===!0){const ae=this.type!==Oi?{minFilter:In,magFilter:In}:{};Q.map!==null&&Q.map.dispose(),Q.map=new js(s.x,s.y,ae),Q.map.texture.name=j.name+".shadowMap",Q.camera.updateProjectionMatrix()}i.setRenderTarget(Q.map),i.clear();const ee=Q.getViewportCount();for(let ae=0;ae<ee;ae++){const ye=Q.getViewport(ae);a.set(r.x*ye.x,r.y*ye.y,r.x*ye.z,r.y*ye.w),K.viewport(a),Q.updateMatrices(j,ae),n=Q.getFrustum(),_(S,T,Q.camera,j,this.type)}Q.isPointLightShadow!==!0&&this.type===Oi&&y(Q,T),Q.needsUpdate=!1}p=this.type,A.needsUpdate=!1,i.setRenderTarget(v,C,F)};function y(w,S){const T=e.update(g);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new js(s.x,s.y)),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(S,null,T,d,g,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(S,null,T,f,g,null)}function b(w,S,T,v){let C=null;const F=T.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(F!==void 0)C=F;else if(C=T.isPointLight===!0?c:o,i.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0||S.map&&S.alphaTest>0||S.alphaToCoverage===!0){const K=C.uuid,q=S.uuid;let $=l[K];$===void 0&&($={},l[K]=$);let D=$[q];D===void 0&&(D=C.clone(),$[q]=D,S.addEventListener("dispose",M)),C=D}if(C.visible=S.visible,C.wireframe=S.wireframe,v===Oi?C.side=S.shadowSide!==null?S.shadowSide:S.side:C.side=S.shadowSide!==null?S.shadowSide:u[S.side],C.alphaMap=S.alphaMap,C.alphaTest=S.alphaToCoverage===!0?.5:S.alphaTest,C.map=S.map,C.clipShadows=S.clipShadows,C.clippingPlanes=S.clippingPlanes,C.clipIntersection=S.clipIntersection,C.displacementMap=S.displacementMap,C.displacementScale=S.displacementScale,C.displacementBias=S.displacementBias,C.wireframeLinewidth=S.wireframeLinewidth,C.linewidth=S.linewidth,T.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const K=i.properties.get(C);K.light=T}return C}function _(w,S,T,v,C){if(w.visible===!1)return;if(w.layers.test(S.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&C===Oi)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,w.matrixWorld);const q=e.update(w),$=w.material;if(Array.isArray($)){const D=q.groups;for(let O=0,j=D.length;O<j;O++){const Q=D[O],J=$[Q.materialIndex];if(J&&J.visible){const ee=b(w,J,v,C);w.onBeforeShadow(i,w,S,T,q,ee,Q),i.renderBufferDirect(T,null,q,ee,w,Q),w.onAfterShadow(i,w,S,T,q,ee,Q)}}}else if($.visible){const D=b(w,$,v,C);w.onBeforeShadow(i,w,S,T,q,D,null),i.renderBufferDirect(T,null,q,D,w,null),w.onAfterShadow(i,w,S,T,q,D,null)}}const K=w.children;for(let q=0,$=K.length;q<$;q++)_(K[q],S,T,v,C)}function M(w){w.target.removeEventListener("dispose",M);for(const T in l){const v=l[T],C=w.target.uuid;C in v&&(v[C].dispose(),delete v[C])}}}const CS={[lh]:hh,[uh]:ph,[dh]:Ah,[Fr]:fh,[hh]:lh,[ph]:uh,[Ah]:dh,[fh]:Fr};function vS(i,e){function t(){let W=!1;const ne=new _t;let re=null;const de=new _t(0,0,0,0);return{setMask:function(Ie){re!==Ie&&!W&&(i.colorMask(Ie,Ie,Ie,Ie),re=Ie)},setLocked:function(Ie){W=Ie},setClear:function(Ie,Se,it,Ot,bn){bn===!0&&(Ie*=Ot,Se*=Ot,it*=Ot),ne.set(Ie,Se,it,Ot),de.equals(ne)===!1&&(i.clearColor(Ie,Se,it,Ot),de.copy(ne))},reset:function(){W=!1,re=null,de.set(-1,0,0,0)}}}function n(){let W=!1,ne=!1,re=null,de=null,Ie=null;return{setReversed:function(Se){if(ne!==Se){const it=e.get("EXT_clip_control");Se?it.clipControlEXT(it.LOWER_LEFT_EXT,it.ZERO_TO_ONE_EXT):it.clipControlEXT(it.LOWER_LEFT_EXT,it.NEGATIVE_ONE_TO_ONE_EXT),ne=Se;const Ot=Ie;Ie=null,this.setClear(Ot)}},getReversed:function(){return ne},setTest:function(Se){Se?xe(i.DEPTH_TEST):Pe(i.DEPTH_TEST)},setMask:function(Se){re!==Se&&!W&&(i.depthMask(Se),re=Se)},setFunc:function(Se){if(ne&&(Se=CS[Se]),de!==Se){switch(Se){case lh:i.depthFunc(i.NEVER);break;case hh:i.depthFunc(i.ALWAYS);break;case uh:i.depthFunc(i.LESS);break;case Fr:i.depthFunc(i.LEQUAL);break;case dh:i.depthFunc(i.EQUAL);break;case fh:i.depthFunc(i.GEQUAL);break;case ph:i.depthFunc(i.GREATER);break;case Ah:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}de=Se}},setLocked:function(Se){W=Se},setClear:function(Se){Ie!==Se&&(ne&&(Se=1-Se),i.clearDepth(Se),Ie=Se)},reset:function(){W=!1,re=null,de=null,Ie=null,ne=!1}}}function s(){let W=!1,ne=null,re=null,de=null,Ie=null,Se=null,it=null,Ot=null,bn=null;return{setTest:function(yt){W||(yt?xe(i.STENCIL_TEST):Pe(i.STENCIL_TEST))},setMask:function(yt){ne!==yt&&!W&&(i.stencilMask(yt),ne=yt)},setFunc:function(yt,jn,vi){(re!==yt||de!==jn||Ie!==vi)&&(i.stencilFunc(yt,jn,vi),re=yt,de=jn,Ie=vi)},setOp:function(yt,jn,vi){(Se!==yt||it!==jn||Ot!==vi)&&(i.stencilOp(yt,jn,vi),Se=yt,it=jn,Ot=vi)},setLocked:function(yt){W=yt},setClear:function(yt){bn!==yt&&(i.clearStencil(yt),bn=yt)},reset:function(){W=!1,ne=null,re=null,de=null,Ie=null,Se=null,it=null,Ot=null,bn=null}}}const r=new t,a=new n,o=new s,c=new WeakMap,l=new WeakMap;let h={},u={},d=new WeakMap,f=[],m=null,g=!1,A=null,p=null,y=null,b=null,_=null,M=null,w=null,S=new qe(0,0,0),T=0,v=!1,C=null,F=null,K=null,q=null,$=null;const D=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let O=!1,j=0;const Q=i.getParameter(i.VERSION);Q.indexOf("WebGL")!==-1?(j=parseFloat(/^WebGL (\d)/.exec(Q)[1]),O=j>=1):Q.indexOf("OpenGL ES")!==-1&&(j=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),O=j>=2);let J=null,ee={};const ae=i.getParameter(i.SCISSOR_BOX),ye=i.getParameter(i.VIEWPORT),Me=new _t().fromArray(ae),se=new _t().fromArray(ye);function me(W,ne,re,de){const Ie=new Uint8Array(4),Se=i.createTexture();i.bindTexture(W,Se),i.texParameteri(W,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(W,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let it=0;it<re;it++)W===i.TEXTURE_3D||W===i.TEXTURE_2D_ARRAY?i.texImage3D(ne,0,i.RGBA,1,1,de,0,i.RGBA,i.UNSIGNED_BYTE,Ie):i.texImage2D(ne+it,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,Ie);return Se}const be={};be[i.TEXTURE_2D]=me(i.TEXTURE_2D,i.TEXTURE_2D,1),be[i.TEXTURE_CUBE_MAP]=me(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),be[i.TEXTURE_2D_ARRAY]=me(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),be[i.TEXTURE_3D]=me(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),xe(i.DEPTH_TEST),a.setFunc(Fr),dt(!1),pt(ip),xe(i.CULL_FACE),G(gs);function xe(W){h[W]!==!0&&(i.enable(W),h[W]=!0)}function Pe(W){h[W]!==!1&&(i.disable(W),h[W]=!1)}function $e(W,ne){return u[W]!==ne?(i.bindFramebuffer(W,ne),u[W]=ne,W===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=ne),W===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=ne),!0):!1}function Qe(W,ne){let re=f,de=!1;if(W){re=d.get(ne),re===void 0&&(re=[],d.set(ne,re));const Ie=W.textures;if(re.length!==Ie.length||re[0]!==i.COLOR_ATTACHMENT0){for(let Se=0,it=Ie.length;Se<it;Se++)re[Se]=i.COLOR_ATTACHMENT0+Se;re.length=Ie.length,de=!0}}else re[0]!==i.BACK&&(re[0]=i.BACK,de=!0);de&&i.drawBuffers(re)}function St(W){return m!==W?(i.useProgram(W),m=W,!0):!1}const ut={[qs]:i.FUNC_ADD,[lE]:i.FUNC_SUBTRACT,[hE]:i.FUNC_REVERSE_SUBTRACT};ut[uE]=i.MIN,ut[dE]=i.MAX;const Je={[fE]:i.ZERO,[pE]:i.ONE,[AE]:i.SRC_COLOR,[oh]:i.SRC_ALPHA,[_E]:i.SRC_ALPHA_SATURATE,[xE]:i.DST_COLOR,[mE]:i.DST_ALPHA,[gE]:i.ONE_MINUS_SRC_COLOR,[ch]:i.ONE_MINUS_SRC_ALPHA,[EE]:i.ONE_MINUS_DST_COLOR,[bE]:i.ONE_MINUS_DST_ALPHA,[yE]:i.CONSTANT_COLOR,[wE]:i.ONE_MINUS_CONSTANT_COLOR,[CE]:i.CONSTANT_ALPHA,[vE]:i.ONE_MINUS_CONSTANT_ALPHA};function G(W,ne,re,de,Ie,Se,it,Ot,bn,yt){if(W===gs){g===!0&&(Pe(i.BLEND),g=!1);return}if(g===!1&&(xe(i.BLEND),g=!0),W!==cE){if(W!==A||yt!==v){if((p!==qs||_!==qs)&&(i.blendEquation(i.FUNC_ADD),p=qs,_=qs),yt)switch(W){case Nr:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case rp:i.blendFunc(i.ONE,i.ONE);break;case ap:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case op:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",W);break}else switch(W){case Nr:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case rp:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case ap:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case op:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",W);break}y=null,b=null,M=null,w=null,S.set(0,0,0),T=0,A=W,v=yt}return}Ie=Ie||ne,Se=Se||re,it=it||de,(ne!==p||Ie!==_)&&(i.blendEquationSeparate(ut[ne],ut[Ie]),p=ne,_=Ie),(re!==y||de!==b||Se!==M||it!==w)&&(i.blendFuncSeparate(Je[re],Je[de],Je[Se],Je[it]),y=re,b=de,M=Se,w=it),(Ot.equals(S)===!1||bn!==T)&&(i.blendColor(Ot.r,Ot.g,Ot.b,bn),S.copy(Ot),T=bn),A=W,v=!1}function mn(W,ne){W.side===Si?Pe(i.CULL_FACE):xe(i.CULL_FACE);let re=W.side===Sn;ne&&(re=!re),dt(re),W.blending===Nr&&W.transparent===!1?G(gs):G(W.blending,W.blendEquation,W.blendSrc,W.blendDst,W.blendEquationAlpha,W.blendSrcAlpha,W.blendDstAlpha,W.blendColor,W.blendAlpha,W.premultipliedAlpha),a.setFunc(W.depthFunc),a.setTest(W.depthTest),a.setMask(W.depthWrite),r.setMask(W.colorWrite);const de=W.stencilWrite;o.setTest(de),de&&(o.setMask(W.stencilWriteMask),o.setFunc(W.stencilFunc,W.stencilRef,W.stencilFuncMask),o.setOp(W.stencilFail,W.stencilZFail,W.stencilZPass)),Rt(W.polygonOffset,W.polygonOffsetFactor,W.polygonOffsetUnits),W.alphaToCoverage===!0?xe(i.SAMPLE_ALPHA_TO_COVERAGE):Pe(i.SAMPLE_ALPHA_TO_COVERAGE)}function dt(W){C!==W&&(W?i.frontFace(i.CW):i.frontFace(i.CCW),C=W)}function pt(W){W!==rE?(xe(i.CULL_FACE),W!==F&&(W===ip?i.cullFace(i.BACK):W===aE?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Pe(i.CULL_FACE),F=W}function ze(W){W!==K&&(O&&i.lineWidth(W),K=W)}function Rt(W,ne,re){W?(xe(i.POLYGON_OFFSET_FILL),(q!==ne||$!==re)&&(i.polygonOffset(ne,re),q=ne,$=re)):Pe(i.POLYGON_OFFSET_FILL)}function Ge(W){W?xe(i.SCISSOR_TEST):Pe(i.SCISSOR_TEST)}function L(W){W===void 0&&(W=i.TEXTURE0+D-1),J!==W&&(i.activeTexture(W),J=W)}function I(W,ne,re){re===void 0&&(J===null?re=i.TEXTURE0+D-1:re=J);let de=ee[re];de===void 0&&(de={type:void 0,texture:void 0},ee[re]=de),(de.type!==W||de.texture!==ne)&&(J!==re&&(i.activeTexture(re),J=re),i.bindTexture(W,ne||be[W]),de.type=W,de.texture=ne)}function Z(){const W=ee[J];W!==void 0&&W.type!==void 0&&(i.bindTexture(W.type,null),W.type=void 0,W.texture=void 0)}function le(){try{i.compressedTexImage2D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ae(){try{i.compressedTexImage3D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function oe(){try{i.texSubImage2D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ue(){try{i.texSubImage3D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ce(){try{i.compressedTexSubImage2D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ve(){try{i.compressedTexSubImage3D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function je(){try{i.texStorage2D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ee(){try{i.texStorage3D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ne(){try{i.texImage2D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function ke(){try{i.texImage3D(...arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Oe(W){Me.equals(W)===!1&&(i.scissor(W.x,W.y,W.z,W.w),Me.copy(W))}function Te(W){se.equals(W)===!1&&(i.viewport(W.x,W.y,W.z,W.w),se.copy(W))}function tt(W,ne){let re=l.get(ne);re===void 0&&(re=new WeakMap,l.set(ne,re));let de=re.get(W);de===void 0&&(de=i.getUniformBlockIndex(ne,W.name),re.set(W,de))}function We(W,ne){const de=l.get(ne).get(W);c.get(ne)!==de&&(i.uniformBlockBinding(ne,de,W.__bindingPointIndex),c.set(ne,de))}function nt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),h={},J=null,ee={},u={},d=new WeakMap,f=[],m=null,g=!1,A=null,p=null,y=null,b=null,_=null,M=null,w=null,S=new qe(0,0,0),T=0,v=!1,C=null,F=null,K=null,q=null,$=null,Me.set(0,0,i.canvas.width,i.canvas.height),se.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:xe,disable:Pe,bindFramebuffer:$e,drawBuffers:Qe,useProgram:St,setBlending:G,setMaterial:mn,setFlipSided:dt,setCullFace:pt,setLineWidth:ze,setPolygonOffset:Rt,setScissorTest:Ge,activeTexture:L,bindTexture:I,unbindTexture:Z,compressedTexImage2D:le,compressedTexImage3D:Ae,texImage2D:Ne,texImage3D:ke,updateUBOMapping:tt,uniformBlockBinding:We,texStorage2D:je,texStorage3D:Ee,texSubImage2D:oe,texSubImage3D:Ue,compressedTexSubImage2D:Ce,compressedTexSubImage3D:Ve,scissor:Oe,viewport:Te,reset:nt}}function SS(i,e,t,n,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ze,h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(L,I){return f?new OffscreenCanvas(L,I):eo("canvas")}function g(L,I,Z){let le=1;const Ae=Ge(L);if((Ae.width>Z||Ae.height>Z)&&(le=Z/Math.max(Ae.width,Ae.height)),le<1)if(typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&L instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&L instanceof ImageBitmap||typeof VideoFrame<"u"&&L instanceof VideoFrame){const oe=Math.floor(le*Ae.width),Ue=Math.floor(le*Ae.height);u===void 0&&(u=m(oe,Ue));const Ce=I?m(oe,Ue):u;return Ce.width=oe,Ce.height=Ue,Ce.getContext("2d").drawImage(L,0,0,oe,Ue),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Ae.width+"x"+Ae.height+") to ("+oe+"x"+Ue+")."),Ce}else return"data"in L&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Ae.width+"x"+Ae.height+")."),L;return L}function A(L){return L.generateMipmaps}function p(L){i.generateMipmap(L)}function y(L){return L.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:L.isWebGL3DRenderTarget?i.TEXTURE_3D:L.isWebGLArrayRenderTarget||L.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function b(L,I,Z,le,Ae=!1){if(L!==null){if(i[L]!==void 0)return i[L];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+L+"'")}let oe=I;if(I===i.RED&&(Z===i.FLOAT&&(oe=i.R32F),Z===i.HALF_FLOAT&&(oe=i.R16F),Z===i.UNSIGNED_BYTE&&(oe=i.R8)),I===i.RED_INTEGER&&(Z===i.UNSIGNED_BYTE&&(oe=i.R8UI),Z===i.UNSIGNED_SHORT&&(oe=i.R16UI),Z===i.UNSIGNED_INT&&(oe=i.R32UI),Z===i.BYTE&&(oe=i.R8I),Z===i.SHORT&&(oe=i.R16I),Z===i.INT&&(oe=i.R32I)),I===i.RG&&(Z===i.FLOAT&&(oe=i.RG32F),Z===i.HALF_FLOAT&&(oe=i.RG16F),Z===i.UNSIGNED_BYTE&&(oe=i.RG8)),I===i.RG_INTEGER&&(Z===i.UNSIGNED_BYTE&&(oe=i.RG8UI),Z===i.UNSIGNED_SHORT&&(oe=i.RG16UI),Z===i.UNSIGNED_INT&&(oe=i.RG32UI),Z===i.BYTE&&(oe=i.RG8I),Z===i.SHORT&&(oe=i.RG16I),Z===i.INT&&(oe=i.RG32I)),I===i.RGB_INTEGER&&(Z===i.UNSIGNED_BYTE&&(oe=i.RGB8UI),Z===i.UNSIGNED_SHORT&&(oe=i.RGB16UI),Z===i.UNSIGNED_INT&&(oe=i.RGB32UI),Z===i.BYTE&&(oe=i.RGB8I),Z===i.SHORT&&(oe=i.RGB16I),Z===i.INT&&(oe=i.RGB32I)),I===i.RGBA_INTEGER&&(Z===i.UNSIGNED_BYTE&&(oe=i.RGBA8UI),Z===i.UNSIGNED_SHORT&&(oe=i.RGBA16UI),Z===i.UNSIGNED_INT&&(oe=i.RGBA32UI),Z===i.BYTE&&(oe=i.RGBA8I),Z===i.SHORT&&(oe=i.RGBA16I),Z===i.INT&&(oe=i.RGBA32I)),I===i.RGB&&Z===i.UNSIGNED_INT_5_9_9_9_REV&&(oe=i.RGB9_E5),I===i.RGBA){const Ue=Ae?Ac:At.getTransfer(le);Z===i.FLOAT&&(oe=i.RGBA32F),Z===i.HALF_FLOAT&&(oe=i.RGBA16F),Z===i.UNSIGNED_BYTE&&(oe=Ue===Mt?i.SRGB8_ALPHA8:i.RGBA8),Z===i.UNSIGNED_SHORT_4_4_4_4&&(oe=i.RGBA4),Z===i.UNSIGNED_SHORT_5_5_5_1&&(oe=i.RGB5_A1)}return(oe===i.R16F||oe===i.R32F||oe===i.RG16F||oe===i.RG32F||oe===i.RGBA16F||oe===i.RGBA32F)&&e.get("EXT_color_buffer_float"),oe}function _(L,I){let Z;return L?I===null||I===Xs||I===Ha?Z=i.DEPTH24_STENCIL8:I===nn?Z=i.DEPTH32F_STENCIL8:I===Ga&&(Z=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):I===null||I===Xs||I===Ha?Z=i.DEPTH_COMPONENT24:I===nn?Z=i.DEPTH_COMPONENT32F:I===Ga&&(Z=i.DEPTH_COMPONENT16),Z}function M(L,I){return A(L)===!0||L.isFramebufferTexture&&L.minFilter!==In&&L.minFilter!==zt?Math.log2(Math.max(I.width,I.height))+1:L.mipmaps!==void 0&&L.mipmaps.length>0?L.mipmaps.length:L.isCompressedTexture&&Array.isArray(L.image)?I.mipmaps.length:1}function w(L){const I=L.target;I.removeEventListener("dispose",w),T(I),I.isVideoTexture&&h.delete(I)}function S(L){const I=L.target;I.removeEventListener("dispose",S),C(I)}function T(L){const I=n.get(L);if(I.__webglInit===void 0)return;const Z=L.source,le=d.get(Z);if(le){const Ae=le[I.__cacheKey];Ae.usedTimes--,Ae.usedTimes===0&&v(L),Object.keys(le).length===0&&d.delete(Z)}n.remove(L)}function v(L){const I=n.get(L);i.deleteTexture(I.__webglTexture);const Z=L.source,le=d.get(Z);delete le[I.__cacheKey],a.memory.textures--}function C(L){const I=n.get(L);if(L.depthTexture&&(L.depthTexture.dispose(),n.remove(L.depthTexture)),L.isWebGLCubeRenderTarget)for(let le=0;le<6;le++){if(Array.isArray(I.__webglFramebuffer[le]))for(let Ae=0;Ae<I.__webglFramebuffer[le].length;Ae++)i.deleteFramebuffer(I.__webglFramebuffer[le][Ae]);else i.deleteFramebuffer(I.__webglFramebuffer[le]);I.__webglDepthbuffer&&i.deleteRenderbuffer(I.__webglDepthbuffer[le])}else{if(Array.isArray(I.__webglFramebuffer))for(let le=0;le<I.__webglFramebuffer.length;le++)i.deleteFramebuffer(I.__webglFramebuffer[le]);else i.deleteFramebuffer(I.__webglFramebuffer);if(I.__webglDepthbuffer&&i.deleteRenderbuffer(I.__webglDepthbuffer),I.__webglMultisampledFramebuffer&&i.deleteFramebuffer(I.__webglMultisampledFramebuffer),I.__webglColorRenderbuffer)for(let le=0;le<I.__webglColorRenderbuffer.length;le++)I.__webglColorRenderbuffer[le]&&i.deleteRenderbuffer(I.__webglColorRenderbuffer[le]);I.__webglDepthRenderbuffer&&i.deleteRenderbuffer(I.__webglDepthRenderbuffer)}const Z=L.textures;for(let le=0,Ae=Z.length;le<Ae;le++){const oe=n.get(Z[le]);oe.__webglTexture&&(i.deleteTexture(oe.__webglTexture),a.memory.textures--),n.remove(Z[le])}n.remove(L)}let F=0;function K(){F=0}function q(){const L=F;return L>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+L+" texture units while this GPU supports only "+s.maxTextures),F+=1,L}function $(L){const I=[];return I.push(L.wrapS),I.push(L.wrapT),I.push(L.wrapR||0),I.push(L.magFilter),I.push(L.minFilter),I.push(L.anisotropy),I.push(L.internalFormat),I.push(L.format),I.push(L.type),I.push(L.generateMipmaps),I.push(L.premultiplyAlpha),I.push(L.flipY),I.push(L.unpackAlignment),I.push(L.colorSpace),I.join()}function D(L,I){const Z=n.get(L);if(L.isVideoTexture&&ze(L),L.isRenderTargetTexture===!1&&L.version>0&&Z.__version!==L.version){const le=L.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{se(Z,L,I);return}}t.bindTexture(i.TEXTURE_2D,Z.__webglTexture,i.TEXTURE0+I)}function O(L,I){const Z=n.get(L);if(L.version>0&&Z.__version!==L.version){se(Z,L,I);return}t.bindTexture(i.TEXTURE_2D_ARRAY,Z.__webglTexture,i.TEXTURE0+I)}function j(L,I){const Z=n.get(L);if(L.version>0&&Z.__version!==L.version){se(Z,L,I);return}t.bindTexture(i.TEXTURE_3D,Z.__webglTexture,i.TEXTURE0+I)}function Q(L,I){const Z=n.get(L);if(L.version>0&&Z.__version!==L.version){me(Z,L,I);return}t.bindTexture(i.TEXTURE_CUBE_MAP,Z.__webglTexture,i.TEXTURE0+I)}const J={[Lr]:i.REPEAT,[ai]:i.CLAMP_TO_EDGE,[sc]:i.MIRRORED_REPEAT},ee={[In]:i.NEAREST,[dp]:i.NEAREST_MIPMAP_NEAREST,[Qa]:i.NEAREST_MIPMAP_LINEAR,[zt]:i.LINEAR,[rc]:i.LINEAR_MIPMAP_NEAREST,[Jn]:i.LINEAR_MIPMAP_LINEAR},ae={[QE]:i.NEVER,[qE]:i.ALWAYS,[GE]:i.LESS,[Cp]:i.LEQUAL,[HE]:i.EQUAL,[WE]:i.GEQUAL,[zE]:i.GREATER,[VE]:i.NOTEQUAL};function ye(L,I){if(I.type===nn&&e.has("OES_texture_float_linear")===!1&&(I.magFilter===zt||I.magFilter===rc||I.magFilter===Qa||I.magFilter===Jn||I.minFilter===zt||I.minFilter===rc||I.minFilter===Qa||I.minFilter===Jn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(L,i.TEXTURE_WRAP_S,J[I.wrapS]),i.texParameteri(L,i.TEXTURE_WRAP_T,J[I.wrapT]),(L===i.TEXTURE_3D||L===i.TEXTURE_2D_ARRAY)&&i.texParameteri(L,i.TEXTURE_WRAP_R,J[I.wrapR]),i.texParameteri(L,i.TEXTURE_MAG_FILTER,ee[I.magFilter]),i.texParameteri(L,i.TEXTURE_MIN_FILTER,ee[I.minFilter]),I.compareFunction&&(i.texParameteri(L,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(L,i.TEXTURE_COMPARE_FUNC,ae[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(I.magFilter===In||I.minFilter!==Qa&&I.minFilter!==Jn||I.type===nn&&e.has("OES_texture_float_linear")===!1)return;if(I.anisotropy>1||n.get(I).__currentAnisotropy){const Z=e.get("EXT_texture_filter_anisotropic");i.texParameterf(L,Z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,s.getMaxAnisotropy())),n.get(I).__currentAnisotropy=I.anisotropy}}}function Me(L,I){let Z=!1;L.__webglInit===void 0&&(L.__webglInit=!0,I.addEventListener("dispose",w));const le=I.source;let Ae=d.get(le);Ae===void 0&&(Ae={},d.set(le,Ae));const oe=$(I);if(oe!==L.__cacheKey){Ae[oe]===void 0&&(Ae[oe]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,Z=!0),Ae[oe].usedTimes++;const Ue=Ae[L.__cacheKey];Ue!==void 0&&(Ae[L.__cacheKey].usedTimes--,Ue.usedTimes===0&&v(I)),L.__cacheKey=oe,L.__webglTexture=Ae[oe].texture}return Z}function se(L,I,Z){let le=i.TEXTURE_2D;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(le=i.TEXTURE_2D_ARRAY),I.isData3DTexture&&(le=i.TEXTURE_3D);const Ae=Me(L,I),oe=I.source;t.bindTexture(le,L.__webglTexture,i.TEXTURE0+Z);const Ue=n.get(oe);if(oe.version!==Ue.__version||Ae===!0){t.activeTexture(i.TEXTURE0+Z);const Ce=At.getPrimaries(At.workingColorSpace),Ve=I.colorSpace===oi?null:At.getPrimaries(I.colorSpace),je=I.colorSpace===oi||Ce===Ve?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,I.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,I.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,je);let Ee=g(I.image,!1,s.maxTextureSize);Ee=Rt(I,Ee);const Ne=r.convert(I.format,I.colorSpace),ke=r.convert(I.type);let Oe=b(I.internalFormat,Ne,ke,I.colorSpace,I.isVideoTexture);ye(le,I);let Te;const tt=I.mipmaps,We=I.isVideoTexture!==!0,nt=Ue.__version===void 0||Ae===!0,W=oe.dataReady,ne=M(I,Ee);if(I.isDepthTexture)Oe=_(I.format===Va,I.type),nt&&(We?t.texStorage2D(i.TEXTURE_2D,1,Oe,Ee.width,Ee.height):t.texImage2D(i.TEXTURE_2D,0,Oe,Ee.width,Ee.height,0,Ne,ke,null));else if(I.isDataTexture)if(tt.length>0){We&&nt&&t.texStorage2D(i.TEXTURE_2D,ne,Oe,tt[0].width,tt[0].height);for(let re=0,de=tt.length;re<de;re++)Te=tt[re],We?W&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,Te.width,Te.height,Ne,ke,Te.data):t.texImage2D(i.TEXTURE_2D,re,Oe,Te.width,Te.height,0,Ne,ke,Te.data);I.generateMipmaps=!1}else We?(nt&&t.texStorage2D(i.TEXTURE_2D,ne,Oe,Ee.width,Ee.height),W&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Ee.width,Ee.height,Ne,ke,Ee.data)):t.texImage2D(i.TEXTURE_2D,0,Oe,Ee.width,Ee.height,0,Ne,ke,Ee.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){We&&nt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ne,Oe,tt[0].width,tt[0].height,Ee.depth);for(let re=0,de=tt.length;re<de;re++)if(Te=tt[re],I.format!==sn)if(Ne!==null)if(We){if(W)if(I.layerUpdates.size>0){const Ie=FA(Te.width,Te.height,I.format,I.type);for(const Se of I.layerUpdates){const it=Te.data.subarray(Se*Ie/Te.data.BYTES_PER_ELEMENT,(Se+1)*Ie/Te.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,Se,Te.width,Te.height,1,Ne,it)}I.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,0,Te.width,Te.height,Ee.depth,Ne,Te.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,re,Oe,Te.width,Te.height,Ee.depth,0,Te.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else We?W&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,0,Te.width,Te.height,Ee.depth,Ne,ke,Te.data):t.texImage3D(i.TEXTURE_2D_ARRAY,re,Oe,Te.width,Te.height,Ee.depth,0,Ne,ke,Te.data)}else{We&&nt&&t.texStorage2D(i.TEXTURE_2D,ne,Oe,tt[0].width,tt[0].height);for(let re=0,de=tt.length;re<de;re++)Te=tt[re],I.format!==sn?Ne!==null?We?W&&t.compressedTexSubImage2D(i.TEXTURE_2D,re,0,0,Te.width,Te.height,Ne,Te.data):t.compressedTexImage2D(i.TEXTURE_2D,re,Oe,Te.width,Te.height,0,Te.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):We?W&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,Te.width,Te.height,Ne,ke,Te.data):t.texImage2D(i.TEXTURE_2D,re,Oe,Te.width,Te.height,0,Ne,ke,Te.data)}else if(I.isDataArrayTexture)if(We){if(nt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ne,Oe,Ee.width,Ee.height,Ee.depth),W)if(I.layerUpdates.size>0){const re=FA(Ee.width,Ee.height,I.format,I.type);for(const de of I.layerUpdates){const Ie=Ee.data.subarray(de*re/Ee.data.BYTES_PER_ELEMENT,(de+1)*re/Ee.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,de,Ee.width,Ee.height,1,Ne,ke,Ie)}I.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Ee.width,Ee.height,Ee.depth,Ne,ke,Ee.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Oe,Ee.width,Ee.height,Ee.depth,0,Ne,ke,Ee.data);else if(I.isData3DTexture)We?(nt&&t.texStorage3D(i.TEXTURE_3D,ne,Oe,Ee.width,Ee.height,Ee.depth),W&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Ee.width,Ee.height,Ee.depth,Ne,ke,Ee.data)):t.texImage3D(i.TEXTURE_3D,0,Oe,Ee.width,Ee.height,Ee.depth,0,Ne,ke,Ee.data);else if(I.isFramebufferTexture){if(nt)if(We)t.texStorage2D(i.TEXTURE_2D,ne,Oe,Ee.width,Ee.height);else{let re=Ee.width,de=Ee.height;for(let Ie=0;Ie<ne;Ie++)t.texImage2D(i.TEXTURE_2D,Ie,Oe,re,de,0,Ne,ke,null),re>>=1,de>>=1}}else if(tt.length>0){if(We&&nt){const re=Ge(tt[0]);t.texStorage2D(i.TEXTURE_2D,ne,Oe,re.width,re.height)}for(let re=0,de=tt.length;re<de;re++)Te=tt[re],We?W&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,Ne,ke,Te):t.texImage2D(i.TEXTURE_2D,re,Oe,Ne,ke,Te);I.generateMipmaps=!1}else if(We){if(nt){const re=Ge(Ee);t.texStorage2D(i.TEXTURE_2D,ne,Oe,re.width,re.height)}W&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Ne,ke,Ee)}else t.texImage2D(i.TEXTURE_2D,0,Oe,Ne,ke,Ee);A(I)&&p(le),Ue.__version=oe.version,I.onUpdate&&I.onUpdate(I)}L.__version=I.version}function me(L,I,Z){if(I.image.length!==6)return;const le=Me(L,I),Ae=I.source;t.bindTexture(i.TEXTURE_CUBE_MAP,L.__webglTexture,i.TEXTURE0+Z);const oe=n.get(Ae);if(Ae.version!==oe.__version||le===!0){t.activeTexture(i.TEXTURE0+Z);const Ue=At.getPrimaries(At.workingColorSpace),Ce=I.colorSpace===oi?null:At.getPrimaries(I.colorSpace),Ve=I.colorSpace===oi||Ue===Ce?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,I.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,I.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ve);const je=I.isCompressedTexture||I.image[0].isCompressedTexture,Ee=I.image[0]&&I.image[0].isDataTexture,Ne=[];for(let de=0;de<6;de++)!je&&!Ee?Ne[de]=g(I.image[de],!0,s.maxCubemapSize):Ne[de]=Ee?I.image[de].image:I.image[de],Ne[de]=Rt(I,Ne[de]);const ke=Ne[0],Oe=r.convert(I.format,I.colorSpace),Te=r.convert(I.type),tt=b(I.internalFormat,Oe,Te,I.colorSpace),We=I.isVideoTexture!==!0,nt=oe.__version===void 0||le===!0,W=Ae.dataReady;let ne=M(I,ke);ye(i.TEXTURE_CUBE_MAP,I);let re;if(je){We&&nt&&t.texStorage2D(i.TEXTURE_CUBE_MAP,ne,tt,ke.width,ke.height);for(let de=0;de<6;de++){re=Ne[de].mipmaps;for(let Ie=0;Ie<re.length;Ie++){const Se=re[Ie];I.format!==sn?Oe!==null?We?W&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie,0,0,Se.width,Se.height,Oe,Se.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie,tt,Se.width,Se.height,0,Se.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):We?W&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie,0,0,Se.width,Se.height,Oe,Te,Se.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie,tt,Se.width,Se.height,0,Oe,Te,Se.data)}}}else{if(re=I.mipmaps,We&&nt){re.length>0&&ne++;const de=Ge(Ne[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ne,tt,de.width,de.height)}for(let de=0;de<6;de++)if(Ee){We?W&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,0,0,Ne[de].width,Ne[de].height,Oe,Te,Ne[de].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,tt,Ne[de].width,Ne[de].height,0,Oe,Te,Ne[de].data);for(let Ie=0;Ie<re.length;Ie++){const it=re[Ie].image[de].image;We?W&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie+1,0,0,it.width,it.height,Oe,Te,it.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie+1,tt,it.width,it.height,0,Oe,Te,it.data)}}else{We?W&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,0,0,Oe,Te,Ne[de]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,0,tt,Oe,Te,Ne[de]);for(let Ie=0;Ie<re.length;Ie++){const Se=re[Ie];We?W&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie+1,0,0,Oe,Te,Se.image[de]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+de,Ie+1,tt,Oe,Te,Se.image[de])}}}A(I)&&p(i.TEXTURE_CUBE_MAP),oe.__version=Ae.version,I.onUpdate&&I.onUpdate(I)}L.__version=I.version}function be(L,I,Z,le,Ae,oe){const Ue=r.convert(Z.format,Z.colorSpace),Ce=r.convert(Z.type),Ve=b(Z.internalFormat,Ue,Ce,Z.colorSpace),je=n.get(I),Ee=n.get(Z);if(Ee.__renderTarget=I,!je.__hasExternalTextures){const Ne=Math.max(1,I.width>>oe),ke=Math.max(1,I.height>>oe);Ae===i.TEXTURE_3D||Ae===i.TEXTURE_2D_ARRAY?t.texImage3D(Ae,oe,Ve,Ne,ke,I.depth,0,Ue,Ce,null):t.texImage2D(Ae,oe,Ve,Ne,ke,0,Ue,Ce,null)}t.bindFramebuffer(i.FRAMEBUFFER,L),pt(I)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,le,Ae,Ee.__webglTexture,0,dt(I)):(Ae===i.TEXTURE_2D||Ae>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Ae<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,le,Ae,Ee.__webglTexture,oe),t.bindFramebuffer(i.FRAMEBUFFER,null)}function xe(L,I,Z){if(i.bindRenderbuffer(i.RENDERBUFFER,L),I.depthBuffer){const le=I.depthTexture,Ae=le&&le.isDepthTexture?le.type:null,oe=_(I.stencilBuffer,Ae),Ue=I.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ce=dt(I);pt(I)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Ce,oe,I.width,I.height):Z?i.renderbufferStorageMultisample(i.RENDERBUFFER,Ce,oe,I.width,I.height):i.renderbufferStorage(i.RENDERBUFFER,oe,I.width,I.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ue,i.RENDERBUFFER,L)}else{const le=I.textures;for(let Ae=0;Ae<le.length;Ae++){const oe=le[Ae],Ue=r.convert(oe.format,oe.colorSpace),Ce=r.convert(oe.type),Ve=b(oe.internalFormat,Ue,Ce,oe.colorSpace),je=dt(I);Z&&pt(I)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,je,Ve,I.width,I.height):pt(I)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,je,Ve,I.width,I.height):i.renderbufferStorage(i.RENDERBUFFER,Ve,I.width,I.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Pe(L,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,L),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const le=n.get(I.depthTexture);le.__renderTarget=I,(!le.__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),D(I.depthTexture,0);const Ae=le.__webglTexture,oe=dt(I);if(I.depthTexture.format===za)pt(I)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Ae,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Ae,0);else if(I.depthTexture.format===Va)pt(I)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Ae,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Ae,0);else throw new Error("Unknown depthTexture format")}function $e(L){const I=n.get(L),Z=L.isWebGLCubeRenderTarget===!0;if(I.__boundDepthTexture!==L.depthTexture){const le=L.depthTexture;if(I.__depthDisposeCallback&&I.__depthDisposeCallback(),le){const Ae=()=>{delete I.__boundDepthTexture,delete I.__depthDisposeCallback,le.removeEventListener("dispose",Ae)};le.addEventListener("dispose",Ae),I.__depthDisposeCallback=Ae}I.__boundDepthTexture=le}if(L.depthTexture&&!I.__autoAllocateDepthBuffer){if(Z)throw new Error("target.depthTexture not supported in Cube render targets");const le=L.texture.mipmaps;le&&le.length>0?Pe(I.__webglFramebuffer[0],L):Pe(I.__webglFramebuffer,L)}else if(Z){I.__webglDepthbuffer=[];for(let le=0;le<6;le++)if(t.bindFramebuffer(i.FRAMEBUFFER,I.__webglFramebuffer[le]),I.__webglDepthbuffer[le]===void 0)I.__webglDepthbuffer[le]=i.createRenderbuffer(),xe(I.__webglDepthbuffer[le],L,!1);else{const Ae=L.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=I.__webglDepthbuffer[le];i.bindRenderbuffer(i.RENDERBUFFER,oe),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ae,i.RENDERBUFFER,oe)}}else{const le=L.texture.mipmaps;if(le&&le.length>0?t.bindFramebuffer(i.FRAMEBUFFER,I.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,I.__webglFramebuffer),I.__webglDepthbuffer===void 0)I.__webglDepthbuffer=i.createRenderbuffer(),xe(I.__webglDepthbuffer,L,!1);else{const Ae=L.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=I.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,oe),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ae,i.RENDERBUFFER,oe)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Qe(L,I,Z){const le=n.get(L);I!==void 0&&be(le.__webglFramebuffer,L,L.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),Z!==void 0&&$e(L)}function St(L){const I=L.texture,Z=n.get(L),le=n.get(I);L.addEventListener("dispose",S);const Ae=L.textures,oe=L.isWebGLCubeRenderTarget===!0,Ue=Ae.length>1;if(Ue||(le.__webglTexture===void 0&&(le.__webglTexture=i.createTexture()),le.__version=I.version,a.memory.textures++),oe){Z.__webglFramebuffer=[];for(let Ce=0;Ce<6;Ce++)if(I.mipmaps&&I.mipmaps.length>0){Z.__webglFramebuffer[Ce]=[];for(let Ve=0;Ve<I.mipmaps.length;Ve++)Z.__webglFramebuffer[Ce][Ve]=i.createFramebuffer()}else Z.__webglFramebuffer[Ce]=i.createFramebuffer()}else{if(I.mipmaps&&I.mipmaps.length>0){Z.__webglFramebuffer=[];for(let Ce=0;Ce<I.mipmaps.length;Ce++)Z.__webglFramebuffer[Ce]=i.createFramebuffer()}else Z.__webglFramebuffer=i.createFramebuffer();if(Ue)for(let Ce=0,Ve=Ae.length;Ce<Ve;Ce++){const je=n.get(Ae[Ce]);je.__webglTexture===void 0&&(je.__webglTexture=i.createTexture(),a.memory.textures++)}if(L.samples>0&&pt(L)===!1){Z.__webglMultisampledFramebuffer=i.createFramebuffer(),Z.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,Z.__webglMultisampledFramebuffer);for(let Ce=0;Ce<Ae.length;Ce++){const Ve=Ae[Ce];Z.__webglColorRenderbuffer[Ce]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,Z.__webglColorRenderbuffer[Ce]);const je=r.convert(Ve.format,Ve.colorSpace),Ee=r.convert(Ve.type),Ne=b(Ve.internalFormat,je,Ee,Ve.colorSpace,L.isXRRenderTarget===!0),ke=dt(L);i.renderbufferStorageMultisample(i.RENDERBUFFER,ke,Ne,L.width,L.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ce,i.RENDERBUFFER,Z.__webglColorRenderbuffer[Ce])}i.bindRenderbuffer(i.RENDERBUFFER,null),L.depthBuffer&&(Z.__webglDepthRenderbuffer=i.createRenderbuffer(),xe(Z.__webglDepthRenderbuffer,L,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(oe){t.bindTexture(i.TEXTURE_CUBE_MAP,le.__webglTexture),ye(i.TEXTURE_CUBE_MAP,I);for(let Ce=0;Ce<6;Ce++)if(I.mipmaps&&I.mipmaps.length>0)for(let Ve=0;Ve<I.mipmaps.length;Ve++)be(Z.__webglFramebuffer[Ce][Ve],L,I,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Ve);else be(Z.__webglFramebuffer[Ce],L,I,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0);A(I)&&p(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ue){for(let Ce=0,Ve=Ae.length;Ce<Ve;Ce++){const je=Ae[Ce],Ee=n.get(je);t.bindTexture(i.TEXTURE_2D,Ee.__webglTexture),ye(i.TEXTURE_2D,je),be(Z.__webglFramebuffer,L,je,i.COLOR_ATTACHMENT0+Ce,i.TEXTURE_2D,0),A(je)&&p(i.TEXTURE_2D)}t.unbindTexture()}else{let Ce=i.TEXTURE_2D;if((L.isWebGL3DRenderTarget||L.isWebGLArrayRenderTarget)&&(Ce=L.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Ce,le.__webglTexture),ye(Ce,I),I.mipmaps&&I.mipmaps.length>0)for(let Ve=0;Ve<I.mipmaps.length;Ve++)be(Z.__webglFramebuffer[Ve],L,I,i.COLOR_ATTACHMENT0,Ce,Ve);else be(Z.__webglFramebuffer,L,I,i.COLOR_ATTACHMENT0,Ce,0);A(I)&&p(Ce),t.unbindTexture()}L.depthBuffer&&$e(L)}function ut(L){const I=L.textures;for(let Z=0,le=I.length;Z<le;Z++){const Ae=I[Z];if(A(Ae)){const oe=y(L),Ue=n.get(Ae).__webglTexture;t.bindTexture(oe,Ue),p(oe),t.unbindTexture()}}}const Je=[],G=[];function mn(L){if(L.samples>0){if(pt(L)===!1){const I=L.textures,Z=L.width,le=L.height;let Ae=i.COLOR_BUFFER_BIT;const oe=L.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ue=n.get(L),Ce=I.length>1;if(Ce)for(let je=0;je<I.length;je++)t.bindFramebuffer(i.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+je,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,Ue.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+je,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer);const Ve=L.texture.mipmaps;Ve&&Ve.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ue.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ue.__webglFramebuffer);for(let je=0;je<I.length;je++){if(L.resolveDepthBuffer&&(L.depthBuffer&&(Ae|=i.DEPTH_BUFFER_BIT),L.stencilBuffer&&L.resolveStencilBuffer&&(Ae|=i.STENCIL_BUFFER_BIT)),Ce){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,Ue.__webglColorRenderbuffer[je]);const Ee=n.get(I[je]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Ee,0)}i.blitFramebuffer(0,0,Z,le,0,0,Z,le,Ae,i.NEAREST),c===!0&&(Je.length=0,G.length=0,Je.push(i.COLOR_ATTACHMENT0+je),L.depthBuffer&&L.resolveDepthBuffer===!1&&(Je.push(oe),G.push(oe),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,G)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Je))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),Ce)for(let je=0;je<I.length;je++){t.bindFramebuffer(i.FRAMEBUFFER,Ue.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+je,i.RENDERBUFFER,Ue.__webglColorRenderbuffer[je]);const Ee=n.get(I[je]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,Ue.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+je,i.TEXTURE_2D,Ee,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ue.__webglMultisampledFramebuffer)}else if(L.depthBuffer&&L.resolveDepthBuffer===!1&&c){const I=L.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[I])}}}function dt(L){return Math.min(s.maxSamples,L.samples)}function pt(L){const I=n.get(L);return L.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function ze(L){const I=a.render.frame;h.get(L)!==I&&(h.set(L,I),L.update())}function Rt(L,I){const Z=L.colorSpace,le=L.format,Ae=L.type;return L.isCompressedTexture===!0||L.isVideoTexture===!0||Z!==rn&&Z!==oi&&(At.getTransfer(Z)===Mt?(le!==sn||Ae!==tn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Z)),I}function Ge(L){return typeof HTMLImageElement<"u"&&L instanceof HTMLImageElement?(l.width=L.naturalWidth||L.width,l.height=L.naturalHeight||L.height):typeof VideoFrame<"u"&&L instanceof VideoFrame?(l.width=L.displayWidth,l.height=L.displayHeight):(l.width=L.width,l.height=L.height),l}this.allocateTextureUnit=q,this.resetTextureUnits=K,this.setTexture2D=D,this.setTexture2DArray=O,this.setTexture3D=j,this.setTextureCube=Q,this.rebindTextures=Qe,this.setupRenderTarget=St,this.updateRenderTargetMipmap=ut,this.updateMultisampleRenderTarget=mn,this.setupDepthRenderbuffer=$e,this.setupFrameBufferTexture=be,this.useMultisampledRTT=pt}function IS(i,e){function t(n,s=oi){let r;const a=At.getTransfer(s);if(n===tn)return i.UNSIGNED_BYTE;if(n===Eh)return i.UNSIGNED_SHORT_4_4_4_4;if(n===_h)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Ap)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===fp)return i.BYTE;if(n===pp)return i.SHORT;if(n===Ga)return i.UNSIGNED_SHORT;if(n===xh)return i.INT;if(n===Xs)return i.UNSIGNED_INT;if(n===nn)return i.FLOAT;if(n===Mn)return i.HALF_FLOAT;if(n===gp)return i.ALPHA;if(n===mp)return i.RGB;if(n===sn)return i.RGBA;if(n===za)return i.DEPTH_COMPONENT;if(n===Va)return i.DEPTH_STENCIL;if(n===Gi)return i.RED;if(n===yh)return i.RED_INTEGER;if(n===Ys)return i.RG;if(n===wh)return i.RG_INTEGER;if(n===Ch)return i.RGBA_INTEGER;if(n===ac||n===Wa||n===oc||n===qa)if(a===Mt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===ac)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Wa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===oc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===qa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===ac)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Wa)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===oc)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===qa)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===cc||n===vh||n===lc||n===Sh)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===cc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===vh)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===lc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Sh)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===hc||n===uc||n===dc)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===hc||n===uc)return a===Mt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===dc)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Ka||n===Ih||n===Mh||n===Bh||n===Xa||n===Th||n===Rh||n===Nh||n===Fh||n===Dh||n===Lh||n===Ph||n===kh||n===Uh)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Ka)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ih)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Mh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Bh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Xa)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Th)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Rh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Nh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Fh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Dh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Lh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ph)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===kh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Uh)return a===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ya||n===Oh||n===fc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Ya)return a===Mt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Oh)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===fc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===bp||n===Qh||n===Gh||n===Hh)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Ya)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Qh)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Gh)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Hh)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ha?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const MS=`+void main() {++ gl_Position = vec4( position, 1.0 );++}`,BS=`+uniform sampler2DArray depthColor;+uniform float depthWidth;+uniform float depthHeight;++void main() {++ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );++ if ( coord.x >= 1.0 ) {++ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;++ } else {++ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;++ }++}`;class TS{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const s=new an,r=e.properties.get(s);r.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=s}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new vs({vertexShader:MS,fragmentShader:BS,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Jt(new qc(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class RS extends bs{constructor(e,t){super();const n=this;let s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,m=null;const g=new TS,A=t.getContextAttributes();let p=null,y=null;const b=[],_=[],M=new Ze;let w=null;const S=new vn;S.viewport=new _t;const T=new vn;T.viewport=new _t;const v=[S,T],C=new my;let F=null,K=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(se){let me=b[se];return me===void 0&&(me=new pu,b[se]=me),me.getTargetRaySpace()},this.getControllerGrip=function(se){let me=b[se];return me===void 0&&(me=new pu,b[se]=me),me.getGripSpace()},this.getHand=function(se){let me=b[se];return me===void 0&&(me=new pu,b[se]=me),me.getHandSpace()};function q(se){const me=_.indexOf(se.inputSource);if(me===-1)return;const be=b[me];be!==void 0&&(be.update(se.inputSource,se.frame,l||a),be.dispatchEvent({type:se.type,data:se.inputSource}))}function $(){s.removeEventListener("select",q),s.removeEventListener("selectstart",q),s.removeEventListener("selectend",q),s.removeEventListener("squeeze",q),s.removeEventListener("squeezestart",q),s.removeEventListener("squeezeend",q),s.removeEventListener("end",$),s.removeEventListener("inputsourceschange",D);for(let se=0;se<b.length;se++){const me=_[se];me!==null&&(_[se]=null,b[se].disconnect(me))}F=null,K=null,g.reset(),e.setRenderTarget(p),f=null,d=null,u=null,s=null,y=null,Me.stop(),n.isPresenting=!1,e.setPixelRatio(w),e.setSize(M.width,M.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(se){r=se,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(se){o=se,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(se){l=se},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u},this.getFrame=function(){return m},this.getSession=function(){return s},this.setSession=async function(se){if(s=se,s!==null){if(p=e.getRenderTarget(),s.addEventListener("select",q),s.addEventListener("selectstart",q),s.addEventListener("selectend",q),s.addEventListener("squeeze",q),s.addEventListener("squeezestart",q),s.addEventListener("squeezeend",q),s.addEventListener("end",$),s.addEventListener("inputsourceschange",D),A.xrCompatible!==!0&&await t.makeXRCompatible(),w=e.getPixelRatio(),e.getSize(M),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let be=null,xe=null,Pe=null;A.depth&&(Pe=A.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,be=A.stencil?Va:za,xe=A.stencil?Ha:Xs);const $e={colorFormat:t.RGBA8,depthFormat:Pe,scaleFactor:r};u=new XRWebGLBinding(s,t),d=u.createProjectionLayer($e),s.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new js(d.textureWidth,d.textureHeight,{format:sn,type:tn,depthTexture:new bA(d.textureWidth,d.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,be),stencilBuffer:A.stencil,colorSpace:e.outputColorSpace,samples:A.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const be={antialias:A.antialias,alpha:!0,depth:A.depth,stencil:A.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,t,be),s.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new js(f.framebufferWidth,f.framebufferHeight,{format:sn,type:tn,colorSpace:e.outputColorSpace,stencilBuffer:A.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),Me.setContext(s),Me.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function D(se){for(let me=0;me<se.removed.length;me++){const be=se.removed[me],xe=_.indexOf(be);xe>=0&&(_[xe]=null,b[xe].disconnect(be))}for(let me=0;me<se.added.length;me++){const be=se.added[me];let xe=_.indexOf(be);if(xe===-1){for(let $e=0;$e<b.length;$e++)if($e>=_.length){_.push(be),xe=$e;break}else if(_[$e]===null){_[$e]=be,xe=$e;break}if(xe===-1)break}const Pe=b[xe];Pe&&Pe.connect(be)}}const O=new H,j=new H;function Q(se,me,be){O.setFromMatrixPosition(me.matrixWorld),j.setFromMatrixPosition(be.matrixWorld);const xe=O.distanceTo(j),Pe=me.projectionMatrix.elements,$e=be.projectionMatrix.elements,Qe=Pe[14]/(Pe[10]-1),St=Pe[14]/(Pe[10]+1),ut=(Pe[9]+1)/Pe[5],Je=(Pe[9]-1)/Pe[5],G=(Pe[8]-1)/Pe[0],mn=($e[8]+1)/$e[0],dt=Qe*G,pt=Qe*mn,ze=xe/(-G+mn),Rt=ze*-G;if(me.matrixWorld.decompose(se.position,se.quaternion,se.scale),se.translateX(Rt),se.translateZ(ze),se.matrixWorld.compose(se.position,se.quaternion,se.scale),se.matrixWorldInverse.copy(se.matrixWorld).invert(),Pe[10]===-1)se.projectionMatrix.copy(me.projectionMatrix),se.projectionMatrixInverse.copy(me.projectionMatrixInverse);else{const Ge=Qe+ze,L=St+ze,I=dt-Rt,Z=pt+(xe-Rt),le=ut*St/L*Ge,Ae=Je*St/L*Ge;se.projectionMatrix.makePerspective(I,Z,le,Ae,Ge,L),se.projectionMatrixInverse.copy(se.projectionMatrix).invert()}}function J(se,me){me===null?se.matrixWorld.copy(se.matrix):se.matrixWorld.multiplyMatrices(me.matrixWorld,se.matrix),se.matrixWorldInverse.copy(se.matrixWorld).invert()}this.updateCamera=function(se){if(s===null)return;let me=se.near,be=se.far;g.texture!==null&&(g.depthNear>0&&(me=g.depthNear),g.depthFar>0&&(be=g.depthFar)),C.near=T.near=S.near=me,C.far=T.far=S.far=be,(F!==C.near||K!==C.far)&&(s.updateRenderState({depthNear:C.near,depthFar:C.far}),F=C.near,K=C.far),S.layers.mask=se.layers.mask|2,T.layers.mask=se.layers.mask|4,C.layers.mask=S.layers.mask|T.layers.mask;const xe=se.parent,Pe=C.cameras;J(C,xe);for(let $e=0;$e<Pe.length;$e++)J(Pe[$e],xe);Pe.length===2?Q(C,S,T):C.projectionMatrix.copy(S.projectionMatrix),ee(se,C,xe)};function ee(se,me,be){be===null?se.matrix.copy(me.matrixWorld):(se.matrix.copy(be.matrixWorld),se.matrix.invert(),se.matrix.multiply(me.matrixWorld)),se.matrix.decompose(se.position,se.quaternion,se.scale),se.updateMatrixWorld(!0),se.projectionMatrix.copy(me.projectionMatrix),se.projectionMatrixInverse.copy(me.projectionMatrixInverse),se.isPerspectiveCamera&&(se.fov=Or*2*Math.atan(1/se.projectionMatrix.elements[5]),se.zoom=1)}this.getCamera=function(){return C},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(se){c=se,d!==null&&(d.fixedFoveation=se),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=se)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(C)};let ae=null;function ye(se,me){if(h=me.getViewerPose(l||a),m=me,h!==null){const be=h.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let xe=!1;be.length!==C.cameras.length&&(C.cameras.length=0,xe=!0);for(let Qe=0;Qe<be.length;Qe++){const St=be[Qe];let ut=null;if(f!==null)ut=f.getViewport(St);else{const G=u.getViewSubImage(d,St);ut=G.viewport,Qe===0&&(e.setRenderTargetTextures(y,G.colorTexture,G.depthStencilTexture),e.setRenderTarget(y))}let Je=v[Qe];Je===void 0&&(Je=new vn,Je.layers.enable(Qe),Je.viewport=new _t,v[Qe]=Je),Je.matrix.fromArray(St.transform.matrix),Je.matrix.decompose(Je.position,Je.quaternion,Je.scale),Je.projectionMatrix.fromArray(St.projectionMatrix),Je.projectionMatrixInverse.copy(Je.projectionMatrix).invert(),Je.viewport.set(ut.x,ut.y,ut.width,ut.height),Qe===0&&(C.matrix.copy(Je.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),xe===!0&&C.cameras.push(Je)}const Pe=s.enabledFeatures;if(Pe&&Pe.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&u){const Qe=u.getDepthInformation(be[0]);Qe&&Qe.isValid&&Qe.texture&&g.init(e,Qe,s.renderState)}}for(let be=0;be<b.length;be++){const xe=_[be],Pe=b[be];xe!==null&&Pe!==void 0&&Pe.update(xe,me,l||a)}ae&&ae(se,me),me.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:me}),m=null}const Me=new DA;Me.setAnimationLoop(ye),this.setAnimationLoop=function(se){ae=se},this.dispose=function(){}}}const rr=new Bi,NS=new et;function FS(i,e){function t(A,p){A.matrixAutoUpdate===!0&&A.updateMatrix(),p.value.copy(A.matrix)}function n(A,p){p.color.getRGB(A.fogColor.value,Jp(i)),p.isFog?(A.fogNear.value=p.near,A.fogFar.value=p.far):p.isFogExp2&&(A.fogDensity.value=p.density)}function s(A,p,y,b,_){p.isMeshBasicMaterial||p.isMeshLambertMaterial?r(A,p):p.isMeshToonMaterial?(r(A,p),u(A,p)):p.isMeshPhongMaterial?(r(A,p),h(A,p)):p.isMeshStandardMaterial?(r(A,p),d(A,p),p.isMeshPhysicalMaterial&&f(A,p,_)):p.isMeshMatcapMaterial?(r(A,p),m(A,p)):p.isMeshDepthMaterial?r(A,p):p.isMeshDistanceMaterial?(r(A,p),g(A,p)):p.isMeshNormalMaterial?r(A,p):p.isLineBasicMaterial?(a(A,p),p.isLineDashedMaterial&&o(A,p)):p.isPointsMaterial?c(A,p,y,b):p.isSpriteMaterial?l(A,p):p.isShadowMaterial?(A.color.value.copy(p.color),A.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(A,p){A.opacity.value=p.opacity,p.color&&A.diffuse.value.copy(p.color),p.emissive&&A.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(A.map.value=p.map,t(p.map,A.mapTransform)),p.alphaMap&&(A.alphaMap.value=p.alphaMap,t(p.alphaMap,A.alphaMapTransform)),p.bumpMap&&(A.bumpMap.value=p.bumpMap,t(p.bumpMap,A.bumpMapTransform),A.bumpScale.value=p.bumpScale,p.side===Sn&&(A.bumpScale.value*=-1)),p.normalMap&&(A.normalMap.value=p.normalMap,t(p.normalMap,A.normalMapTransform),A.normalScale.value.copy(p.normalScale),p.side===Sn&&A.normalScale.value.negate()),p.displacementMap&&(A.displacementMap.value=p.displacementMap,t(p.displacementMap,A.displacementMapTransform),A.displacementScale.value=p.displacementScale,A.displacementBias.value=p.displacementBias),p.emissiveMap&&(A.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,A.emissiveMapTransform)),p.specularMap&&(A.specularMap.value=p.specularMap,t(p.specularMap,A.specularMapTransform)),p.alphaTest>0&&(A.alphaTest.value=p.alphaTest);const y=e.get(p),b=y.envMap,_=y.envMapRotation;b&&(A.envMap.value=b,rr.copy(_),rr.x*=-1,rr.y*=-1,rr.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(rr.y*=-1,rr.z*=-1),A.envMapRotation.value.setFromMatrix4(NS.makeRotationFromEuler(rr)),A.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,A.reflectivity.value=p.reflectivity,A.ior.value=p.ior,A.refractionRatio.value=p.refractionRatio),p.lightMap&&(A.lightMap.value=p.lightMap,A.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,A.lightMapTransform)),p.aoMap&&(A.aoMap.value=p.aoMap,A.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,A.aoMapTransform))}function a(A,p){A.diffuse.value.copy(p.color),A.opacity.value=p.opacity,p.map&&(A.map.value=p.map,t(p.map,A.mapTransform))}function o(A,p){A.dashSize.value=p.dashSize,A.totalSize.value=p.dashSize+p.gapSize,A.scale.value=p.scale}function c(A,p,y,b){A.diffuse.value.copy(p.color),A.opacity.value=p.opacity,A.size.value=p.size*y,A.scale.value=b*.5,p.map&&(A.map.value=p.map,t(p.map,A.uvTransform)),p.alphaMap&&(A.alphaMap.value=p.alphaMap,t(p.alphaMap,A.alphaMapTransform)),p.alphaTest>0&&(A.alphaTest.value=p.alphaTest)}function l(A,p){A.diffuse.value.copy(p.color),A.opacity.value=p.opacity,A.rotation.value=p.rotation,p.map&&(A.map.value=p.map,t(p.map,A.mapTransform)),p.alphaMap&&(A.alphaMap.value=p.alphaMap,t(p.alphaMap,A.alphaMapTransform)),p.alphaTest>0&&(A.alphaTest.value=p.alphaTest)}function h(A,p){A.specular.value.copy(p.specular),A.shininess.value=Math.max(p.shininess,1e-4)}function u(A,p){p.gradientMap&&(A.gradientMap.value=p.gradientMap)}function d(A,p){A.metalness.value=p.metalness,p.metalnessMap&&(A.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,A.metalnessMapTransform)),A.roughness.value=p.roughness,p.roughnessMap&&(A.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,A.roughnessMapTransform)),p.envMap&&(A.envMapIntensity.value=p.envMapIntensity)}function f(A,p,y){A.ior.value=p.ior,p.sheen>0&&(A.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),A.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(A.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,A.sheenColorMapTransform)),p.sheenRoughnessMap&&(A.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,A.sheenRoughnessMapTransform))),p.clearcoat>0&&(A.clearcoat.value=p.clearcoat,A.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(A.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,A.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(A.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,A.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(A.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,A.clearcoatNormalMapTransform),A.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Sn&&A.clearcoatNormalScale.value.negate())),p.dispersion>0&&(A.dispersion.value=p.dispersion),p.iridescence>0&&(A.iridescence.value=p.iridescence,A.iridescenceIOR.value=p.iridescenceIOR,A.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],A.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(A.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,A.iridescenceMapTransform)),p.iridescenceThicknessMap&&(A.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,A.iridescenceThicknessMapTransform))),p.transmission>0&&(A.transmission.value=p.transmission,A.transmissionSamplerMap.value=y.texture,A.transmissionSamplerSize.value.set(y.width,y.height),p.transmissionMap&&(A.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,A.transmissionMapTransform)),A.thickness.value=p.thickness,p.thicknessMap&&(A.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,A.thicknessMapTransform)),A.attenuationDistance.value=p.attenuationDistance,A.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(A.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(A.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,A.anisotropyMapTransform))),A.specularIntensity.value=p.specularIntensity,A.specularColor.value.copy(p.specularColor),p.specularColorMap&&(A.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,A.specularColorMapTransform)),p.specularIntensityMap&&(A.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,A.specularIntensityMapTransform))}function m(A,p){p.matcap&&(A.matcap.value=p.matcap)}function g(A,p){const y=e.get(p).light;A.referencePosition.value.setFromMatrixPosition(y.matrixWorld),A.nearDistance.value=y.shadow.camera.near,A.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function DS(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,b){const _=b.program;n.uniformBlockBinding(y,_)}function l(y,b){let _=s[y.id];_===void 0&&(m(y),_=h(y),s[y.id]=_,y.addEventListener("dispose",A));const M=b.program;n.updateUBOMapping(y,M);const w=e.render.frame;r[y.id]!==w&&(d(y),r[y.id]=w)}function h(y){const b=u();y.__bindingPointIndex=b;const _=i.createBuffer(),M=y.__size,w=y.usage;return i.bindBuffer(i.UNIFORM_BUFFER,_),i.bufferData(i.UNIFORM_BUFFER,M,w),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,b,_),_}function u(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const b=s[y.id],_=y.uniforms,M=y.__cache;i.bindBuffer(i.UNIFORM_BUFFER,b);for(let w=0,S=_.length;w<S;w++){const T=Array.isArray(_[w])?_[w]:[_[w]];for(let v=0,C=T.length;v<C;v++){const F=T[v];if(f(F,w,v,M)===!0){const K=F.__offset,q=Array.isArray(F.value)?F.value:[F.value];let $=0;for(let D=0;D<q.length;D++){const O=q[D],j=g(O);typeof O=="number"||typeof O=="boolean"?(F.__data[0]=O,i.bufferSubData(i.UNIFORM_BUFFER,K+$,F.__data)):O.isMatrix3?(F.__data[0]=O.elements[0],F.__data[1]=O.elements[1],F.__data[2]=O.elements[2],F.__data[3]=0,F.__data[4]=O.elements[3],F.__data[5]=O.elements[4],F.__data[6]=O.elements[5],F.__data[7]=0,F.__data[8]=O.elements[6],F.__data[9]=O.elements[7],F.__data[10]=O.elements[8],F.__data[11]=0):(O.toArray(F.__data,$),$+=j.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,K,F.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(y,b,_,M){const w=y.value,S=b+"_"+_;if(M[S]===void 0)return typeof w=="number"||typeof w=="boolean"?M[S]=w:M[S]=w.clone(),!0;{const T=M[S];if(typeof w=="number"||typeof w=="boolean"){if(T!==w)return M[S]=w,!0}else if(T.equals(w)===!1)return T.copy(w),!0}return!1}function m(y){const b=y.uniforms;let _=0;const M=16;for(let S=0,T=b.length;S<T;S++){const v=Array.isArray(b[S])?b[S]:[b[S]];for(let C=0,F=v.length;C<F;C++){const K=v[C],q=Array.isArray(K.value)?K.value:[K.value];for(let $=0,D=q.length;$<D;$++){const O=q[$],j=g(O),Q=_%M,J=Q%j.boundary,ee=Q+J;_+=J,ee!==0&&M-ee<j.storage&&(_+=M-ee),K.__data=new Float32Array(j.storage/Float32Array.BYTES_PER_ELEMENT),K.__offset=_,_+=j.storage}}}const w=_%M;return w>0&&(_+=M-w),y.__size=_,y.__cache={},this}function g(y){const b={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(b.boundary=4,b.storage=4):y.isVector2?(b.boundary=8,b.storage=8):y.isVector3||y.isColor?(b.boundary=16,b.storage=12):y.isVector4?(b.boundary=16,b.storage=16):y.isMatrix3?(b.boundary=48,b.storage=48):y.isMatrix4?(b.boundary=64,b.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),b}function A(y){const b=y.target;b.removeEventListener("dispose",A);const _=a.indexOf(b.__bindingPointIndex);a.splice(_,1),i.deleteBuffer(s[b.id]),delete s[b.id],delete r[b.id]}function p(){for(const y in s)i.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:c,update:l,dispose:p}}class cg{constructor(e={}){const{canvas:t=l_(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reverseDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=a;const m=new Uint32Array(4),g=new Int32Array(4);let A=null,p=null;const y=[],b=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ms,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const _=this;let M=!1;this._outputColorSpace=Kt;let w=0,S=0,T=null,v=-1,C=null;const F=new _t,K=new _t;let q=null;const $=new qe(0);let D=0,O=t.width,j=t.height,Q=1,J=null,ee=null;const ae=new _t(0,0,O,j),ye=new _t(0,0,O,j);let Me=!1;const se=new yu;let me=!1,be=!1;const xe=new et,Pe=new et,$e=new H,Qe=new _t,St={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ut=!1;function Je(){return T===null?Q:1}let G=n;function mn(E,R){return t.getContext(E,R)}try{const E={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r176"),t.addEventListener("webglcontextlost",de,!1),t.addEventListener("webglcontextrestored",Ie,!1),t.addEventListener("webglcontextcreationerror",Se,!1),G===null){const R="webgl2";if(G=mn(R,E),G===null)throw mn(R)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let dt,pt,ze,Rt,Ge,L,I,Z,le,Ae,oe,Ue,Ce,Ve,je,Ee,Ne,ke,Oe,Te,tt,We,nt,W;function ne(){dt=new WC(G),dt.init(),We=new IS(G,dt),pt=new UC(G,dt,e,We),ze=new vS(G,dt),pt.reverseDepthBuffer&&d&&ze.buffers.depth.setReversed(!0),Rt=new XC(G),Ge=new dS,L=new SS(G,dt,ze,Ge,pt,We,Rt),I=new QC(_),Z=new VC(_),le=new Dy(G),nt=new PC(G,le),Ae=new qC(G,le,Rt,nt),oe=new jC(G,Ae,le,Rt),Oe=new YC(G,pt,L),Ee=new OC(Ge),Ue=new uS(_,I,Z,dt,pt,nt,Ee),Ce=new FS(_,Ge),Ve=new pS,je=new ES(dt),ke=new LC(_,I,Z,ze,oe,f,c),Ne=new wS(_,oe,pt),W=new DS(G,Rt,pt,ze),Te=new kC(G,dt,Rt),tt=new KC(G,dt,Rt),Rt.programs=Ue.programs,_.capabilities=pt,_.extensions=dt,_.properties=Ge,_.renderLists=Ve,_.shadowMap=Ne,_.state=ze,_.info=Rt}ne();const re=new RS(_,G);this.xr=re,this.getContext=function(){return G},this.getContextAttributes=function(){return G.getContextAttributes()},this.forceContextLoss=function(){const E=dt.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=dt.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return Q},this.setPixelRatio=function(E){E!==void 0&&(Q=E,this.setSize(O,j,!1))},this.getSize=function(E){return E.set(O,j)},this.setSize=function(E,R,N=!0){if(re.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}O=E,j=R,t.width=Math.floor(E*Q),t.height=Math.floor(R*Q),N===!0&&(t.style.width=E+"px",t.style.height=R+"px"),this.setViewport(0,0,E,R)},this.getDrawingBufferSize=function(E){return E.set(O*Q,j*Q).floor()},this.setDrawingBufferSize=function(E,R,N){O=E,j=R,Q=N,t.width=Math.floor(E*N),t.height=Math.floor(R*N),this.setViewport(0,0,E,R)},this.getCurrentViewport=function(E){return E.copy(F)},this.getViewport=function(E){return E.copy(ae)},this.setViewport=function(E,R,N,U){E.isVector4?ae.set(E.x,E.y,E.z,E.w):ae.set(E,R,N,U),ze.viewport(F.copy(ae).multiplyScalar(Q).round())},this.getScissor=function(E){return E.copy(ye)},this.setScissor=function(E,R,N,U){E.isVector4?ye.set(E.x,E.y,E.z,E.w):ye.set(E,R,N,U),ze.scissor(K.copy(ye).multiplyScalar(Q).round())},this.getScissorTest=function(){return Me},this.setScissorTest=function(E){ze.setScissorTest(Me=E)},this.setOpaqueSort=function(E){J=E},this.setTransparentSort=function(E){ee=E},this.getClearColor=function(E){return E.copy(ke.getClearColor())},this.setClearColor=function(){ke.setClearColor(...arguments)},this.getClearAlpha=function(){return ke.getClearAlpha()},this.setClearAlpha=function(){ke.setClearAlpha(...arguments)},this.clear=function(E=!0,R=!0,N=!0){let U=0;if(E){let P=!1;if(T!==null){const z=T.texture.format;P=z===Ch||z===wh||z===yh}if(P){const z=T.texture.type,X=z===tn||z===Xs||z===Ga||z===Ha||z===Eh||z===_h,Y=ke.getClearColor(),ie=ke.getClearAlpha(),he=Y.r,ce=Y.g,fe=Y.b;X?(m[0]=he,m[1]=ce,m[2]=fe,m[3]=ie,G.clearBufferuiv(G.COLOR,0,m)):(g[0]=he,g[1]=ce,g[2]=fe,g[3]=ie,G.clearBufferiv(G.COLOR,0,g))}else U|=G.COLOR_BUFFER_BIT}R&&(U|=G.DEPTH_BUFFER_BIT),N&&(U|=G.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G.clear(U)},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",de,!1),t.removeEventListener("webglcontextrestored",Ie,!1),t.removeEventListener("webglcontextcreationerror",Se,!1),ke.dispose(),Ve.dispose(),je.dispose(),Ge.dispose(),I.dispose(),Z.dispose(),oe.dispose(),nt.dispose(),W.dispose(),Ue.dispose(),re.dispose(),re.removeEventListener("sessionstart",ih),re.removeEventListener("sessionend",sh),ps.stop()};function de(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),M=!0}function Ie(){console.log("THREE.WebGLRenderer: Context Restored."),M=!1;const E=Rt.autoReset,R=Ne.enabled,N=Ne.autoUpdate,U=Ne.needsUpdate,P=Ne.type;ne(),Rt.autoReset=E,Ne.enabled=R,Ne.autoUpdate=N,Ne.needsUpdate=U,Ne.type=P}function Se(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function it(E){const R=E.target;R.removeEventListener("dispose",it),Ot(R)}function Ot(E){bn(E),Ge.remove(E)}function bn(E){const R=Ge.get(E).programs;R!==void 0&&(R.forEach(function(N){Ue.releaseProgram(N)}),E.isShaderMaterial&&Ue.releaseShaderCache(E))}this.renderBufferDirect=function(E,R,N,U,P,z){R===null&&(R=St);const X=P.isMesh&&P.matrixWorld.determinant()<0,Y=tp(E,R,N,U,P);ze.setMaterial(U,X);let ie=N.index,he=1;if(U.wireframe===!0){if(ie=Ae.getWireframeAttribute(N),ie===void 0)return;he=2}const ce=N.drawRange,fe=N.attributes.position;let ge=ce.start*he,_e=(ce.start+ce.count)*he;z!==null&&(ge=Math.max(ge,z.start*he),_e=Math.min(_e,(z.start+z.count)*he)),ie!==null?(ge=Math.max(ge,0),_e=Math.min(_e,ie.count)):fe!=null&&(ge=Math.max(ge,0),_e=Math.min(_e,fe.count));const De=_e-ge;if(De<0||De===1/0)return;nt.setup(P,U,Y,N,ie);let Ke,He=Te;if(ie!==null&&(Ke=le.get(ie),He=tt,He.setIndex(Ke)),P.isMesh)U.wireframe===!0?(ze.setLineWidth(U.wireframeLinewidth*Je()),He.setMode(G.LINES)):He.setMode(G.TRIANGLES);else if(P.isLine){let Fe=U.linewidth;Fe===void 0&&(Fe=1),ze.setLineWidth(Fe*Je()),P.isLineSegments?He.setMode(G.LINES):P.isLineLoop?He.setMode(G.LINE_LOOP):He.setMode(G.LINE_STRIP)}else P.isPoints?He.setMode(G.POINTS):P.isSprite&&He.setMode(G.TRIANGLES);if(P.isBatchedMesh)if(P._multiDrawInstances!==null)mc("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),He.renderMultiDrawInstances(P._multiDrawStarts,P._multiDrawCounts,P._multiDrawCount,P._multiDrawInstances);else if(dt.get("WEBGL_multi_draw"))He.renderMultiDraw(P._multiDrawStarts,P._multiDrawCounts,P._multiDrawCount);else{const Fe=P._multiDrawStarts,st=P._multiDrawCounts,Le=P._multiDrawCount,wt=ie?le.get(ie).bytesPerElement:1,un=Ge.get(U).currentProgram.getUniforms();for(let Et=0;Et<Le;Et++)un.setValue(G,"_gl_DrawID",Et),He.render(Fe[Et]/wt,st[Et])}else if(P.isInstancedMesh)He.renderInstances(ge,De,P.count);else if(N.isInstancedBufferGeometry){const Fe=N._maxInstanceCount!==void 0?N._maxInstanceCount:1/0,st=Math.min(N.instanceCount,Fe);He.renderInstances(ge,De,st)}else He.render(ge,De)};function yt(E,R,N){E.transparent===!0&&E.side===Si&&E.forceSinglePass===!1?(E.side=Sn,E.needsUpdate=!0,Oa(E,R,N),E.side=Qi,E.needsUpdate=!0,Oa(E,R,N),E.side=Si):Oa(E,R,N)}this.compile=function(E,R,N=null){N===null&&(N=E),p=je.get(N),p.init(R),b.push(p),N.traverseVisible(function(P){P.isLight&&P.layers.test(R.layers)&&(p.pushLight(P),P.castShadow&&p.pushShadow(P))}),E!==N&&E.traverseVisible(function(P){P.isLight&&P.layers.test(R.layers)&&(p.pushLight(P),P.castShadow&&p.pushShadow(P))}),p.setupLights();const U=new Set;return E.traverse(function(P){if(!(P.isMesh||P.isPoints||P.isLine||P.isSprite))return;const z=P.material;if(z)if(Array.isArray(z))for(let X=0;X<z.length;X++){const Y=z[X];yt(Y,N,P),U.add(Y)}else yt(z,N,P),U.add(z)}),p=b.pop(),U},this.compileAsync=function(E,R,N=null){const U=this.compile(E,R,N);return new Promise(P=>{function z(){if(U.forEach(function(X){Ge.get(X).currentProgram.isReady()&&U.delete(X)}),U.size===0){P(E);return}setTimeout(z,10)}dt.get("KHR_parallel_shader_compile")!==null?z():setTimeout(z,10)})};let jn=null;function vi(E){jn&&jn(E)}function ih(){ps.stop()}function sh(){ps.start()}const ps=new DA;ps.setAnimationLoop(vi),typeof self<"u"&&ps.setContext(self),this.setAnimationLoop=function(E){jn=E,re.setAnimationLoop(E),E===null?ps.stop():ps.start()},re.addEventListener("sessionstart",ih),re.addEventListener("sessionend",sh),this.render=function(E,R){if(R!==void 0&&R.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(M===!0)return;if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),R.parent===null&&R.matrixWorldAutoUpdate===!0&&R.updateMatrixWorld(),re.enabled===!0&&re.isPresenting===!0&&(re.cameraAutoUpdate===!0&&re.updateCamera(R),R=re.getCamera()),E.isScene===!0&&E.onBeforeRender(_,E,R,T),p=je.get(E,b.length),p.init(R),b.push(p),Pe.multiplyMatrices(R.projectionMatrix,R.matrixWorldInverse),se.setFromProjectionMatrix(Pe),be=this.localClippingEnabled,me=Ee.init(this.clippingPlanes,be),A=Ve.get(E,y.length),A.init(),y.push(A),re.enabled===!0&&re.isPresenting===!0){const z=_.xr.getDepthSensingMesh();z!==null&&Zo(z,R,-1/0,_.sortObjects)}Zo(E,R,0,_.sortObjects),A.finish(),_.sortObjects===!0&&A.sort(J,ee),ut=re.enabled===!1||re.isPresenting===!1||re.hasDepthSensing()===!1,ut&&ke.addToRenderList(A,E),this.info.render.frame++,me===!0&&Ee.beginShadows();const N=p.state.shadowsArray;Ne.render(N,E,R),me===!0&&Ee.endShadows(),this.info.autoReset===!0&&this.info.reset();const U=A.opaque,P=A.transmissive;if(p.setupLights(),R.isArrayCamera){const z=R.cameras;if(P.length>0)for(let X=0,Y=z.length;X<Y;X++){const ie=z[X];rh(U,P,E,ie)}ut&&ke.render(E);for(let X=0,Y=z.length;X<Y;X++){const ie=z[X];$o(A,E,ie,ie.viewport)}}else P.length>0&&rh(U,P,E,R),ut&&ke.render(E),$o(A,E,R);T!==null&&S===0&&(L.updateMultisampleRenderTarget(T),L.updateRenderTargetMipmap(T)),E.isScene===!0&&E.onAfterRender(_,E,R),nt.resetDefaultState(),v=-1,C=null,b.pop(),b.length>0?(p=b[b.length-1],me===!0&&Ee.setGlobalState(_.clippingPlanes,p.state.camera)):p=null,y.pop(),y.length>0?A=y[y.length-1]:A=null};function Zo(E,R,N,U){if(E.visible===!1)return;if(E.layers.test(R.layers)){if(E.isGroup)N=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(R);else if(E.isLight)p.pushLight(E),E.castShadow&&p.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||se.intersectsSprite(E)){U&&Qe.setFromMatrixPosition(E.matrixWorld).applyMatrix4(Pe);const X=oe.update(E),Y=E.material;Y.visible&&A.push(E,X,Y,N,Qe.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||se.intersectsObject(E))){const X=oe.update(E),Y=E.material;if(U&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),Qe.copy(E.boundingSphere.center)):(X.boundingSphere===null&&X.computeBoundingSphere(),Qe.copy(X.boundingSphere.center)),Qe.applyMatrix4(E.matrixWorld).applyMatrix4(Pe)),Array.isArray(Y)){const ie=X.groups;for(let he=0,ce=ie.length;he<ce;he++){const fe=ie[he],ge=Y[fe.materialIndex];ge&&ge.visible&&A.push(E,X,ge,N,Qe.z,fe)}}else Y.visible&&A.push(E,X,Y,N,Qe.z,null)}}const z=E.children;for(let X=0,Y=z.length;X<Y;X++)Zo(z[X],R,N,U)}function $o(E,R,N,U){const P=E.opaque,z=E.transmissive,X=E.transparent;p.setupLightsView(N),me===!0&&Ee.setGlobalState(_.clippingPlanes,N),U&&ze.viewport(F.copy(U)),P.length>0&&Ua(P,R,N),z.length>0&&Ua(z,R,N),X.length>0&&Ua(X,R,N),ze.buffers.depth.setTest(!0),ze.buffers.depth.setMask(!0),ze.buffers.color.setMask(!0),ze.setPolygonOffset(!1)}function rh(E,R,N,U){if((N.isScene===!0?N.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[U.id]===void 0&&(p.state.transmissionRenderTarget[U.id]=new js(1,1,{generateMipmaps:!0,type:dt.has("EXT_color_buffer_half_float")||dt.has("EXT_color_buffer_float")?Mn:tn,minFilter:Jn,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:At.workingColorSpace}));const z=p.state.transmissionRenderTarget[U.id],X=U.viewport||F;z.setSize(X.z*_.transmissionResolutionScale,X.w*_.transmissionResolutionScale);const Y=_.getRenderTarget();_.setRenderTarget(z),_.getClearColor($),D=_.getClearAlpha(),D<1&&_.setClearColor(16777215,.5),_.clear(),ut&&ke.render(N);const ie=_.toneMapping;_.toneMapping=ms;const he=U.viewport;if(U.viewport!==void 0&&(U.viewport=void 0),p.setupLightsView(U),me===!0&&Ee.setGlobalState(_.clippingPlanes,U),Ua(E,N,U),L.updateMultisampleRenderTarget(z),L.updateRenderTargetMipmap(z),dt.has("WEBGL_multisampled_render_to_texture")===!1){let ce=!1;for(let fe=0,ge=R.length;fe<ge;fe++){const _e=R[fe],De=_e.object,Ke=_e.geometry,He=_e.material,Fe=_e.group;if(He.side===Si&&De.layers.test(U.layers)){const st=He.side;He.side=Sn,He.needsUpdate=!0,ah(De,N,U,Ke,He,Fe),He.side=st,He.needsUpdate=!0,ce=!0}}ce===!0&&(L.updateMultisampleRenderTarget(z),L.updateRenderTargetMipmap(z))}_.setRenderTarget(Y),_.setClearColor($,D),he!==void 0&&(U.viewport=he),_.toneMapping=ie}function Ua(E,R,N){const U=R.isScene===!0?R.overrideMaterial:null;for(let P=0,z=E.length;P<z;P++){const X=E[P],Y=X.object,ie=X.geometry,he=X.group;let ce=X.material;ce.allowOverride===!0&&U!==null&&(ce=U),Y.layers.test(N.layers)&&ah(Y,R,N,ie,ce,he)}}function ah(E,R,N,U,P,z){E.onBeforeRender(_,R,N,U,P,z),E.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),P.onBeforeRender(_,R,N,U,E,z),P.transparent===!0&&P.side===Si&&P.forceSinglePass===!1?(P.side=Sn,P.needsUpdate=!0,_.renderBufferDirect(N,R,U,P,E,z),P.side=Qi,P.needsUpdate=!0,_.renderBufferDirect(N,R,U,P,E,z),P.side=Si):_.renderBufferDirect(N,R,U,P,E,z),E.onAfterRender(_,R,N,U,P,z)}function Oa(E,R,N){R.isScene!==!0&&(R=St);const U=Ge.get(E),P=p.state.lights,z=p.state.shadowsArray,X=P.state.version,Y=Ue.getParameters(E,P.state,z,R,N),ie=Ue.getProgramCacheKey(Y);let he=U.programs;U.environment=E.isMeshStandardMaterial?R.environment:null,U.fog=R.fog,U.envMap=(E.isMeshStandardMaterial?Z:I).get(E.envMap||U.environment),U.envMapRotation=U.environment!==null&&E.envMap===null?R.environmentRotation:E.envMapRotation,he===void 0&&(E.addEventListener("dispose",it),he=new Map,U.programs=he);let ce=he.get(ie);if(ce!==void 0){if(U.currentProgram===ce&&U.lightsStateVersion===X)return tc(E,Y),ce}else Y.uniforms=Ue.getUniforms(E),E.onBeforeCompile(Y,_),ce=Ue.acquireProgram(Y,ie),he.set(ie,ce),U.uniforms=Y.uniforms;const fe=U.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(fe.clippingPlanes=Ee.uniform),tc(E,Y),U.needsLights=Ws(E),U.lightsStateVersion=X,U.needsLights&&(fe.ambientLightColor.value=P.state.ambient,fe.lightProbe.value=P.state.probe,fe.directionalLights.value=P.state.directional,fe.directionalLightShadows.value=P.state.directionalShadow,fe.spotLights.value=P.state.spot,fe.spotLightShadows.value=P.state.spotShadow,fe.rectAreaLights.value=P.state.rectArea,fe.ltc_1.value=P.state.rectAreaLTC1,fe.ltc_2.value=P.state.rectAreaLTC2,fe.pointLights.value=P.state.point,fe.pointLightShadows.value=P.state.pointShadow,fe.hemisphereLights.value=P.state.hemi,fe.directionalShadowMap.value=P.state.directionalShadowMap,fe.directionalShadowMatrix.value=P.state.directionalShadowMatrix,fe.spotShadowMap.value=P.state.spotShadowMap,fe.spotLightMatrix.value=P.state.spotLightMatrix,fe.spotLightMap.value=P.state.spotLightMap,fe.pointShadowMap.value=P.state.pointShadowMap,fe.pointShadowMatrix.value=P.state.pointShadowMatrix),U.currentProgram=ce,U.uniformsList=null,ce}function ec(E){if(E.uniformsList===null){const R=E.currentProgram.getUniforms();E.uniformsList=Zc.seqWithValue(R.seq,E.uniforms)}return E.uniformsList}function tc(E,R){const N=Ge.get(E);N.outputColorSpace=R.outputColorSpace,N.batching=R.batching,N.batchingColor=R.batchingColor,N.instancing=R.instancing,N.instancingColor=R.instancingColor,N.instancingMorph=R.instancingMorph,N.skinning=R.skinning,N.morphTargets=R.morphTargets,N.morphNormals=R.morphNormals,N.morphColors=R.morphColors,N.morphTargetsCount=R.morphTargetsCount,N.numClippingPlanes=R.numClippingPlanes,N.numIntersection=R.numClipIntersection,N.vertexAlphas=R.vertexAlphas,N.vertexTangents=R.vertexTangents,N.toneMapping=R.toneMapping}function tp(E,R,N,U,P){R.isScene!==!0&&(R=St),L.resetTextureUnits();const z=R.fog,X=U.isMeshStandardMaterial?R.environment:null,Y=T===null?_.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:rn,ie=(U.isMeshStandardMaterial?Z:I).get(U.envMap||X),he=U.vertexColors===!0&&!!N.attributes.color&&N.attributes.color.itemSize===4,ce=!!N.attributes.tangent&&(!!U.normalMap||U.anisotropy>0),fe=!!N.morphAttributes.position,ge=!!N.morphAttributes.normal,_e=!!N.morphAttributes.color;let De=ms;U.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(De=_.toneMapping);const Ke=N.morphAttributes.position||N.morphAttributes.normal||N.morphAttributes.color,He=Ke!==void 0?Ke.length:0,Fe=Ge.get(U),st=p.state.lights;if(me===!0&&(be===!0||E!==C)){const Lt=E===C&&U.id===v;Ee.setState(U,E,Lt)}let Le=!1;U.version===Fe.__version?(Fe.needsLights&&Fe.lightsStateVersion!==st.state.version||Fe.outputColorSpace!==Y||P.isBatchedMesh&&Fe.batching===!1||!P.isBatchedMesh&&Fe.batching===!0||P.isBatchedMesh&&Fe.batchingColor===!0&&P.colorTexture===null||P.isBatchedMesh&&Fe.batchingColor===!1&&P.colorTexture!==null||P.isInstancedMesh&&Fe.instancing===!1||!P.isInstancedMesh&&Fe.instancing===!0||P.isSkinnedMesh&&Fe.skinning===!1||!P.isSkinnedMesh&&Fe.skinning===!0||P.isInstancedMesh&&Fe.instancingColor===!0&&P.instanceColor===null||P.isInstancedMesh&&Fe.instancingColor===!1&&P.instanceColor!==null||P.isInstancedMesh&&Fe.instancingMorph===!0&&P.morphTexture===null||P.isInstancedMesh&&Fe.instancingMorph===!1&&P.morphTexture!==null||Fe.envMap!==ie||U.fog===!0&&Fe.fog!==z||Fe.numClippingPlanes!==void 0&&(Fe.numClippingPlanes!==Ee.numPlanes||Fe.numIntersection!==Ee.numIntersection)||Fe.vertexAlphas!==he||Fe.vertexTangents!==ce||Fe.morphTargets!==fe||Fe.morphNormals!==ge||Fe.morphColors!==_e||Fe.toneMapping!==De||Fe.morphTargetsCount!==He)&&(Le=!0):(Le=!0,Fe.__version=U.version);let wt=Fe.currentProgram;Le===!0&&(wt=Oa(U,R,P));let un=!1,Et=!1,bt=!1;const Xe=wt.getUniforms(),qt=Fe.uniforms;if(ze.useProgram(wt.program)&&(un=!0,Et=!0,bt=!0),U.id!==v&&(v=U.id,Et=!0),un||C!==E){ze.buffers.depth.getReversed()?(xe.copy(E.projectionMatrix),u_(xe),d_(xe),Xe.setValue(G,"projectionMatrix",xe)):Xe.setValue(G,"projectionMatrix",E.projectionMatrix),Xe.setValue(G,"viewMatrix",E.matrixWorldInverse);const dn=Xe.map.cameraPosition;dn!==void 0&&dn.setValue(G,$e.setFromMatrixPosition(E.matrixWorld)),pt.logarithmicDepthBuffer&&Xe.setValue(G,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial)&&Xe.setValue(G,"isOrthographic",E.isOrthographicCamera===!0),C!==E&&(C=E,Et=!0,bt=!0)}if(P.isSkinnedMesh){Xe.setOptional(G,P,"bindMatrix"),Xe.setOptional(G,P,"bindMatrixInverse");const Lt=P.skeleton;Lt&&(Lt.boneTexture===null&&Lt.computeBoneTexture(),Xe.setValue(G,"boneTexture",Lt.boneTexture,L))}P.isBatchedMesh&&(Xe.setOptional(G,P,"batchingTexture"),Xe.setValue(G,"batchingTexture",P._matricesTexture,L),Xe.setOptional(G,P,"batchingIdTexture"),Xe.setValue(G,"batchingIdTexture",P._indirectTexture,L),Xe.setOptional(G,P,"batchingColorTexture"),P._colorsTexture!==null&&Xe.setValue(G,"batchingColorTexture",P._colorsTexture,L));const xn=N.morphAttributes;if((xn.position!==void 0||xn.normal!==void 0||xn.color!==void 0)&&Oe.update(P,N,wt),(Et||Fe.receiveShadow!==P.receiveShadow)&&(Fe.receiveShadow=P.receiveShadow,Xe.setValue(G,"receiveShadow",P.receiveShadow)),U.isMeshGouraudMaterial&&U.envMap!==null&&(qt.envMap.value=ie,qt.flipEnvMap.value=ie.isCubeTexture&&ie.isRenderTargetTexture===!1?-1:1),U.isMeshStandardMaterial&&U.envMap===null&&R.environment!==null&&(qt.envMapIntensity.value=R.environmentIntensity),Et&&(Xe.setValue(G,"toneMappingExposure",_.toneMappingExposure),Fe.needsLights&&As(qt,bt),z&&U.fog===!0&&Ce.refreshFogUniforms(qt,z),Ce.refreshMaterialUniforms(qt,U,Q,j,p.state.transmissionRenderTarget[E.id]),Zc.upload(G,ec(Fe),qt,L)),U.isShaderMaterial&&U.uniformsNeedUpdate===!0&&(Zc.upload(G,ec(Fe),qt,L),U.uniformsNeedUpdate=!1),U.isSpriteMaterial&&Xe.setValue(G,"center",P.center),Xe.setValue(G,"modelViewMatrix",P.modelViewMatrix),Xe.setValue(G,"normalMatrix",P.normalMatrix),Xe.setValue(G,"modelMatrix",P.matrixWorld),U.isShaderMaterial||U.isRawShaderMaterial){const Lt=U.uniformsGroups;for(let dn=0,np=Lt.length;dn<np;dn++){const Br=Lt[dn];W.update(Br,wt),W.bind(Br,wt)}}return wt}function As(E,R){E.ambientLightColor.needsUpdate=R,E.lightProbe.needsUpdate=R,E.directionalLights.needsUpdate=R,E.directionalLightShadows.needsUpdate=R,E.pointLights.needsUpdate=R,E.pointLightShadows.needsUpdate=R,E.spotLights.needsUpdate=R,E.spotLightShadows.needsUpdate=R,E.rectAreaLights.needsUpdate=R,E.hemisphereLights.needsUpdate=R}function Ws(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return S},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(E,R,N){const U=Ge.get(E);U.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,U.__autoAllocateDepthBuffer===!1&&(U.__useRenderToTexture=!1),Ge.get(E.texture).__webglTexture=R,Ge.get(E.depthTexture).__webglTexture=U.__autoAllocateDepthBuffer?void 0:N,U.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,R){const N=Ge.get(E);N.__webglFramebuffer=R,N.__useDefaultFramebuffer=R===void 0};const x=G.createFramebuffer();this.setRenderTarget=function(E,R=0,N=0){T=E,w=R,S=N;let U=!0,P=null,z=!1,X=!1;if(E){const ie=Ge.get(E);if(ie.__useDefaultFramebuffer!==void 0)ze.bindFramebuffer(G.FRAMEBUFFER,null),U=!1;else if(ie.__webglFramebuffer===void 0)L.setupRenderTarget(E);else if(ie.__hasExternalTextures)L.rebindTextures(E,Ge.get(E.texture).__webglTexture,Ge.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const fe=E.depthTexture;if(ie.__boundDepthTexture!==fe){if(fe!==null&&Ge.has(fe)&&(E.width!==fe.image.width||E.height!==fe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");L.setupDepthRenderbuffer(E)}}const he=E.texture;(he.isData3DTexture||he.isDataArrayTexture||he.isCompressedArrayTexture)&&(X=!0);const ce=Ge.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(ce[R])?P=ce[R][N]:P=ce[R],z=!0):E.samples>0&&L.useMultisampledRTT(E)===!1?P=Ge.get(E).__webglMultisampledFramebuffer:Array.isArray(ce)?P=ce[N]:P=ce,F.copy(E.viewport),K.copy(E.scissor),q=E.scissorTest}else F.copy(ae).multiplyScalar(Q).floor(),K.copy(ye).multiplyScalar(Q).floor(),q=Me;if(N!==0&&(P=x),ze.bindFramebuffer(G.FRAMEBUFFER,P)&&U&&ze.drawBuffers(E,P),ze.viewport(F),ze.scissor(K),ze.setScissorTest(q),z){const ie=Ge.get(E.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_CUBE_MAP_POSITIVE_X+R,ie.__webglTexture,N)}else if(X){const ie=Ge.get(E.texture),he=R;G.framebufferTextureLayer(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,ie.__webglTexture,N,he)}else if(E!==null&&N!==0){const ie=Ge.get(E.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,ie.__webglTexture,N)}v=-1},this.readRenderTargetPixels=function(E,R,N,U,P,z,X){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Y=Ge.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&X!==void 0&&(Y=Y[X]),Y){ze.bindFramebuffer(G.FRAMEBUFFER,Y);try{const ie=E.texture,he=ie.format,ce=ie.type;if(!pt.textureFormatReadable(he)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!pt.textureTypeReadable(ce)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}R>=0&&R<=E.width-U&&N>=0&&N<=E.height-P&&G.readPixels(R,N,U,P,We.convert(he),We.convert(ce),z)}finally{const ie=T!==null?Ge.get(T).__webglFramebuffer:null;ze.bindFramebuffer(G.FRAMEBUFFER,ie)}}},this.readRenderTargetPixelsAsync=async function(E,R,N,U,P,z,X){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Y=Ge.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&X!==void 0&&(Y=Y[X]),Y)if(R>=0&&R<=E.width-U&&N>=0&&N<=E.height-P){ze.bindFramebuffer(G.FRAMEBUFFER,Y);const ie=E.texture,he=ie.format,ce=ie.type;if(!pt.textureFormatReadable(he))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!pt.textureTypeReadable(ce))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const fe=G.createBuffer();G.bindBuffer(G.PIXEL_PACK_BUFFER,fe),G.bufferData(G.PIXEL_PACK_BUFFER,z.byteLength,G.STREAM_READ),G.readPixels(R,N,U,P,We.convert(he),We.convert(ce),0);const ge=T!==null?Ge.get(T).__webglFramebuffer:null;ze.bindFramebuffer(G.FRAMEBUFFER,ge);const _e=G.fenceSync(G.SYNC_GPU_COMMANDS_COMPLETE,0);return G.flush(),await h_(G,_e,4),G.bindBuffer(G.PIXEL_PACK_BUFFER,fe),G.getBufferSubData(G.PIXEL_PACK_BUFFER,0,z),G.deleteBuffer(fe),G.deleteSync(_e),z}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,R=null,N=0){const U=Math.pow(2,-N),P=Math.floor(E.image.width*U),z=Math.floor(E.image.height*U),X=R!==null?R.x:0,Y=R!==null?R.y:0;L.setTexture2D(E,0),G.copyTexSubImage2D(G.TEXTURE_2D,N,0,0,X,Y,P,z),ze.unbindTexture()};const B=G.createFramebuffer(),k=G.createFramebuffer();this.copyTextureToTexture=function(E,R,N=null,U=null,P=0,z=null){z===null&&(P!==0?(mc("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),z=P,P=0):z=0);let X,Y,ie,he,ce,fe,ge,_e,De;const Ke=E.isCompressedTexture?E.mipmaps[z]:E.image;if(N!==null)X=N.max.x-N.min.x,Y=N.max.y-N.min.y,ie=N.isBox3?N.max.z-N.min.z:1,he=N.min.x,ce=N.min.y,fe=N.isBox3?N.min.z:0;else{const xn=Math.pow(2,-P);X=Math.floor(Ke.width*xn),Y=Math.floor(Ke.height*xn),E.isDataArrayTexture?ie=Ke.depth:E.isData3DTexture?ie=Math.floor(Ke.depth*xn):ie=1,he=0,ce=0,fe=0}U!==null?(ge=U.x,_e=U.y,De=U.z):(ge=0,_e=0,De=0);const He=We.convert(R.format),Fe=We.convert(R.type);let st;R.isData3DTexture?(L.setTexture3D(R,0),st=G.TEXTURE_3D):R.isDataArrayTexture||R.isCompressedArrayTexture?(L.setTexture2DArray(R,0),st=G.TEXTURE_2D_ARRAY):(L.setTexture2D(R,0),st=G.TEXTURE_2D),G.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,R.flipY),G.pixelStorei(G.UNPACK_PREMULTIPLY_ALPHA_WEBGL,R.premultiplyAlpha),G.pixelStorei(G.UNPACK_ALIGNMENT,R.unpackAlignment);const Le=G.getParameter(G.UNPACK_ROW_LENGTH),wt=G.getParameter(G.UNPACK_IMAGE_HEIGHT),un=G.getParameter(G.UNPACK_SKIP_PIXELS),Et=G.getParameter(G.UNPACK_SKIP_ROWS),bt=G.getParameter(G.UNPACK_SKIP_IMAGES);G.pixelStorei(G.UNPACK_ROW_LENGTH,Ke.width),G.pixelStorei(G.UNPACK_IMAGE_HEIGHT,Ke.height),G.pixelStorei(G.UNPACK_SKIP_PIXELS,he),G.pixelStorei(G.UNPACK_SKIP_ROWS,ce),G.pixelStorei(G.UNPACK_SKIP_IMAGES,fe);const Xe=E.isDataArrayTexture||E.isData3DTexture,qt=R.isDataArrayTexture||R.isData3DTexture;if(E.isDepthTexture){const xn=Ge.get(E),Lt=Ge.get(R),dn=Ge.get(xn.__renderTarget),np=Ge.get(Lt.__renderTarget);ze.bindFramebuffer(G.READ_FRAMEBUFFER,dn.__webglFramebuffer),ze.bindFramebuffer(G.DRAW_FRAMEBUFFER,np.__webglFramebuffer);for(let Br=0;Br<ie;Br++)Xe&&(G.framebufferTextureLayer(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Ge.get(E).__webglTexture,P,fe+Br),G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Ge.get(R).__webglTexture,z,De+Br)),G.blitFramebuffer(he,ce,X,Y,ge,_e,X,Y,G.DEPTH_BUFFER_BIT,G.NEAREST);ze.bindFramebuffer(G.READ_FRAMEBUFFER,null),ze.bindFramebuffer(G.DRAW_FRAMEBUFFER,null)}else if(P!==0||E.isRenderTargetTexture||Ge.has(E)){const xn=Ge.get(E),Lt=Ge.get(R);ze.bindFramebuffer(G.READ_FRAMEBUFFER,B),ze.bindFramebuffer(G.DRAW_FRAMEBUFFER,k);for(let dn=0;dn<ie;dn++)Xe?G.framebufferTextureLayer(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,xn.__webglTexture,P,fe+dn):G.framebufferTexture2D(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,xn.__webglTexture,P),qt?G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,Lt.__webglTexture,z,De+dn):G.framebufferTexture2D(G.DRAW_FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,Lt.__webglTexture,z),P!==0?G.blitFramebuffer(he,ce,X,Y,ge,_e,X,Y,G.COLOR_BUFFER_BIT,G.NEAREST):qt?G.copyTexSubImage3D(st,z,ge,_e,De+dn,he,ce,X,Y):G.copyTexSubImage2D(st,z,ge,_e,he,ce,X,Y);ze.bindFramebuffer(G.READ_FRAMEBUFFER,null),ze.bindFramebuffer(G.DRAW_FRAMEBUFFER,null)}else qt?E.isDataTexture||E.isData3DTexture?G.texSubImage3D(st,z,ge,_e,De,X,Y,ie,He,Fe,Ke.data):R.isCompressedArrayTexture?G.compressedTexSubImage3D(st,z,ge,_e,De,X,Y,ie,He,Ke.data):G.texSubImage3D(st,z,ge,_e,De,X,Y,ie,He,Fe,Ke):E.isDataTexture?G.texSubImage2D(G.TEXTURE_2D,z,ge,_e,X,Y,He,Fe,Ke.data):E.isCompressedTexture?G.compressedTexSubImage2D(G.TEXTURE_2D,z,ge,_e,Ke.width,Ke.height,He,Ke.data):G.texSubImage2D(G.TEXTURE_2D,z,ge,_e,X,Y,He,Fe,Ke);G.pixelStorei(G.UNPACK_ROW_LENGTH,Le),G.pixelStorei(G.UNPACK_IMAGE_HEIGHT,wt),G.pixelStorei(G.UNPACK_SKIP_PIXELS,un),G.pixelStorei(G.UNPACK_SKIP_ROWS,Et),G.pixelStorei(G.UNPACK_SKIP_IMAGES,bt),z===0&&R.generateMipmaps&&G.generateMipmap(st),ze.unbindTexture()},this.copyTextureToTexture3D=function(E,R,N=null,U=null,P=0){return mc('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(E,R,N,U,P)},this.initRenderTarget=function(E){Ge.get(E).__webglFramebuffer===void 0&&L.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?L.setTextureCube(E,0):E.isData3DTexture?L.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?L.setTexture2DArray(E,0):L.setTexture2D(E,0),ze.unbindTexture()},this.resetState=function(){w=0,S=0,T=null,ze.reset(),nt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Hi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=At._getDrawingBufferColorSpace(e),t.unpackColorSpace=At._getUnpackColorSpace()}}var go=function(){var i=0,e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",function(h){h.preventDefault(),n(++i%e.children.length)},!1);function t(h){return e.appendChild(h.dom),h}function n(h){for(var u=0;u<e.children.length;u++)e.children[u].style.display=u===h?"block":"none";i=h}var s=(performance||Date).now(),r=s,a=0,o=t(new go.Panel("FPS","#0ff","#002")),c=t(new go.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var l=t(new go.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:e,addPanel:t,showPanel:n,begin:function(){s=(performance||Date).now()},end:function(){a++;var h=(performance||Date).now();if(c.update(h-s,200),h>=r+1e3&&(o.update(a*1e3/(h-r),100),r=h,a=0,l)){var u=performance.memory;l.update(u.usedJSHeapSize/1048576,u.jsHeapSizeLimit/1048576)}return h},update:function(){s=this.end()},domElement:e,setMode:n}};go.Panel=function(i,e,t){var n=1/0,s=0,r=Math.round,a=r(window.devicePixelRatio||1),o=80*a,c=48*a,l=3*a,h=2*a,u=3*a,d=15*a,f=74*a,m=30*a,g=document.createElement("canvas");g.width=o,g.height=c,g.style.cssText="width:80px;height:48px";var A=g.getContext("2d");return A.font="bold "+9*a+"px Helvetica,Arial,sans-serif",A.textBaseline="top",A.fillStyle=t,A.fillRect(0,0,o,c),A.fillStyle=e,A.fillText(i,l,h),A.fillRect(u,d,f,m),A.fillStyle=t,A.globalAlpha=.9,A.fillRect(u,d,f,m),{dom:g,update:function(p,y){n=Math.min(n,p),s=Math.max(s,p),A.fillStyle=t,A.globalAlpha=1,A.fillRect(0,0,o,d),A.fillStyle=e,A.fillText(r(p)+" "+i+" ("+r(n)+"-"+r(s)+")",l,h),A.drawImage(g,u+a,d,f-a,m,u,d,f-a,m),A.fillRect(u+f-a,d,a,m),A.fillStyle=t,A.globalAlpha=.9,A.fillRect(u+f-a,d,a,r((1-p/y)*m))}}};function lg(i,e){if(e===PE)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===Wh||e===_p){let t=i.getIndex();if(t===null){const a=[],o=i.getAttribute("position");if(o!==void 0){for(let c=0;c<o.count;c++)a.push(c);i.setIndex(a),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}const n=t.count-2,s=[];if(e===Wh)for(let a=1;a<=n;a++)s.push(t.getX(0)),s.push(t.getX(a)),s.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(s.push(t.getX(a)),s.push(t.getX(a+1)),s.push(t.getX(a+2))):(s.push(t.getX(a+2)),s.push(t.getX(a+1)),s.push(t.getX(a)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=i.clone();return r.setIndex(s),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}class Vu extends Ji{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new OS(t)}),this.register(function(t){return new QS(t)}),this.register(function(t){return new YS(t)}),this.register(function(t){return new jS(t)}),this.register(function(t){return new JS(t)}),this.register(function(t){return new HS(t)}),this.register(function(t){return new zS(t)}),this.register(function(t){return new VS(t)}),this.register(function(t){return new WS(t)}),this.register(function(t){return new US(t)}),this.register(function(t){return new qS(t)}),this.register(function(t){return new GS(t)}),this.register(function(t){return new XS(t)}),this.register(function(t){return new KS(t)}),this.register(function(t){return new PS(t)}),this.register(function(t){return new ZS(t)}),this.register(function(t){return new $S(t)})}load(e,t,n,s){const r=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const l=oa.extractUrlBase(e);a=oa.resolveURL(l,this.path)}else a=oa.extractUrlBase(e);this.manager.itemStart(e);const o=function(l){s?s(l):console.error(l),r.manager.itemError(e),r.manager.itemEnd(e)},c=new Ms(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{r.parse(l,a,function(h){t(h),r.manager.itemEnd(e)},o)}catch(h){o(h)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let r;const a={},o={},c=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===hg){try{a[ft.KHR_BINARY_GLTF]=new eI(e)}catch(u){s&&s(u);return}r=JSON.parse(a[ft.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new fI(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[u.name]=u,a[u.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const u=r.extensionsUsed[h],d=r.extensionsRequired||[];switch(u){case ft.KHR_MATERIALS_UNLIT:a[u]=new kS;break;case ft.KHR_DRACO_MESH_COMPRESSION:a[u]=new tI(r,this.dracoLoader);break;case ft.KHR_TEXTURE_TRANSFORM:a[u]=new nI;break;case ft.KHR_MESH_QUANTIZATION:a[u]=new iI;break;default:d.indexOf(u)>=0&&o[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(a),l.setPlugins(o),l.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,r){n.parse(e,t,s,r)})}}function LS(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}const ft={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class PS{constructor(e){this.parser=e,this.name=ft.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let l;const h=new qe(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],rn);const u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new MA(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new IA(h),l.distance=u;break;case"spot":l=new dy(h),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),$i(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),s=Promise.resolve(l),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(c){return n._getNodeRef(t.cache,o,c)})}}class kS{constructor(){this.name=ft.KHR_MATERIALS_UNLIT}getMaterialType(){return Cs}extendParams(e,t,n){const s=[];e.color=new qe(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const a=r.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],rn),e.opacity=a[3]}r.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",r.baseColorTexture,Kt))}return Promise.all(s)}}class US{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class OS{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Ri}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const o=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ze(o,o)}return Promise.all(r)}}class QS{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Ri}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class GS{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Ri}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(r)}}class HS{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Ri}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new qe(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=s.extensions[this.name];if(a.sheenColorFactor!==void 0){const o=a.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],rn)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,Kt)),a.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(r)}}class zS{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Ri}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(r)}}class VS{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Ri}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new qe().setRGB(o[0],o[1],o[2],rn),Promise.all(r)}}class WS{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Ri}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class qS{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Ri}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new qe().setRGB(o[0],o[1],o[2],rn),a.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,Kt)),Promise.all(r)}}class KS{constructor(e){this.parser=e,this.name=ft.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Ri}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(r)}}class XS{constructor(e){this.parser=e,this.name=ft.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Ri}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],a=s.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(r)}}class YS{constructor(e){this.parser=e,this.name=ft.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const r=s.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}class jS{constructor(e){this.parser=e,this.name=ft.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=s.images[a.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return n.loadTextureImage(e,a.source,c)}}class JS{constructor(e){this.parser=e,this.name=ft.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=s.images[a.source];let c=n.textureLoader;if(o.uri){const l=n.options.manager.getHandler(o.uri);l!==null&&(c=l)}return n.loadTextureImage(e,a.source,c)}}class ZS{constructor(e){this.name=ft.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(o){const c=s.byteOffset||0,l=s.byteLength||0,h=s.count,u=s.byteStride,d=new Uint8Array(o,c,l);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,u,d,s.mode,s.filter).then(function(f){return f.buffer}):a.ready.then(function(){const f=new ArrayBuffer(h*u);return a.decodeGltfBuffer(new Uint8Array(f),h,u,d,s.mode,s.filter),f})})}else return null}}class $S{constructor(e){this.name=ft.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const l of s.primitives)if(l.mode!==$n.TRIANGLES&&l.mode!==$n.TRIANGLE_STRIP&&l.mode!==$n.TRIANGLE_FAN&&l.mode!==void 0)return null;const a=n.extensions[this.name].attributes,o=[],c={};for(const l in a)o.push(this.parser.getDependency("accessor",a[l]).then(h=>(c[l]=h,c[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(l=>{const h=l.pop(),u=h.isGroup?h.children:[h],d=l[0].count,f=[];for(const m of u){const g=new et,A=new H,p=new Vn,y=new H(1,1,1),b=new uA(m.geometry,m.material,d);for(let _=0;_<d;_++)c.TRANSLATION&&A.fromBufferAttribute(c.TRANSLATION,_),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,_),c.SCALE&&y.fromBufferAttribute(c.SCALE,_),b.setMatrixAt(_,g.compose(A,p,y));for(const _ in c)if(_==="_COLOR_0"){const M=c[_];b.instanceColor=new Eu(M.array,M.itemSize,M.normalized)}else _!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&m.geometry.setAttribute(_,c[_]);Pt.prototype.copy.call(b,m),this.parser.assignFinalMaterial(b),f.push(b)}return h.isGroup?(h.clear(),h.add(...f),h):f[0]}))}}const hg="glTF",mo=12,ug={JSON:1313821514,BIN:5130562};class eI{constructor(e){this.name=ft.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,mo),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==hg)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-mo,r=new DataView(e,mo);let a=0;for(;a<s;){const o=r.getUint32(a,!0);a+=4;const c=r.getUint32(a,!0);if(a+=4,c===ug.JSON){const l=new Uint8Array(e,mo+a,o);this.content=n.decode(l)}else if(c===ug.BIN){const l=mo+a;this.body=e.slice(l,l+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class tI{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ft.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},c={},l={};for(const h in a){const u=qu[h]||h.toLowerCase();o[u]=a[h]}for(const h in e.attributes){const u=qu[h]||h.toLowerCase();if(a[h]!==void 0){const d=n.accessors[e.attributes[h]],f=ua[d.componentType];l[u]=f.name,c[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,d){s.decodeDracoFile(h,function(f){for(const m in f.attributes){const g=f.attributes[m],A=c[m];A!==void 0&&(g.normalized=A)}u(f)},o,l,rn,d)})})}}class nI{constructor(){this.name=ft.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class iI{constructor(){this.name=ft.KHR_MESH_QUANTIZATION}}class dg extends uo{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let a=0;a!==s;a++)t[a]=n[r+a];return t}interpolate_(e,t,n,s){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=o*2,l=o*3,h=s-t,u=(n-t)/h,d=u*u,f=d*u,m=e*l,g=m-l,A=-2*f+3*d,p=f-d,y=1-A,b=p-d+u;for(let _=0;_!==o;_++){const M=a[g+_+o],w=a[g+_+c]*h,S=a[m+_+o],T=a[m+_]*h;r[_]=y*M+b*w+A*S+p*T}return r}}const sI=new Vn;class rI extends dg{interpolate_(e,t,n,s){const r=super.interpolate_(e,t,n,s);return sI.fromArray(r).normalize().toArray(r),r}}const $n={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ua={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},fg={9728:In,9729:zt,9984:dp,9985:rc,9986:Qa,9987:Jn},pg={33071:ai,33648:sc,10497:Lr},Wu={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qu={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Ts={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},aI={CUBICSPLINE:void 0,LINEAR:Ja,STEP:ja},Ku={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function oI(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new ho({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Qi})),i.DefaultMaterial}function ar(i,e,t){for(const n in t.extensions)i[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function $i(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function cI(i,e,t){let n=!1,s=!1,r=!1;for(let l=0,h=e.length;l<h;l++){const u=e[l];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(s=!0),u.COLOR_0!==void 0&&(r=!0),n&&s&&r)break}if(!n&&!s&&!r)return Promise.resolve(i);const a=[],o=[],c=[];for(let l=0,h=e.length;l<h;l++){const u=e[l];if(n){const d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):i.attributes.position;a.push(d)}if(s){const d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):i.attributes.normal;o.push(d)}if(r){const d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):i.attributes.color;c.push(d)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c)]).then(function(l){const h=l[0],u=l[1],d=l[2];return n&&(i.morphAttributes.position=h),s&&(i.morphAttributes.normal=u),r&&(i.morphAttributes.color=d),i.morphTargetsRelative=!0,i})}function lI(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)i.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function hI(i){let e;const t=i.extensions&&i.extensions[ft.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Xu(t.attributes):e=i.indices+":"+Xu(i.attributes)+":"+i.mode,i.targets!==void 0)for(let n=0,s=i.targets.length;n<s;n++)e+=":"+Xu(i.targets[n]);return e}function Xu(i){let e="";const t=Object.keys(i).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+i[t[n]]+";";return e}function Yu(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function uI(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":i.search(/\.ktx2($|\?)/i)>0||i.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const dI=new et;class fI{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new LS,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=-1,r=!1,a=-1;if(typeof navigator<"u"){const o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;const c=o.match(/Version\/(\d+)/);s=n&&c?parseInt(c[1],10):-1,r=o.indexOf("Firefox")>-1,a=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||r&&a<98?this.textureLoader=new ly(this.options.manager):this.textureLoader=new gy(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ms(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const o={scene:a[0][s.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:s.asset,parser:n,userData:{}};return ar(r,o,s),$i(o,s),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(o)})).then(function(){for(const c of o.scenes)c.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){const a=t[s].joints;for(let o=0,c=a.length;o<c;o++)e[a[o]].isBone=!0}for(let s=0,r=e.length;s<r;s++){const a=e[s];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),r=(a,o)=>{const c=this.associations.get(a);c!=null&&this.associations.set(o,c);for(const[l,h]of a.children.entries())r(h,o.children[l])};return r(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const r=e(t[s]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(r,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[ft.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(r,a){n.load(oa.resolveURL(t.uri,s.path),r,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const s=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const a=Wu[s.type],o=ua[s.componentType],c=s.normalized===!0,l=new o(s.count*a);return Promise.resolve(new En(l,a,c))}const r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(a){const o=a[0],c=Wu[s.type],l=ua[s.componentType],h=l.BYTES_PER_ELEMENT,u=h*c,d=s.byteOffset||0,f=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,m=s.normalized===!0;let g,A;if(f&&f!==u){const p=Math.floor(d/f),y="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+p+":"+s.count;let b=t.cache.get(y);b||(g=new l(o,p*f,s.count*f/h),b=new O_(g,f/h),t.cache.add(y,b)),A=new gu(b,c,d%f/h,m)}else o===null?g=new l(s.count*c):g=new l(o,d,s.count*c),A=new En(g,c,m);if(s.sparse!==void 0){const p=Wu.SCALAR,y=ua[s.sparse.indices.componentType],b=s.sparse.indices.byteOffset||0,_=s.sparse.values.byteOffset||0,M=new y(a[1],b,s.sparse.count*p),w=new l(a[2],_,s.sparse.count*c);o!==null&&(A=new En(A.array.slice(),A.itemSize,A.normalized)),A.normalized=!1;for(let S=0,T=M.length;S<T;S++){const v=M[S];if(A.setX(v,w[S*c]),c>=2&&A.setY(v,w[S*c+1]),c>=3&&A.setZ(v,w[S*c+2]),c>=4&&A.setW(v,w[S*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}A.normalized=m}return A})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,a=t.images[r];let o=this.textureLoader;if(a.uri){const c=n.manager.getHandler(a.uri);c!==null&&(o=c)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){const s=this,r=this.json,a=r.textures[e],o=r.images[t],c=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=a.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const d=(r.samplers||{})[a.sampler]||{};return h.magFilter=fg[d.magFilter]||zt,h.minFilter=fg[d.minFilter]||Jn,h.wrapS=pg[d.wrapS]||Lr,h.wrapT=pg[d.wrapT]||Lr,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==In&&h.minFilter!==zt,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const a=s.images[e],o=self.URL||self.webkitURL;let c=a.uri||"",l=!1;if(a.bufferView!==void 0)c=n.getDependency("bufferView",a.bufferView).then(function(u){l=!0;const d=new Blob([u],{type:a.mimeType});return c=o.createObjectURL(d),c});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(c).then(function(u){return new Promise(function(d,f){let m=d;t.isImageBitmapLoader===!0&&(m=function(g){const A=new an(g);A.needsUpdate=!0,d(A)}),t.load(oa.resolveURL(u,r.path),m,void 0,f)})}).then(function(u){return l===!0&&o.revokeObjectURL(c),$i(u,a),u.userData.mimeType=a.mimeType||uI(a.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,s){const r=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),r.extensions[ft.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[ft.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const c=r.associations.get(a);a=r.extensions[ft.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),r.associations.set(a,c)}}return s!==void 0&&(a.colorSpace=s),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new vu,Ti.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(o,c)),n=c}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let c=this.cache.get(o);c||(c=new co,Ti.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(o,c)),n=c}if(s||r||a){let o="ClonedMaterial:"+n.uuid+":";s&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let c=this.cache.get(o);c||(c=n.clone(),r&&(c.vertexColors=!0),a&&(c.flatShading=!0),s&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(o,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return ho}loadMaterial(e){const t=this,n=this.json,s=this.extensions,r=n.materials[e];let a;const o={},c=r.extensions||{},l=[];if(c[ft.KHR_MATERIALS_UNLIT]){const u=s[ft.KHR_MATERIALS_UNLIT];a=u.getMaterialType(),l.push(u.extendParams(o,r,t))}else{const u=r.pbrMetallicRoughness||{};if(o.color=new qe(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],rn),o.opacity=d[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(o,"map",u.baseColorTexture,Kt)),o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),a=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=Si);const h=r.alphaMode||Ku.OPAQUE;if(h===Ku.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===Ku.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&a!==Cs&&(l.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Ze(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;o.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&a!==Cs&&(l.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&a!==Cs){const u=r.emissiveFactor;o.emissive=new qe().setRGB(u[0],u[1],u[2],rn)}return r.emissiveTexture!==void 0&&a!==Cs&&l.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Kt)),Promise.all(l).then(function(){const u=new a(o);return r.name&&(u.name=r.name),$i(u,r),t.associations.set(u,{materials:e}),r.extensions&&ar(s,u,r),u})}createUniqueName(e){const t=Ct.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function r(o){return n[ft.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(c){return Ag(c,o,t)})}const a=[];for(let o=0,c=e.length;o<c;o++){const l=e[o],h=hI(l),u=s[h];if(u)a.push(u.promise);else{let d;l.extensions&&l.extensions[ft.KHR_DRACO_MESH_COMPRESSION]?d=r(l):d=Ag(new On,l,t),s[h]={primitive:l,promise:d},a.push(d)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,s=this.extensions,r=n.meshes[e],a=r.primitives,o=[];for(let c=0,l=a.length;c<l;c++){const h=a[c].material===void 0?oI(this.cache):this.getDependency("material",a[c].material);o.push(h)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(c){const l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let f=0,m=h.length;f<m;f++){const g=h[f],A=a[f];let p;const y=l[f];if(A.mode===$n.TRIANGLES||A.mode===$n.TRIANGLE_STRIP||A.mode===$n.TRIANGLE_FAN||A.mode===void 0)p=r.isSkinnedMesh===!0?new G_(g,y):new Jt(g,y),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),A.mode===$n.TRIANGLE_STRIP?p.geometry=lg(p.geometry,_p):A.mode===$n.TRIANGLE_FAN&&(p.geometry=lg(p.geometry,Wh));else if(A.mode===$n.LINES)p=new Hc(g,y);else if(A.mode===$n.LINE_STRIP)p=new Cu(g,y);else if(A.mode===$n.LINE_LOOP)p=new q_(g,y);else if(A.mode===$n.POINTS)p=new K_(g,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+A.mode);Object.keys(p.geometry.morphAttributes).length>0&&lI(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),$i(p,r),A.extensions&&ar(s,p,A),t.assignFinalMaterial(p),u.push(p)}for(let f=0,m=u.length;f<m;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return r.extensions&&ar(s,u[0],r),u[0];const d=new er;r.extensions&&ar(s,d,r),t.associations.set(d,{meshes:e});for(let f=0,m=u.length;f<m;f++)d.add(u[f]);return d})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new vn(Ip.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new Ru(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),$i(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,r=t.joints.length;s<r;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const r=s.pop(),a=s,o=[],c=[];for(let l=0,h=a.length;l<h;l++){const u=a[l];if(u){o.push(u);const d=new et;r!==null&&d.fromArray(r.array,l*16),c.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new xu(o,c)})}loadAnimation(e){const t=this.json,n=this,s=t.animations[e],r=s.name?s.name:"animation_"+e,a=[],o=[],c=[],l=[],h=[];for(let u=0,d=s.channels.length;u<d;u++){const f=s.channels[u],m=s.samplers[f.sampler],g=f.target,A=g.node,p=s.parameters!==void 0?s.parameters[m.input]:m.input,y=s.parameters!==void 0?s.parameters[m.output]:m.output;g.node!==void 0&&(a.push(this.getDependency("node",A)),o.push(this.getDependency("accessor",p)),c.push(this.getDependency("accessor",y)),l.push(m),h.push(g))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){const d=u[0],f=u[1],m=u[2],g=u[3],A=u[4],p=[];for(let y=0,b=d.length;y<b;y++){const _=d[y],M=f[y],w=m[y],S=g[y],T=A[y];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const v=n._createAnimationTracks(_,M,w,S,T);if(v)for(let C=0;C<v.length;C++)p.push(v[C])}return new Iu(r,void 0,p)})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(r){const a=n._getNodeRef(n.meshCache,s.mesh,r);return s.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let c=0,l=s.weights.length;c<l;c++)o.morphTargetInfluences[c]=s.weights[c]}),a})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],r=n._loadNodeShallow(e),a=[],o=s.children||[];for(let l=0,h=o.length;l<h;l++)a.push(n.getDependency("node",o[l]));const c=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([r,Promise.all(a),c]).then(function(l){const h=l[0],u=l[1],d=l[2];d!==null&&h.traverse(function(f){f.isSkinnedMesh&&f.bind(d,dI)});for(let f=0,m=u.length;f<m;f++)h.add(u[f]);return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],a=r.name?s.createUniqueName(r.name):"",o=[],c=s._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&o.push(c),r.camera!==void 0&&o.push(s.getDependency("camera",r.camera).then(function(l){return s._getNodeRef(s.cameraCache,r.camera,l)})),s._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){o.push(l)}),this.nodeCache[e]=Promise.all(o).then(function(l){let h;if(r.isBone===!0?h=new oA:l.length>1?h=new er:l.length===1?h=l[0]:h=new Pt,h!==l[0])for(let u=0,d=l.length;u<d;u++)h.add(l[u]);if(r.name&&(h.userData.name=r.name,h.name=a),$i(h,r),r.extensions&&ar(n,h,r),r.matrix!==void 0){const u=new et;u.fromArray(r.matrix),h.applyMatrix4(u)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);return s.associations.has(h)||s.associations.set(h,{}),s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,r=new er;n.name&&(r.name=s.createUniqueName(n.name)),$i(r,n),n.extensions&&ar(t,r,n);const a=n.nodes||[],o=[];for(let c=0,l=a.length;c<l;c++)o.push(s.getDependency("node",a[c]));return Promise.all(o).then(function(c){for(let h=0,u=c.length;h<u;h++)r.add(c[h]);const l=h=>{const u=new Map;for(const[d,f]of s.associations)(d instanceof Ti||d instanceof an)&&u.set(d,f);return h.traverse(d=>{const f=s.associations.get(d);f!=null&&u.set(d,f)}),u};return s.associations=l(r),r})}_createAnimationTracks(e,t,n,s,r){const a=[],o=e.name?e.name:e.uuid,c=[];Ts[r.path]===Ts.weights?e.traverse(function(d){d.morphTargetInfluences&&c.push(d.name?d.name:d.uuid)}):c.push(o);let l;switch(Ts[r.path]){case Ts.weights:l=ia;break;case Ts.rotation:l=sa;break;case Ts.translation:case Ts.scale:l=aa;break;default:n.itemSize===1?l=ia:l=aa;break}const h=s.interpolation!==void 0?aI[s.interpolation]:Ja,u=this._getArrayFromAccessor(n);for(let d=0,f=c.length;d<f;d++){const m=new l(c[d]+"."+Ts[r.path],t.array,u,h);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),a.push(m)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Yu(t.constructor),s=new Float32Array(t.length);for(let r=0,a=t.length;r<a;r++)s[r]=t[r]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const s=this instanceof sa?rI:dg;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function pI(i,e,t){const n=e.attributes,s=new Ii;if(n.POSITION!==void 0){const o=t.json.accessors[n.POSITION],c=o.min,l=o.max;if(c!==void 0&&l!==void 0){if(s.set(new H(c[0],c[1],c[2]),new H(l[0],l[1],l[2])),o.normalized){const h=Yu(ua[o.componentType]);s.min.multiplyScalar(h),s.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const o=new H,c=new H;for(let l=0,h=r.length;l<h;l++){const u=r[l];if(u.POSITION!==void 0){const d=t.json.accessors[u.POSITION],f=d.min,m=d.max;if(f!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),d.normalized){const g=Yu(ua[d.componentType]);c.multiplyScalar(g)}o.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(o)}i.boundingBox=s;const a=new Mi;s.getCenter(a.center),a.radius=s.min.distanceTo(s.max)/2,i.boundingSphere=a}function Ag(i,e,t){const n=e.attributes,s=[];function r(a,o){return t.getDependency("accessor",a).then(function(c){i.setAttribute(o,c)})}for(const a in n){const o=qu[a]||a.toLowerCase();o in i.attributes||s.push(r(n[a],o))}if(e.indices!==void 0&&!i.index){const a=t.getDependency("accessor",e.indices).then(function(o){i.setIndex(o)});s.push(a)}return At.workingColorSpace!==rn&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${At.workingColorSpace}" not supported.`),$i(i,e),pI(i,e,t),Promise.all(s).then(function(){return e.targets!==void 0?cI(i,e.targets,t):i})}var AI=(function(){var i="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),n=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var s=WebAssembly.validate(t)?e:i,r,a=WebAssembly.instantiate(o(s),{}).then(function(p){r=p.instance,r.exports.__wasm_call_ctors()});function o(p){for(var y=new Uint8Array(p.length),b=0;b<p.length;++b){var _=p.charCodeAt(b);y[b]=_>96?_-97:_>64?_-39:_+4}for(var M=0,b=0;b<p.length;++b)y[M++]=y[b]<60?n[y[b]]:(y[b]-60)*64+y[++b];return y.buffer.slice(0,M)}function c(p,y,b,_,M,w){var S=r.exports.sbrk,T=b+3&-4,v=S(T*_),C=S(M.length),F=new Uint8Array(r.exports.memory.buffer);F.set(M,C);var K=p(v,b,_,C,M.length);if(K==0&&w&&w(v,T,_),y.set(F.subarray(v,v+b*_)),S(v-S(0)),K!=0)throw new Error("Malformed buffer data: "+K)}var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},u=[],d=0;function f(p){var y={object:new Worker(p),pending:0,requests:{}};return y.object.onmessage=function(b){var _=b.data;y.pending-=_.count,y.requests[_.id][_.action](_.value),delete y.requests[_.id]},y}function m(p){for(var y="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(o(s))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+c.toString()+A.toString(),b=new Blob([y],{type:"text/javascript"}),_=URL.createObjectURL(b),M=0;M<p;++M)u[M]=f(_);URL.revokeObjectURL(_)}function g(p,y,b,_,M){for(var w=u[0],S=1;S<u.length;++S)u[S].pending<w.pending&&(w=u[S]);return new Promise(function(T,v){var C=new Uint8Array(b),F=d++;w.pending+=p,w.requests[F]={resolve:T,reject:v},w.object.postMessage({id:F,count:p,size:y,source:C,mode:_,filter:M},[C.buffer])})}function A(p){a.then(function(){var y=p.data;try{var b=new Uint8Array(y.count*y.size);c(r.exports[y.mode],b,y.count,y.size,y.source,r.exports[y.filter]),self.postMessage({id:y.id,count:y.count,action:"resolve",value:b},[b.buffer])}catch(_){self.postMessage({id:y.id,count:y.count,action:"reject",value:_})}})}return{ready:a,supported:!0,useWorkers:function(p){m(p)},decodeVertexBuffer:function(p,y,b,_,M){c(r.exports.meshopt_decodeVertexBuffer,p,y,b,_,r.exports[l[M]])},decodeIndexBuffer:function(p,y,b,_){c(r.exports.meshopt_decodeIndexBuffer,p,y,b,_)},decodeIndexSequence:function(p,y,b,_){c(r.exports.meshopt_decodeIndexSequence,p,y,b,_)},decodeGltfBuffer:function(p,y,b,_,M,w){c(r.exports[h[M]],p,y,b,_,r.exports[l[w]])},decodeGltfBufferAsync:function(p,y,b,_,M){return u.length>0?g(p,y,b,h[_],l[M]):a.then(function(){var w=new Uint8Array(p*y);return c(r.exports[h[_]],w,p,y,b,r.exports[l[M]]),w})}}})();const gg={type:"change"},ju={type:"start"},mg={type:"end"},el=new io,bg=new Is,gI=Math.cos(70*Ip.DEG2RAD),ln=new H,Qn=2*Math.PI,Bt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ju=1e-6;class mI extends Ny{constructor(e,t=null){super(e,t),this.state=Bt.NONE,this.target=new H,this.cursor=new H,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Tr.ROTATE,MIDDLE:Tr.DOLLY,RIGHT:Tr.PAN},this.touches={ONE:Rr.ROTATE,TWO:Rr.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new H,this._lastQuaternion=new Vn,this._lastTargetPosition=new H,this._quat=new Vn().setFromUnitVectors(e.up,new H(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new TA,this._sphericalDelta=new TA,this._scale=1,this._panOffset=new H,this._rotateStart=new Ze,this._rotateEnd=new Ze,this._rotateDelta=new Ze,this._panStart=new Ze,this._panEnd=new Ze,this._panDelta=new Ze,this._dollyStart=new Ze,this._dollyEnd=new Ze,this._dollyDelta=new Ze,this._dollyDirection=new H,this._mouse=new Ze,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=xI.bind(this),this._onPointerDown=bI.bind(this),this._onPointerUp=EI.bind(this),this._onContextMenu=II.bind(this),this._onMouseWheel=wI.bind(this),this._onKeyDown=CI.bind(this),this._onTouchStart=vI.bind(this),this._onTouchMove=SI.bind(this),this._onMouseDown=_I.bind(this),this._onMouseMove=yI.bind(this),this._interceptControlDown=MI.bind(this),this._interceptControlUp=BI.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(gg),this.update(),this.state=Bt.NONE}update(e=null){const t=this.object.position;ln.copy(t).sub(this.target),ln.applyQuaternion(this._quat),this._spherical.setFromVector3(ln),this.autoRotate&&this.state===Bt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=Qn:n>Math.PI&&(n-=Qn),s<-Math.PI?s+=Qn:s>Math.PI&&(s-=Qn),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(ln.setFromSpherical(this._spherical),ln.applyQuaternion(this._quatInverse),t.copy(this.target).add(ln),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=ln.length();a=this._clampDistance(o*this._scale);const c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){const o=new H(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=c!==this.object.zoom;const l=new H(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=ln.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(el.origin.copy(this.object.position),el.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(el.direction))<gI?this.object.lookAt(this.target):(bg.setFromNormalAndCoplanarPoint(this.object.up,this.target),el.intersectPlane(bg,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Ju||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ju||this._lastTargetPosition.distanceToSquared(this.target)>Ju?(this.dispatchEvent(gg),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Qn/60*this.autoRotateSpeed*e:Qn/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ln.setFromMatrixColumn(t,0),ln.multiplyScalar(-e),this._panOffset.add(ln)}_panUp(e,t){this.screenSpacePanning===!0?ln.setFromMatrixColumn(t,1):(ln.setFromMatrixColumn(t,0),ln.crossVectors(this.object.up,ln)),ln.multiplyScalar(e),this._panOffset.add(ln)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;ln.copy(s).sub(this.target);let r=ln.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Qn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Qn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Qn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Qn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Qn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Qn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Qn*this._rotateDelta.x/t.clientHeight),this._rotateUp(Qn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ze,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function bI(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function xI(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function EI(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(mg),this.state=Bt.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function _I(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Tr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Bt.DOLLY;break;case Tr.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Bt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Bt.ROTATE}break;case Tr.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Bt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Bt.PAN}break;default:this.state=Bt.NONE}this.state!==Bt.NONE&&this.dispatchEvent(ju)}function yI(i){switch(this.state){case Bt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Bt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Bt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function wI(i){this.enabled===!1||this.enableZoom===!1||this.state!==Bt.NONE||(i.preventDefault(),this.dispatchEvent(ju),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(mg))}function CI(i){this.enabled!==!1&&this._handleKeyDown(i)}function vI(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case Rr.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Bt.TOUCH_ROTATE;break;case Rr.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Bt.TOUCH_PAN;break;default:this.state=Bt.NONE}break;case 2:switch(this.touches.TWO){case Rr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Bt.TOUCH_DOLLY_PAN;break;case Rr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Bt.TOUCH_DOLLY_ROTATE;break;default:this.state=Bt.NONE}break;default:this.state=Bt.NONE}this.state!==Bt.NONE&&this.dispatchEvent(ju)}function SI(i){switch(this._trackPointer(i),this.state){case Bt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Bt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Bt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Bt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Bt.NONE}}function II(i){this.enabled!==!1&&i.preventDefault()}function MI(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function BI(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class TI extends Au{constructor(){super();const e=new Jr;e.deleteAttribute("uv");const t=new ho({side:Sn}),n=new ho,s=new IA(16777215,900,28,2);s.position.set(.418,16.199,.3),this.add(s);const r=new Jt(e,t);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const a=new uA(e,n,6),o=new Pt;o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),o.updateMatrix(),a.setMatrixAt(0,o.matrix),o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),o.updateMatrix(),a.setMatrixAt(1,o.matrix),o.position.set(6.167,.857,7.803),o.rotation.set(0,.561,0),o.scale.set(3.927,6.285,3.687),o.updateMatrix(),a.setMatrixAt(2,o.matrix),o.position.set(-2.017,.018,6.124),o.rotation.set(0,.333,0),o.scale.set(2.002,4.566,2.064),o.updateMatrix(),a.setMatrixAt(3,o.matrix),o.position.set(2.291,-.756,-2.621),o.rotation.set(0,-.286,0),o.scale.set(1.546,1.552,1.496),o.updateMatrix(),a.setMatrixAt(4,o.matrix),o.position.set(-2.193,-.369,-5.547),o.rotation.set(0,.516,0),o.scale.set(3.875,3.487,2.986),o.updateMatrix(),a.setMatrixAt(5,o.matrix),this.add(a);const c=new Jt(e,da(50));c.position.set(-16.116,14.37,8.208),c.scale.set(.1,2.428,2.739),this.add(c);const l=new Jt(e,da(50));l.position.set(-16.109,18.021,-8.207),l.scale.set(.1,2.425,2.751),this.add(l);const h=new Jt(e,da(17));h.position.set(14.904,12.198,-1.832),h.scale.set(.15,4.265,6.331),this.add(h);const u=new Jt(e,da(43));u.position.set(-.462,8.89,14.52),u.scale.set(4.38,5.441,.088),this.add(u);const d=new Jt(e,da(20));d.position.set(3.235,11.486,-12.541),d.scale.set(2.5,2,.1),this.add(d);const f=new Jt(e,da(100));f.position.set(0,20,0),f.scale.set(1,.1,1),this.add(f)}dispose(){const e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(const t of e)t.dispose()}}function da(i){const e=new Cs;return e.color.setScalar(i),e}function RI(i){if(!(typeof window>"u")){var e=document.createElement("style");return e.setAttribute("type","text/css"),e.innerHTML=i,document.head.appendChild(e),i}}function fa(i,e){var t=i.__state.conversionName.toString(),n=Math.round(i.r),s=Math.round(i.g),r=Math.round(i.b),a=i.a,o=Math.round(i.h),c=i.s.toFixed(1),l=i.v.toFixed(1);if(e||t==="THREE_CHAR_HEX"||t==="SIX_CHAR_HEX"){for(var h=i.hex.toString(16);h.length<6;)h="0"+h;return"#"+h}else{if(t==="CSS_RGB")return"rgb("+n+","+s+","+r+")";if(t==="CSS_RGBA")return"rgba("+n+","+s+","+r+","+a+")";if(t==="HEX")return"0x"+i.hex.toString(16);if(t==="RGB_ARRAY")return"["+n+","+s+","+r+"]";if(t==="RGBA_ARRAY")return"["+n+","+s+","+r+","+a+"]";if(t==="RGB_OBJ")return"{r:"+n+",g:"+s+",b:"+r+"}";if(t==="RGBA_OBJ")return"{r:"+n+",g:"+s+",b:"+r+",a:"+a+"}";if(t==="HSV_OBJ")return"{h:"+o+",s:"+c+",v:"+l+"}";if(t==="HSVA_OBJ")return"{h:"+o+",s:"+c+",v:"+l+",a:"+a+"}"}return"unknown format"}var xg=Array.prototype.forEach,bo=Array.prototype.slice,ue={BREAK:{},extend:function(e){return this.each(bo.call(arguments,1),function(t){var n=this.isObject(t)?Object.keys(t):[];n.forEach((function(s){this.isUndefined(t[s])||(e[s]=t[s])}).bind(this))},this),e},defaults:function(e){return this.each(bo.call(arguments,1),function(t){var n=this.isObject(t)?Object.keys(t):[];n.forEach((function(s){this.isUndefined(e[s])&&(e[s]=t[s])}).bind(this))},this),e},compose:function(){var e=bo.call(arguments);return function(){for(var t=bo.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e){if(xg&&e.forEach&&e.forEach===xg)e.forEach(t,n);else if(e.length===e.length+0){var s=void 0,r=void 0;for(s=0,r=e.length;s<r;s++)if(s in e&&t.call(n,e[s],s)===this.BREAK)return}else for(var a in e)if(t.call(n,e[a],a)===this.BREAK)return}},defer:function(e){setTimeout(e,0)},debounce:function(e,t,n){var s=void 0;return function(){var r=this,a=arguments;function o(){s=null,n||e.apply(r,a)}var c=n||!s;clearTimeout(s),s=setTimeout(o,t),c&&e.apply(r,a)}},toArray:function(e){return e.toArray?e.toArray():bo.call(e)},isUndefined:function(e){return e===void 0},isNull:function(e){return e===null},isNaN:(function(i){function e(t){return i.apply(this,arguments)}return e.toString=function(){return i.toString()},e})(function(i){return isNaN(i)}),isArray:Array.isArray||function(i){return i.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return e===!1||e===!0},isFunction:function(e){return e instanceof Function}},NI=[{litmus:ue.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return t===null?!1:{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString(),0)}},write:fa},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return t===null?!1:{space:"HEX",hex:parseInt("0x"+t[1].toString(),0)}},write:fa},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return t===null?!1:{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:fa},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/);return t===null?!1:{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:fa}}},{litmus:ue.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:ue.isArray,conversions:{RGB_ARRAY:{read:function(e){return e.length!==3?!1:{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return e.length!==4?!1:{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:ue.isObject,conversions:{RGBA_OBJ:{read:function(e){return ue.isNumber(e.r)&&ue.isNumber(e.g)&&ue.isNumber(e.b)&&ue.isNumber(e.a)?{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}:!1},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return ue.isNumber(e.r)&&ue.isNumber(e.g)&&ue.isNumber(e.b)?{space:"RGB",r:e.r,g:e.g,b:e.b}:!1},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return ue.isNumber(e.h)&&ue.isNumber(e.s)&&ue.isNumber(e.v)&&ue.isNumber(e.a)?{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}:!1},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return ue.isNumber(e.h)&&ue.isNumber(e.s)&&ue.isNumber(e.v)?{space:"HSV",h:e.h,s:e.s,v:e.v}:!1},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}],xo=void 0,tl=void 0,Zu=function(){tl=!1;var e=arguments.length>1?ue.toArray(arguments):arguments[0];return ue.each(NI,function(t){if(t.litmus(e))return ue.each(t.conversions,function(n,s){if(xo=n.read(e),tl===!1&&xo!==!1)return tl=xo,xo.conversionName=s,xo.conversion=n,ue.BREAK}),ue.BREAK}),tl},Eg=void 0,nl={hsv_to_rgb:function(e,t,n){var s=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),a=n*(1-t),o=n*(1-r*t),c=n*(1-(1-r)*t),l=[[n,c,a],[o,n,a],[a,n,c],[a,o,n],[c,a,n],[n,a,o]][s];return{r:l[0]*255,g:l[1]*255,b:l[2]*255}},rgb_to_hsv:function(e,t,n){var s=Math.min(e,t,n),r=Math.max(e,t,n),a=r-s,o=void 0,c=void 0;if(r!==0)c=a/r;else return{h:NaN,s:0,v:0};return e===r?o=(t-n)/a:t===r?o=2+(n-e)/a:o=4+(e-t)/a,o/=6,o<0&&(o+=1),{h:o*360,s:c,v:r/255}},rgb_to_hex:function(e,t,n){var s=this.hex_with_component(0,2,e);return s=this.hex_with_component(s,1,t),s=this.hex_with_component(s,0,n),s},component_from_hex:function(e,t){return e>>t*8&255},hex_with_component:function(e,t,n){return n<<(Eg=t*8)|e&~(255<<Eg)}},FI=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},Ai=function(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")},gi=(function(){function i(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}return function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}})(),Rs=function i(e,t,n){e===null&&(e=Function.prototype);var s=Object.getOwnPropertyDescriptor(e,t);if(s===void 0){var r=Object.getPrototypeOf(e);return r===null?void 0:i(r,t,n)}else{if("value"in s)return s.value;var a=s.get;return a===void 0?void 0:a.call(n)}},Ns=function(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof e);i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(i,e):i.__proto__=e)},Fs=function(i,e){if(!i)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e&&(typeof e=="object"||typeof e=="function")?e:i},pn=(function(){function i(){if(Ai(this,i),this.__state=Zu.apply(this,arguments),this.__state===!1)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return gi(i,[{key:"toString",value:function(){return fa(this)}},{key:"toHexString",value:function(){return fa(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),i})();function $u(i,e,t){Object.defineProperty(i,e,{get:function(){return this.__state.space==="RGB"?this.__state[e]:(pn.recalculateRGB(this,e,t),this.__state[e])},set:function(s){this.__state.space!=="RGB"&&(pn.recalculateRGB(this,e,t),this.__state.space="RGB"),this.__state[e]=s}})}function ed(i,e){Object.defineProperty(i,e,{get:function(){return this.__state.space==="HSV"?this.__state[e]:(pn.recalculateHSV(this),this.__state[e])},set:function(n){this.__state.space!=="HSV"&&(pn.recalculateHSV(this),this.__state.space="HSV"),this.__state[e]=n}})}pn.recalculateRGB=function(i,e,t){if(i.__state.space==="HEX")i.__state[e]=nl.component_from_hex(i.__state.hex,t);else if(i.__state.space==="HSV")ue.extend(i.__state,nl.hsv_to_rgb(i.__state.h,i.__state.s,i.__state.v));else throw new Error("Corrupted color state")},pn.recalculateHSV=function(i){var e=nl.rgb_to_hsv(i.r,i.g,i.b);ue.extend(i.__state,{s:e.s,v:e.v}),ue.isNaN(e.h)?ue.isUndefined(i.__state.h)&&(i.__state.h=0):i.__state.h=e.h},pn.COMPONENTS=["r","g","b","h","s","v","hex","a"],$u(pn.prototype,"r",2),$u(pn.prototype,"g",1),$u(pn.prototype,"b",0),ed(pn.prototype,"h"),ed(pn.prototype,"s"),ed(pn.prototype,"v"),Object.defineProperty(pn.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(pn.prototype,"hex",{get:function(){return this.__state.space!=="HEX"&&(this.__state.hex=nl.rgb_to_hex(this.r,this.g,this.b),this.__state.space="HEX"),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}});var or=(function(){function i(e,t){Ai(this,i),this.initialValue=e[t],this.domElement=document.createElement("div"),this.object=e,this.property=t,this.__onChange=void 0,this.__onFinishChange=void 0}return gi(i,[{key:"onChange",value:function(t){return this.__onChange=t,this}},{key:"onFinishChange",value:function(t){return this.__onFinishChange=t,this}},{key:"setValue",value:function(t){return this.object[this.property]=t,this.__onChange&&this.__onChange.call(this,t),this.updateDisplay(),this}},{key:"getValue",value:function(){return this.object[this.property]}},{key:"updateDisplay",value:function(){return this}},{key:"isModified",value:function(){return this.initialValue!==this.getValue()}}]),i})(),DI={HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},_g={};ue.each(DI,function(i,e){ue.each(i,function(t){_g[t]=e})});var LI=/(\d+(\.\d+)?)px/;function Fi(i){if(i==="0"||ue.isUndefined(i))return 0;var e=i.match(LI);return ue.isNull(e)?0:parseFloat(e[1])}var te={makeSelectable:function(e,t){e===void 0||e.style===void 0||(e.onselectstart=t?function(){return!1}:function(){},e.style.MozUserSelect=t?"auto":"none",e.style.KhtmlUserSelect=t?"auto":"none",e.unselectable=t?"on":"off")},makeFullscreen:function(e,t,n){var s=n,r=t;ue.isUndefined(r)&&(r=!0),ue.isUndefined(s)&&(s=!0),e.style.position="absolute",r&&(e.style.left=0,e.style.right=0),s&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,n,s){var r=n||{},a=_g[t];if(!a)throw new Error("Event type "+t+" not supported.");var o=document.createEvent(a);switch(a){case"MouseEvents":{var c=r.x||r.clientX||0,l=r.y||r.clientY||0;o.initMouseEvent(t,r.bubbles||!1,r.cancelable||!0,window,r.clickCount||1,0,0,c,l,!1,!1,!1,!1,0,null);break}case"KeyboardEvents":{var h=o.initKeyboardEvent||o.initKeyEvent;ue.defaults(r,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),h(t,r.bubbles||!1,r.cancelable,window,r.ctrlKey,r.altKey,r.shiftKey,r.metaKey,r.keyCode,r.charCode);break}default:{o.initEvent(t,r.bubbles||!1,r.cancelable||!0);break}}ue.defaults(o,s),e.dispatchEvent(o)},bind:function(e,t,n,s){var r=s||!1;return e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on"+t,n),te},unbind:function(e,t,n,s){var r=s||!1;return e.removeEventListener?e.removeEventListener(t,n,r):e.detachEvent&&e.detachEvent("on"+t,n),te},addClass:function(e,t){if(e.className===void 0)e.className=t;else if(e.className!==t){var n=e.className.split(/ +/);n.indexOf(t)===-1&&(n.push(t),e.className=n.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return te},removeClass:function(e,t){if(t)if(e.className===t)e.removeAttribute("class");else{var n=e.className.split(/ +/),s=n.indexOf(t);s!==-1&&(n.splice(s,1),e.className=n.join(" "))}else e.className=void 0;return te},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return Fi(t["border-left-width"])+Fi(t["border-right-width"])+Fi(t["padding-left"])+Fi(t["padding-right"])+Fi(t.width)},getHeight:function(e){var t=getComputedStyle(e);return Fi(t["border-top-width"])+Fi(t["border-bottom-width"])+Fi(t["padding-top"])+Fi(t["padding-bottom"])+Fi(t.height)},getOffset:function(e){var t=e,n={left:0,top:0};if(t.offsetParent)do n.left+=t.offsetLeft,n.top+=t.offsetTop,t=t.offsetParent;while(t);return n},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}},yg=(function(i){Ns(e,i);function e(t,n){Ai(this,e);var s=Fs(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),r=s;s.__prev=s.getValue(),s.__checkbox=document.createElement("input"),s.__checkbox.setAttribute("type","checkbox");function a(){r.setValue(!r.__prev)}return te.bind(s.__checkbox,"change",a,!1),s.domElement.appendChild(s.__checkbox),s.updateDisplay(),s}return gi(e,[{key:"setValue",value:function(n){var s=Rs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,n);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),s}},{key:"updateDisplay",value:function(){return this.getValue()===!0?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0,this.__prev=!0):(this.__checkbox.checked=!1,this.__prev=!1),Rs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e})(or),PI=(function(i){Ns(e,i);function e(t,n,s){Ai(this,e);var r=Fs(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),a=s,o=r;if(r.__select=document.createElement("select"),ue.isArray(a)){var c={};ue.each(a,function(l){c[l]=l}),a=c}return ue.each(a,function(l,h){var u=document.createElement("option");u.innerHTML=h,u.setAttribute("value",l),o.__select.appendChild(u)}),r.updateDisplay(),te.bind(r.__select,"change",function(){var l=this.options[this.selectedIndex].value;o.setValue(l)}),r.domElement.appendChild(r.__select),r}return gi(e,[{key:"setValue",value:function(n){var s=Rs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,n);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),s}},{key:"updateDisplay",value:function(){return te.isActive(this.__select)?this:(this.__select.value=this.getValue(),Rs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this))}}]),e})(or),kI=(function(i){Ns(e,i);function e(t,n){Ai(this,e);var s=Fs(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),r=s;function a(){r.setValue(r.__input.value)}function o(){r.__onFinishChange&&r.__onFinishChange.call(r,r.getValue())}return s.__input=document.createElement("input"),s.__input.setAttribute("type","text"),te.bind(s.__input,"keyup",a),te.bind(s.__input,"change",a),te.bind(s.__input,"blur",o),te.bind(s.__input,"keydown",function(c){c.keyCode===13&&this.blur()}),s.updateDisplay(),s.domElement.appendChild(s.__input),s}return gi(e,[{key:"updateDisplay",value:function(){return te.isActive(this.__input)||(this.__input.value=this.getValue()),Rs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e})(or);function wg(i){var e=i.toString();return e.indexOf(".")>-1?e.length-e.indexOf(".")-1:0}var Cg=(function(i){Ns(e,i);function e(t,n,s){Ai(this,e);var r=Fs(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),a=s||{};return r.__min=a.min,r.__max=a.max,r.__step=a.step,ue.isUndefined(r.__step)?r.initialValue===0?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=wg(r.__impliedStep),r}return gi(e,[{key:"setValue",value:function(n){var s=n;return this.__min!==void 0&&s<this.__min?s=this.__min:this.__max!==void 0&&s>this.__max&&(s=this.__max),this.__step!==void 0&&s%this.__step!==0&&(s=Math.round(s/this.__step)*this.__step),Rs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,s)}},{key:"min",value:function(n){return this.__min=n,this}},{key:"max",value:function(n){return this.__max=n,this}},{key:"step",value:function(n){return this.__step=n,this.__impliedStep=n,this.__precision=wg(n),this}}]),e})(or);function UI(i,e){var t=Math.pow(10,e);return Math.round(i*t)/t}var il=(function(i){Ns(e,i);function e(t,n,s){Ai(this,e);var r=Fs(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,s));r.__truncationSuspended=!1;var a=r,o=void 0;function c(){var m=parseFloat(a.__input.value);ue.isNaN(m)||a.setValue(m)}function l(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function h(){l()}function u(m){var g=o-m.clientY;a.setValue(a.getValue()+g*a.__impliedStep),o=m.clientY}function d(){te.unbind(window,"mousemove",u),te.unbind(window,"mouseup",d),l()}function f(m){te.bind(window,"mousemove",u),te.bind(window,"mouseup",d),o=m.clientY}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),te.bind(r.__input,"change",c),te.bind(r.__input,"blur",h),te.bind(r.__input,"mousedown",f),te.bind(r.__input,"keydown",function(m){m.keyCode===13&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,l())}),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return gi(e,[{key:"updateDisplay",value:function(){return this.__input.value=this.__truncationSuspended?this.getValue():UI(this.getValue(),this.__precision),Rs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e})(Cg);function vg(i,e,t,n,s){return n+(s-n)*((i-e)/(t-e))}var td=(function(i){Ns(e,i);function e(t,n,s,r,a){Ai(this,e);var o=Fs(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,{min:s,max:r,step:a})),c=o;o.__background=document.createElement("div"),o.__foreground=document.createElement("div"),te.bind(o.__background,"mousedown",l),te.bind(o.__background,"touchstart",d),te.addClass(o.__background,"slider"),te.addClass(o.__foreground,"slider-fg");function l(g){document.activeElement.blur(),te.bind(window,"mousemove",h),te.bind(window,"mouseup",u),h(g)}function h(g){g.preventDefault();var A=c.__background.getBoundingClientRect();return c.setValue(vg(g.clientX,A.left,A.right,c.__min,c.__max)),!1}function u(){te.unbind(window,"mousemove",h),te.unbind(window,"mouseup",u),c.__onFinishChange&&c.__onFinishChange.call(c,c.getValue())}function d(g){g.touches.length===1&&(te.bind(window,"touchmove",f),te.bind(window,"touchend",m),f(g))}function f(g){var A=g.touches[0].clientX,p=c.__background.getBoundingClientRect();c.setValue(vg(A,p.left,p.right,c.__min,c.__max))}function m(){te.unbind(window,"touchmove",f),te.unbind(window,"touchend",m),c.__onFinishChange&&c.__onFinishChange.call(c,c.getValue())}return o.updateDisplay(),o.__background.appendChild(o.__foreground),o.domElement.appendChild(o.__background),o}return gi(e,[{key:"updateDisplay",value:function(){var n=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=n*100+"%",Rs(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e})(Cg),Sg=(function(i){Ns(e,i);function e(t,n,s){Ai(this,e);var r=Fs(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),a=r;return r.__button=document.createElement("div"),r.__button.innerHTML=s===void 0?"Fire":s,te.bind(r.__button,"click",function(o){return o.preventDefault(),a.fire(),!1}),te.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return gi(e,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),e})(or),nd=(function(i){Ns(e,i);function e(t,n){Ai(this,e);var s=Fs(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));s.__color=new pn(s.getValue()),s.__temp=new pn(0);var r=s;s.domElement=document.createElement("div"),te.makeSelectable(s.domElement,!1),s.__selector=document.createElement("div"),s.__selector.className="selector",s.__saturation_field=document.createElement("div"),s.__saturation_field.className="saturation-field",s.__field_knob=document.createElement("div"),s.__field_knob.className="field-knob",s.__field_knob_border="2px solid ",s.__hue_knob=document.createElement("div"),s.__hue_knob.className="hue-knob",s.__hue_field=document.createElement("div"),s.__hue_field.className="hue-field",s.__input=document.createElement("input"),s.__input.type="text",s.__input_textShadow="0 1px 1px ",te.bind(s.__input,"keydown",function(g){g.keyCode===13&&u.call(this)}),te.bind(s.__input,"blur",u),te.bind(s.__selector,"mousedown",function(){te.addClass(this,"drag").bind(window,"mouseup",function(){te.removeClass(r.__selector,"drag")})}),te.bind(s.__selector,"touchstart",function(){te.addClass(this,"drag").bind(window,"touchend",function(){te.removeClass(r.__selector,"drag")})});var a=document.createElement("div");ue.extend(s.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),ue.extend(s.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:s.__field_knob_border+(s.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),ue.extend(s.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),ue.extend(s.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),ue.extend(a.style,{width:"100%",height:"100%",background:"none"}),Ig(a,"top","rgba(0,0,0,0)","#000"),ue.extend(s.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),QI(s.__hue_field),ue.extend(s.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:s.__input_textShadow+"rgba(0,0,0,0.7)"}),te.bind(s.__saturation_field,"mousedown",o),te.bind(s.__saturation_field,"touchstart",o),te.bind(s.__field_knob,"mousedown",o),te.bind(s.__field_knob,"touchstart",o),te.bind(s.__hue_field,"mousedown",c),te.bind(s.__hue_field,"touchstart",c);function o(g){f(g),te.bind(window,"mousemove",f),te.bind(window,"touchmove",f),te.bind(window,"mouseup",l),te.bind(window,"touchend",l)}function c(g){m(g),te.bind(window,"mousemove",m),te.bind(window,"touchmove",m),te.bind(window,"mouseup",h),te.bind(window,"touchend",h)}function l(){te.unbind(window,"mousemove",f),te.unbind(window,"touchmove",f),te.unbind(window,"mouseup",l),te.unbind(window,"touchend",l),d()}function h(){te.unbind(window,"mousemove",m),te.unbind(window,"touchmove",m),te.unbind(window,"mouseup",h),te.unbind(window,"touchend",h),d()}function u(){var g=Zu(this.value);g!==!1?(r.__color.__state=g,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function d(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}s.__saturation_field.appendChild(a),s.__selector.appendChild(s.__field_knob),s.__selector.appendChild(s.__saturation_field),s.__selector.appendChild(s.__hue_field),s.__hue_field.appendChild(s.__hue_knob),s.domElement.appendChild(s.__input),s.domElement.appendChild(s.__selector),s.updateDisplay();function f(g){g.type.indexOf("touch")===-1&&g.preventDefault();var A=r.__saturation_field.getBoundingClientRect(),p=g.touches&&g.touches[0]||g,y=p.clientX,b=p.clientY,_=(y-A.left)/(A.right-A.left),M=1-(b-A.top)/(A.bottom-A.top);return M>1?M=1:M<0&&(M=0),_>1?_=1:_<0&&(_=0),r.__color.v=M,r.__color.s=_,r.setValue(r.__color.toOriginal()),!1}function m(g){g.type.indexOf("touch")===-1&&g.preventDefault();var A=r.__hue_field.getBoundingClientRect(),p=g.touches&&g.touches[0]||g,y=p.clientY,b=1-(y-A.top)/(A.bottom-A.top);return b>1?b=1:b<0&&(b=0),r.__color.h=b*360,r.setValue(r.__color.toOriginal()),!1}return s}return gi(e,[{key:"updateDisplay",value:function(){var n=Zu(this.getValue());if(n!==!1){var s=!1;ue.each(pn.COMPONENTS,function(o){if(!ue.isUndefined(n[o])&&!ue.isUndefined(this.__color.__state[o])&&n[o]!==this.__color.__state[o])return s=!0,{}},this),s&&ue.extend(this.__color.__state,n)}ue.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var r=this.__color.v<.5||this.__color.s>.5?255:0,a=255-r;ue.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+r+","+r+","+r+")"}),this.__hue_knob.style.marginTop=(1-this.__color.h/360)*100+"px",this.__temp.s=1,this.__temp.v=1,Ig(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),ue.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+r+","+r+","+r+")",textShadow:this.__input_textShadow+"rgba("+a+","+a+","+a+",.7)"})}}]),e})(or),OI=["-moz-","-o-","-webkit-","-ms-",""];function Ig(i,e,t,n){i.style.background="",ue.each(OI,function(s){i.style.cssText+="background: "+s+"linear-gradient("+e+", "+t+" 0%, "+n+" 100%); "})}function QI(i){i.style.background="",i.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",i.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",i.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",i.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",i.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}var GI={load:function(e,t){var n=t||document,s=n.createElement("link");s.type="text/css",s.rel="stylesheet",s.href=e,n.getElementsByTagName("head")[0].appendChild(s)},inject:function(e,t){var n=t||document,s=document.createElement("style");s.type="text/css",s.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(s)}catch{}}},HI=`<div id="dg-save" class="dg dialogue">++ Here's the new load parameter for your <code>GUI</code>'s constructor:++ <textarea id="dg-new-constructor"></textarea>++ <div id="dg-save-locally">++ <input id="dg-local-storage" type="checkbox"/> Automatically save+ values to <code>localStorage</code> on exit.++ <div id="dg-local-explain">The values saved to <code>localStorage</code> will+ override those passed to <code>dat.GUI</code>'s constructor. This makes it+ easier to work incrementally, but <code>localStorage</code> is fragile,+ and your friends may not see the same values you do.++ </div>++ </div>++</div>`,zI=function(e,t){var n=e[t];return ue.isArray(arguments[2])||ue.isObject(arguments[2])?new PI(e,t,arguments[2]):ue.isNumber(n)?ue.isNumber(arguments[2])&&ue.isNumber(arguments[3])?ue.isNumber(arguments[4])?new td(e,t,arguments[2],arguments[3],arguments[4]):new td(e,t,arguments[2],arguments[3]):ue.isNumber(arguments[4])?new il(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new il(e,t,{min:arguments[2],max:arguments[3]}):ue.isString(n)?new kI(e,t):ue.isFunction(n)?new Sg(e,t,""):ue.isBoolean(n)?new yg(e,t):null};function VI(i){setTimeout(i,1e3/60)}var WI=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||VI,qI=(function(){function i(){Ai(this,i),this.backgroundElement=document.createElement("div"),ue.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),te.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),ue.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var e=this;te.bind(this.backgroundElement,"click",function(){e.hide()})}return gi(i,[{key:"show",value:function(){var t=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),ue.defer(function(){t.backgroundElement.style.opacity=1,t.domElement.style.opacity=1,t.domElement.style.webkitTransform="scale(1)"})}},{key:"hide",value:function(){var t=this,n=function s(){t.domElement.style.display="none",t.backgroundElement.style.display="none",te.unbind(t.domElement,"webkitTransitionEnd",s),te.unbind(t.domElement,"transitionend",s),te.unbind(t.domElement,"oTransitionEnd",s)};te.bind(this.domElement,"webkitTransitionEnd",n),te.bind(this.domElement,"transitionend",n),te.bind(this.domElement,"oTransitionEnd",n),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-te.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-te.getHeight(this.domElement)/2+"px"}}]),i})(),KI=RI(`.dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}+`);GI.inject(KI);var Mg="dg",Bg=72,Tg=20,Eo="Default",_o=(function(){try{return!!window.localStorage}catch{return!1}})(),yo=void 0,Rg=!0,pa=void 0,id=!1,Ng=[],Nt=function i(e){var t=this,n=e||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),te.addClass(this.domElement,Mg),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],n=ue.defaults(n,{closeOnTop:!1,autoPlace:!0,width:i.DEFAULT_WIDTH}),n=ue.defaults(n,{resizable:n.autoPlace,hideable:n.autoPlace}),ue.isUndefined(n.load)?n.load={preset:Eo}:n.preset&&(n.load.preset=n.preset),ue.isUndefined(n.parent)&&n.hideable&&Ng.push(this),n.resizable=ue.isUndefined(n.parent)&&n.resizable,n.autoPlace&&ue.isUndefined(n.scrollable)&&(n.scrollable=!0);var s=_o&&localStorage.getItem(Aa(this,"isLocal"))==="true",r=void 0,a=void 0;if(Object.defineProperties(this,{parent:{get:function(){return n.parent}},scrollable:{get:function(){return n.scrollable}},autoPlace:{get:function(){return n.autoPlace}},closeOnTop:{get:function(){return n.closeOnTop}},preset:{get:function(){return t.parent?t.getRoot().preset:n.load.preset},set:function(d){t.parent?t.getRoot().preset=d:n.load.preset=d,JI(this),t.revert()}},width:{get:function(){return n.width},set:function(d){n.width=d,od(t,d)}},name:{get:function(){return n.name},set:function(d){n.name=d,a&&(a.innerHTML=n.name)}},closed:{get:function(){return n.closed},set:function(d){n.closed=d,n.closed?te.addClass(t.__ul,i.CLASS_CLOSED):te.removeClass(t.__ul,i.CLASS_CLOSED),this.onResize(),t.__closeButton&&(t.__closeButton.innerHTML=d?i.TEXT_OPEN:i.TEXT_CLOSED)}},load:{get:function(){return n.load}},useLocalStorage:{get:function(){return s},set:function(d){_o&&(s=d,d?te.bind(window,"unload",r):te.unbind(window,"unload",r),localStorage.setItem(Aa(t,"isLocal"),d))}}}),ue.isUndefined(n.parent)){if(this.closed=n.closed||!1,te.addClass(this.domElement,i.CLASS_MAIN),te.makeSelectable(this.domElement,!1),_o&&s){t.useLocalStorage=!0;var o=localStorage.getItem(Aa(this,"gui"));o&&(n.load=JSON.parse(o))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=i.TEXT_CLOSED,te.addClass(this.__closeButton,i.CLASS_CLOSE_BUTTON),n.closeOnTop?(te.addClass(this.__closeButton,i.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(te.addClass(this.__closeButton,i.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),te.bind(this.__closeButton,"click",function(){t.closed=!t.closed})}else{n.closed===void 0&&(n.closed=!0);var c=document.createTextNode(n.name);te.addClass(c,"controller-name"),a=sd(t,c);var l=function(d){return d.preventDefault(),t.closed=!t.closed,!1};te.addClass(this.__ul,i.CLASS_CLOSED),te.addClass(a,"title"),te.bind(a,"click",l),n.closed||(this.closed=!1)}n.autoPlace&&(ue.isUndefined(n.parent)&&(Rg&&(pa=document.createElement("div"),te.addClass(pa,Mg),te.addClass(pa,i.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(pa),Rg=!1),pa.appendChild(this.domElement),te.addClass(this.domElement,i.CLASS_AUTO_PLACE)),this.parent||od(t,n.width)),this.__resizeHandler=function(){t.onResizeDebounced()},te.bind(window,"resize",this.__resizeHandler),te.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),te.bind(this.__ul,"transitionend",this.__resizeHandler),te.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),n.resizable&&jI(this),r=function(){_o&&localStorage.getItem(Aa(t,"isLocal"))==="true"&&localStorage.setItem(Aa(t,"gui"),JSON.stringify(t.getSaveObject()))},this.saveToLocalStorageIfPossible=r;function h(){var u=t.getRoot();u.width+=1,ue.defer(function(){u.width-=1})}n.parent||h()};Nt.toggleHide=function(){id=!id,ue.each(Ng,function(i){i.domElement.style.display=id?"none":""})},Nt.CLASS_AUTO_PLACE="a",Nt.CLASS_AUTO_PLACE_CONTAINER="ac",Nt.CLASS_MAIN="main",Nt.CLASS_CONTROLLER_ROW="cr",Nt.CLASS_TOO_TALL="taller-than-window",Nt.CLASS_CLOSED="closed",Nt.CLASS_CLOSE_BUTTON="close-button",Nt.CLASS_CLOSE_TOP="close-top",Nt.CLASS_CLOSE_BOTTOM="close-bottom",Nt.CLASS_DRAG="drag",Nt.DEFAULT_WIDTH=245,Nt.TEXT_CLOSED="Close Controls",Nt.TEXT_OPEN="Open Controls",Nt._keydownHandler=function(i){document.activeElement.type!=="text"&&(i.which===Bg||i.keyCode===Bg)&&Nt.toggleHide()},te.bind(window,"keydown",Nt._keydownHandler,!1),ue.extend(Nt.prototype,{add:function(e,t){return wo(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return wo(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;ue.defer(function(){t.onResize()})},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&pa.removeChild(this.domElement);var e=this;ue.each(this.__folders,function(t){e.removeFolder(t)}),te.unbind(window,"keydown",Nt._keydownHandler,!1),Fg(this)},addFolder:function(e){if(this.__folders[e]!==void 0)throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new Nt(t);this.__folders[e]=n;var s=sd(this,n.domElement);return te.addClass(s,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],Fg(e);var t=this;ue.each(e.__folders,function(n){e.removeFolder(n)}),ue.defer(function(){t.onResize()})},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=te.getOffset(e.__ul).top,n=0;ue.each(e.__ul.childNodes,function(s){e.autoPlace&&s===e.__save_row||(n+=te.getHeight(s))}),window.innerHeight-t-Tg<n?(te.addClass(e.domElement,Nt.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-Tg+"px"):(te.removeClass(e.domElement,Nt.CLASS_TOO_TALL),e.__ul.style.height="auto")}e.__resize_handle&&ue.defer(function(){e.__resize_handle.style.height=e.__ul.offsetHeight+"px"}),e.__closeButton&&(e.__closeButton.style.width=e.width+"px")},onResizeDebounced:ue.debounce(function(){this.onResize()},50),remember:function(){if(ue.isUndefined(yo)&&(yo=new qI,yo.domElement.innerHTML=HI),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;ue.each(Array.prototype.slice.call(arguments),function(t){e.__rememberedObjects.length===0&&YI(e),e.__rememberedObjects.indexOf(t)===-1&&e.__rememberedObjects.push(t)}),this.autoPlace&&od(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var e=this.load;return e.closed=this.closed,this.__rememberedObjects.length>0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=sl(this)),e.folders={},ue.each(this.__folders,function(t,n){e.folders[n]=t.getSaveObject()}),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=sl(this),rd(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[Eo]=sl(this,!0)),this.load.remembered[e]=sl(this),this.preset=e,ad(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){ue.each(this.__controllers,function(t){this.getRoot().load.remembered?Dg(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())},this),ue.each(this.__folders,function(t){t.revert(t)}),e||rd(this.getRoot(),!1)},listen:function(e){var t=this.__listening.length===0;this.__listening.push(e),t&&Pg(this.__listening)},updateDisplay:function(){ue.each(this.__controllers,function(e){e.updateDisplay()}),ue.each(this.__folders,function(e){e.updateDisplay()})}});function sd(i,e,t){var n=document.createElement("li");return e&&n.appendChild(e),t?i.__ul.insertBefore(n,t):i.__ul.appendChild(n),i.onResize(),n}function Fg(i){te.unbind(window,"resize",i.__resizeHandler),i.saveToLocalStorageIfPossible&&te.unbind(window,"unload",i.saveToLocalStorageIfPossible)}function rd(i,e){var t=i.__preset_select[i.__preset_select.selectedIndex];e?t.innerHTML=t.value+"*":t.innerHTML=t.value}function XI(i,e,t){if(t.__li=e,t.__gui=i,ue.extend(t,{options:function(a){if(arguments.length>1){var o=t.__li.nextElementSibling;return t.remove(),wo(i,t.object,t.property,{before:o,factoryArgs:[ue.toArray(arguments)]})}if(ue.isArray(a)||ue.isObject(a)){var c=t.__li.nextElementSibling;return t.remove(),wo(i,t.object,t.property,{before:c,factoryArgs:[a]})}},name:function(a){return t.__li.firstElementChild.firstElementChild.innerHTML=a,t},listen:function(){return t.__gui.listen(t),t},remove:function(){return t.__gui.remove(t),t}}),t instanceof td){var n=new il(t.object,t.property,{min:t.__min,max:t.__max,step:t.__step});ue.each(["updateDisplay","onChange","onFinishChange","step","min","max"],function(r){var a=t[r],o=n[r];t[r]=n[r]=function(){var c=Array.prototype.slice.call(arguments);return o.apply(n,c),a.apply(t,c)}}),te.addClass(e,"has-slider"),t.domElement.insertBefore(n.domElement,t.domElement.firstElementChild)}else if(t instanceof il){var s=function(a){if(ue.isNumber(t.__min)&&ue.isNumber(t.__max)){var o=t.__li.firstElementChild.firstElementChild.innerHTML,c=t.__gui.__listening.indexOf(t)>-1;t.remove();var l=wo(i,t.object,t.property,{before:t.__li.nextElementSibling,factoryArgs:[t.__min,t.__max,t.__step]});return l.name(o),c&&l.listen(),l}return a};t.min=ue.compose(s,t.min),t.max=ue.compose(s,t.max)}else t instanceof yg?(te.bind(e,"click",function(){te.fakeEvent(t.__checkbox,"click")}),te.bind(t.__checkbox,"click",function(r){r.stopPropagation()})):t instanceof Sg?(te.bind(e,"click",function(){te.fakeEvent(t.__button,"click")}),te.bind(e,"mouseover",function(){te.addClass(t.__button,"hover")}),te.bind(e,"mouseout",function(){te.removeClass(t.__button,"hover")})):t instanceof nd&&(te.addClass(e,"color"),t.updateDisplay=ue.compose(function(r){return e.style.borderLeftColor=t.__color.toString(),r},t.updateDisplay),t.updateDisplay());t.setValue=ue.compose(function(r){return i.getRoot().__preset_select&&t.isModified()&&rd(i.getRoot(),!0),r},t.setValue)}function Dg(i,e){var t=i.getRoot(),n=t.__rememberedObjects.indexOf(e.object);if(n!==-1){var s=t.__rememberedObjectIndecesToControllers[n];if(s===void 0&&(s={},t.__rememberedObjectIndecesToControllers[n]=s),s[e.property]=e,t.load&&t.load.remembered){var r=t.load.remembered,a=void 0;if(r[i.preset])a=r[i.preset];else if(r[Eo])a=r[Eo];else return;if(a[n]&&a[n][e.property]!==void 0){var o=a[n][e.property];e.initialValue=o,e.setValue(o)}}}}function wo(i,e,t,n){if(e[t]===void 0)throw new Error('Object "'+e+'" has no property "'+t+'"');var s=void 0;if(n.color)s=new nd(e,t);else{var r=[e,t].concat(n.factoryArgs);s=zI.apply(i,r)}n.before instanceof or&&(n.before=n.before.__li),Dg(i,s),te.addClass(s.domElement,"c");var a=document.createElement("span");te.addClass(a,"property-name"),a.innerHTML=s.property;var o=document.createElement("div");o.appendChild(a),o.appendChild(s.domElement);var c=sd(i,o,n.before);return te.addClass(c,Nt.CLASS_CONTROLLER_ROW),s instanceof nd?te.addClass(c,"color"):te.addClass(c,FI(s.getValue())),XI(i,c,s),i.__controllers.push(s),s}function Aa(i,e){return document.location.href+"."+e}function ad(i,e,t){var n=document.createElement("option");n.innerHTML=e,n.value=e,i.__preset_select.appendChild(n),t&&(i.__preset_select.selectedIndex=i.__preset_select.length-1)}function Lg(i,e){e.style.display=i.useLocalStorage?"block":"none"}function YI(i){var e=i.__save_row=document.createElement("li");te.addClass(i.domElement,"has-save"),i.__ul.insertBefore(e,i.__ul.firstChild),te.addClass(e,"save-row");var t=document.createElement("span");t.innerHTML=" ",te.addClass(t,"button gears");var n=document.createElement("span");n.innerHTML="Save",te.addClass(n,"button"),te.addClass(n,"save");var s=document.createElement("span");s.innerHTML="New",te.addClass(s,"button"),te.addClass(s,"save-as");var r=document.createElement("span");r.innerHTML="Revert",te.addClass(r,"button"),te.addClass(r,"revert");var a=i.__preset_select=document.createElement("select");if(i.load&&i.load.remembered?ue.each(i.load.remembered,function(u,d){ad(i,d,d===i.preset)}):ad(i,Eo,!1),te.bind(a,"change",function(){for(var u=0;u<i.__preset_select.length;u++)i.__preset_select[u].innerHTML=i.__preset_select[u].value;i.preset=this.value}),e.appendChild(a),e.appendChild(t),e.appendChild(n),e.appendChild(s),e.appendChild(r),_o){var o=document.getElementById("dg-local-explain"),c=document.getElementById("dg-local-storage"),l=document.getElementById("dg-save-locally");l.style.display="block",localStorage.getItem(Aa(i,"isLocal"))==="true"&&c.setAttribute("checked","checked"),Lg(i,o),te.bind(c,"change",function(){i.useLocalStorage=!i.useLocalStorage,Lg(i,o)})}var h=document.getElementById("dg-new-constructor");te.bind(h,"keydown",function(u){u.metaKey&&(u.which===67||u.keyCode===67)&&yo.hide()}),te.bind(t,"click",function(){h.innerHTML=JSON.stringify(i.getSaveObject(),void 0,2),yo.show(),h.focus(),h.select()}),te.bind(n,"click",function(){i.save()}),te.bind(s,"click",function(){var u=prompt("Enter a new preset name.");u&&i.saveAs(u)}),te.bind(r,"click",function(){i.revert()})}function jI(i){var e=void 0;i.__resize_handle=document.createElement("div"),ue.extend(i.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"});function t(r){return r.preventDefault(),i.width+=e-r.clientX,i.onResize(),e=r.clientX,!1}function n(){te.removeClass(i.__closeButton,Nt.CLASS_DRAG),te.unbind(window,"mousemove",t),te.unbind(window,"mouseup",n)}function s(r){return r.preventDefault(),e=r.clientX,te.addClass(i.__closeButton,Nt.CLASS_DRAG),te.bind(window,"mousemove",t),te.bind(window,"mouseup",n),!1}te.bind(i.__resize_handle,"mousedown",s),te.bind(i.__closeButton,"mousedown",s),i.domElement.insertBefore(i.__resize_handle,i.domElement.firstElementChild)}function od(i,e){i.domElement.style.width=e+"px",i.__save_row&&i.autoPlace&&(i.__save_row.style.width=e+"px"),i.__closeButton&&(i.__closeButton.style.width=e+"px")}function sl(i,e){var t={};return ue.each(i.__rememberedObjects,function(n,s){var r={},a=i.__rememberedObjectIndecesToControllers[s];ue.each(a,function(o,c){r[c]=e?o.initialValue:o.getValue()}),t[s]=r}),t}function JI(i){for(var e=0;e<i.__preset_select.length;e++)i.__preset_select[e].value===i.preset&&(i.__preset_select.selectedIndex=e)}function Pg(i){i.length!==0&&WI.call(window,function(){Pg(i)}),ue.each(i,function(e){e.updateDisplay()})}var ZI=Nt;const rl=[{id:"",name:"None",path:null},{id:"neutral",name:"Neutral",path:null},{id:"venice-sunset",name:"Venice Sunset",path:"https://storage.googleapis.com/donmccurdy-static/venice_sunset_1k.exr",format:".exr"},{id:"footprint-court",name:"Footprint Court (HDR Labs)",path:"https://storage.googleapis.com/donmccurdy-static/footprint_court_2k.exr",format:".exr"}],$I=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","BN","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],kg=[[697,698,"ON"],[706,719,"ON"],[722,735,"ON"],[741,749,"ON"],[751,767,"ON"],[768,879,"NSM"],[884,885,"ON"],[894,894,"ON"],[900,901,"ON"],[903,903,"ON"],[1014,1014,"ON"],[1155,1161,"NSM"],[1418,1418,"ON"],[1421,1422,"ON"],[1423,1423,"ET"],[1424,1424,"R"],[1425,1469,"NSM"],[1470,1470,"R"],[1471,1471,"NSM"],[1472,1472,"R"],[1473,1474,"NSM"],[1475,1475,"R"],[1476,1477,"NSM"],[1478,1478,"R"],[1479,1479,"NSM"],[1480,1535,"R"],[1536,1541,"AN"],[1542,1543,"ON"],[1544,1544,"AL"],[1545,1546,"ET"],[1547,1547,"AL"],[1548,1548,"CS"],[1549,1549,"AL"],[1550,1551,"ON"],[1552,1562,"NSM"],[1563,1610,"AL"],[1611,1631,"NSM"],[1632,1641,"AN"],[1642,1642,"ET"],[1643,1644,"AN"],[1645,1647,"AL"],[1648,1648,"NSM"],[1649,1749,"AL"],[1750,1756,"NSM"],[1757,1757,"AN"],[1758,1758,"ON"],[1759,1764,"NSM"],[1765,1766,"AL"],[1767,1768,"NSM"],[1769,1769,"ON"],[1770,1773,"NSM"],[1774,1775,"AL"],[1776,1785,"EN"],[1786,1808,"AL"],[1809,1809,"NSM"],[1810,1839,"AL"],[1840,1866,"NSM"],[1867,1957,"AL"],[1958,1968,"NSM"],[1969,1983,"AL"],[1984,2026,"R"],[2027,2035,"NSM"],[2036,2037,"R"],[2038,2041,"ON"],[2042,2044,"R"],[2045,2045,"NSM"],[2046,2069,"R"],[2070,2073,"NSM"],[2074,2074,"R"],[2075,2083,"NSM"],[2084,2084,"R"],[2085,2087,"NSM"],[2088,2088,"R"],[2089,2093,"NSM"],[2094,2136,"R"],[2137,2139,"NSM"],[2140,2143,"R"],[2144,2191,"AL"],[2192,2193,"AN"],[2194,2198,"AL"],[2199,2207,"NSM"],[2208,2249,"AL"],[2250,2273,"NSM"],[2274,2274,"AN"],[2275,2306,"NSM"],[2362,2362,"NSM"],[2364,2364,"NSM"],[2369,2376,"NSM"],[2381,2381,"NSM"],[2385,2391,"NSM"],[2402,2403,"NSM"],[2433,2433,"NSM"],[2492,2492,"NSM"],[2497,2500,"NSM"],[2509,2509,"NSM"],[2530,2531,"NSM"],[2546,2547,"ET"],[2555,2555,"ET"],[2558,2558,"NSM"],[2561,2562,"NSM"],[2620,2620,"NSM"],[2625,2626,"NSM"],[2631,2632,"NSM"],[2635,2637,"NSM"],[2641,2641,"NSM"],[2672,2673,"NSM"],[2677,2677,"NSM"],[2689,2690,"NSM"],[2748,2748,"NSM"],[2753,2757,"NSM"],[2759,2760,"NSM"],[2765,2765,"NSM"],[2786,2787,"NSM"],[2801,2801,"ET"],[2810,2815,"NSM"],[2817,2817,"NSM"],[2876,2876,"NSM"],[2879,2879,"NSM"],[2881,2884,"NSM"],[2893,2893,"NSM"],[2901,2902,"NSM"],[2914,2915,"NSM"],[2946,2946,"NSM"],[3008,3008,"NSM"],[3021,3021,"NSM"],[3059,3064,"ON"],[3065,3065,"ET"],[3066,3066,"ON"],[3072,3072,"NSM"],[3076,3076,"NSM"],[3132,3132,"NSM"],[3134,3136,"NSM"],[3142,3144,"NSM"],[3146,3149,"NSM"],[3157,3158,"NSM"],[3170,3171,"NSM"],[3192,3198,"ON"],[3201,3201,"NSM"],[3260,3260,"NSM"],[3276,3277,"NSM"],[3298,3299,"NSM"],[3328,3329,"NSM"],[3387,3388,"NSM"],[3393,3396,"NSM"],[3405,3405,"NSM"],[3426,3427,"NSM"],[3457,3457,"NSM"],[3530,3530,"NSM"],[3538,3540,"NSM"],[3542,3542,"NSM"],[3633,3633,"NSM"],[3636,3642,"NSM"],[3647,3647,"ET"],[3655,3662,"NSM"],[3761,3761,"NSM"],[3764,3772,"NSM"],[3784,3790,"NSM"],[3864,3865,"NSM"],[3893,3893,"NSM"],[3895,3895,"NSM"],[3897,3897,"NSM"],[3898,3901,"ON"],[3953,3966,"NSM"],[3968,3972,"NSM"],[3974,3975,"NSM"],[3981,3991,"NSM"],[3993,4028,"NSM"],[4038,4038,"NSM"],[4141,4144,"NSM"],[4146,4151,"NSM"],[4153,4154,"NSM"],[4157,4158,"NSM"],[4184,4185,"NSM"],[4190,4192,"NSM"],[4209,4212,"NSM"],[4226,4226,"NSM"],[4229,4230,"NSM"],[4237,4237,"NSM"],[4253,4253,"NSM"],[4957,4959,"NSM"],[5008,5017,"ON"],[5120,5120,"ON"],[5760,5760,"WS"],[5787,5788,"ON"],[5906,5908,"NSM"],[5938,5939,"NSM"],[5970,5971,"NSM"],[6002,6003,"NSM"],[6068,6069,"NSM"],[6071,6077,"NSM"],[6086,6086,"NSM"],[6089,6099,"NSM"],[6107,6107,"ET"],[6109,6109,"NSM"],[6128,6137,"ON"],[6144,6154,"ON"],[6155,6157,"NSM"],[6158,6158,"BN"],[6159,6159,"NSM"],[6277,6278,"NSM"],[6313,6313,"NSM"],[6432,6434,"NSM"],[6439,6440,"NSM"],[6450,6450,"NSM"],[6457,6459,"NSM"],[6464,6464,"ON"],[6468,6469,"ON"],[6622,6655,"ON"],[6679,6680,"NSM"],[6683,6683,"NSM"],[6742,6742,"NSM"],[6744,6750,"NSM"],[6752,6752,"NSM"],[6754,6754,"NSM"],[6757,6764,"NSM"],[6771,6780,"NSM"],[6783,6783,"NSM"],[6832,6877,"NSM"],[6880,6891,"NSM"],[6912,6915,"NSM"],[6964,6964,"NSM"],[6966,6970,"NSM"],[6972,6972,"NSM"],[6978,6978,"NSM"],[7019,7027,"NSM"],[7040,7041,"NSM"],[7074,7077,"NSM"],[7080,7081,"NSM"],[7083,7085,"NSM"],[7142,7142,"NSM"],[7144,7145,"NSM"],[7149,7149,"NSM"],[7151,7153,"NSM"],[7212,7219,"NSM"],[7222,7223,"NSM"],[7376,7378,"NSM"],[7380,7392,"NSM"],[7394,7400,"NSM"],[7405,7405,"NSM"],[7412,7412,"NSM"],[7416,7417,"NSM"],[7616,7679,"NSM"],[8125,8125,"ON"],[8127,8129,"ON"],[8141,8143,"ON"],[8157,8159,"ON"],[8173,8175,"ON"],[8189,8190,"ON"],[8192,8202,"WS"],[8203,8205,"BN"],[8207,8207,"R"],[8208,8231,"ON"],[8232,8232,"WS"],[8233,8233,"B"],[8234,8238,"BN"],[8239,8239,"CS"],[8240,8244,"ET"],[8245,8259,"ON"],[8260,8260,"CS"],[8261,8286,"ON"],[8287,8287,"WS"],[8288,8303,"BN"],[8304,8304,"EN"],[8308,8313,"EN"],[8314,8315,"ES"],[8316,8318,"ON"],[8320,8329,"EN"],[8330,8331,"ES"],[8332,8334,"ON"],[8352,8399,"ET"],[8400,8432,"NSM"],[8448,8449,"ON"],[8451,8454,"ON"],[8456,8457,"ON"],[8468,8468,"ON"],[8470,8472,"ON"],[8478,8483,"ON"],[8485,8485,"ON"],[8487,8487,"ON"],[8489,8489,"ON"],[8494,8494,"ET"],[8506,8507,"ON"],[8512,8516,"ON"],[8522,8525,"ON"],[8528,8543,"ON"],[8585,8587,"ON"],[8592,8721,"ON"],[8722,8722,"ES"],[8723,8723,"ET"],[8724,9013,"ON"],[9083,9108,"ON"],[9110,9257,"ON"],[9280,9290,"ON"],[9312,9351,"ON"],[9352,9371,"EN"],[9450,9899,"ON"],[9901,10239,"ON"],[10496,11123,"ON"],[11126,11263,"ON"],[11493,11498,"ON"],[11503,11505,"NSM"],[11513,11519,"ON"],[11647,11647,"NSM"],[11744,11775,"NSM"],[11776,11869,"ON"],[11904,11929,"ON"],[11931,12019,"ON"],[12032,12245,"ON"],[12272,12287,"ON"],[12288,12288,"WS"],[12289,12292,"ON"],[12296,12320,"ON"],[12330,12333,"NSM"],[12336,12336,"ON"],[12342,12343,"ON"],[12349,12351,"ON"],[12441,12442,"NSM"],[12443,12444,"ON"],[12448,12448,"ON"],[12539,12539,"ON"],[12736,12773,"ON"],[12783,12783,"ON"],[12829,12830,"ON"],[12880,12895,"ON"],[12924,12926,"ON"],[12977,12991,"ON"],[13004,13007,"ON"],[13175,13178,"ON"],[13278,13279,"ON"],[13311,13311,"ON"],[19904,19967,"ON"],[42128,42182,"ON"],[42509,42511,"ON"],[42607,42610,"NSM"],[42611,42611,"ON"],[42612,42621,"NSM"],[42622,42623,"ON"],[42654,42655,"NSM"],[42736,42737,"NSM"],[42752,42785,"ON"],[42888,42888,"ON"],[43010,43010,"NSM"],[43014,43014,"NSM"],[43019,43019,"NSM"],[43045,43046,"NSM"],[43048,43051,"ON"],[43052,43052,"NSM"],[43064,43065,"ET"],[43124,43127,"ON"],[43204,43205,"NSM"],[43232,43249,"NSM"],[43263,43263,"NSM"],[43302,43309,"NSM"],[43335,43345,"NSM"],[43392,43394,"NSM"],[43443,43443,"NSM"],[43446,43449,"NSM"],[43452,43453,"NSM"],[43493,43493,"NSM"],[43561,43566,"NSM"],[43569,43570,"NSM"],[43573,43574,"NSM"],[43587,43587,"NSM"],[43596,43596,"NSM"],[43644,43644,"NSM"],[43696,43696,"NSM"],[43698,43700,"NSM"],[43703,43704,"NSM"],[43710,43711,"NSM"],[43713,43713,"NSM"],[43756,43757,"NSM"],[43766,43766,"NSM"],[43882,43883,"ON"],[44005,44005,"NSM"],[44008,44008,"NSM"],[44013,44013,"NSM"],[64285,64285,"R"],[64286,64286,"NSM"],[64287,64296,"R"],[64297,64297,"ES"],[64298,64335,"R"],[64336,64450,"AL"],[64451,64466,"ON"],[64467,64829,"AL"],[64830,64847,"ON"],[64848,64911,"AL"],[64912,64913,"ON"],[64914,64967,"AL"],[64968,64975,"ON"],[64976,65007,"BN"],[65008,65020,"AL"],[65021,65023,"ON"],[65024,65039,"NSM"],[65040,65049,"ON"],[65056,65071,"NSM"],[65072,65103,"ON"],[65104,65104,"CS"],[65105,65105,"ON"],[65106,65106,"CS"],[65108,65108,"ON"],[65109,65109,"CS"],[65110,65118,"ON"],[65119,65119,"ET"],[65120,65121,"ON"],[65122,65123,"ES"],[65124,65126,"ON"],[65128,65128,"ON"],[65129,65130,"ET"],[65131,65131,"ON"],[65136,65278,"AL"],[65279,65279,"BN"],[65281,65282,"ON"],[65283,65285,"ET"],[65286,65290,"ON"],[65291,65291,"ES"],[65292,65292,"CS"],[65293,65293,"ES"],[65294,65295,"CS"],[65296,65305,"EN"],[65306,65306,"CS"],[65307,65312,"ON"],[65339,65344,"ON"],[65371,65381,"ON"],[65504,65505,"ET"],[65506,65508,"ON"],[65509,65510,"ET"],[65512,65518,"ON"],[65520,65528,"BN"],[65529,65533,"ON"],[65534,65535,"BN"],[65793,65793,"ON"],[65856,65932,"ON"],[65936,65948,"ON"],[65952,65952,"ON"],[66045,66045,"NSM"],[66272,66272,"NSM"],[66273,66299,"EN"],[66422,66426,"NSM"],[67584,67870,"R"],[67871,67871,"ON"],[67872,68096,"R"],[68097,68099,"NSM"],[68100,68100,"R"],[68101,68102,"NSM"],[68103,68107,"R"],[68108,68111,"NSM"],[68112,68151,"R"],[68152,68154,"NSM"],[68155,68158,"R"],[68159,68159,"NSM"],[68160,68324,"R"],[68325,68326,"NSM"],[68327,68408,"R"],[68409,68415,"ON"],[68416,68863,"R"],[68864,68899,"AL"],[68900,68903,"NSM"],[68904,68911,"AL"],[68912,68921,"AN"],[68922,68927,"AL"],[68928,68937,"AN"],[68938,68968,"R"],[68969,68973,"NSM"],[68974,68974,"ON"],[68975,69215,"R"],[69216,69246,"AN"],[69247,69290,"R"],[69291,69292,"NSM"],[69293,69311,"R"],[69312,69327,"AL"],[69328,69336,"ON"],[69337,69369,"AL"],[69370,69375,"NSM"],[69376,69423,"R"],[69424,69445,"AL"],[69446,69456,"NSM"],[69457,69487,"AL"],[69488,69505,"R"],[69506,69509,"NSM"],[69510,69631,"R"],[69633,69633,"NSM"],[69688,69702,"NSM"],[69714,69733,"ON"],[69744,69744,"NSM"],[69747,69748,"NSM"],[69759,69761,"NSM"],[69811,69814,"NSM"],[69817,69818,"NSM"],[69826,69826,"NSM"],[69888,69890,"NSM"],[69927,69931,"NSM"],[69933,69940,"NSM"],[70003,70003,"NSM"],[70016,70017,"NSM"],[70070,70078,"NSM"],[70089,70092,"NSM"],[70095,70095,"NSM"],[70191,70193,"NSM"],[70196,70196,"NSM"],[70198,70199,"NSM"],[70206,70206,"NSM"],[70209,70209,"NSM"],[70367,70367,"NSM"],[70371,70378,"NSM"],[70400,70401,"NSM"],[70459,70460,"NSM"],[70464,70464,"NSM"],[70502,70508,"NSM"],[70512,70516,"NSM"],[70587,70592,"NSM"],[70606,70606,"NSM"],[70608,70608,"NSM"],[70610,70610,"NSM"],[70625,70626,"NSM"],[70712,70719,"NSM"],[70722,70724,"NSM"],[70726,70726,"NSM"],[70750,70750,"NSM"],[70835,70840,"NSM"],[70842,70842,"NSM"],[70847,70848,"NSM"],[70850,70851,"NSM"],[71090,71093,"NSM"],[71100,71101,"NSM"],[71103,71104,"NSM"],[71132,71133,"NSM"],[71219,71226,"NSM"],[71229,71229,"NSM"],[71231,71232,"NSM"],[71264,71276,"ON"],[71339,71339,"NSM"],[71341,71341,"NSM"],[71344,71349,"NSM"],[71351,71351,"NSM"],[71453,71453,"NSM"],[71455,71455,"NSM"],[71458,71461,"NSM"],[71463,71467,"NSM"],[71727,71735,"NSM"],[71737,71738,"NSM"],[71995,71996,"NSM"],[71998,71998,"NSM"],[72003,72003,"NSM"],[72148,72151,"NSM"],[72154,72155,"NSM"],[72160,72160,"NSM"],[72193,72198,"NSM"],[72201,72202,"NSM"],[72243,72248,"NSM"],[72251,72254,"NSM"],[72263,72263,"NSM"],[72273,72278,"NSM"],[72281,72283,"NSM"],[72330,72342,"NSM"],[72344,72345,"NSM"],[72544,72544,"NSM"],[72546,72548,"NSM"],[72550,72550,"NSM"],[72752,72758,"NSM"],[72760,72765,"NSM"],[72850,72871,"NSM"],[72874,72880,"NSM"],[72882,72883,"NSM"],[72885,72886,"NSM"],[73009,73014,"NSM"],[73018,73018,"NSM"],[73020,73021,"NSM"],[73023,73029,"NSM"],[73031,73031,"NSM"],[73104,73105,"NSM"],[73109,73109,"NSM"],[73111,73111,"NSM"],[73459,73460,"NSM"],[73472,73473,"NSM"],[73526,73530,"NSM"],[73536,73536,"NSM"],[73538,73538,"NSM"],[73562,73562,"NSM"],[73685,73692,"ON"],[73693,73696,"ET"],[73697,73713,"ON"],[78912,78912,"NSM"],[78919,78933,"NSM"],[90398,90409,"NSM"],[90413,90415,"NSM"],[92912,92916,"NSM"],[92976,92982,"NSM"],[94031,94031,"NSM"],[94095,94098,"NSM"],[94178,94178,"ON"],[94180,94180,"NSM"],[113821,113822,"NSM"],[113824,113827,"BN"],[117760,117973,"ON"],[118e3,118009,"EN"],[118010,118012,"ON"],[118016,118451,"ON"],[118458,118480,"ON"],[118496,118512,"ON"],[118528,118573,"NSM"],[118576,118598,"NSM"],[119143,119145,"NSM"],[119155,119162,"BN"],[119163,119170,"NSM"],[119173,119179,"NSM"],[119210,119213,"NSM"],[119273,119274,"ON"],[119296,119361,"ON"],[119362,119364,"NSM"],[119365,119365,"ON"],[119552,119638,"ON"],[120513,120513,"ON"],[120539,120539,"ON"],[120571,120571,"ON"],[120597,120597,"ON"],[120629,120629,"ON"],[120655,120655,"ON"],[120687,120687,"ON"],[120713,120713,"ON"],[120745,120745,"ON"],[120771,120771,"ON"],[120782,120831,"EN"],[121344,121398,"NSM"],[121403,121452,"NSM"],[121461,121461,"NSM"],[121476,121476,"NSM"],[121499,121503,"NSM"],[121505,121519,"NSM"],[122880,122886,"NSM"],[122888,122904,"NSM"],[122907,122913,"NSM"],[122915,122916,"NSM"],[122918,122922,"NSM"],[123023,123023,"NSM"],[123184,123190,"NSM"],[123566,123566,"NSM"],[123628,123631,"NSM"],[123647,123647,"ET"],[124140,124143,"NSM"],[124398,124399,"NSM"],[124643,124643,"NSM"],[124646,124646,"NSM"],[124654,124655,"NSM"],[124661,124661,"NSM"],[124928,125135,"R"],[125136,125142,"NSM"],[125143,125251,"R"],[125252,125258,"NSM"],[125259,126063,"R"],[126064,126143,"AL"],[126144,126207,"R"],[126208,126287,"AL"],[126288,126463,"R"],[126464,126703,"AL"],[126704,126705,"ON"],[126706,126719,"AL"],[126720,126975,"R"],[126976,127019,"ON"],[127024,127123,"ON"],[127136,127150,"ON"],[127153,127167,"ON"],[127169,127183,"ON"],[127185,127221,"ON"],[127232,127242,"EN"],[127243,127247,"ON"],[127279,127279,"ON"],[127338,127343,"ON"],[127405,127405,"ON"],[127584,127589,"ON"],[127744,128728,"ON"],[128732,128748,"ON"],[128752,128764,"ON"],[128768,128985,"ON"],[128992,129003,"ON"],[129008,129008,"ON"],[129024,129035,"ON"],[129040,129095,"ON"],[129104,129113,"ON"],[129120,129159,"ON"],[129168,129197,"ON"],[129200,129211,"ON"],[129216,129217,"ON"],[129232,129240,"ON"],[129280,129623,"ON"],[129632,129645,"ON"],[129648,129660,"ON"],[129664,129674,"ON"],[129678,129734,"ON"],[129736,129736,"ON"],[129741,129756,"ON"],[129759,129770,"ON"],[129775,129784,"ON"],[129792,129938,"ON"],[129940,130031,"ON"],[130032,130041,"EN"],[130042,130042,"ON"],[131070,131071,"BN"],[196606,196607,"BN"],[262142,262143,"BN"],[327678,327679,"BN"],[393214,393215,"BN"],[458750,458751,"BN"],[524286,524287,"BN"],[589822,589823,"BN"],[655358,655359,"BN"],[720894,720895,"BN"],[786430,786431,"BN"],[851966,851967,"BN"],[917502,917759,"BN"],[917760,917999,"NSM"],[918e3,921599,"BN"],[983038,983039,"BN"],[1048574,1048575,"BN"],[1114110,1114111,"BN"]];function e1(i){if(i<=255)return $I[i];let e=0,t=kg.length-1;for(;e<=t;){const n=e+t>>1,s=kg[n];if(i<s[0]){t=n-1;continue}if(i>s[1]){e=n+1;continue}return s[2]}return"L"}function t1(i){const e=i.length;if(e===0)return null;const t=new Array(e);let n=!1;for(let l=0;l<e;){const h=i.charCodeAt(l);let u=h,d=1;if(h>=55296&&h<=56319&&l+1<e){const m=i.charCodeAt(l+1);m>=56320&&m<=57343&&(u=(h-55296<<10)+(m-56320)+65536,d=2)}const f=e1(u);(f==="R"||f==="AL"||f==="AN")&&(n=!0);for(let m=0;m<d;m++)t[l+m]=f;l+=d}if(!n)return null;let s=0;for(let l=0;l<e;l++){const h=t[l];if(h==="L"){s=0;break}if(h==="R"||h==="AL"){s=1;break}}const r=new Int8Array(e);for(let l=0;l<e;l++)r[l]=s;const a=s&1?"R":"L",o=a;let c=o;for(let l=0;l<e;l++)t[l]==="NSM"?t[l]=c:c=t[l];c=o;for(let l=0;l<e;l++){const h=t[l];h==="EN"?t[l]=c==="AL"?"AN":"EN":(h==="R"||h==="L"||h==="AL")&&(c=h)}for(let l=0;l<e;l++)t[l]==="AL"&&(t[l]="R");for(let l=1;l<e-1;l++)t[l]==="ES"&&t[l-1]==="EN"&&t[l+1]==="EN"&&(t[l]="EN"),t[l]==="CS"&&(t[l-1]==="EN"||t[l-1]==="AN")&&t[l+1]===t[l-1]&&(t[l]=t[l-1]);for(let l=0;l<e;l++){if(t[l]!=="EN")continue;let h;for(h=l-1;h>=0&&t[h]==="ET";h--)t[h]="EN";for(h=l+1;h<e&&t[h]==="ET";h++)t[h]="EN"}for(let l=0;l<e;l++){const h=t[l];(h==="WS"||h==="ES"||h==="ET"||h==="CS")&&(t[l]="ON")}c=o;for(let l=0;l<e;l++){const h=t[l];h==="EN"?t[l]=c==="L"?"L":"EN":(h==="R"||h==="L")&&(c=h)}for(let l=0;l<e;l++){if(t[l]!=="ON")continue;let h=l+1;for(;h<e&&t[h]==="ON";)h++;const u=l>0?t[l-1]:o,d=h<e?t[h]:o,f=u!=="L"?"R":"L";if(f===(d!=="L"?"R":"L"))for(let g=l;g<h;g++)t[g]=f;l=h-1}for(let l=0;l<e;l++)t[l]==="ON"&&(t[l]=a);for(let l=0;l<e;l++){const h=t[l];(r[l]&1)===0?h==="R"?r[l]++:(h==="AN"||h==="EN")&&(r[l]+=2):(h==="L"||h==="AN"||h==="EN")&&r[l]++}return r}function n1(i,e){const t=t1(i);if(t===null)return null;const n=new Int8Array(e.length);for(let s=0;s<e.length;s++)n[s]=t[e[s]];return n}const i1=/[ \t\n\r\f]+/g,s1=/[\t\n\r\f]| {2,}|^ | $/;function r1(i){const e=i??"normal";return e==="pre-wrap"?{mode:e,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:e,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function a1(i){if(!s1.test(i))return i;let e=i.replace(i1," ");return e.charCodeAt(0)===32&&(e=e.slice(1)),e.length>0&&e.charCodeAt(e.length-1)===32&&(e=e.slice(0,-1)),e}function o1(i){return/[\r\f]/.test(i)?i.replace(/\r\n/g,`+`).replace(/[\r\f]/g,`+`):i.replace(/\r\n/g,`+`)}let cd=null,c1;function l1(){return cd===null&&(cd=new Intl.Segmenter(c1,{granularity:"word"})),cd}const h1=new RegExp("\\p{Script=Arabic}","u"),al=new RegExp("\\p{M}","u"),Ug=new RegExp("\\p{Nd}","u");function Og(i){return h1.test(i)}function Qg(i){return i>=19968&&i<=40959||i>=13312&&i<=19903||i>=131072&&i<=173791||i>=173824&&i<=177983||i>=177984&&i<=178207||i>=178208&&i<=183983||i>=183984&&i<=191471||i>=191472&&i<=192093||i>=194560&&i<=195103||i>=196608&&i<=201551||i>=201552&&i<=205743||i>=205744&&i<=210041||i>=63744&&i<=64255||i>=12288&&i<=12351||i>=12352&&i<=12447||i>=12448&&i<=12543||i>=44032&&i<=55215||i>=65280&&i<=65519}function cr(i){for(let e=0;e<i.length;e++){const t=i.charCodeAt(e);if(!(t<12288)){if(t>=55296&&t<=56319&&e+1<i.length){const n=i.charCodeAt(e+1);if(n>=56320&&n<=57343){const s=(t-55296<<10)+(n-56320)+65536;if(Qg(s))return!0;e++;continue}}if(Qg(t))return!0}}return!1}function u1(i){const e=cl(i);return e!==null&&(ld.has(e)||lr.has(e))}const d1=new Set([" "," ","","\uFEFF"]);function f1(i){return cr(i)}function p1(i){const e=cl(i);return e!==null&&d1.has(e)}function A1(i){return!u1(i)&&!p1(i)}const ld=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),ol=new Set(['"',"(","[","{","“","‘","«","‹","(","〔","〈","《","「","『","【","〖","〘","〚"]),hd=new Set(["'","’"]),lr=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),g1=new Set([":",".","،","؛"]),m1=new Set(["၏"]),b1=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function x1(i){if(ud(i))return!0;let e=!1;for(const t of i){if(lr.has(t)){e=!0;continue}if(!(e&&al.test(t)))return!1}return e}function E1(i){for(const e of i)if(!ld.has(e)&&!lr.has(e))return!1;return i.length>0}function _1(i){if(ud(i))return!0;for(const e of i)if(!ol.has(e)&&!hd.has(e)&&!al.test(e))return!1;return i.length>0}function ud(i){let e=!1;for(const t of i)if(!(t==="\\"||al.test(t))){if(ol.has(t)||lr.has(t)||hd.has(t)){e=!0;continue}return!1}return e}function Gg(i,e){const t=e-1;if(t<=0)return Math.max(t,0);const n=i.charCodeAt(t);if(n<56320||n>57343)return t;const s=t-1;if(s<0)return t;const r=i.charCodeAt(s);return r>=55296&&r<=56319?s:t}function cl(i){if(i.length===0)return null;const e=Gg(i,i.length);return i.slice(e)}function y1(i){const e=Array.from(i);let t=e.length;for(;t>0;){const n=e[t-1];if(al.test(n)){t--;continue}if(ol.has(n)||hd.has(n)){t--;continue}break}return t<=0||t===e.length?null:{head:e.slice(0,t).join(""),tail:e.slice(t).join("")}}function w1(i,e,t){return t==="text"&&!e&&i.length===1&&i!=="-"&&i!=="—"?i:null}function Hg(i,e,t,n){const s=e[n],r=i[n];if(s==null)return r;const a=t[n];if(r.length===a)return r;const o=s.repeat(a);return i[n]=o,o}function zg(i,e){return i&&e!==null&&g1.has(e)}function C1(i){const e=cl(i);return e!==null&&m1.has(e)}function v1(i){if(i.length<2||i[0]!==" ")return null;const e=i.slice(1);return new RegExp("^\\p{M}+$","u").test(e)?{space:" ",marks:e}:null}function dd(i){let e=i.length;for(;e>0;){const t=Gg(i,e),n=i.slice(t,e);if(b1.has(n))return!0;if(!lr.has(n))return!1;e=t}return!1}function S1(i,e){if(e.preserveOrdinarySpaces||e.preserveHardBreaks){if(i===" ")return"preserved-space";if(i===" ")return"tab";if(e.preserveHardBreaks&&i===`+`)return"hard-break"}return i===" "?"space":i===" "||i===" "||i===""||i==="\uFEFF"?"glue":i===""?"zero-width-break":i===""?"soft-hyphen":"text"}const I1=/[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;function ei(i){return i.length===1?i[0]:i.join("")}function M1(i,e){const t=[];for(let n=i.length-1;n>=0;n--)t.push(i[n]);return t.push(e),ei(t)}function B1(i,e,t,n){if(!I1.test(i))return[{text:i,isWordLike:e,kind:"text",start:t}];const s=[];let r=null,a=[],o=t,c=!1,l=0;for(const h of i){const u=S1(h,n),d=u==="text"&&e;if(r!==null&&u===r&&d===c){a.push(h),l+=h.length;continue}r!==null&&s.push({text:ei(a),isWordLike:c,kind:r,start:o}),r=u,a=[h],o=t+l,c=d,l+=h.length}return r!==null&&s.push({text:ei(a),isWordLike:c,kind:r,start:o}),s}function fd(i){return i==="space"||i==="preserved-space"||i==="zero-width-break"||i==="hard-break"}const T1=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function R1(i,e){const t=i.texts[e];return t.startsWith("www.")?!0:T1.test(t)&&e+1<i.len&&i.kinds[e+1]==="text"&&i.texts[e+1]==="//"}function N1(i){return i.includes("?")&&(i.includes("://")||i.startsWith("www."))}function F1(i){const e=i.texts.slice(),t=i.isWordLike.slice(),n=i.kinds.slice(),s=i.starts.slice();for(let a=0;a<i.len;a++){if(n[a]!=="text"||!R1(i,a))continue;const o=[e[a]];let c=a+1;for(;c<i.len&&!fd(n[c]);){o.push(e[c]),t[a]=!0;const l=e[c].includes("?");if(n[c]="text",e[c]="",c++,l)break}e[a]=ei(o)}let r=0;for(let a=0;a<e.length;a++){const o=e[a];o.length!==0&&(r!==a&&(e[r]=o,t[r]=t[a],n[r]=n[a],s[r]=s[a]),r++)}return e.length=r,t.length=r,n.length=r,s.length=r,{len:r,texts:e,isWordLike:t,kinds:n,starts:s}}function D1(i){const e=[],t=[],n=[],s=[];for(let r=0;r<i.len;r++){const a=i.texts[r];if(e.push(a),t.push(i.isWordLike[r]),n.push(i.kinds[r]),s.push(i.starts[r]),!N1(a))continue;const o=r+1;if(o>=i.len||fd(i.kinds[o]))continue;const c=[],l=i.starts[o];let h=o;for(;h<i.len&&!fd(i.kinds[h]);)c.push(i.texts[h]),h++;c.length>0&&(e.push(ei(c)),t.push(!0),n.push("text"),s.push(l),r=h-1)}return{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}const L1=new Set([":","-","/","×",",",".","+","–","—"]),Vg=/^[A-Za-z0-9_]+[,:;]*$/,Wg=/[,:;]+$/;function qg(i){for(const e of i)if(Ug.test(e))return!0;return!1}function ll(i){if(i.length===0)return!1;for(const e of i)if(!(Ug.test(e)||L1.has(e)))return!1;return!0}function P1(i){const e=[],t=[],n=[],s=[];for(let r=0;r<i.len;r++){const a=i.texts[r],o=i.kinds[r];if(o==="text"&&ll(a)&&qg(a)){const c=[a];let l=r+1;for(;l<i.len&&i.kinds[l]==="text"&&ll(i.texts[l]);)c.push(i.texts[l]),l++;e.push(ei(c)),t.push(!0),n.push("text"),s.push(i.starts[r]),r=l-1;continue}e.push(a),t.push(i.isWordLike[r]),n.push(o),s.push(i.starts[r])}return{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}function k1(i){const e=[],t=[],n=[],s=[];for(let r=0;r<i.len;r++){const a=i.texts[r],o=i.kinds[r],c=i.isWordLike[r];if(o==="text"&&c&&Vg.test(a)){const l=[a];let h=Wg.test(a),u=r+1;for(;h&&u<i.len&&i.kinds[u]==="text"&&i.isWordLike[u]&&Vg.test(i.texts[u]);){const d=i.texts[u];l.push(d),h=Wg.test(d),u++}e.push(ei(l)),t.push(!0),n.push("text"),s.push(i.starts[r]),r=u-1;continue}e.push(a),t.push(c),n.push(o),s.push(i.starts[r])}return{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}function U1(i){const e=[],t=[],n=[],s=[];for(let r=0;r<i.len;r++){const a=i.texts[r];if(i.kinds[r]==="text"&&a.includes("-")){const o=a.split("-");let c=o.length>1;for(let l=0;l<o.length;l++){const h=o[l];if(!c)break;(h.length===0||!qg(h)||!ll(h))&&(c=!1)}if(c){let l=0;for(let h=0;h<o.length;h++){const u=o[h],d=h<o.length-1?`${u}-`:u;e.push(d),t.push(!0),n.push("text"),s.push(i.starts[r]+l),l+=d.length}continue}}e.push(a),t.push(i.isWordLike[r]),n.push(i.kinds[r]),s.push(i.starts[r])}return{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}function O1(i){const e=[],t=[],n=[],s=[];let r=0;for(;r<i.len;){const a=[i.texts[r]];let o=i.isWordLike[r],c=i.kinds[r],l=i.starts[r];if(c==="glue"){const h=[a[0]],u=l;for(r++;r<i.len&&i.kinds[r]==="glue";)h.push(i.texts[r]),r++;const d=ei(h);if(r<i.len&&i.kinds[r]==="text")a[0]=d,a.push(i.texts[r]),o=i.isWordLike[r],c="text",l=u,r++;else{e.push(d),t.push(!1),n.push("glue"),s.push(u);continue}}else r++;if(c==="text")for(;r<i.len&&i.kinds[r]==="glue";){const h=[];for(;r<i.len&&i.kinds[r]==="glue";)h.push(i.texts[r]),r++;const u=ei(h);if(r<i.len&&i.kinds[r]==="text"){a.push(u,i.texts[r]),o=o||i.isWordLike[r],r++;continue}a.push(u)}e.push(ei(a)),t.push(o),n.push(c),s.push(l)}return{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}function Q1(i){const e=i.texts.slice(),t=i.isWordLike.slice(),n=i.kinds.slice(),s=i.starts.slice();for(let r=0;r<e.length-1;r++){if(n[r]!=="text"||n[r+1]!=="text"||!cr(e[r])||!cr(e[r+1]))continue;const a=y1(e[r]);a!==null&&(e[r]=a.head,e[r+1]=a.tail+e[r+1],s[r+1]=s[r]+a.head.length)}return{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}function Kg(i,e,t){const n=l1();let s=0;const r=[],a=[],o=[],c=[],l=[],h=[],u=[],d=[],f=[],m=[],g=[],A=[];for(const w of n.segment(i))for(const S of B1(w.segment,w.isWordLike??!1,w.index,t)){let O=function(){h[D]!==null&&(a[D]=[Hg(r,h,u,D)],h[D]=null),a[D].push(S.text),o[D]=o[D]||S.isWordLike,d[D]=d[D]||C,f[D]=f[D]||F,m[D]=q,g[D]=$,A[D]=zg(f[D],K)};const T=S.kind==="text",v=w1(S.text,S.isWordLike,S.kind),C=cr(S.text),F=Og(S.text),K=cl(S.text),q=dd(S.text),$=C1(S.text),D=s-1;e.carryCJKAfterClosingQuote&&T&&s>0&&c[D]==="text"&&C&&d[D]&&m[D]||T&&s>0&&c[D]==="text"&&E1(S.text)&&d[D]||T&&s>0&&c[D]==="text"&&g[D]?O():T&&s>0&&c[D]==="text"&&S.isWordLike&&F&&A[D]?(O(),o[D]=!0):v!==null&&s>0&&c[D]==="text"&&h[D]===v?u[D]=(u[D]??1)+1:T&&!S.isWordLike&&s>0&&c[D]==="text"&&(x1(S.text)||S.text==="-"&&o[D])?O():(r[s]=S.text,a[s]=[S.text],o[s]=S.isWordLike,c[s]=S.kind,l[s]=S.start,h[s]=v,u[s]=v===null?0:1,d[s]=C,f[s]=F,m[s]=q,g[s]=$,A[s]=zg(F,K),s++)}for(let w=0;w<s;w++){if(h[w]!==null){r[w]=Hg(r,h,u,w);continue}r[w]=ei(a[w])}for(let w=1;w<s;w++)c[w]==="text"&&!o[w]&&ud(r[w])&&c[w-1]==="text"&&(r[w-1]+=r[w],o[w-1]=o[w-1]||o[w],r[w]="");const p=Array.from({length:s},()=>null);let y=-1;for(let w=s-1;w>=0;w--){const S=r[w];if(S.length!==0){if(c[w]==="text"&&!o[w]&&_1(S)&&y>=0&&c[y]==="text"){const T=p[y]??[];T.push(S),p[y]=T,l[y]=l[w],r[w]="";continue}y=w}}for(let w=0;w<s;w++){const S=p[w];S!=null&&(r[w]=M1(S,r[w]))}let b=0;for(let w=0;w<s;w++){const S=r[w];S.length!==0&&(b!==w&&(r[b]=S,o[b]=o[w],c[b]=c[w],l[b]=l[w]),b++)}r.length=b,o.length=b,c.length=b,l.length=b;const _=O1({len:b,texts:r,isWordLike:o,kinds:c,starts:l}),M=Q1(k1(U1(P1(D1(F1(_))))));for(let w=0;w<M.len-1;w++){const S=v1(M.texts[w]);S!==null&&(M.kinds[w]!=="space"&&M.kinds[w]!=="preserved-space"||M.kinds[w+1]!=="text"||!Og(M.texts[w+1])||(M.texts[w]=S.space,M.isWordLike[w]=!1,M.kinds[w]=M.kinds[w]==="preserved-space"?"preserved-space":"space",M.texts[w+1]=S.marks+M.texts[w+1],M.starts[w+1]=M.starts[w]+S.space.length))}return M}function G1(i,e){if(i.len===0)return[];if(!e.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:i.len,consumedEndSegmentIndex:i.len}];const t=[];let n=0;for(let s=0;s<i.len;s++)i.kinds[s]==="hard-break"&&(t.push({startSegmentIndex:n,endSegmentIndex:s,consumedEndSegmentIndex:s+1}),n=s+1);return n<i.len&&t.push({startSegmentIndex:n,endSegmentIndex:i.len,consumedEndSegmentIndex:i.len}),t}function H1(i){if(i.len<=1)return i;const e=[],t=[],n=[],s=[];let r=null,a=!1,o=0,c=!1,l=!1;function h(){r!==null&&(e.push(ei(r)),t.push(a),n.push("text"),s.push(o),r=null)}for(let u=0;u<i.len;u++){const d=i.texts[u],f=i.kinds[u],m=i.isWordLike[u],g=i.starts[u];if(f==="text"){const A=f1(d),p=A1(d);if(r!==null&&c&&l){r.push(d),a=a||m,c=c||A,l=p;continue}h(),r=[d],a=m,o=g,c=A,l=p;continue}h(),e.push(d),t.push(m),n.push(f),s.push(g)}return h(),{len:e.length,texts:e,isWordLike:t,kinds:n,starts:s}}function z1(i,e,t="normal",n="normal"){const s=r1(t),r=s.mode==="pre-wrap"?o1(i):a1(i);if(r.length===0)return{normalized:r,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};const a=n==="keep-all"?H1(Kg(r,e,s)):Kg(r,e,s);return{normalized:r,chunks:G1(a,s),...a}}let ga=null;const Xg=new Map;let ma=null;const V1=96,W1=new RegExp("\\p{Emoji_Presentation}","u"),q1=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;let pd=null;const Yg=new Map;function Ad(){if(ga!==null)return ga;if(typeof OffscreenCanvas<"u")return ga=new OffscreenCanvas(1,1).getContext("2d"),ga;if(typeof document<"u")return ga=document.createElement("canvas").getContext("2d"),ga;throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function K1(i){let e=Xg.get(i);return e||(e=new Map,Xg.set(i,e)),e}function Ds(i,e){let t=e.get(i);return t===void 0&&(t={width:Ad().measureText(i).width,containsCJK:cr(i)},e.set(i,t)),t}function ba(){if(ma!==null)return ma;if(typeof navigator>"u")return ma={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},ma;const i=navigator.userAgent,t=navigator.vendor==="Apple Computer, Inc."&&i.includes("Safari/")&&!i.includes("Chrome/")&&!i.includes("Chromium/")&&!i.includes("CriOS/")&&!i.includes("FxiOS/")&&!i.includes("EdgiOS/"),n=i.includes("Chrome/")||i.includes("Chromium/")||i.includes("CriOS/")||i.includes("Edg/");return ma={lineFitEpsilon:t?1/64:.005,carryCJKAfterClosingQuote:n,preferPrefixWidthsForBreakableRuns:t,preferEarlySoftHyphenBreak:t},ma}function X1(i){const e=i.match(/(\d+(?:\.\d+)?)\s*px/);return e?parseFloat(e[1]):16}function jg(){return pd===null&&(pd=new Intl.Segmenter(void 0,{granularity:"grapheme"})),pd}function Y1(i){return W1.test(i)||i.includes("️")}function j1(i){return q1.test(i)}function J1(i,e){let t=Yg.get(i);if(t!==void 0)return t;const n=Ad();n.font=i;const s=n.measureText("😀").width;if(t=0,s>e+.5&&typeof document<"u"&&document.body!==null){const r=document.createElement("span");r.style.font=i,r.style.display="inline-block",r.style.visibility="hidden",r.style.position="absolute",r.textContent="😀",document.body.appendChild(r);const a=r.getBoundingClientRect().width;document.body.removeChild(r),s-a>.5&&(t=s-a)}return Yg.set(i,t),t}function Z1(i){let e=0;const t=jg();for(const n of t.segment(i))Y1(n.segment)&&e++;return e}function $1(i,e){return e.emojiCount===void 0&&(e.emojiCount=Z1(i)),e.emojiCount}function hr(i,e,t){return t===0?e.width:e.width-$1(i,e)*t}function eM(i,e,t,n,s){if(e.breakableFitAdvances!==void 0)return e.breakableFitAdvances;const r=jg(),a=[];for(const h of r.segment(i))a.push(h.segment);if(a.length<=1)return e.breakableFitAdvances=null,e.breakableFitAdvances;if(s==="sum-graphemes"){const h=[];for(const u of a){const d=Ds(u,t);h.push(hr(u,d,n))}return e.breakableFitAdvances=h,e.breakableFitAdvances}if(s==="pair-context"||a.length>V1){const h=[];let u=null,d=0;for(const f of a){const m=Ds(f,t),g=hr(f,m,n);if(u===null)h.push(g);else{const A=u+f,p=Ds(A,t);h.push(hr(A,p,n)-d)}u=f,d=g}return e.breakableFitAdvances=h,e.breakableFitAdvances}const o=[];let c="",l=0;for(const h of a){c+=h;const u=Ds(c,t),d=hr(c,u,n);o.push(d-l),l=d}return e.breakableFitAdvances=o,e.breakableFitAdvances}function tM(i,e){const t=Ad();t.font=i;const n=K1(i),s=X1(i),r=e?J1(i,s):0;return{cache:n,fontSize:s,emojiCorrection:r}}function nM(i,e){for(;e<i.widths.length;){const t=i.kinds[e];if(t!=="space"&&t!=="zero-width-break"&&t!=="soft-hyphen")break;e++}return e}function Jg(i,e){if(e<=0)return 0;const t=i%e;return Math.abs(t)<=1e-6?e:e-t}function Zg(i,e,t,n,s){let r=0,a=e;for(;r<i.length;){const o=a+i[r];if((r+1<i.length?o+s:o)>t+n)break;a=o,r++}return{fitCount:r,fittedWidth:a}}function iM(i,e){let t=0,n=i.chunks.length;for(;t<n;){const s=Math.floor((t+n)/2);e<i.chunks[s].consumedEndSegmentIndex?n=s:t=s+1}return t<i.chunks.length?t:-1}function $g(i,e,t){let n=t.segmentIndex;if(t.graphemeIndex>0)return e;const s=i.chunks[e];if(s.startSegmentIndex===s.endSegmentIndex&&n===s.startSegmentIndex)return t.segmentIndex=n,t.graphemeIndex=0,e;for(n<s.startSegmentIndex&&(n=s.startSegmentIndex);n<s.endSegmentIndex;){const r=i.kinds[n];if(r!=="space"&&r!=="zero-width-break"&&r!=="soft-hyphen")return t.segmentIndex=n,t.graphemeIndex=0,e;n++}return s.consumedEndSegmentIndex>=i.widths.length?-1:(t.segmentIndex=s.consumedEndSegmentIndex,t.graphemeIndex=0,e+1)}function gd(i,e){if(e.segmentIndex>=i.widths.length)return-1;const t=iM(i,e.segmentIndex);return t<0?-1:$g(i,t,e)}function sM(i,e,t){if(t.segmentIndex>=i.widths.length)return-1;let n=e;for(;n<i.chunks.length&&t.segmentIndex>=i.chunks[n].consumedEndSegmentIndex;)n++;return n>=i.chunks.length?-1:$g(i,n,t)}function rM(i,e){return i.simpleLineWalkFastPath?em(i,e):md(i,e)}function em(i,e,t){const{widths:n,kinds:s,breakableFitAdvances:r}=i;if(n.length===0)return 0;const o=ba().lineFitEpsilon,c=e+o;let l=0,h=0,u=!1,d=0,f=0,m=0,g=0,A=-1,p=0;function y(){A=-1,p=0}function b(v=m,C=g,F=h){l++,t?.({startSegmentIndex:d,startGraphemeIndex:f,endSegmentIndex:v,endGraphemeIndex:C,width:F}),h=0,u=!1,y()}function _(v,C){u=!0,d=v,f=0,m=v+1,g=0,h=C}function M(v,C,F){u=!0,d=v,f=C,m=v,g=C+1,h=F}function w(v,C){if(!u){_(v,C);return}h+=C,m=v+1,g=0}function S(v,C){const F=r[v];for(let K=C;K<F.length;K++){const q=F[K];u?h+q>c?(b(),M(v,K,q)):(h+=q,m=v,g=K+1):M(v,K,q)}u&&m===v&&g===F.length&&(m=v+1,g=0)}let T=0;for(;T<n.length&&!(!u&&(T=nM(i,T),T>=n.length));){const v=n[T],C=s[T],F=C==="space"||C==="preserved-space"||C==="tab"||C==="zero-width-break"||C==="soft-hyphen";if(!u){v>e&&r[T]!==null?S(T,0):_(T,v),F&&(A=T+1,p=h-v),T++;continue}if(h+v>c){if(F){w(T,v),b(T+1,0,h-v),T++;continue}if(A>=0){if(m>A||m===A&&g>0){b();continue}b(A,0,p);continue}if(v>e&&r[T]!==null){b(),S(T,0),T++;continue}b();continue}w(T,v),F&&(A=T+1,p=h-v),T++}return u&&b(),l}function md(i,e,t){if(i.simpleLineWalkFastPath)return em(i,e,t);const{widths:n,lineEndFitAdvances:s,lineEndPaintAdvances:r,kinds:a,breakableFitAdvances:o,discretionaryHyphenWidth:c,tabStopAdvance:l,chunks:h}=i;if(n.length===0||h.length===0)return 0;const u=ba(),d=u.lineFitEpsilon,f=e+d;let m=0,g=0,A=!1,p=0,y=0,b=0,_=0,M=-1,w=0,S=0,T=null;function v(){M=-1,w=0,S=0,T=null}function C(Q=b,J=_,ee=g){m++,t?.({startSegmentIndex:p,startGraphemeIndex:y,endSegmentIndex:Q,endGraphemeIndex:J,width:ee}),g=0,A=!1,v()}function F(Q,J){A=!0,p=Q,y=0,b=Q+1,_=0,g=J}function K(Q,J,ee){A=!0,p=Q,y=J,b=Q,_=J+1,g=ee}function q(Q,J){if(!A){F(Q,J);return}g+=J,b=Q+1,_=0}function $(Q,J,ee,ae){if(!J)return;const ye=Q==="tab"?0:s[ee],Me=Q==="tab"?ae:r[ee];M=ee+1,w=g-ae+ye,S=g-ae+Me,T=Q}function D(Q,J){const ee=o[Q];for(let ae=J;ae<ee.length;ae++){const ye=ee[ae];A?g+ye>f?(C(),K(Q,ae,ye)):(g+=ye,b=Q,_=ae+1):K(Q,ae,ye)}A&&b===Q&&_===ee.length&&(b=Q+1,_=0)}function O(Q){if(T!=="soft-hyphen")return!1;const J=o[Q];if(J==null)return!1;const{fitCount:ee,fittedWidth:ae}=Zg(J,g,e,d,c);return ee===0?!1:(g=ae,b=Q,_=ee,v(),ee===J.length?(b=Q+1,_=0,!0):(C(Q,ee,ae+c),D(Q,ee),!0))}function j(Q){m++,t?.({startSegmentIndex:Q.startSegmentIndex,startGraphemeIndex:0,endSegmentIndex:Q.consumedEndSegmentIndex,endGraphemeIndex:0,width:0}),v()}for(let Q=0;Q<h.length;Q++){const J=h[Q];if(J.startSegmentIndex===J.endSegmentIndex){j(J);continue}A=!1,g=0,p=J.startSegmentIndex,y=0,b=J.startSegmentIndex,_=0,v();let ee=J.startSegmentIndex;for(;ee<J.endSegmentIndex;){const ae=a[ee],ye=ae==="space"||ae==="preserved-space"||ae==="tab"||ae==="zero-width-break"||ae==="soft-hyphen",Me=ae==="tab"?Jg(g,l):n[ee];if(ae==="soft-hyphen"){A&&(b=ee+1,_=0,M=ee+1,w=g+c,S=g+c,T=ae),ee++;continue}if(!A){Me>e&&o[ee]!==null?D(ee,0):F(ee,Me),$(ae,ye,ee,Me),ee++;continue}if(g+Me>f){const me=g+(ae==="tab"?0:s[ee]),be=g+(ae==="tab"?Me:r[ee]);if(T==="soft-hyphen"&&u.preferEarlySoftHyphenBreak&&w<=f){C(M,0,S);continue}if(T==="soft-hyphen"&&O(ee)){ee++;continue}if(ye&&me<=f){q(ee,Me),C(ee+1,0,be),ee++;continue}if(M>=0&&w<=f){if(b>M||b===M&&_>0){C();continue}const xe=M;C(xe,0,S),ee=xe;continue}if(Me>e&&o[ee]!==null){C(),D(ee,0),ee++;continue}C();continue}q(ee,Me),$(ae,ye,ee,Me),ee++}if(A){const ae=M===J.consumedEndSegmentIndex?S:g;C(J.consumedEndSegmentIndex,0,ae)}}return m}function bd(i,e,t,n){const s=i.chunks[t];if(s.startSegmentIndex===s.endSegmentIndex)return e.segmentIndex=s.consumedEndSegmentIndex,e.graphemeIndex=0,0;const{widths:r,lineEndFitAdvances:a,lineEndPaintAdvances:o,kinds:c,breakableFitAdvances:l,discretionaryHyphenWidth:h,tabStopAdvance:u}=i,d=ba(),f=d.lineFitEpsilon,m=n+f;let g=0,A=!1,p=e.segmentIndex,y=e.graphemeIndex,b=-1,_=0,M=0,w=null;function S(){b=-1,_=0,M=0,w=null}function T(D=p,O=y,j=g){return A?(e.segmentIndex=D,e.graphemeIndex=O,j):null}function v(D,O){A=!0,p=D+1,y=0,g=O}function C(D,O,j){A=!0,p=D,y=O+1,g=j}function F(D,O){if(!A){v(D,O);return}g+=O,p=D+1,y=0}function K(D,O,j,Q){if(!O)return;const J=D==="tab"?0:a[j],ee=D==="tab"?Q:o[j];b=j+1,_=g-Q+J,M=g-Q+ee,w=D}function q(D,O){const j=l[D];for(let Q=O;Q<j.length;Q++){const J=j[Q];if(!A)C(D,Q,J);else{if(g+J>m)return T();g+=J,p=D,y=Q+1}}return A&&p===D&&y===j.length&&(p=D+1,y=0),null}function $(D){if(w!=="soft-hyphen"||b<0)return null;const O=l[D]??null;if(O!==null){const{fitCount:j,fittedWidth:Q}=Zg(O,g,n,f,h);if(j===O.length)return g=Q,p=D+1,y=0,S(),null;if(j>0)return T(D,j,Q+h)}return _<=m?T(b,0,M):null}for(let D=e.segmentIndex;D<s.endSegmentIndex;D++){const O=c[D],j=O==="space"||O==="preserved-space"||O==="tab"||O==="zero-width-break"||O==="soft-hyphen",Q=D===e.segmentIndex?e.graphemeIndex:0,J=O==="tab"?Jg(g,u):r[D];if(O==="soft-hyphen"&&Q===0){A&&(p=D+1,y=0,b=D+1,_=g+h,M=g+h,w=O);continue}if(!A){if(Q>0){const ae=q(D,Q);if(ae!==null)return ae}else if(J>n&&l[D]!==null){const ae=q(D,0);if(ae!==null)return ae}else v(D,J);K(O,j,D,J);continue}if(g+J>m){const ae=g+(O==="tab"?0:a[D]),ye=g+(O==="tab"?J:o[D]);if(w==="soft-hyphen"&&d.preferEarlySoftHyphenBreak&&_<=m)return T(b,0,M);const Me=$(D);if(Me!==null)return Me;if(j&&ae<=m)return F(D,J),T(D+1,0,ye);if(b>=0&&_<=m)return p>b||p===b&&y>0?T():T(b,0,M);if(J>n&&l[D]!==null){const se=T();if(se!==null)return se;const me=q(D,0);if(me!==null)return me}return T()}F(D,J),K(O,j,D,J)}return b===s.consumedEndSegmentIndex&&y===0?T(s.consumedEndSegmentIndex,0,M):T(s.consumedEndSegmentIndex,0,g)}function tm(i,e,t){const{widths:n,kinds:s,breakableFitAdvances:r}=i,o=ba().lineFitEpsilon,c=t+o;let l=0,h=!1,u=e.segmentIndex,d=e.graphemeIndex,f=-1,m=0;for(let g=e.segmentIndex;g<n.length;g++){const A=n[g],p=s[g],y=p==="space"||p==="preserved-space"||p==="tab"||p==="zero-width-break"||p==="soft-hyphen",b=g===e.segmentIndex?e.graphemeIndex:0,_=r[g];if(!h){if(b>0||A>t&&_!==null){const M=_,w=M[b];h=!0,l=w,u=g,d=b+1;for(let S=b+1;S<M.length;S++){const T=M[S];if(l+T>c)return e.segmentIndex=u,e.graphemeIndex=d,l;l+=T,u=g,d=S+1}u===g&&d===M.length&&(u=g+1,d=0)}else h=!0,l=A,u=g+1,d=0;y&&(f=g+1,m=l-A);continue}if(l+A>c)return y?(e.segmentIndex=g+1,e.graphemeIndex=0,l):f>=0?u>f||u===f&&d>0?(e.segmentIndex=u,e.graphemeIndex=d,l):(e.segmentIndex=f,e.graphemeIndex=0,m):(e.segmentIndex=u,e.graphemeIndex=d,l);l+=A,u=g+1,d=0,y&&(f=g+1,m=l-A)}return h?(e.segmentIndex=u,e.graphemeIndex=d,l):null}function xd(i,e,t){const n={segmentIndex:e.segmentIndex,graphemeIndex:e.graphemeIndex},s=gd(i,n);if(s<0)return null;const r=n.segmentIndex,a=n.graphemeIndex,o=i.simpleLineWalkFastPath?tm(i,n,t):bd(i,n,s,t);return o===null?null:{startSegmentIndex:r,startGraphemeIndex:a,endSegmentIndex:n.segmentIndex,endGraphemeIndex:n.graphemeIndex,width:o}}function aM(i,e,t){const n=gd(i,e);return n<0?null:i.simpleLineWalkFastPath?tm(i,e,t):bd(i,e,n,t)}function oM(i,e){if(i.widths.length===0)return{lineCount:0,maxLineWidth:0};const t={segmentIndex:0,graphemeIndex:0};let n=0,s=0;if(!i.simpleLineWalkFastPath){let r=gd(i,t);for(;r>=0;){const a=bd(i,t,r,e);if(a===null)return{lineCount:n,maxLineWidth:s};n++,a>s&&(s=a),r=sM(i,r,t)}return{lineCount:n,maxLineWidth:s}}for(;;){const r=aM(i,t,e);if(r===null)return{lineCount:n,maxLineWidth:s};n++,r>s&&(s=r)}}let Ed=null,nm=new WeakMap;function im(){return Ed===null&&(Ed=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Ed}function cM(i){return i?{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]}:{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[]}}function lM(i,e){const t=[];let n=[],s=0,r=!1,a=!1,o=!1;function c(){n.length!==0&&(t.push({text:n.length===1?n[0]:n.join(""),start:s}),n=[],r=!1,a=!1,o=!1)}function l(u,d,f){n=[u],s=d,r=f,a=dd(u),o=ol.has(u)}function h(u,d){n.push(u),r=r||d;const f=dd(u);u.length===1&&lr.has(u)?a=a||f:a=f,o=!1}for(const u of im().segment(i)){const d=u.segment,f=cr(d);if(n.length===0){l(d,u.index,f);continue}if(o||ld.has(d)||lr.has(d)||e.carryCJKAfterClosingQuote&&f&&a){h(d,f);continue}if(!r&&!f){h(d,f);continue}c(),l(d,u.index,f)}return c(),t}function hM(i,e,t,n){const s=ba(),{cache:r,emojiCorrection:a}=tM(e,j1(i.normalized)),o=hr("-",Ds("-",r),a),l=hr(" ",Ds(" ",r),a)*8;if(i.len===0)return cM(t);const h=[],u=[],d=[],f=[];let m=i.chunks.length<=1;const g=t?[]:null,A=[],p=t?[]:null,y=Array.from({length:i.len});function b(S,T,v,C,F,K,q){F!=="text"&&F!=="space"&&F!=="zero-width-break"&&(m=!1),h.push(T),u.push(v),d.push(C),f.push(F),g?.push(K),A.push(q),p!==null&&p.push(S)}function _(S,T,v,C,F){const K=Ds(S,r),q=hr(S,K,a),$=T==="space"||T==="preserved-space"||T==="zero-width-break"?0:q,D=T==="space"||T==="zero-width-break"?0:q;if(F&&C&&S.length>1){let O="sum-graphemes";ll(S)?O="pair-context":s.preferPrefixWidthsForBreakableRuns&&(O="segment-prefixes");const j=eM(S,K,r,a,O);b(S,q,$,D,T,v,j);return}b(S,q,$,D,T,v,null)}for(let S=0;S<i.len;S++){y[S]=h.length;const T=i.texts[S],v=i.isWordLike[S],C=i.kinds[S],F=i.starts[S];if(C==="soft-hyphen"){b(T,0,o,o,C,F,null);continue}if(C==="hard-break"){b(T,0,0,0,C,F,null);continue}if(C==="tab"){b(T,0,0,0,C,F,null);continue}const K=Ds(T,r);if(C==="text"&&K.containsCJK){const $=lM(T,s);for(let D=0;D<$.length;D++){const O=$[D];_(O.text,"text",F+O.start,v,!cr(O.text))}continue}_(T,C,F,v,!0)}const M=uM(i.chunks,y,h.length),w=g===null?null:n1(i.normalized,g);return p!==null?{widths:h,lineEndFitAdvances:u,lineEndPaintAdvances:d,kinds:f,simpleLineWalkFastPath:m,segLevels:w,breakableFitAdvances:A,discretionaryHyphenWidth:o,tabStopAdvance:l,chunks:M,segments:p}:{widths:h,lineEndFitAdvances:u,lineEndPaintAdvances:d,kinds:f,simpleLineWalkFastPath:m,segLevels:w,breakableFitAdvances:A,discretionaryHyphenWidth:o,tabStopAdvance:l,chunks:M}}function uM(i,e,t){const n=[];for(let s=0;s<i.length;s++){const r=i[s],a=r.startSegmentIndex<e.length?e[r.startSegmentIndex]:t,o=r.endSegmentIndex<e.length?e[r.endSegmentIndex]:t,c=r.consumedEndSegmentIndex<e.length?e[r.consumedEndSegmentIndex]:t;n.push({startSegmentIndex:a,endSegmentIndex:o,consumedEndSegmentIndex:c})}return n}function sm(i,e,t,n){const r=z1(i,ba(),n?.whiteSpace,"normal");return hM(r,e,t)}function hl(i,e,t){return sm(i,e,!1,t)}function ul(i,e,t){return sm(i,e,!0,t)}function aL(i){return i}function dM(i,e,t){const n=rM(i,e);return{lineCount:n,height:n*t}}function rm(i,e,t){let n=t.get(i);if(n!==void 0)return n;n=[];const s=im();for(const r of s.segment(e[i]))n.push(r.segment);return t.set(i,n),n}function am(i){let e=nm.get(i);return e!==void 0||(e=new Map,nm.set(i,e)),e}function fM(i,e,t,n){return n>0&&i[n-1]==="soft-hyphen"&&!(e===n&&t>0)}function pM(i,e,t,n,s,r,a){let o="";const c=fM(e,n,s,r);for(let l=n;l<r;l++)e[l]==="soft-hyphen"||e[l]==="hard-break"||(l===n&&s>0?o+=rm(l,i,t).slice(s).join(""):o+=i[l]);return a>0?(c&&(o+="-"),o+=rm(r,i,t).slice(n===r?s:0,a).join("")):c&&(o+="-"),o}function om(i,e,t,n,s,r,a){return{text:pM(i.segments,i.kinds,e,n,s,r,a),width:t,start:{segmentIndex:n,graphemeIndex:s},end:{segmentIndex:r,graphemeIndex:a}}}function AM(i,e,t){return om(i,e,t.width,t.startSegmentIndex,t.startGraphemeIndex,t.endSegmentIndex,t.endGraphemeIndex)}function gM(i){return{width:i.width,start:{segmentIndex:i.startSegmentIndex,graphemeIndex:i.startGraphemeIndex},end:{segmentIndex:i.endSegmentIndex,graphemeIndex:i.endGraphemeIndex}}}function mM(i,e){return om(i,am(i),e.width,e.start.segmentIndex,e.start.graphemeIndex,e.end.segmentIndex,e.end.graphemeIndex)}function bM(i,e,t){return i.widths.length===0?0:md(i,e,n=>{t(gM(n))})}function _d(i,e){return oM(i,e)}function cm(i){let e=0;return bM(i,Number.POSITIVE_INFINITY,t=>{t.width>e&&(e=t.width)}),e}function xM(i,e,t){const n=[];if(i.widths.length===0)return{lineCount:0,height:0,lines:n};const s=am(i),r=md(i,e,a=>{n.push(AM(i,s,a))});return{lineCount:r,height:r*t,lines:n}}const EM=/[ \t\n\f\r]+/,lm=/^[ \t\n\f\r]+/,hm=/[ \t\n\f\r]+$/,dl={segmentIndex:0,graphemeIndex:0},um={itemIndex:0,segmentIndex:0,graphemeIndex:0};function oL(i){return i}function yd(i){return{segmentIndex:i.segmentIndex,graphemeIndex:i.graphemeIndex}}function dm(i){return i.segmentIndex===0&&i.graphemeIndex===0}function fl(i,e){const t=e.get(i);if(t!==void 0)return t;const n=cm(ul("A A",i)),s=cm(ul("AA",i)),r=Math.max(0,n-s);return e.set(i,r),r}function _M(i){const e=xd(i,dl,Number.POSITIVE_INFINITY);return e===null?null:{endGraphemeIndex:e.endGraphemeIndex,endSegmentIndex:e.endSegmentIndex,width:e.width}}function yM(i,e){return i===0&&e>0}function fm(i){const e=[],t=Array.from({length:i.length}),n=new Map;let s=0;for(let r=0;r<i.length;r++){const a=i[r],o=lm.test(a.text),c=hm.test(a.text),l=a.text.replace(lm,"").replace(hm,"");if(l.length===0){EM.test(a.text)&&s===0&&(s=fl(a.font,n));continue}const h=s>0?s:o?fl(a.font,n):0,u=ul(l,a.font),d=_M(u);if(d===null){s=c?fl(a.font,n):0;continue}const f={break:a.break??"normal",endGraphemeIndex:d.endGraphemeIndex,endSegmentIndex:d.endSegmentIndex,extraWidth:a.extraWidth??0,gapBefore:h,naturalWidth:d.width,prepared:u,sourceItemIndex:r};e.push(f),t[r]=f,s=c?fl(a.font,n):0}return{items:e,itemsBySourceItemIndex:t}}function wM(i,e,t,n){if(i.items.length===0||t.itemIndex>=i.items.length)return null;const s=Math.max(1,e);let r=0,a=s,o=t.itemIndex;const c={segmentIndex:t.segmentIndex,graphemeIndex:t.graphemeIndex};e:for(;o<i.items.length;){const l=i.items[o];if(!dm(c)&&c.segmentIndex===l.endSegmentIndex&&c.graphemeIndex===l.endGraphemeIndex){o++,c.segmentIndex=0,c.graphemeIndex=0;continue}const h=r===0?0:l.gapBefore,u=dm(c);if(l.break==="never"){if(!u){o++,c.segmentIndex=0,c.graphemeIndex=0;continue}const g=l.naturalWidth+l.extraWidth,A=h+g;if(r>0&&A>a)break e;n?.(l,h,g,yd(dl),{segmentIndex:l.endSegmentIndex,graphemeIndex:l.endGraphemeIndex}),r+=A,a=Math.max(0,s-r),o++,c.segmentIndex=0,c.graphemeIndex=0;continue}const d=h+l.extraWidth;if(r>0&&d>=a)break e;if(u){const g=d+l.naturalWidth;if(g<=a){n?.(l,h,l.naturalWidth+l.extraWidth,yd(dl),{segmentIndex:l.endSegmentIndex,graphemeIndex:l.endGraphemeIndex}),r+=g,a=Math.max(0,s-r),o++,c.segmentIndex=0,c.graphemeIndex=0;continue}}const f=Math.max(1,a-d),m=xd(l.prepared,c,f);if(m===null){o++,c.segmentIndex=0,c.graphemeIndex=0;continue}if(c.segmentIndex===m.endSegmentIndex&&c.graphemeIndex===m.endGraphemeIndex){o++,c.segmentIndex=0,c.graphemeIndex=0;continue}if(r>0&&u&&h>0&&yM(m.endSegmentIndex,m.endGraphemeIndex)){const g=xd(l.prepared,dl,Math.max(1,s-l.extraWidth));if(g!==null&&(g.endSegmentIndex>m.endSegmentIndex||g.endSegmentIndex===m.endSegmentIndex&&g.endGraphemeIndex>m.endGraphemeIndex))break e}if(n?.(l,h,m.width+l.extraWidth,yd(c),{segmentIndex:m.endSegmentIndex,graphemeIndex:m.endGraphemeIndex}),r+=h+m.width+l.extraWidth,a=Math.max(0,s-r),m.endSegmentIndex===l.endSegmentIndex&&m.endGraphemeIndex===l.endGraphemeIndex){o++,c.segmentIndex=0,c.graphemeIndex=0;continue}c.segmentIndex=m.endSegmentIndex,c.graphemeIndex=m.endGraphemeIndex;break}return r===0?null:(t.itemIndex=o,t.segmentIndex=c.segmentIndex,t.graphemeIndex=c.graphemeIndex,r)}function CM(i,e,t=um){const n=i,s={itemIndex:t.itemIndex,segmentIndex:t.segmentIndex,graphemeIndex:t.graphemeIndex},r=[],a=wM(n,e,s,(o,c,l,h,u)=>{r.push({itemIndex:o.sourceItemIndex,gapBefore:c,occupiedWidth:l,start:h,end:u})});return a===null?null:{fragments:r,width:a,end:s}}function vM(i,e){return mM(i.prepared,{width:e.occupiedWidth-i.extraWidth,start:e.start,end:e.end}).text}function pm(i,e){const t=i;return{fragments:e.fragments.map(n=>{const s=t.itemsBySourceItemIndex[n.itemIndex];if(s===void 0)throw new Error("Missing rich-text inline item for fragment");return{...n,text:vM(s,n)}}),width:e.width,end:e.end}}function Am(i,e,t){let n=0,s=um;for(;;){const r=CM(i,e,s);if(r===null)return n;t(r),n++,s=r.end}}const gm="500 14px Inter, sans-serif",wd="600 10px Inter, sans-serif",Cd="300 13px Inter, sans-serif",mm="600 10px Inter, sans-serif",bm="300 12px Inter, sans-serif",Co=18,pl=16,hn=16,Di=6,xm=12,Al=Math.min(window.devicePixelRatio||1,2),SM="rgba(0, 0, 0, 0.75)",IM="rgba(255, 255, 255, 0.08)",MM="rgba(255, 255, 255, 0.9)",BM="rgba(255, 255, 255, 0.30)",TM="rgba(255, 255, 255, 0.85)",Em="rgba(255, 255, 255, 0.08)",RM="rgba(255, 255, 255, 0.45)",NM="rgba(255, 255, 255, 0.08)",FM="rgba(255, 255, 255, 0.7)";function DM(i){let e=0,t=0,n=0;const s=new Set,r=new Set,a=new Set;let o=!1,c=!1;return i.traverse(l=>{if(l.isMesh||l.isPoints||l.isLine){n++;const h=l.geometry;h&&(h.index?t+=h.index.count/3:h.attributes.position&&(t+=h.attributes.position.count/3),h.attributes.position&&(e+=h.attributes.position.count)),l.skeleton&&(o=!0),l.morphTargetInfluences&&l.morphTargetInfluences.length>0&&(c=!0),(Array.isArray(l.material)?l.material:[l.material]).forEach(d=>{if(d){s.add(d.uuid),a.add(d.type.replace("Material",""));for(const f in d)d[f]&&d[f].isTexture&&r.add(d[f].uuid)}})}}),{vertices:e,triangles:Math.floor(t),meshes:n,materials:s.size,textures:r.size,materialTypes:Array.from(a),hasSkinning:o,hasMorphs:c}}function vo(i){return i>=1e6?(i/1e6).toFixed(1)+"M":i>=1e3?(i/1e3).toFixed(1)+"K":i.toString()}function LM(i,e){const t=[];return i.hasSkinning&&t.push("skinned"),i.hasMorphs&&t.push("morph targets"),e&&e.length>0&&t.push(`${e.length} animation${e.length>1?"s":""}`),i.materialTypes.length>0&&t.push(i.materialTypes.join(", ")),t.length>0?t.join(" · "):""}function PM(i,e,t){const n=DM(e),s=LM(n,t),r=[{label:"MESHES",value:vo(n.meshes)},{label:"VERTICES",value:vo(n.vertices)},{label:"TRIANGLES",value:vo(n.triangles)},{label:"MATERIALS",value:vo(n.materials)},{label:"TEXTURES",value:vo(n.textures)}];t&&t.length>0&&r.push({label:"ANIMATIONS",value:t.length.toString()});const a=[];n.materialTypes.forEach(w=>a.push(w)),n.hasSkinning&&a.push("Skinned"),n.hasMorphs&&a.push("Morph"),t&&t.length>0&&a.push("Animated");const o=200,c=hl("Model Info",gm),l=dM(c,o,Co+2),h=r.map(w=>{const S=[{text:w.label+" ",font:wd},{text:w.value,font:Cd}],T=fm(S),v=hl(w.label,wd),C=_d(v,o),F=hl(w.value,Cd),K=_d(F,o);return{...w,labelWidth:C.maxLineWidth,valueWidth:K.maxLineWidth,richPrepared:T}}),u=a.map(w=>{const S=hl(w,mm),T=_d(S,300);return{text:w,width:T.maxLineWidth+xm}});let d=[],f=0;if(s){const w=ul(s,bm),S=xM(w,o-hn,Co);d=S.lines,f=S.height}const m=Math.max(l.width+hn*2,...h.map(w=>w.labelWidth+w.valueWidth+hn*3)),g=Math.max(m,180);let A=0;if(u.length>0){let w=0,S=1;u.forEach(T=>{w>0&&w+T.width>g-hn*2&&(S++,w=0),w+=T.width+6}),A=S*(pl+6)+Di}const p=hn+l.height+Di+Di+h.length*(Co+Di)+A+(f>0?Di+f:0)+hn,y=document.createElement("canvas");y.width=g*Al,y.height=p*Al,y.style.width=g+"px",y.style.height=p+"px";const b=y.getContext("2d");b.scale(Al,Al),b.fillStyle=SM,vd(b,0,0,g,p,10),b.fill(),b.strokeStyle=IM,b.lineWidth=1,vd(b,.5,.5,g-1,p-1,10),b.stroke();let _=hn;if(b.font=gm,b.fillStyle=MM,b.textBaseline="top",b.fillText("Model Info",hn,_),_+=l.height+Di,b.strokeStyle=Em,b.beginPath(),b.moveTo(hn,_),b.lineTo(g-hn,_),b.stroke(),_+=Di,h.forEach(w=>{b.font=wd,b.fillStyle=BM,b.textAlign="left",b.fillText(w.label,hn,_),b.font=Cd,b.fillStyle=TM,b.textAlign="right",b.fillText(w.value,g-hn,_),b.textAlign="left",_+=Co+Di}),u.length>0){let w=hn;u.forEach(S=>{w>hn&&w+S.width>g-hn&&(w=hn,_+=pl+6),b.fillStyle=NM,vd(b,w,_,S.width,pl,4),b.fill(),b.font=mm,b.fillStyle=FM,b.textBaseline="top",b.fillText(S.text,w+xm/2,_+3),w+=S.width+6}),_+=pl+Di+4}d.length>0&&(b.strokeStyle=Em,b.beginPath(),b.moveTo(hn,_),b.lineTo(g-hn,_),b.stroke(),_+=Di,b.font=bm,b.fillStyle=RM,b.textBaseline="top",d.forEach(w=>{b.fillText(w.text,hn,_),_+=Co}));const M=document.createElement("div");return M.classList.add("model-info"),M.appendChild(y),i.appendChild(M),{el:M,canvas:y,remove(){M.remove()}}}function vd(i,e,t,n,s,r){i.beginPath(),i.moveTo(e+r,t),i.lineTo(e+n-r,t),i.quadraticCurveTo(e+n,t,e+n,t+r),i.lineTo(e+n,t+s-r),i.quadraticCurveTo(e+n,t+s,e+n-r,t+s),i.lineTo(e+r,t+s),i.quadraticCurveTo(e,t+s,e,t+s-r),i.lineTo(e,t+r),i.quadraticCurveTo(e,t,e+r,t),i.closePath()}const kM="500 11px Inter, sans-serif",_m="300 10px Inter, sans-serif",Sd=10,ym=6,wm=14,gl=Math.min(window.devicePixelRatio||1,2),UM=8;function OM(i){const e=[];return i.traverse(t=>{if(e.length>=UM||!t.isMesh||!t.name||t.name.startsWith("_"))return;const n=t.geometry,s=Array.isArray(t.material)?t.material[0]:t.material,r=n&&n.attributes.position?n.attributes.position.count:0,a=s?s.type.replace("Material",""):"",o=[{text:t.name,font:kM}];r>0&&o.push({text:" "+GM(r)+" verts",font:_m}),a&&o.push({text:" "+a,font:_m});const c=fm(o);let l=0,h=0;Am(c,300,g=>{const A=pm(c,g);l=Math.max(l,A.width),h++});const u=l+Sd*2,d=h*wm+ym*2;n&&n.computeBoundingBox();const f=n?n.boundingBox:null,m=new H;f?(f.getCenter(m),m.applyMatrix4(t.matrixWorld)):t.getWorldPosition(m),e.push({name:t.name,items:o,prepared:c,labelWidth:u,labelHeight:d,position:m,vertCount:r,matType:a})}),e}function QM(i){const{labelWidth:e,labelHeight:t,items:n,prepared:s}=i,r=document.createElement("canvas");r.width=e*gl,r.height=t*gl,r.style.width=e+"px",r.style.height=t+"px";const a=r.getContext("2d");a.scale(gl,gl),a.fillStyle="rgba(0, 0, 0, 0.8)",Cm(a,0,0,e,t,6),a.fill(),a.strokeStyle="rgba(255, 255, 255, 0.1)",a.lineWidth=1,Cm(a,.5,.5,e-1,t-1,6),a.stroke(),a.textBaseline="top";let o=ym;return Am(s,e-Sd*2,c=>{const l=pm(s,c);let h=Sd;l.fragments.forEach(u=>{h+=u.gapBefore;const d=n[u.itemIndex];a.font=d.font,a.fillStyle=u.itemIndex===0?"rgba(255, 255, 255, 0.9)":"rgba(255, 255, 255, 0.45)",a.fillText(u.text,h,o),h+=u.occupiedWidth}),o+=wm}),r}function GM(i){return i>=1e6?(i/1e6).toFixed(1)+"M":i>=1e3?(i/1e3).toFixed(1)+"K":i.toString()}function Cm(i,e,t,n,s,r){i.beginPath(),i.moveTo(e+r,t),i.lineTo(e+n-r,t),i.quadraticCurveTo(e+n,t,e+n,t+r),i.lineTo(e+n,t+s-r),i.quadraticCurveTo(e+n,t+s,e+n-r,t+s),i.lineTo(e+r,t+s),i.quadraticCurveTo(e,t+s,e,t+s-r),i.lineTo(e,t+r),i.quadraticCurveTo(e,t,e+r,t),i.closePath()}const Id=new WeakMap;class HM extends Ji{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,s){const r=new Ms(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,a=>{this.parse(a,t,s)},n,s)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,Kt,n).catch(n)}decodeDracoFile(e,t,n,s,r=rn,a=()=>{}){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,o).then(t).catch(a)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Id.has(e)){const c=Id.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const r=this.workerNextTaskID++,a=e.byteLength,o=this._getWorker(r,a).then(c=>(s=c,new Promise((l,h)=>{s._callbacks[r]={resolve:l,reject:h},s.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return o.catch(()=>!0).then(()=>{s&&r&&this._releaseTask(s,r)}),Id.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new On;e.index&&t.setIndex(new En(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n],r=s.name,a=s.array,o=s.itemSize,c=new En(a,o);r==="color"&&(this._assignVertexColorSpace(c,s.vertexColorSpace),c.normalized=!(a instanceof Float32Array)),t.setAttribute(r,c)}return t}_assignVertexColorSpace(e,t){if(t!==Kt)return;const n=new qe;for(let s=0,r=e.count;s<r;s++)n.fromBufferAttribute(e,s),At.toWorkingColorSpace(n,Kt),e.setXYZ(s,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new Ms(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((s,r)=>{n.load(e,s,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const s=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const r=zM.toString(),a=["/* draco decoder */",s,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`+`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(r){const a=r.data;switch(a.type){case"decode":s._callbacks[a.id].resolve(a);break;case"error":s._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,r){return s._taskLoad>r._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function zM(){let i,e;onmessage=function(a){const o=a.data;switch(o.type){case"init":i=o.decoderConfig,e=new Promise(function(h){i.onModuleLoaded=function(u){h({draco:u})},DracoDecoderModule(i)});break;case"decode":const c=o.buffer,l=o.taskConfig;e.then(h=>{const u=h.draco,d=new u.Decoder;try{const f=t(u,d,new Int8Array(c),l),m=f.attributes.map(g=>g.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{u.destroy(d)}});break}};function t(a,o,c,l){const h=l.attributeIDs,u=l.attributeTypes;let d,f;const m=o.GetEncodedGeometryType(c);if(m===a.TRIANGULAR_MESH)d=new a.Mesh,f=o.DecodeArrayToMesh(c,c.byteLength,d);else if(m===a.POINT_CLOUD)d=new a.PointCloud,f=o.DecodeArrayToPointCloud(c,c.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const g={index:null,attributes:[]};for(const A in h){const p=self[u[A]];let y,b;if(l.useUniqueIDs)b=h[A],y=o.GetAttributeByUniqueId(d,b);else{if(b=o.GetAttributeId(d,a[h[A]]),b===-1)continue;y=o.GetAttribute(d,b)}const _=s(a,o,d,A,p,y);A==="color"&&(_.vertexColorSpace=l.vertexColorSpace),g.attributes.push(_)}return m===a.TRIANGULAR_MESH&&(g.index=n(a,o,d)),a.destroy(d),g}function n(a,o,c){const h=c.num_faces()*3,u=h*4,d=a._malloc(u);o.GetTrianglesUInt32Array(c,u,d);const f=new Uint32Array(a.HEAPF32.buffer,d,h).slice();return a._free(d),{array:f,itemSize:1}}function s(a,o,c,l,h,u){const d=u.num_components(),m=c.num_points()*d,g=m*h.BYTES_PER_ELEMENT,A=r(a,h),p=a._malloc(g);o.GetAttributeDataArrayForAllPoints(c,u,A,g,p);const y=new h(a.HEAPF32.buffer,p,m).slice();return a._free(p),{name:l,array:y,itemSize:d}}function r(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}class VM{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0,this.workerCreator=null}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const n=this.workersResolve[e];if(n&&n(t),this.queue.length){const{resolve:s,msg:r,transfer:a}=this.queue.shift();this.workersResolve[e]=s,this.workers[e].postMessage(r,a)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise(n=>{const s=this._getIdleWorker();s!==-1?(this._initWorker(s),this.workerStatus|=1<<s,this.workersResolve[s]=n,this.workers[s].postMessage(e,t)):this.queue.push({resolve:n,msg:e,transfer:t})})}dispose(){this.workers.forEach(e=>e.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const WM=0,vm=2,qM=1,Sm=2,KM=0,XM=1,YM=10,jM=0,Im=9,Mm=15,Bm=16,Tm=22,Rm=37,Nm=43,Fm=76,Dm=83,Lm=97,Pm=100,km=103,Um=109,Om=165,Qm=166,Md=1000066e3;class JM{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class So{constructor(e,t,n,s){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,n),this._littleEndian=s,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){const t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t){t===void 0&&(t=0);const n=this._offset;let s=0;for(;this._dataView.getUint8(this._offset)!==t&&s<e;)s++,this._offset++;return s<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,s)}}const Nn=[171,75,84,88,32,50,48,187,13,10,26,10];function Gm(i){return new TextDecoder().decode(i)}function ZM(i){const e=new Uint8Array(i.buffer,i.byteOffset,Nn.length);if(e[0]!==Nn[0]||e[1]!==Nn[1]||e[2]!==Nn[2]||e[3]!==Nn[3]||e[4]!==Nn[4]||e[5]!==Nn[5]||e[6]!==Nn[6]||e[7]!==Nn[7]||e[8]!==Nn[8]||e[9]!==Nn[9]||e[10]!==Nn[10]||e[11]!==Nn[11])throw new Error("Missing KTX 2.0 identifier.");const t=new JM,n=17*Uint32Array.BYTES_PER_ELEMENT,s=new So(i,Nn.length,n,!0);t.vkFormat=s._nextUint32(),t.typeSize=s._nextUint32(),t.pixelWidth=s._nextUint32(),t.pixelHeight=s._nextUint32(),t.pixelDepth=s._nextUint32(),t.layerCount=s._nextUint32(),t.faceCount=s._nextUint32();const r=s._nextUint32();t.supercompressionScheme=s._nextUint32();const a=s._nextUint32(),o=s._nextUint32(),c=s._nextUint32(),l=s._nextUint32(),h=s._nextUint64(),u=s._nextUint64(),d=new So(i,Nn.length+n,3*r*8,!0);for(let j=0;j<r;j++)t.levels.push({levelData:new Uint8Array(i.buffer,i.byteOffset+d._nextUint64(),d._nextUint64()),uncompressedByteLength:d._nextUint64()});const f=new So(i,a,o,!0),m={vendorId:f._skip(4)._nextUint16(),descriptorType:f._nextUint16(),versionNumber:f._nextUint16(),descriptorBlockSize:f._nextUint16(),colorModel:f._nextUint8(),colorPrimaries:f._nextUint8(),transferFunction:f._nextUint8(),flags:f._nextUint8(),texelBlockDimension:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],bytesPlane:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],samples:[]},g=(m.descriptorBlockSize/4-6)/4;for(let j=0;j<g;j++){const Q={bitOffset:f._nextUint16(),bitLength:f._nextUint8(),channelType:f._nextUint8(),samplePosition:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&Q.channelType?(Q.sampleLower=f._nextInt32(),Q.sampleUpper=f._nextInt32()):(Q.sampleLower=f._nextUint32(),Q.sampleUpper=f._nextUint32()),m.samples[j]=Q}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(m);const A=new So(i,c,l,!0);for(;A._offset<l;){const j=A._nextUint32(),Q=A._scan(j),J=Gm(Q);if(t.keyValue[J]=A._nextUint8Array(j-Q.byteLength-1),J.match(/^ktx/i)){const ee=Gm(t.keyValue[J]);t.keyValue[J]=ee.substring(0,ee.lastIndexOf("\0"))}A._skip(j%4?4-j%4:0)}if(u<=0)return t;const p=new So(i,h,u,!0),y=p._nextUint16(),b=p._nextUint16(),_=p._nextUint32(),M=p._nextUint32(),w=p._nextUint32(),S=p._nextUint32(),T=[];for(let j=0;j<r;j++)T.push({imageFlags:p._nextUint32(),rgbSliceByteOffset:p._nextUint32(),rgbSliceByteLength:p._nextUint32(),alphaSliceByteOffset:p._nextUint32(),alphaSliceByteLength:p._nextUint32()});const v=h+p._offset,C=v+_,F=C+M,K=F+w,q=new Uint8Array(i.buffer,i.byteOffset+v,_),$=new Uint8Array(i.buffer,i.byteOffset+C,M),D=new Uint8Array(i.buffer,i.byteOffset+F,w),O=new Uint8Array(i.buffer,i.byteOffset+K,S);return t.globalData={endpointCount:y,selectorCount:b,imageDescs:T,endpointsData:q,selectorsData:$,tablesData:D,extendedData:O},t}let Bd,es,Td;const Rd={env:{emscripten_notify_memory_growth:function(i){Td=new Uint8Array(es.exports.memory.buffer)}}};class $M{init(){return Bd||(Bd=typeof fetch<"u"?fetch("data:application/wasm;base64,"+Hm).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,Rd)).then(this._init):WebAssembly.instantiate(Buffer.from(Hm,"base64"),Rd).then(this._init),Bd)}_init(e){es=e.instance,Rd.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!es)throw new Error("ZSTDDecoder: Await .init() before decoding.");const n=e.byteLength,s=es.exports.malloc(n);Td.set(e,s),t=t||Number(es.exports.ZSTD_findDecompressedSize(s,n));const r=es.exports.malloc(t),a=es.exports.ZSTD_decompress(r,t,s,n),o=Td.slice(r,r+a);return es.exports.free(s),es.exports.free(r),o}}const Hm="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IAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQh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ASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigC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C0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY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wOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEE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",eB="display-p3",tB="display-p3-linear",Nd=new WeakMap;let Fd=0,Dd;class ti extends Ji{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new VM,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER<"u"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}async detectSupportAsync(e){return this.workerConfig={astcSupported:await e.hasFeatureAsync("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:await e.hasFeatureAsync("texture-compression-etc1"),etc2Supported:await e.hasFeatureAsync("texture-compression-etc2"),dxtSupported:await e.hasFeatureAsync("texture-compression-bc"),bptcSupported:await e.hasFeatureAsync("texture-compression-bptc"),pvrtcSupported:await e.hasFeatureAsync("texture-compression-pvrtc")},this}detectSupport(e){return e.isWebGPURenderer===!0?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:e.hasFeature("texture-compression-etc1"),etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-bc"),bptcSupported:e.hasFeature("texture-compression-bptc"),pvrtcSupported:e.hasFeature("texture-compression-pvrtc")}:this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:e.extensions.has("WEBGL_compressed_texture_astc")&&e.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},this}init(){if(!this.transcoderPending){const e=new Ms(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),n=new Ms(this.manager);n.setPath(this.transcoderPath),n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials);const s=n.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,s]).then(([r,a])=>{const o=ti.BasisWorker.toString(),c=["/* constants */","let _EngineFormat = "+JSON.stringify(ti.EngineFormat),"let _EngineType = "+JSON.stringify(ti.EngineType),"let _TranscoderFormat = "+JSON.stringify(ti.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(ti.BasisFormat),"/* basis_transcoder.js */",r,"/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`+`);this.workerSourceURL=URL.createObjectURL(new Blob([c])),this.transcoderBinary=a,this.workerPool.setWorkerCreator(()=>{const l=new Worker(this.workerSourceURL),h=this.transcoderBinary.slice(0);return l.postMessage({type:"init",config:this.workerConfig,transcoderBinary:h},[h]),l})}),Fd>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),Fd++}return this.transcoderPending}load(e,t,n,s){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new Ms(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials),r.load(e,a=>{this.parse(a,t,s)},n,s)}parse(e,t,n){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(Nd.has(e))return Nd.get(e).promise.then(t).catch(n);this._createTexture(e).then(s=>t?t(s):null).catch(n)}_createTextureFrom(e,t){const{type:n,error:s,data:{faces:r,width:a,height:o,format:c,type:l,dfdFlags:h}}=e;if(n==="error")return Promise.reject(s);let u;if(t.faceCount===6)u=new Y_(r,c,l);else{const d=r[0].mipmaps;u=t.layerCount>1?new X_(d,a,o,t.layerCount,c,l):new Wc(d,a,o,c,l)}return u.minFilter=r[0].mipmaps.length===1?zt:Jn,u.magFilter=zt,u.generateMipmaps=!1,u.needsUpdate=!0,u.colorSpace=zm(t),u.premultiplyAlpha=!!(h&qM),u}async _createTexture(e,t={}){const n=ZM(new Uint8Array(e)),s=n.vkFormat===Md&&n.dataFormatDescriptor[0].colorModel===167;if(!(n.vkFormat===jM||s&&!this.workerConfig.astcHDRSupported))return iB(n);const a=t,o=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:a},[e])).then(c=>this._createTextureFrom(c.data,n));return Nd.set(e,{promise:o}),o}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),Fd--}}ti.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},ti.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},ti.EngineFormat={RGBAFormat:sn,RGBA_ASTC_4x4_Format:Ka,RGB_BPTC_UNSIGNED_Format:fc,RGBA_BPTC_Format:Ya,RGBA_ETC2_EAC_Format:dc,RGBA_PVRTC_4BPPV1_Format:lc,RGBA_S3TC_DXT5_Format:qa,RGB_ETC1_Format:hc,RGB_ETC2_Format:uc,RGB_PVRTC_4BPPV1_Format:cc,RGBA_S3TC_DXT1_Format:Wa},ti.EngineType={UnsignedByteType:tn,HalfFloatType:Mn,FloatType:nn},ti.BasisWorker=function(){let i,e,t;const n=_EngineFormat,s=_EngineType,r=_TranscoderFormat,a=_BasisFormat;self.addEventListener("message",function(m){const g=m.data;switch(g.type){case"init":i=g.config,o(g.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:A,buffers:p,width:y,height:b,hasAlpha:_,format:M,type:w,dfdFlags:S}=c(g.buffer);self.postMessage({type:"transcode",id:g.id,data:{faces:A,width:y,height:b,hasAlpha:_,format:M,type:w,dfdFlags:S}},p)}catch(A){console.error(A),self.postMessage({type:"error",id:g.id,error:A.message})}});break}});function o(m){e=new Promise(g=>{t={wasmBinary:m,onRuntimeInitialized:g},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function c(m){const g=new t.KTX2File(new Uint8Array(m));function A(){g.close(),g.delete()}if(!g.isValid())throw A(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");let p;if(g.isUASTC())p=a.UASTC;else if(g.isETC1S())p=a.ETC1S;else if(g.isHDR())p=a.UASTC_HDR;else throw new Error("THREE.KTX2Loader: Unknown Basis encoding");const y=g.getWidth(),b=g.getHeight(),_=g.getLayers()||1,M=g.getLevels(),w=g.getFaces(),S=g.getHasAlpha(),T=g.getDFDFlags(),{transcoderFormat:v,engineFormat:C,engineType:F}=u(p,y,b,S);if(!y||!b||!M)throw A(),new Error("THREE.KTX2Loader: Invalid texture");if(!g.startTranscoding())throw A(),new Error("THREE.KTX2Loader: .startTranscoding failed");const K=[],q=[];for(let $=0;$<w;$++){const D=[];for(let O=0;O<M;O++){const j=[];let Q,J;for(let ae=0;ae<_;ae++){const ye=g.getImageLevelInfo(O,ae,$);$===0&&O===0&&ae===0&&(ye.origWidth%4!==0||ye.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),M>1?(Q=ye.origWidth,J=ye.origHeight):(Q=ye.width,J=ye.height);let Me=new Uint8Array(g.getImageTranscodedSizeInBytes(O,ae,0,v));const se=g.transcodeImage(Me,O,ae,$,v,0,-1,-1);if(F===s.HalfFloatType&&(Me=new Uint16Array(Me.buffer,Me.byteOffset,Me.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!se)throw A(),new Error("THREE.KTX2Loader: .transcodeImage failed.");j.push(Me)}const ee=f(j);D.push({data:ee,width:Q,height:J}),q.push(ee.buffer)}K.push({mipmaps:D,width:y,height:b,format:C,type:F})}return A(),{faces:K,buffers:q,width:y,height:b,hasAlpha:S,dfdFlags:T,format:C,type:F}}const l=[{if:"astcSupported",basisFormat:[a.UASTC],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[n.RGBA_ASTC_4x4_Format,n.RGBA_ASTC_4x4_Format],engineType:[s.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[n.RGBA_BPTC_Format,n.RGBA_BPTC_Format],engineType:[s.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.BC1,r.BC3],engineFormat:[n.RGBA_S3TC_DXT1_Format,n.RGBA_S3TC_DXT5_Format],engineType:[s.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[n.RGB_ETC2_Format,n.RGBA_ETC2_EAC_Format],engineType:[s.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.ETC1],engineFormat:[n.RGB_ETC1_Format],engineType:[s.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[n.RGB_PVRTC_4BPPV1_Format,n.RGBA_PVRTC_4BPPV1_Format],engineType:[s.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[a.UASTC_HDR],transcoderFormat:[r.BC6H],engineFormat:[n.RGB_BPTC_UNSIGNED_Format],engineType:[s.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[a.ETC1S,a.UASTC],transcoderFormat:[r.RGBA32,r.RGBA32],engineFormat:[n.RGBAFormat,n.RGBAFormat],engineType:[s.UnsignedByteType,s.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[a.UASTC_HDR],transcoderFormat:[r.RGBA_HALF],engineFormat:[n.RGBAFormat],engineType:[s.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],h={[a.ETC1S]:l.filter(m=>m.basisFormat.includes(a.ETC1S)).sort((m,g)=>m.priorityUASTC-g.priorityUASTC),[a.UASTC]:l.filter(m=>m.basisFormat.includes(a.UASTC)).sort((m,g)=>m.priorityUASTC-g.priorityUASTC),[a.UASTC_HDR]:l.filter(m=>m.basisFormat.includes(a.UASTC_HDR)).sort((m,g)=>m.priorityHDR-g.priorityHDR)};function u(m,g,A,p){const y=h[m];for(let b=0;b<y.length;b++){const _=y[b];if(_.if&&!i[_.if]||!_.basisFormat.includes(m)||p&&_.transcoderFormat.length<2||_.needsPowerOfTwo&&!(d(g)&&d(A)))continue;const M=_.transcoderFormat[p?1:0],w=_.engineFormat[p?1:0],S=_.engineType[0];return{transcoderFormat:M,engineFormat:w,engineType:S}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}function d(m){return m<=2?!0:(m&m-1)===0&&m!==0}function f(m){if(m.length===1)return m[0];let g=0;for(let y=0;y<m.length;y++){const b=m[y];g+=b.byteLength}const A=new Uint8Array(g);let p=0;for(let y=0;y<m.length;y++){const b=m[y];A.set(b,p),p+=b.byteLength}return A}};const nB=new Set([sn,Ys,Gi]),Ld={[Um]:sn,[Lm]:sn,[Rm]:sn,[Nm]:sn,[km]:Ys,[Dm]:Ys,[Bm]:Ys,[Tm]:Ys,[Pm]:Gi,[Fm]:Gi,[Mm]:Gi,[Im]:Gi,[Md]:Ka,[Qm]:Xa,[Om]:Xa},Pd={[Um]:nn,[Lm]:Mn,[Rm]:tn,[Nm]:tn,[km]:nn,[Dm]:Mn,[Bm]:tn,[Tm]:tn,[Pm]:nn,[Fm]:Mn,[Mm]:tn,[Im]:tn,[Md]:Mn,[Qm]:tn,[Om]:tn};async function iB(i){const{vkFormat:e}=i;if(Ld[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");let t;i.supercompressionScheme===vm&&(Dd||(Dd=new Promise(async r=>{const a=new $M;await a.init(),r(a)})),t=await Dd);const n=[];for(let r=0;r<i.levels.length;r++){const a=Math.max(1,i.pixelWidth>>r),o=Math.max(1,i.pixelHeight>>r),c=i.pixelDepth?Math.max(1,i.pixelDepth>>r):0,l=i.levels[r];let h;if(i.supercompressionScheme===WM)h=l.levelData;else if(i.supercompressionScheme===vm)h=t.decode(l.levelData,l.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let u;Pd[e]===nn?u=new Float32Array(h.buffer,h.byteOffset,h.byteLength/Float32Array.BYTES_PER_ELEMENT):Pd[e]===Mn?u=new Uint16Array(h.buffer,h.byteOffset,h.byteLength/Uint16Array.BYTES_PER_ELEMENT):u=h,n.push({data:u,width:a,height:o,depth:c})}let s;if(nB.has(Ld[e]))s=i.pixelDepth===0?new Lc(n[0].data,i.pixelWidth,i.pixelHeight):new Fp(n[0].data,i.pixelWidth,i.pixelHeight,i.pixelDepth);else{if(i.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");s=new Wc(n,i.pixelWidth,i.pixelHeight),s.minFilter=n.length===1?zt:Jn,s.magFilter=zt}return s.mipmaps=n,s.type=Pd[e],s.format=Ld[e],s.colorSpace=zm(i),s.needsUpdate=!0,Promise.resolve(s)}function zm(i){const e=i.dataFormatDescriptor[0];return e.colorPrimaries===XM?e.transferFunction===Sm?Kt:rn:e.colorPrimaries===YM?e.transferFunction===Sm?eB:tB:(e.colorPrimaries===KM||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),oi)}const ml="[default]",kd={ASSET_GENERATOR:"assetgenerator"},bl=new wA,Vm="https://unpkg.com/[email protected]",sB=new HM(bl).setDecoderPath(`${Vm}/examples/jsm/libs/draco/gltf/`),rB=new ti(bl).setTranscoderPath(`${Vm}/examples/jsm/libs/basis/`);function Wm(i,e){const t=new Set;i.traverse(n=>{if(!n.geometry)return;(Array.isArray(n.material)?n.material:[n.material]).forEach(r=>{r&&!t.has(r.uuid)&&(t.add(r.uuid),e(r))})})}function aB(i){const{state:e,options:t}=i;if(t.preset===kd.ASSET_GENERATOR){const r=new hy;r.name="hemi_light",i.scene.add(r),i.lights.push(r);return}const n=new Ay(e.ambientColor,e.ambientIntensity);n.name="ambient_light",i.defaultCamera.add(n);const s=new MA(e.directColor,e.directIntensity);s.position.set(.5,0,.866),s.name="main_light",i.defaultCamera.add(s),i.lights.push(n,s)}function oB(i){i.lights.forEach(e=>e.parent.remove(e)),i.lights.length=0}var ni=Uint8Array,xa=Uint16Array,cB=Int32Array,qm=new ni([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]),Km=new ni([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]),lB=new ni([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xm=function(i,e){for(var t=new xa(31),n=0;n<31;++n)t[n]=e+=1<<i[n-1];for(var s=new cB(t[30]),n=1;n<30;++n)for(var r=t[n];r<t[n+1];++r)s[r]=r-t[n]<<5|n;return{b:t,r:s}},Ym=Xm(qm,2),jm=Ym.b,hB=Ym.r;jm[28]=258,hB[258]=28;for(var uB=Xm(Km,0),dB=uB.b,Ud=new xa(32768),kt=0;kt<32768;++kt){var Ls=(kt&43690)>>1|(kt&21845)<<1;Ls=(Ls&52428)>>2|(Ls&13107)<<2,Ls=(Ls&61680)>>4|(Ls&3855)<<4,Ud[kt]=((Ls&65280)>>8|(Ls&255)<<8)>>1}for(var Io=(function(i,e,t){for(var n=i.length,s=0,r=new xa(e);s<n;++s)i[s]&&++r[i[s]-1];var a=new xa(e);for(s=1;s<e;++s)a[s]=a[s-1]+r[s-1]<<1;var o;if(t){o=new xa(1<<e);var c=15-e;for(s=0;s<n;++s)if(i[s])for(var l=s<<4|i[s],h=e-i[s],u=a[i[s]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)o[Ud[u]>>c]=l}else for(o=new xa(n),s=0;s<n;++s)i[s]&&(o[s]=Ud[a[i[s]-1]++]>>15-i[s]);return o}),Mo=new ni(288),kt=0;kt<144;++kt)Mo[kt]=8;for(var kt=144;kt<256;++kt)Mo[kt]=9;for(var kt=256;kt<280;++kt)Mo[kt]=7;for(var kt=280;kt<288;++kt)Mo[kt]=8;for(var Jm=new ni(32),kt=0;kt<32;++kt)Jm[kt]=5;var fB=Io(Mo,9,1),pB=Io(Jm,5,1),Od=function(i){for(var e=i[0],t=1;t<i.length;++t)i[t]>e&&(e=i[t]);return e},mi=function(i,e,t){var n=e/8|0;return(i[n]|i[n+1]<<8)>>(e&7)&t},Qd=function(i,e){var t=e/8|0;return(i[t]|i[t+1]<<8|i[t+2]<<16)>>(e&7)},AB=function(i){return(i+7)/8|0},gB=function(i,e,t){return(t==null||t>i.length)&&(t=i.length),new ni(i.subarray(e,t))},mB=["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"],bi=function(i,e,t){var n=new Error(e||mB[i]);if(n.code=i,Error.captureStackTrace&&Error.captureStackTrace(n,bi),!t)throw n;return n},bB=function(i,e,t,n){var s=i.length,r=0;if(!s||e.f&&!e.l)return t||new ni(0);var a=!t,o=a||e.i!=2,c=e.i;a&&(t=new ni(s*3));var l=function(St){var ut=t.length;if(St>ut){var Je=new ni(Math.max(ut*2,St));Je.set(t),t=Je}},h=e.f||0,u=e.p||0,d=e.b||0,f=e.l,m=e.d,g=e.m,A=e.n,p=s*8;do{if(!f){h=mi(i,u,1);var y=mi(i,u+1,3);if(u+=3,y)if(y==1)f=fB,m=pB,g=9,A=5;else if(y==2){var w=mi(i,u,31)+257,S=mi(i,u+10,15)+4,T=w+mi(i,u+5,31)+1;u+=14;for(var v=new ni(T),C=new ni(19),F=0;F<S;++F)C[lB[F]]=mi(i,u+F*3,7);u+=S*3;for(var K=Od(C),q=(1<<K)-1,$=Io(C,K,1),F=0;F<T;){var D=$[mi(i,u,q)];u+=D&15;var b=D>>4;if(b<16)v[F++]=b;else{var O=0,j=0;for(b==16?(j=3+mi(i,u,3),u+=2,O=v[F-1]):b==17?(j=3+mi(i,u,7),u+=3):b==18&&(j=11+mi(i,u,127),u+=7);j--;)v[F++]=O}}var Q=v.subarray(0,w),J=v.subarray(w);g=Od(Q),A=Od(J),f=Io(Q,g,1),m=Io(J,A,1)}else bi(1);else{var b=AB(u)+4,_=i[b-4]|i[b-3]<<8,M=b+_;if(M>s){c&&bi(0);break}o&&l(d+_),t.set(i.subarray(b,M),d),e.b=d+=_,e.p=u=M*8,e.f=h;continue}if(u>p){c&&bi(0);break}}o&&l(d+131072);for(var ee=(1<<g)-1,ae=(1<<A)-1,ye=u;;ye=u){var O=f[Qd(i,u)&ee],Me=O>>4;if(u+=O&15,u>p){c&&bi(0);break}if(O||bi(2),Me<256)t[d++]=Me;else if(Me==256){ye=u,f=null;break}else{var se=Me-254;if(Me>264){var F=Me-257,me=qm[F];se=mi(i,u,(1<<me)-1)+jm[F],u+=me}var be=m[Qd(i,u)&ae],xe=be>>4;be||bi(3),u+=be&15;var J=dB[xe];if(xe>3){var me=Km[xe];J+=Qd(i,u)&(1<<me)-1,u+=me}if(u>p){c&&bi(0);break}o&&l(d+131072);var Pe=d+se;if(d<J){var $e=r-J,Qe=Math.min(J,Pe);for($e+d<0&&bi(3);d<Qe;++d)t[d]=n[$e+d]}for(;d<Pe;++d)t[d]=t[d-J]}}e.l=f,e.p=ye,e.b=d,e.f=h,f&&(h=1,e.m=g,e.d=m,e.n=A)}while(!h);return d!=t.length&&a?gB(t,0,d):t.subarray(0,d)},xB=new ni(0),EB=function(i,e){return((i[0]&15)!=8||i[0]>>4>7||(i[0]<<8|i[1])%31)&&bi(6,"invalid zlib data"),(i[1]>>5&1)==1&&bi(6,"invalid zlib data: "+(i[1]&32?"need":"unexpected")+" dictionary"),(i[1]>>3&4)+2};function xl(i,e){return bB(i.subarray(EB(i),-4),{i:2},e,e)}var _B=typeof TextDecoder<"u"&&new TextDecoder,yB=0;try{_B.decode(xB,{stream:!0}),yB=1}catch{}class wB extends cy{constructor(e){super(e),this.type=Mn}parse(e){const v=Math.pow(2.7182818,2.2);function C(x,B){let k=0;for(let R=0;R<65536;++R)(R==0||x[R>>3]&1<<(R&7))&&(B[k++]=R);const E=k-1;for(;k<65536;)B[k++]=0;return E}function F(x){for(let B=0;B<16384;B++)x[B]={},x[B].len=0,x[B].lit=0,x[B].p=null}const K={l:0,c:0,lc:0};function q(x,B,k,E,R){for(;k<x;)B=B<<8|Te(E,R),k+=8;k-=x,K.l=B>>k&(1<<x)-1,K.c=B,K.lc=k}const $=new Array(59);function D(x){for(let k=0;k<=58;++k)$[k]=0;for(let k=0;k<65537;++k)$[x[k]]+=1;let B=0;for(let k=58;k>0;--k){const E=B+$[k]>>1;$[k]=B,B=E}for(let k=0;k<65537;++k){const E=x[k];E>0&&(x[k]=E|$[E]++<<6)}}function O(x,B,k,E,R,N){const U=B;let P=0,z=0;for(;E<=R;E++){if(U.value-B.value>k)return!1;q(6,P,z,x,U);const X=K.l;if(P=K.c,z=K.lc,N[E]=X,X==63){if(U.value-B.value>k)throw new Error("Something wrong with hufUnpackEncTable");q(8,P,z,x,U);let Y=K.l+6;if(P=K.c,z=K.lc,E+Y>R+1)throw new Error("Something wrong with hufUnpackEncTable");for(;Y--;)N[E++]=0;E--}else if(X>=59){let Y=X-59+2;if(E+Y>R+1)throw new Error("Something wrong with hufUnpackEncTable");for(;Y--;)N[E++]=0;E--}}D(N)}function j(x){return x&63}function Q(x){return x>>6}function J(x,B,k,E){for(;B<=k;B++){const R=Q(x[B]),N=j(x[B]);if(R>>N)throw new Error("Invalid table entry");if(N>14){const U=E[R>>N-14];if(U.len)throw new Error("Invalid table entry");if(U.lit++,U.p){const P=U.p;U.p=new Array(U.lit);for(let z=0;z<U.lit-1;++z)U.p[z]=P[z]}else U.p=new Array(1);U.p[U.lit-1]=B}else if(N){let U=0;for(let P=1<<14-N;P>0;P--){const z=E[(R<<14-N)+U];if(z.len||z.p)throw new Error("Invalid table entry");z.len=N,z.lit=B,U++}}}return!0}const ee={c:0,lc:0};function ae(x,B,k,E){x=x<<8|Te(k,E),B+=8,ee.c=x,ee.lc=B}const ye={c:0,lc:0};function Me(x,B,k,E,R,N,U,P,z){if(x==B){E<8&&(ae(k,E,R,N),k=ee.c,E=ee.lc),E-=8;let X=k>>E;if(X=new Uint8Array([X])[0],P.value+X>z)return!1;const Y=U[P.value-1];for(;X-- >0;)U[P.value++]=Y}else if(P.value<z)U[P.value++]=x;else return!1;ye.c=k,ye.lc=E}function se(x){return x&65535}function me(x){const B=se(x);return B>32767?B-65536:B}const be={a:0,b:0};function xe(x,B){const k=me(x),R=me(B),N=k+(R&1)+(R>>1),U=N,P=N-R;be.a=U,be.b=P}function Pe(x,B){const k=se(x),E=se(B),R=k-(E>>1)&65535,N=E+R-32768&65535;be.a=N,be.b=R}function $e(x,B,k,E,R,N,U){const P=U<16384,z=k>R?R:k;let X=1,Y,ie;for(;X<=z;)X<<=1;for(X>>=1,Y=X,X>>=1;X>=1;){ie=0;const he=ie+N*(R-Y),ce=N*X,fe=N*Y,ge=E*X,_e=E*Y;let De,Ke,He,Fe;for(;ie<=he;ie+=fe){let st=ie;const Le=ie+E*(k-Y);for(;st<=Le;st+=_e){const wt=st+ge,un=st+ce,Et=un+ge;P?(xe(x[st+B],x[un+B]),De=be.a,He=be.b,xe(x[wt+B],x[Et+B]),Ke=be.a,Fe=be.b,xe(De,Ke),x[st+B]=be.a,x[wt+B]=be.b,xe(He,Fe),x[un+B]=be.a,x[Et+B]=be.b):(Pe(x[st+B],x[un+B]),De=be.a,He=be.b,Pe(x[wt+B],x[Et+B]),Ke=be.a,Fe=be.b,Pe(De,Ke),x[st+B]=be.a,x[wt+B]=be.b,Pe(He,Fe),x[un+B]=be.a,x[Et+B]=be.b)}if(k&X){const wt=st+ce;P?xe(x[st+B],x[wt+B]):Pe(x[st+B],x[wt+B]),De=be.a,x[wt+B]=be.b,x[st+B]=De}}if(R&X){let st=ie;const Le=ie+E*(k-Y);for(;st<=Le;st+=_e){const wt=st+ge;P?xe(x[st+B],x[wt+B]):Pe(x[st+B],x[wt+B]),De=be.a,x[wt+B]=be.b,x[st+B]=De}}Y=X,X>>=1}return ie}function Qe(x,B,k,E,R,N,U,P,z){let X=0,Y=0;const ie=U,he=Math.trunc(E.value+(R+7)/8);for(;E.value<he;)for(ae(X,Y,k,E),X=ee.c,Y=ee.lc;Y>=14;){const fe=X>>Y-14&16383,ge=B[fe];if(ge.len)Y-=ge.len,Me(ge.lit,N,X,Y,k,E,P,z,ie),X=ye.c,Y=ye.lc;else{if(!ge.p)throw new Error("hufDecode issues");let _e;for(_e=0;_e<ge.lit;_e++){const De=j(x[ge.p[_e]]);for(;Y<De&&E.value<he;)ae(X,Y,k,E),X=ee.c,Y=ee.lc;if(Y>=De&&Q(x[ge.p[_e]])==(X>>Y-De&(1<<De)-1)){Y-=De,Me(ge.p[_e],N,X,Y,k,E,P,z,ie),X=ye.c,Y=ye.lc;break}}if(_e==ge.lit)throw new Error("hufDecode issues")}}const ce=8-R&7;for(X>>=ce,Y-=ce;Y>0;){const fe=B[X<<14-Y&16383];if(fe.len)Y-=fe.len,Me(fe.lit,N,X,Y,k,E,P,z,ie),X=ye.c,Y=ye.lc;else throw new Error("hufDecode issues")}return!0}function St(x,B,k,E,R,N){const U={value:0},P=k.value,z=Oe(B,k),X=Oe(B,k);k.value+=4;const Y=Oe(B,k);if(k.value+=4,z<0||z>=65537||X<0||X>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const ie=new Array(65537),he=new Array(16384);F(he);const ce=E-(k.value-P);if(O(x,k,ce,z,X,ie),Y>8*(E-(k.value-P)))throw new Error("Something wrong with hufUncompress");J(ie,z,X,he),Qe(ie,he,x,k,Y,X,N,R,U)}function ut(x,B,k){for(let E=0;E<k;++E)B[E]=x[B[E]]}function Je(x){for(let B=1;B<x.length;B++){const k=x[B-1]+x[B]-128;x[B]=k}}function G(x,B){let k=0,E=Math.floor((x.length+1)/2),R=0;const N=x.length-1;for(;!(R>N||(B[R++]=x[k++],R>N));)B[R++]=x[E++]}function mn(x){let B=x.byteLength;const k=new Array;let E=0;const R=new DataView(x);for(;B>0;){const N=R.getInt8(E++);if(N<0){const U=-N;B-=U+1;for(let P=0;P<U;P++)k.push(R.getUint8(E++))}else{const U=N;B-=2;const P=R.getUint8(E++);for(let z=0;z<U+1;z++)k.push(P)}}return k}function dt(x,B,k,E,R,N){let U=new DataView(N.buffer);const P=k[x.idx[0]].width,z=k[x.idx[0]].height,X=3,Y=Math.floor(P/8),ie=Math.ceil(P/8),he=Math.ceil(z/8),ce=P-(ie-1)*8,fe=z-(he-1)*8,ge={value:0},_e=new Array(X),De=new Array(X),Ke=new Array(X),He=new Array(X),Fe=new Array(X);for(let Le=0;Le<X;++Le)Fe[Le]=B[x.idx[Le]],_e[Le]=Le<1?0:_e[Le-1]+ie*he,De[Le]=new Float32Array(64),Ke[Le]=new Uint16Array(64),He[Le]=new Uint16Array(ie*64);for(let Le=0;Le<he;++Le){let wt=8;Le==he-1&&(wt=fe);let un=8;for(let bt=0;bt<ie;++bt){bt==ie-1&&(un=ce);for(let Xe=0;Xe<X;++Xe)Ke[Xe].fill(0),Ke[Xe][0]=R[_e[Xe]++],pt(ge,E,Ke[Xe]),ze(Ke[Xe],De[Xe]),Rt(De[Xe]);Ge(De);for(let Xe=0;Xe<X;++Xe)L(De[Xe],He[Xe],bt*64)}let Et=0;for(let bt=0;bt<X;++bt){const Xe=k[x.idx[bt]].type;for(let qt=8*Le;qt<8*Le+wt;++qt){Et=Fe[bt][qt];for(let xn=0;xn<Y;++xn){const Lt=xn*64+(qt&7)*8;U.setUint16(Et+0*Xe,He[bt][Lt+0],!0),U.setUint16(Et+2*Xe,He[bt][Lt+1],!0),U.setUint16(Et+4*Xe,He[bt][Lt+2],!0),U.setUint16(Et+6*Xe,He[bt][Lt+3],!0),U.setUint16(Et+8*Xe,He[bt][Lt+4],!0),U.setUint16(Et+10*Xe,He[bt][Lt+5],!0),U.setUint16(Et+12*Xe,He[bt][Lt+6],!0),U.setUint16(Et+14*Xe,He[bt][Lt+7],!0),Et+=16*Xe}}if(Y!=ie)for(let qt=8*Le;qt<8*Le+wt;++qt){const xn=Fe[bt][qt]+8*Y*2*Xe,Lt=Y*64+(qt&7)*8;for(let dn=0;dn<un;++dn)U.setUint16(xn+dn*2*Xe,He[bt][Lt+dn],!0)}}}const st=new Uint16Array(P);U=new DataView(N.buffer);for(let Le=0;Le<X;++Le){k[x.idx[Le]].decoded=!0;const wt=k[x.idx[Le]].type;if(k[Le].type==2)for(let un=0;un<z;++un){const Et=Fe[Le][un];for(let bt=0;bt<P;++bt)st[bt]=U.getUint16(Et+bt*2*wt,!0);for(let bt=0;bt<P;++bt)U.setFloat32(Et+bt*2*wt,ne(st[bt]),!0)}}}function pt(x,B,k){let E,R=1;for(;R<64;)E=B[x.value],E==65280?R=64:E>>8==255?R+=E&255:(k[R]=E,R++),x.value++}function ze(x,B){B[0]=ne(x[0]),B[1]=ne(x[1]),B[2]=ne(x[5]),B[3]=ne(x[6]),B[4]=ne(x[14]),B[5]=ne(x[15]),B[6]=ne(x[27]),B[7]=ne(x[28]),B[8]=ne(x[2]),B[9]=ne(x[4]),B[10]=ne(x[7]),B[11]=ne(x[13]),B[12]=ne(x[16]),B[13]=ne(x[26]),B[14]=ne(x[29]),B[15]=ne(x[42]),B[16]=ne(x[3]),B[17]=ne(x[8]),B[18]=ne(x[12]),B[19]=ne(x[17]),B[20]=ne(x[25]),B[21]=ne(x[30]),B[22]=ne(x[41]),B[23]=ne(x[43]),B[24]=ne(x[9]),B[25]=ne(x[11]),B[26]=ne(x[18]),B[27]=ne(x[24]),B[28]=ne(x[31]),B[29]=ne(x[40]),B[30]=ne(x[44]),B[31]=ne(x[53]),B[32]=ne(x[10]),B[33]=ne(x[19]),B[34]=ne(x[23]),B[35]=ne(x[32]),B[36]=ne(x[39]),B[37]=ne(x[45]),B[38]=ne(x[52]),B[39]=ne(x[54]),B[40]=ne(x[20]),B[41]=ne(x[22]),B[42]=ne(x[33]),B[43]=ne(x[38]),B[44]=ne(x[46]),B[45]=ne(x[51]),B[46]=ne(x[55]),B[47]=ne(x[60]),B[48]=ne(x[21]),B[49]=ne(x[34]),B[50]=ne(x[37]),B[51]=ne(x[47]),B[52]=ne(x[50]),B[53]=ne(x[56]),B[54]=ne(x[59]),B[55]=ne(x[61]),B[56]=ne(x[35]),B[57]=ne(x[36]),B[58]=ne(x[48]),B[59]=ne(x[49]),B[60]=ne(x[57]),B[61]=ne(x[58]),B[62]=ne(x[62]),B[63]=ne(x[63])}function Rt(x){const B=.5*Math.cos(.7853975),k=.5*Math.cos(3.14159/16),E=.5*Math.cos(3.14159/8),R=.5*Math.cos(3*3.14159/16),N=.5*Math.cos(5*3.14159/16),U=.5*Math.cos(3*3.14159/8),P=.5*Math.cos(7*3.14159/16),z=new Array(4),X=new Array(4),Y=new Array(4),ie=new Array(4);for(let he=0;he<8;++he){const ce=he*8;z[0]=E*x[ce+2],z[1]=U*x[ce+2],z[2]=E*x[ce+6],z[3]=U*x[ce+6],X[0]=k*x[ce+1]+R*x[ce+3]+N*x[ce+5]+P*x[ce+7],X[1]=R*x[ce+1]-P*x[ce+3]-k*x[ce+5]-N*x[ce+7],X[2]=N*x[ce+1]-k*x[ce+3]+P*x[ce+5]+R*x[ce+7],X[3]=P*x[ce+1]-N*x[ce+3]+R*x[ce+5]-k*x[ce+7],Y[0]=B*(x[ce+0]+x[ce+4]),Y[3]=B*(x[ce+0]-x[ce+4]),Y[1]=z[0]+z[3],Y[2]=z[1]-z[2],ie[0]=Y[0]+Y[1],ie[1]=Y[3]+Y[2],ie[2]=Y[3]-Y[2],ie[3]=Y[0]-Y[1],x[ce+0]=ie[0]+X[0],x[ce+1]=ie[1]+X[1],x[ce+2]=ie[2]+X[2],x[ce+3]=ie[3]+X[3],x[ce+4]=ie[3]-X[3],x[ce+5]=ie[2]-X[2],x[ce+6]=ie[1]-X[1],x[ce+7]=ie[0]-X[0]}for(let he=0;he<8;++he)z[0]=E*x[16+he],z[1]=U*x[16+he],z[2]=E*x[48+he],z[3]=U*x[48+he],X[0]=k*x[8+he]+R*x[24+he]+N*x[40+he]+P*x[56+he],X[1]=R*x[8+he]-P*x[24+he]-k*x[40+he]-N*x[56+he],X[2]=N*x[8+he]-k*x[24+he]+P*x[40+he]+R*x[56+he],X[3]=P*x[8+he]-N*x[24+he]+R*x[40+he]-k*x[56+he],Y[0]=B*(x[he]+x[32+he]),Y[3]=B*(x[he]-x[32+he]),Y[1]=z[0]+z[3],Y[2]=z[1]-z[2],ie[0]=Y[0]+Y[1],ie[1]=Y[3]+Y[2],ie[2]=Y[3]-Y[2],ie[3]=Y[0]-Y[1],x[0+he]=ie[0]+X[0],x[8+he]=ie[1]+X[1],x[16+he]=ie[2]+X[2],x[24+he]=ie[3]+X[3],x[32+he]=ie[3]-X[3],x[40+he]=ie[2]-X[2],x[48+he]=ie[1]-X[1],x[56+he]=ie[0]-X[0]}function Ge(x){for(let B=0;B<64;++B){const k=x[0][B],E=x[1][B],R=x[2][B];x[0][B]=k+1.5747*R,x[1][B]=k-.1873*E-.4682*R,x[2][B]=k+1.8556*E}}function L(x,B,k){for(let E=0;E<64;++E)B[k+E]=Wp.toHalfFloat(I(x[E]))}function I(x){return x<=1?Math.sign(x)*Math.pow(Math.abs(x),2.2):Math.sign(x)*Math.pow(v,Math.abs(x)-1)}function Z(x){return new DataView(x.array.buffer,x.offset.value,x.size)}function le(x){const B=x.viewer.buffer.slice(x.offset.value,x.offset.value+x.size),k=new Uint8Array(mn(B)),E=new Uint8Array(k.length);return Je(k),G(k,E),new DataView(E.buffer)}function Ae(x){const B=x.array.slice(x.offset.value,x.offset.value+x.size),k=xl(B),E=new Uint8Array(k.length);return Je(k),G(k,E),new DataView(E.buffer)}function oe(x){const B=x.viewer,k={value:x.offset.value},E=new Uint16Array(x.columns*x.lines*(x.inputChannels.length*x.type)),R=new Uint8Array(8192);let N=0;const U=new Array(x.inputChannels.length);for(let fe=0,ge=x.inputChannels.length;fe<ge;fe++)U[fe]={},U[fe].start=N,U[fe].end=U[fe].start,U[fe].nx=x.columns,U[fe].ny=x.lines,U[fe].size=x.type,N+=U[fe].nx*U[fe].ny*U[fe].size;const P=re(B,k),z=re(B,k);if(z>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(P<=z)for(let fe=0;fe<z-P+1;fe++)R[fe+P]=tt(B,k);const X=new Uint16Array(65536),Y=C(R,X),ie=Oe(B,k);St(x.array,B,k,ie,E,N);for(let fe=0;fe<x.inputChannels.length;++fe){const ge=U[fe];for(let _e=0;_e<U[fe].size;++_e)$e(E,ge.start+_e,ge.nx,ge.size,ge.ny,ge.nx*ge.size,Y)}ut(X,E,N);let he=0;const ce=new Uint8Array(E.buffer.byteLength);for(let fe=0;fe<x.lines;fe++)for(let ge=0;ge<x.inputChannels.length;ge++){const _e=U[ge],De=_e.nx*_e.size,Ke=new Uint8Array(E.buffer,_e.end*2,De*2);ce.set(Ke,he),he+=De*2,_e.end+=De}return new DataView(ce.buffer)}function Ue(x){const B=x.array.slice(x.offset.value,x.offset.value+x.size),k=xl(B),E=x.inputChannels.length*x.lines*x.columns*x.totalBytes,R=new ArrayBuffer(E),N=new DataView(R);let U=0,P=0;const z=new Array(4);for(let X=0;X<x.lines;X++)for(let Y=0;Y<x.inputChannels.length;Y++){let ie=0;switch(x.inputChannels[Y].pixelType){case 1:z[0]=U,z[1]=z[0]+x.columns,U=z[1]+x.columns;for(let ce=0;ce<x.columns;++ce){const fe=k[z[0]++]<<8|k[z[1]++];ie+=fe,N.setUint16(P,ie,!0),P+=2}break;case 2:z[0]=U,z[1]=z[0]+x.columns,z[2]=z[1]+x.columns,U=z[2]+x.columns;for(let ce=0;ce<x.columns;++ce){const fe=k[z[0]++]<<24|k[z[1]++]<<16|k[z[2]++]<<8;ie+=fe,N.setUint32(P,ie,!0),P+=4}break}}return N}function Ce(x){const B=x.viewer,k={value:x.offset.value},E=new Uint8Array(x.columns*x.lines*(x.inputChannels.length*x.type*2)),R={version:We(B,k),unknownUncompressedSize:We(B,k),unknownCompressedSize:We(B,k),acCompressedSize:We(B,k),dcCompressedSize:We(B,k),rleCompressedSize:We(B,k),rleUncompressedSize:We(B,k),rleRawSize:We(B,k),totalAcUncompressedCount:We(B,k),totalDcUncompressedCount:We(B,k),acCompression:We(B,k)};if(R.version<2)throw new Error("EXRLoader.parse: "+As.compression+" version "+R.version+" is unsupported");const N=new Array;let U=re(B,k)-2;for(;U>0;){const ge=Ve(B.buffer,k),_e=tt(B,k),De=_e>>2&3,Ke=(_e>>4)-1,He=new Int8Array([Ke])[0],Fe=tt(B,k);N.push({name:ge,index:He,type:Fe,compression:De}),U-=ge.length+3}const P=As.channels,z=new Array(x.inputChannels.length);for(let ge=0;ge<x.inputChannels.length;++ge){const _e=z[ge]={},De=P[ge];_e.name=De.name,_e.compression=0,_e.decoded=!1,_e.type=De.pixelType,_e.pLinear=De.pLinear,_e.width=x.columns,_e.height=x.lines}const X={idx:new Array(3)};for(let ge=0;ge<x.inputChannels.length;++ge){const _e=z[ge];for(let De=0;De<N.length;++De){const Ke=N[De];_e.name==Ke.name&&(_e.compression=Ke.compression,Ke.index>=0&&(X.idx[Ke.index]=ge),_e.offset=ge)}}let Y,ie,he;if(R.acCompressedSize>0)switch(R.acCompression){case 0:Y=new Uint16Array(R.totalAcUncompressedCount),St(x.array,B,k,R.acCompressedSize,Y,R.totalAcUncompressedCount);break;case 1:const ge=x.array.slice(k.value,k.value+R.totalAcUncompressedCount),_e=xl(ge);Y=new Uint16Array(_e.buffer),k.value+=R.totalAcUncompressedCount;break}if(R.dcCompressedSize>0){const ge={array:x.array,offset:k,size:R.dcCompressedSize};ie=new Uint16Array(Ae(ge).buffer),k.value+=R.dcCompressedSize}if(R.rleRawSize>0){const ge=x.array.slice(k.value,k.value+R.rleCompressedSize),_e=xl(ge);he=mn(_e.buffer),k.value+=R.rleCompressedSize}let ce=0;const fe=new Array(z.length);for(let ge=0;ge<fe.length;++ge)fe[ge]=new Array;for(let ge=0;ge<x.lines;++ge)for(let _e=0;_e<z.length;++_e)fe[_e].push(ce),ce+=z[_e].width*x.type*2;dt(X,fe,z,Y,ie,E);for(let ge=0;ge<z.length;++ge){const _e=z[ge];if(!_e.decoded)switch(_e.compression){case 2:let De=0,Ke=0;for(let He=0;He<x.lines;++He){let Fe=fe[ge][De];for(let st=0;st<_e.width;++st){for(let Le=0;Le<2*_e.type;++Le)E[Fe++]=he[Ke+Le*_e.width*_e.height];Ke++}De++}break;default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(E.buffer)}function Ve(x,B){const k=new Uint8Array(x);let E=0;for(;k[B.value+E]!=0;)E+=1;const R=new TextDecoder().decode(k.slice(B.value,B.value+E));return B.value=B.value+E+1,R}function je(x,B,k){const E=new TextDecoder().decode(new Uint8Array(x).slice(B.value,B.value+k));return B.value=B.value+k,E}function Ee(x,B){const k=ke(x,B),E=Oe(x,B);return[k,E]}function Ne(x,B){const k=Oe(x,B),E=Oe(x,B);return[k,E]}function ke(x,B){const k=x.getInt32(B.value,!0);return B.value=B.value+4,k}function Oe(x,B){const k=x.getUint32(B.value,!0);return B.value=B.value+4,k}function Te(x,B){const k=x[B.value];return B.value=B.value+1,k}function tt(x,B){const k=x.getUint8(B.value);return B.value=B.value+1,k}const We=function(x,B){let k;return"getBigInt64"in DataView.prototype?k=Number(x.getBigInt64(B.value,!0)):k=x.getUint32(B.value+4,!0)+Number(x.getUint32(B.value,!0)<<32),B.value+=8,k};function nt(x,B){const k=x.getFloat32(B.value,!0);return B.value+=4,k}function W(x,B){return Wp.toHalfFloat(nt(x,B))}function ne(x){const B=(x&31744)>>10,k=x&1023;return(x>>15?-1:1)*(B?B===31?k?NaN:1/0:Math.pow(2,B-15)*(1+k/1024):6103515625e-14*(k/1024))}function re(x,B){const k=x.getUint16(B.value,!0);return B.value+=2,k}function de(x,B){return ne(re(x,B))}function Ie(x,B,k,E){const R=k.value,N=[];for(;k.value<R+E-1;){const U=Ve(B,k),P=ke(x,k),z=tt(x,k);k.value+=3;const X=ke(x,k),Y=ke(x,k);N.push({name:U,pixelType:P,pLinear:z,xSampling:X,ySampling:Y})}return k.value+=1,N}function Se(x,B){const k=nt(x,B),E=nt(x,B),R=nt(x,B),N=nt(x,B),U=nt(x,B),P=nt(x,B),z=nt(x,B),X=nt(x,B);return{redX:k,redY:E,greenX:R,greenY:N,blueX:U,blueY:P,whiteX:z,whiteY:X}}function it(x,B){const k=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],E=tt(x,B);return k[E]}function Ot(x,B){const k=ke(x,B),E=ke(x,B),R=ke(x,B),N=ke(x,B);return{xMin:k,yMin:E,xMax:R,yMax:N}}function bn(x,B){const k=["INCREASING_Y","DECREASING_Y","RANDOM_Y"],E=tt(x,B);return k[E]}function yt(x,B){const k=["ENVMAP_LATLONG","ENVMAP_CUBE"],E=tt(x,B);return k[E]}function jn(x,B){const k=["ONE_LEVEL","MIPMAP_LEVELS","RIPMAP_LEVELS"],E=["ROUND_DOWN","ROUND_UP"],R=Oe(x,B),N=Oe(x,B),U=tt(x,B);return{xSize:R,ySize:N,levelMode:k[U&15],roundingMode:E[U>>4]}}function vi(x,B){const k=nt(x,B),E=nt(x,B);return[k,E]}function ih(x,B){const k=nt(x,B),E=nt(x,B),R=nt(x,B);return[k,E,R]}function sh(x,B,k,E,R){if(E==="string"||E==="stringvector"||E==="iccProfile")return je(B,k,R);if(E==="chlist")return Ie(x,B,k,R);if(E==="chromaticities")return Se(x,k);if(E==="compression")return it(x,k);if(E==="box2i")return Ot(x,k);if(E==="envmap")return yt(x,k);if(E==="tiledesc")return jn(x,k);if(E==="lineOrder")return bn(x,k);if(E==="float")return nt(x,k);if(E==="v2f")return vi(x,k);if(E==="v3f")return ih(x,k);if(E==="int")return ke(x,k);if(E==="rational")return Ee(x,k);if(E==="timecode")return Ne(x,k);if(E==="preview")return k.value+=R,"skipped";k.value+=R}function ps(x,B){const k=Math.log2(x);return B=="ROUND_DOWN"?Math.floor(k):Math.ceil(k)}function Zo(x,B,k){let E=0;switch(x.levelMode){case"ONE_LEVEL":E=1;break;case"MIPMAP_LEVELS":E=ps(Math.max(B,k),x.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return E}function $o(x,B,k,E){const R=new Array(x);for(let N=0;N<x;N++){const U=1<<N;let P=B/U|0;E=="ROUND_UP"&&P*U<B&&(P+=1);const z=Math.max(P,1);R[N]=(z+k-1)/k|0}return R}function rh(){const x=this,B=x.offset,k={value:0};for(let E=0;E<x.tileCount;E++){const R=ke(x.viewer,B),N=ke(x.viewer,B);B.value+=8,x.size=Oe(x.viewer,B);const U=R*x.blockWidth,P=N*x.blockHeight;x.columns=U+x.blockWidth>x.width?x.width-U:x.blockWidth,x.lines=P+x.blockHeight>x.height?x.height-P:x.blockHeight;const z=x.columns*x.totalBytes,Y=x.size<x.lines*z?x.uncompress(x):Z(x);B.value+=x.size;for(let ie=0;ie<x.lines;ie++){const he=ie*x.columns*x.totalBytes;for(let ce=0;ce<x.inputChannels.length;ce++){const fe=As.channels[ce].name,ge=x.channelByteOffsets[fe]*x.columns,_e=x.decodeChannels[fe];if(_e===void 0)continue;k.value=he+ge;const De=(x.height-(1+P+ie))*x.outLineWidth;for(let Ke=0;Ke<x.columns;Ke++){const He=De+(Ke+U)*x.outputChannels+_e;x.byteArray[He]=x.getter(Y,k)}}}}}function Ua(){const x=this,B=x.offset,k={value:0};for(let E=0;E<x.height/x.blockHeight;E++){const R=ke(x.viewer,B)-As.dataWindow.yMin;x.size=Oe(x.viewer,B),x.lines=R+x.blockHeight>x.height?x.height-R:x.blockHeight;const N=x.columns*x.totalBytes,P=x.size<x.lines*N?x.uncompress(x):Z(x);B.value+=x.size;for(let z=0;z<x.blockHeight;z++){const X=E*x.blockHeight,Y=z+x.scanOrder(X);if(Y>=x.height)continue;const ie=z*N,he=(x.height-1-Y)*x.outLineWidth;for(let ce=0;ce<x.inputChannels.length;ce++){const fe=As.channels[ce].name,ge=x.channelByteOffsets[fe]*x.columns,_e=x.decodeChannels[fe];if(_e!==void 0){k.value=ie+ge;for(let De=0;De<x.columns;De++){const Ke=he+De*x.outputChannels+_e;x.byteArray[Ke]=x.getter(P,k)}}}}}}function ah(x,B,k){const E={};if(x.getUint32(0,!0)!=20000630)throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");E.version=x.getUint8(4);const R=x.getUint8(5);E.spec={singleTile:!!(R&2),longName:!!(R&4),deepFormat:!!(R&8),multiPart:!!(R&16)},k.value=8;let N=!0;for(;N;){const U=Ve(B,k);if(U==="")N=!1;else{const P=Ve(B,k),z=Oe(x,k),X=sh(x,B,k,P,z);X===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${P}'.`):E[U]=X}}if((R&-7)!=0)throw console.error("THREE.EXRHeader:",E),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return E}function Oa(x,B,k,E,R){const N={size:0,viewer:B,array:k,offset:E,width:x.dataWindow.xMax-x.dataWindow.xMin+1,height:x.dataWindow.yMax-x.dataWindow.yMin+1,inputChannels:x.channels,channelByteOffsets:{},scanOrder:null,totalBytes:null,columns:null,lines:null,type:null,uncompress:null,getter:null,format:null,colorSpace:rn};switch(x.compression){case"NO_COMPRESSION":N.blockHeight=1,N.uncompress=Z;break;case"RLE_COMPRESSION":N.blockHeight=1,N.uncompress=le;break;case"ZIPS_COMPRESSION":N.blockHeight=1,N.uncompress=Ae;break;case"ZIP_COMPRESSION":N.blockHeight=16,N.uncompress=Ae;break;case"PIZ_COMPRESSION":N.blockHeight=32,N.uncompress=oe;break;case"PXR24_COMPRESSION":N.blockHeight=16,N.uncompress=Ue;break;case"DWAA_COMPRESSION":N.blockHeight=32,N.uncompress=Ce;break;case"DWAB_COMPRESSION":N.blockHeight=256,N.uncompress=Ce;break;default:throw new Error("EXRLoader.parse: "+x.compression+" is unsupported")}const U={};for(const Y of x.channels)switch(Y.name){case"Y":case"R":case"G":case"B":case"A":U[Y.name]=!0,N.type=Y.pixelType}let P=!1;if(U.R&&U.G&&U.B)P=!U.A,N.outputChannels=4,N.decodeChannels={R:0,G:1,B:2,A:3};else if(U.Y)N.outputChannels=1,N.decodeChannels={Y:0};else throw new Error("EXRLoader.parse: file contains unsupported data channels.");if(N.type==1)switch(R){case nn:N.getter=de;break;case Mn:N.getter=re;break}else if(N.type==2)switch(R){case nn:N.getter=nt;break;case Mn:N.getter=W}else throw new Error("EXRLoader.parse: unsupported pixelType "+N.type+" for "+x.compression+".");N.columns=N.width;const z=N.width*N.height*N.outputChannels;switch(R){case nn:N.byteArray=new Float32Array(z),P&&N.byteArray.fill(1,0,z);break;case Mn:N.byteArray=new Uint16Array(z),P&&N.byteArray.fill(15360,0,z);break;default:console.error("THREE.EXRLoader: unsupported type: ",R);break}let X=0;for(const Y of x.channels)N.decodeChannels[Y.name]!==void 0&&(N.channelByteOffsets[Y.name]=X),X+=Y.pixelType*2;if(N.totalBytes=X,N.outLineWidth=N.width*N.outputChannels,x.lineOrder==="INCREASING_Y"?N.scanOrder=Y=>Y:N.scanOrder=Y=>N.height-1-Y,N.outputChannels==4?(N.format=sn,N.colorSpace=rn):(N.format=Gi,N.colorSpace=oi),x.spec.singleTile){N.blockHeight=x.tiles.ySize,N.blockWidth=x.tiles.xSize;const Y=Zo(x.tiles,N.width,N.height),ie=$o(Y,N.width,x.tiles.xSize,x.tiles.roundingMode),he=$o(Y,N.height,x.tiles.ySize,x.tiles.roundingMode);N.tileCount=ie[0]*he[0];for(let ce=0;ce<Y;ce++)for(let fe=0;fe<he[ce];fe++)for(let ge=0;ge<ie[ce];ge++)We(B,E);N.decode=rh.bind(N)}else{N.blockWidth=N.width;const Y=Math.ceil(N.height/N.blockHeight);for(let ie=0;ie<Y;ie++)We(B,E);N.decode=Ua.bind(N)}return N}const ec={value:0},tc=new DataView(e),tp=new Uint8Array(e),As=ah(tc,e,ec),Ws=Oa(As,tc,tp,ec,this.type);return Ws.decode(),{header:As,width:Ws.width,height:Ws.height,data:Ws.byteArray,format:Ws.format,colorSpace:Ws.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,n,s){function r(a,o){a.colorSpace=o.colorSpace,a.minFilter=zt,a.magFilter=zt,a.generateMipmaps=!1,a.flipY=!1,t&&t(a,o)}return super.load(e,r,n,s)}}function CB(i,e){const{id:t,path:n}=e;return t==="neutral"?Promise.resolve({envMap:i.neutralEnvironment}):t===""?Promise.resolve({envMap:null}):new Promise((s,r)=>{new wB().load(n,a=>{const o=i.pmremGenerator.fromEquirectangular(a).texture;a.dispose(),i._loadedEnvironment&&i._loadedEnvironment!==o&&i._loadedEnvironment.dispose(),i._loadedEnvironment=o,s({envMap:o})},void 0,r)})}function vB(i){i.renderer.render(i.scene,i.activeCamera),i.renderer.domElement.toBlob(e=>{if(!e)return;const t=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),n=URL.createObjectURL(e),s=document.createElement("a");s.download=`3d-screenshot-${t}.png`,s.href=n,s.click(),URL.revokeObjectURL(n)},"image/png"),SB(i)}function SB(i){const e=document.createElement("div");e.className="screenshot-flash",i.el.appendChild(e),e.addEventListener("animationend",()=>e.remove())}function IB(i,e){i.mixer&&(i.mixer.stopAllAction(),i.mixer.uncacheRoot(i.mixer.getRoot()),i.mixer=null),i.clips=e,e.length&&(i.mixer=new BA(i.content))}function MB(i){i.clips.forEach(e=>{i.mixer.clipAction(e).reset().play(),i.state.actionStates[e.name]=!0}),i.invalidate()}const BB=.35;class TB{constructor(){this.model=null,this.mixer=null,this.clips=new Map,this.actions=new Map,this.currentName=null,this.currentAction=null,this.loader=new Vu,this.onChange=null,this._gltfCache=new Map,this._animationDefs=[]}attach(e){this.detach(),this.model=e,this.mixer=new BA(e),this.actions.clear(),this.currentAction=null,this.currentName=null;for(const[t,n]of this.clips){const s=this._retargetClip(n,t),r=this.mixer.clipAction(s);r.enabled=!0,this.actions.set(t,r)}}detach(){this.mixer&&(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),this.mixer=null),this.model=null,this.actions.clear(),this.currentAction=null,this.currentName=null}setAnimationDefs(e){this._animationDefs=e}getAnimationDefs(){return this._animationDefs}async loadAnimation(e,t,n={}){if(this.clips.has(e))return this.clips.get(e);let s;this._gltfCache.has(t)?s=this._gltfCache.get(t):(s=await new Promise((a,o)=>{this.loader.load(t,a,void 0,o)}),this._gltfCache.set(t,s));let r;if(n.clipName?(r=s.animations.find(a=>a.name===n.clipName),r||(console.warn(`[AnimationManager] Clip "${n.clipName}" not found in ${t}, using first clip`),r=s.animations[0])):r=s.animations[0],!r)throw new Error(`No animation found in ${t}`);if(r=r.clone(),r.name=e,this.clips.set(e,r),this.model&&this.mixer){const a=this._retargetClip(r,e),o=this.mixer.clipAction(a);o.enabled=!0,o.setLoop(n.loop===!1?xp:Ep),n.loop===!1&&(o.clampWhenFinished=!0),this.actions.set(e,o)}return r}async loadAll(){const e=this._animationDefs.map(async t=>{try{await this.loadAnimation(t.name,t.url,{loop:t.loop!==!1,clipName:t.clipName})}catch(n){console.warn(`[AnimationManager] Failed to load "${t.name}" from ${t.url}:`,n)}});await Promise.all(e)}play(e){const t=this.actions.get(e);if(!t){console.warn(`[AnimationManager] Animation "${e}" not loaded`);return}this.currentAction&&this.currentAction!==t&&this.currentAction.fadeOut(.01),t.reset().fadeIn(.01).play(),this.currentAction=t,this.currentName=e,this.onChange&&this.onChange(e)}crossfadeTo(e,t=BB){if(e===this.currentName)return;const n=this.actions.get(e);if(!n){console.warn(`[AnimationManager] Animation "${e}" not loaded`);return}n.reset(),n.play(),this.currentAction?this.currentAction.crossFadeTo(n,t,!0):n.fadeIn(t),this.currentAction=n,this.currentName=e,this.onChange&&this.onChange(e)}stopAll(){this.mixer&&this.mixer.stopAllAction(),this.currentAction=null,this.currentName=null,this.onChange&&this.onChange(null)}update(e){this.mixer&&this.mixer.update(e)}_retargetClip(e,t){if(!this.model)return e;const n=new Set;if(this.model.traverse(o=>{o.isBone&&n.add(o.name)}),n.size===0)return e;const s=new Set;for(const o of e.tracks){const c=o.name.split(".")[0];s.add(c)}let r=0;for(const o of s)n.has(o)&&r++;if(r/s.size>.5)return e;const a=this._buildBoneNameMap(n,s);return a?(e.tracks.map(o=>{const c=o.name.split("."),l=c[0],h=c.slice(1).join("."),u=a.get(l);if(!u)return null;const d=o.clone();return d.name=`${u}.${h}`,d}).filter(Boolean),e.clone().resetDuration()):e}_buildBoneNameMap(e,t){const n=new Map,s=[...e],r=[...t],a=h=>h.replace(/^mixamorig\d*[_:]?/i,"").replace(/^Armature[_/]?/i,""),o=new Map(s.map(h=>[a(h),h]));let c=0;for(const h of r){const u=a(h);o.has(u)&&(n.set(h,o.get(u)),c++)}if(c/r.length>.5)return n;const l=new Map(s.map(h=>[h.toLowerCase(),h]));n.clear(),c=0;for(const h of r)l.has(h.toLowerCase())&&(n.set(h,l.get(h.toLowerCase())),c++);return c/r.length>.5?n:null}getLoadedNames(){return[...this.clips.keys()]}isLoaded(e){return this.clips.has(e)}dispose(){this.detach(),this.clips.clear(),this._gltfCache.clear(),this._animationDefs=[]}}ji.enabled=!0;class Gd{constructor(e,t){this.el=e,this.options=t,this.lights=[],this.content=null,this.mixer=null,this.clips=[],this.gui=null,this.animationManager=new TB,this._animPanelEl=null,this.state={environment:t.preset===kd.ASSET_GENERATOR?rl.find(r=>r.id==="footprint-court").name:rl[1].name,background:!1,playbackSpeed:1,actionStates:{},camera:ml,wireframe:!1,skeleton:!1,grid:!1,autoRotate:!1,punctualLights:!0,exposure:0,toneMapping:gh,ambientIntensity:.3,ambientColor:"#FFFFFF",directIntensity:.8*Math.PI,directColor:"#FFFFFF",bgColor:"#000000",transparentBg:!1,pointSize:1,showInfo:!0,showLabels:!1,followMode:"mouse"},this.prevTime=0,this.stats=new go,this.stats.dom.height="48px",[].forEach.call(this.stats.dom.children,r=>r.style.display=""),this.backgroundColor=new qe(this.state.bgColor),this.scene=new Au,this.scene.background=this.backgroundColor;const n=t.preset===kd.ASSET_GENERATOR?.8*180/Math.PI:60,s=e.clientWidth/e.clientHeight;this.defaultCamera=new vn(n,s,.01,1e3),this.activeCamera=this.defaultCamera,this.scene.add(this.defaultCamera),this.renderer=window.renderer=new cg({antialias:!0,alpha:!0}),this.renderer.setClearColor(0,1),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(e.clientWidth,e.clientHeight),this.pmremGenerator=new Qu(this.renderer),this.pmremGenerator.compileEquirectangularShader(),this.neutralEnvironment=this.pmremGenerator.fromScene(new TI).texture,this.controls=new mI(this.defaultCamera,this.renderer.domElement),this.controls.screenSpacePanning=!0,this._onControlsChange=()=>this.invalidate(),this.controls.addEventListener("change",this._onControlsChange),this.el.appendChild(this.renderer.domElement),this.cameraCtrl=null,this.cameraFolder=null,this.animFolder=null,this.animCtrls=[],this.morphFolder=null,this.morphCtrls=[],this.skeletonHelpers=[],this.gridHelper=null,this.axesHelper=null,this.modelInfo=null,this.annotationEls=[],this._tempVec=new H,this.addAxesHelper(),this.addGUI(),t.kiosk&&this.gui.close(),this.animate=this.animate.bind(this),this._rafId=null,this._visible=!0,this._tabVisible=!document.hidden,this._disposed=!1,this._loadedEnvironment=null,this._guiWrap=null,this._needsRender=!0,this._animating=!1,this._onVisibilityChange=()=>{const r=!this._tabVisible;this._tabVisible=!document.hidden,r&&this._tabVisible&&(this._needsRender=!0),this._updateRenderLoop()},document.addEventListener("visibilitychange",this._onVisibilityChange),typeof IntersectionObserver<"u"&&(this._intersectionObserver=new IntersectionObserver(r=>{const a=!this._visible;this._visible=r[r.length-1].isIntersecting,a&&this._visible&&(this._needsRender=!0),this._updateRenderLoop()},{threshold:0}),this._intersectionObserver.observe(this.el)),this._onResize=this.resize.bind(this),this._onKeyDown=r=>{(r.key==="p"||r.key==="P")&&!this.isInputFocused()&&this.takeScreenshot()},this._updateRenderLoop(),window.addEventListener("resize",this._onResize,!1),window.addEventListener("keydown",this._onKeyDown)}invalidate(){this._disposed||(this._needsRender=!0,this._updateRenderLoop())}_recomputeAnimating(){let e=!1;if(this.state&&this.state.autoRotate&&(e=!0),!e&&this.mixer&&this.state){for(const t in this.state.actionStates)if(this.state.actionStates[t]){e=!0;break}}!e&&this.animationManager.currentAction&&(e=!0),this._animating=e}_updateRenderLoop(){if(this._disposed)return;const e=this._visible&&this._tabVisible;e&&(this._needsRender||this._animating)&&this._rafId===null?(this.prevTime=performance.now(),this._rafId=requestAnimationFrame(this.animate)):!e&&this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}animate(e){const t=(e-this.prevTime)/1e3;if(this.prevTime=e,this._recomputeAnimating(),this.controls.update(),this.stats.update(),this.mixer&&this.mixer.update(t),this.animationManager.update(t),this._afterAnimateHooks)for(let n=0;n<this._afterAnimateHooks.length;n++)this._afterAnimateHooks[n](t);this.render(),this._needsRender=!1,this._animating&&this._visible&&this._tabVisible&&!this._disposed?this._rafId=requestAnimationFrame(this.animate):this._rafId=null}isInputFocused(){const e=document.activeElement;return e&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable)}render(){this.renderer.render(this.scene,this.activeCamera),this.state.grid&&(this.axesCamera.position.copy(this.defaultCamera.position),this.axesCamera.lookAt(this.axesScene.position),this.axesRenderer.render(this.axesScene,this.axesCamera)),this.projectAnnotations()}takeScreenshot(){vB(this)}resize(){const{clientHeight:e,clientWidth:t}=this.el;this.defaultCamera.aspect=t/e,this.defaultCamera.updateProjectionMatrix(),this.renderer.setSize(t,e),this.axesCamera.aspect=this.axesDiv.clientWidth/this.axesDiv.clientHeight,this.axesCamera.updateProjectionMatrix(),this.axesRenderer.setSize(this.axesDiv.clientWidth,this.axesDiv.clientHeight),this.invalidate()}load(e,t,n){const s=oa.extractUrlBase(e);return new Promise((r,a)=>{bl.setURLModifier((l,h)=>{const u=t+decodeURI(l).replace(s,"").replace(/^(\.?\/)/,"");if(n.has(u)){const d=n.get(u),f=URL.createObjectURL(d);return c.push(f),f}return(h||"")+l});const o=new Vu(bl).setCrossOrigin("anonymous").setDRACOLoader(sB).setKTX2Loader(rB.detectSupport(this.renderer)).setMeshoptDecoder(AI),c=[];o.load(e,l=>{window.VIEWER.json=l;const h=l.scene||l.scenes[0],u=l.animations||[];if(!h)throw new Error("This model contains no scene, and cannot be viewed here. However, it may contain individual 3D resources.");this.setContent(h,u),c.forEach(URL.revokeObjectURL),r(l)},void 0,a)})}setContent(e,t){this.clear(),e.updateMatrixWorld();const n=new Ii().setFromObject(e),s=n.getSize(new H).length(),r=n.getCenter(new H);this.controls.reset(),e.position.x-=r.x,e.position.y-=r.y,e.position.z-=r.z,this.controls.maxDistance=s*10,this.defaultCamera.near=s/100,this.defaultCamera.far=s*100,this.defaultCamera.updateProjectionMatrix(),this.options.cameraPosition?(this.defaultCamera.position.fromArray(this.options.cameraPosition),this.defaultCamera.lookAt(new H)):(this.defaultCamera.position.copy(r),this.defaultCamera.position.x+=s/2,this.defaultCamera.position.y+=s/5,this.defaultCamera.position.z+=s/2,this.defaultCamera.lookAt(r)),this.setCamera(ml),this.axesCamera.position.copy(this.defaultCamera.position),this.axesCamera.lookAt(this.axesScene.position),this.axesCamera.near=s/100,this.axesCamera.far=s*100,this.axesCamera.updateProjectionMatrix(),this.axesCorner.scale.set(s,s,s),this.controls.saveState(),this.scene.add(e),this.content=e,this.state.punctualLights=!0,this.content.traverse(a=>{a.isLight&&(this.state.punctualLights=!1)}),this.setClips(t),this.animationManager.attach(this.content),this._setupAnimationPanel(),this.updateLights(),this.updateGUI(),this.updateEnvironment(),this.updateDisplay(),this.updateModelInfo(e,t),this.updateAnnotations(),window.VIEWER.scene=this.content,this.invalidate()}setClips(e){IB(this,e)}playAllClips(){MB(this)}setCamera(e){e===ml?(this.controls.enabled=!0,this.activeCamera=this.defaultCamera):(this.controls.enabled=!1,this.content.traverse(t=>{t.isCamera&&t.name===e&&(this.activeCamera=t)})),this.invalidate()}updateLights(){const e=this.state,t=this.lights;e.punctualLights&&!t.length?aB(this):!e.punctualLights&&t.length&&oB(this),this.renderer.toneMapping=Number(e.toneMapping),this.renderer.toneMappingExposure=Math.pow(2,e.exposure),t.length===2&&(t[0].intensity=e.ambientIntensity,t[0].color.set(e.ambientColor),t[1].intensity=e.directIntensity,t[1].color.set(e.directColor)),this.invalidate()}updateEnvironment(){const e=rl.filter(t=>t.name===this.state.environment)[0];CB(this,e).then(({envMap:t})=>{this._disposed||!this.scene||(this.scene.environment=t,this.scene.background=this.state.transparentBg?null:this.state.background?t:this.backgroundColor,this.invalidate())})}updateDisplay(){this.skeletonHelpers.length&&this.skeletonHelpers.forEach(e=>this.scene.remove(e)),Wm(this.content,e=>{e.wireframe=this.state.wireframe,e instanceof vu&&(e.size=this.state.pointSize)}),this.content.traverse(e=>{if(e.geometry&&e.skeleton&&this.state.skeleton){const t=new Ty(e.skeleton.bones[0].parent);t.material.linewidth=3,this.scene.add(t),this.skeletonHelpers.push(t)}}),this.state.grid!==!!this.gridHelper&&(this.state.grid?(this.gridHelper=new Ry,this.axesHelper=new NA,this.axesHelper.renderOrder=999,this.axesHelper.onBeforeRender=e=>e.clearDepth(),this.scene.add(this.gridHelper),this.scene.add(this.axesHelper)):(this.scene.remove(this.gridHelper),this.scene.remove(this.axesHelper),this.gridHelper=null,this.axesHelper=null,this.axesRenderer.clear())),this.controls.autoRotate=this.state.autoRotate,this.invalidate()}updateBackground(){this.backgroundColor.set(this.state.bgColor),this.state.transparentBg?(this.scene.background=null,this.renderer.setClearColor(0,0)):(this.scene.background=this.backgroundColor,this.renderer.setClearColor(0,1),this.updateEnvironment()),this.invalidate()}setBackgroundColor(e){this.state.bgColor=typeof e=="string"?e:"#"+e.toString(16).padStart(6,"0"),this.state.transparentBg=!1,this.updateBackground()}updateModelInfo(e,t){this.modelInfo&&(this.modelInfo.remove(),this.modelInfo=null),this.state.showInfo&&e&&(this.modelInfo=PM(this.el,e,t))}updateAnnotations(){if(this.annotationEls.forEach(t=>t.el.remove()),this.annotationEls=[],!this.state.showLabels||!this.content)return;OM(this.content).forEach(t=>{const n=QM(t),s=document.createElement("div");s.classList.add("annotation-label"),s.appendChild(n),this.el.appendChild(s),this.annotationEls.push({el:s,position:t.position})}),this.invalidate()}projectAnnotations(){if(this.annotationEls.length===0)return;const e=this.el.clientWidth,t=this.el.clientHeight,n=e/2,s=t/2,r=this._tempVec;this.annotationEls.forEach(({el:a,position:o})=>{if(r.copy(o),r.project(this.activeCamera),r.z>1){a.style.display="none";return}const c=r.x*n+n,l=-(r.y*s)+s;a.style.display="",a.style.left=c+"px",a.style.top=l+"px"})}addAxesHelper(){this.axesDiv=document.createElement("div"),this.el.appendChild(this.axesDiv),this.axesDiv.classList.add("axes");const{clientWidth:e,clientHeight:t}=this.axesDiv;this.axesScene=new Au,this.axesCamera=new vn(50,e/t,.1,10),this.axesScene.add(this.axesCamera),this.axesRenderer=new cg({alpha:!0}),this.axesRenderer.setPixelRatio(window.devicePixelRatio),this.axesRenderer.setSize(this.axesDiv.clientWidth,this.axesDiv.clientHeight),this.axesCamera.up=this.defaultCamera.up,this.axesCorner=new NA(5),this.axesScene.add(this.axesCorner),this.axesDiv.appendChild(this.axesRenderer.domElement)}addGUI(){const e=window.innerWidth<=700,t=this.gui=new ZI({autoPlace:!1,width:e?220:260,hideable:!0}),n=t.addFolder("Display");n.add(this.state,"background").onChange(()=>this.updateEnvironment()),n.add(this.state,"autoRotate").onChange(()=>this.updateDisplay()),n.add(this.state,"wireframe").onChange(()=>this.updateDisplay()),n.add(this.state,"skeleton").onChange(()=>this.updateDisplay()),n.add(this.state,"grid").onChange(()=>this.updateDisplay()),n.add(this.controls,"screenSpacePanning"),n.add(this.state,"pointSize",1,16).onChange(()=>this.updateDisplay()),n.add(this.state,"transparentBg").name("transparent bg").onChange(()=>this.updateBackground()),n.addColor(this.state,"bgColor").onChange(()=>this.updateBackground()),n.add({screenshot:()=>this.takeScreenshot()},"screenshot").name("Screenshot [P]"),n.add(this.state,"showInfo").name("model info").onChange(()=>this.updateModelInfo(this.content,this.clips)),n.add(this.state,"showLabels").name("mesh labels").onChange(()=>this.updateAnnotations());const m=t.addFolder("Lighting");m.add(this.state,"environment",rl.map(w=>w.name)).onChange(()=>this.updateEnvironment()),[m.add(this.state,"toneMapping",{Linear:gh,"ACES Filmic":lp}),m.add(this.state,"exposure",-10,10,.01),m.add(this.state,"punctualLights").listen(),m.add(this.state,"ambientIntensity",0,2),m.addColor(this.state,"ambientColor"),m.add(this.state,"directIntensity",0,4),m.addColor(this.state,"directColor")].forEach(w=>w.onChange(()=>this.updateLights())),this.animFolder=t.addFolder("Animation"),this.animFolder.domElement.style.display="none",this.animFolder.add(this.state,"playbackSpeed",0,1).onChange(w=>{this.mixer&&(this.mixer.timeScale=w)}),this.animFolder.add({playAll:()=>this.playAllClips()},"playAll"),this.morphFolder=t.addFolder("Morph Targets"),this.morphFolder.domElement.style.display="none",this.cameraFolder=t.addFolder("Cameras"),this.cameraFolder.domElement.style.display="none",t.addFolder("Agent").add(this.state,"followMode",{None:"none","Follow Mouse":"mouse","Follow Keystrokes":"keystrokes"}).name("follow mode");const y=t.addFolder("Performance"),b=document.createElement("li");this.stats.dom.style.position="static",b.appendChild(this.stats.dom),b.classList.add("gui-stats"),y.__ul.appendChild(b);const _=document.createElement("div");this.el.appendChild(_),_.classList.add("gui-wrap"),_.classList.add("gui-wrap--hidden"),_.appendChild(t.domElement),this._guiWrap=_;const M=document.createElement("button");M.className="gui-toggle",M.setAttribute("title","Toggle advanced controls"),M.setAttribute("aria-label","Toggle advanced controls"),M.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg><span class="gui-toggle__label">Controls</span>',M.addEventListener("click",()=>{const w=_.classList.toggle("gui-wrap--hidden");M.classList.toggle("gui-toggle--active",!w)}),this.el.appendChild(M),this._guiToggle=M,e?t.close():t.open()}updateGUI(){this.cameraFolder.domElement.style.display="none",this.morphCtrls.forEach(n=>n.remove()),this.morphCtrls.length=0,this.morphFolder.domElement.style.display="none",this.animCtrls.forEach(n=>n.remove()),this.animCtrls.length=0,this.animFolder.domElement.style.display="none";const e=[],t=[];if(this.content.traverse(n=>{n.geometry&&n.morphTargetInfluences&&t.push(n),n.isCamera&&(n.name=n.name||`VIEWER__camera_${e.length+1}`,e.push(n.name))}),e.length){this.cameraFolder.domElement.style.display="",this.cameraCtrl&&this.cameraCtrl.remove();const n=[ml].concat(e);this.cameraCtrl=this.cameraFolder.add(this.state,"camera",n),this.cameraCtrl.onChange(s=>this.setCamera(s))}if(t.length&&(this.morphFolder.domElement.style.display="",t.forEach(n=>{if(n.morphTargetInfluences.length){const s=this.morphFolder.add({name:n.name||"Untitled"},"name");this.morphCtrls.push(s)}for(let s=0;s<n.morphTargetInfluences.length;s++){const r=this.morphFolder.add(n.morphTargetInfluences,s,0,1,.01).listen();Object.keys(n.morphTargetDictionary).forEach(a=>{a&&n.morphTargetDictionary[a]===s&&r.name(a)}),this.morphCtrls.push(r)}})),this.clips.length){this.animFolder.domElement.style.display="";const n=this.state.actionStates={};this.clips.forEach((s,r)=>{s.name=`${r+1}. ${s.name}`;let a;r===0?(n[s.name]=!0,a=this.mixer.clipAction(s),a.play()):n[s.name]=!1;const o=this.animFolder.add(n,s.name).listen();o.onChange(c=>{a=a||this.mixer.clipAction(s),a.setEffectiveTimeScale(1),c?a.play():a.stop(),this.invalidate()}),this.animCtrls.push(o)})}}setAnimationDefs(e){this.animationManager.setAnimationDefs(e),this.content&&this._setupAnimationPanel()}_setupAnimationPanel(){this._animPanelEl&&(this._animPanelEl.remove(),this._animPanelEl=null);const e=this.animationManager.getAnimationDefs();if(e.length===0)return;let t=!1;if(this.content.traverse(s=>{s.isSkinnedMesh&&(t=!0)}),!t)return;const n=document.createElement("div");n.className="anim-panel",n.innerHTML='<div class="anim-panel__header"><span class="anim-panel__title">Animations</span><button class="anim-panel__stop" title="Stop all">⏹</button></div><div class="anim-panel__grid"></div>',this.el.appendChild(n),this._animPanelEl=n,this._renderAnimButtons(),this.animationManager.loadAll().then(()=>{if(this._renderAnimButtons(),!this.animationManager.currentName&&e.length>0){const s=e[0].name;this.animationManager.isLoaded(s)&&(this.animationManager.play(s),this._renderAnimButtons(),this.invalidate(),this._recomputeAnimating(),this._updateRenderLoop())}}),n.querySelector(".anim-panel__stop").addEventListener("click",()=>{this.animationManager.stopAll(),this._renderAnimButtons(),this.invalidate()}),this.animationManager.onChange=()=>{this._renderAnimButtons()}}_renderAnimButtons(){if(!this._animPanelEl)return;const e=this._animPanelEl.querySelector(".anim-panel__grid"),t=this.animationManager.getAnimationDefs(),n=this.animationManager.currentName,s={idle:"🧍",breathing:"🧍",standing:"🧍",walking:"🚶",walk:"🚶",running:"🏃",run:"🏃",waving:"👋",wave:"👋",dancing:"💃",dance:"💃",sitting:"🪑",sit:"🪑",jumping:"🦘",jump:"🦘",talking:"🗣️",talk:"🗣️",clapping:"👏",clap:"👏",punching:"👊",punch:"👊",kicking:"🦵",kick:"🦵"};e.innerHTML=t.map((r,a)=>{const o=this.animationManager.isLoaded(r.name),c=n===r.name,l=r.icon||s[r.name.toLowerCase()]||"▶",h=r.label||r.name.charAt(0).toUpperCase()+r.name.slice(1),u=a<9?a+1:"";return'<button class="anim-btn'+(c?" anim-btn--active":"")+(o?"":" anim-btn--loading")+'" data-anim="'+r.name+'" title="'+h+(u?" — press "+u:"")+'"'+(o?"":" disabled")+">"+(u?'<span class="anim-btn__key">'+u+"</span>":"")+'<span class="anim-btn__icon">'+l+'</span><span class="anim-btn__label">'+h+"</span></button>"}).join(""),e.querySelectorAll(".anim-btn:not([disabled])").forEach(r=>{r.addEventListener("click",()=>{const a=r.dataset.anim;this.animationManager.crossfadeTo(a),this.invalidate(),this._recomputeAnimating(),this._updateRenderLoop()})}),this._onAnimHotkey||(this._onAnimHotkey=r=>{if(r.target&&/INPUT|TEXTAREA|SELECT/.test(r.target.tagName)||r.metaKey||r.ctrlKey||r.altKey)return;const a=parseInt(r.key,10);if(!a||a<1||a>9)return;const c=this.animationManager.getAnimationDefs()[a-1];!c||!this.animationManager.isLoaded(c.name)||(this.animationManager.crossfadeTo(c.name),this.invalidate(),this._recomputeAnimating(),this._updateRenderLoop())},document.addEventListener("keydown",this._onAnimHotkey))}clear(){this.content&&(this.animationManager.detach(),this._animPanelEl&&(this._animPanelEl.remove(),this._animPanelEl=null),this.modelInfo&&(this.modelInfo.remove(),this.modelInfo=null),this.annotationEls.forEach(e=>e.el.remove()),this.annotationEls=[],this.scene.remove(this.content),this.content.traverse(e=>{e.geometry&&e.geometry.dispose()}),Wm(this.content,e=>{for(const t in e)t!=="envMap"&&e[t]&&e[t].isTexture&&e[t].dispose()}),this.content=null,this._disposed||this.invalidate())}dispose(){if(!this._disposed){if(this._disposed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._onResize,!1),window.removeEventListener("keydown",this._onKeyDown),this._onAnimHotkey&&(document.removeEventListener("keydown",this._onAnimHotkey),this._onAnimHotkey=null),this._intersectionObserver&&(this._intersectionObserver.disconnect(),this._intersectionObserver=null),this.clear(),this.mixer){this.mixer.stopAllAction();const e=this.mixer.getRoot();e&&this.mixer.uncacheRoot(e),this.mixer=null}this.clips=[],this.animationManager.dispose(),this._animPanelEl&&(this._animPanelEl.remove(),this._animPanelEl=null),this.skeletonHelpers.length&&(this.skeletonHelpers.forEach(e=>{this.scene.remove(e),e.dispose?.()}),this.skeletonHelpers.length=0),this.gridHelper&&(this.scene.remove(this.gridHelper),this.gridHelper.geometry?.dispose(),this.gridHelper.material?.dispose(),this.gridHelper=null),this.axesHelper&&(this.scene.remove(this.axesHelper),this.axesHelper.geometry?.dispose(),this.axesHelper.material?.dispose(),this.axesHelper=null),this.axesCorner&&(this.axesScene?.remove(this.axesCorner),this.axesCorner.geometry?.dispose(),this.axesCorner.material?.dispose(),this.axesCorner=null),this.lights.forEach(e=>e.parent?.remove(e)),this.lights=[],this.annotationEls.length&&(this.annotationEls.forEach(e=>e.el.remove()),this.annotationEls=[]),this.modelInfo&&(this.modelInfo.remove(),this.modelInfo=null),this.gui&&(this.gui.destroy(),this.gui=null),this._guiWrap&&(this._guiWrap.remove(),this._guiWrap=null),this._guiToggle&&(this._guiToggle.remove(),this._guiToggle=null),this.stats?.dom&&this.stats.dom.remove(),this.controls&&(this._onControlsChange&&(this.controls.removeEventListener("change",this._onControlsChange),this._onControlsChange=null),this.controls.dispose(),this.controls=null),this._loadedEnvironment&&(this._loadedEnvironment.dispose(),this._loadedEnvironment=null),this.neutralEnvironment&&(this.neutralEnvironment.dispose(),this.neutralEnvironment=null),this.scene&&(this.scene.environment=null,this.scene.background=null),this.pmremGenerator&&(this.pmremGenerator.dispose(),this.pmremGenerator=null),this.axesRenderer&&(this.axesRenderer.dispose(),this.axesRenderer.forceContextLoss?.(),this.axesRenderer.domElement?.remove(),this.axesRenderer=null),this.axesDiv&&(this.axesDiv.remove(),this.axesDiv=null),this.axesScene=null,this.axesCamera=null,this.renderer&&(this.renderer.dispose(),this.renderer.forceContextLoss?.(),this.renderer.domElement?.remove(),window.renderer===this.renderer&&(window.renderer=null),this.renderer=null),this.scene=null,this.content=null,this.activeCamera=null,this.defaultCamera=null,this._afterAnimateHooks=null}}}class RB{constructor({model:e="claude-opus-4-6",proxyURL:t,apiKey:n,temperature:s=.7,maxTokens:r=4096,thinking:a="auto"}={}){this.model=e,this.proxyURL=t,this.apiKey=n,this.temperature=s,this.maxTokens=r,this.thinking=a}async complete({system:e,messages:t,tools:n}){const s={model:this.model,max_tokens:this.maxTokens,temperature:this.temperature,system:e,messages:t};n&&n.length&&(s.tools=n),this.thinking==="always"&&(s.thinking={type:"enabled",budget_tokens:2048});const r=this.proxyURL||"https://api.anthropic.com/v1/messages",a={"content-type":"application/json"};this.apiKey&&(a["x-api-key"]=this.apiKey,a["anthropic-version"]="2023-06-01",a["anthropic-dangerous-direct-browser-access"]="true");const o=await fetch(r,{method:"POST",headers:a,body:JSON.stringify(s)});if(!o.ok){const l=await o.text();throw new Error(`Anthropic ${o.status}: ${l}`)}const c=await o.json();return this._normalize(c)}_normalize(e){const t={text:"",toolCalls:[],thinking:"",stopReason:e.stop_reason};for(const n of e.content||[])n.type==="text"?t.text+=n.text:n.type==="thinking"?t.thinking+=n.thinking||"":n.type==="tool_use"&&t.toolCalls.push({id:n.id,name:n.name,input:n.input});return t}formatToolResults(e){return{role:"user",content:e.map(t=>({type:"tool_result",tool_use_id:t.id,content:typeof t.output=="string"?t.output:JSON.stringify(t.output),is_error:!!t.isError}))}}formatAssistantWithToolCalls(e,t){const n=[];e&&n.push({type:"text",text:e});for(const s of t)n.push({type:"tool_use",id:s.id,name:s.name,input:s.input});return{role:"assistant",content:n}}}class NB{async complete(){return{text:"",toolCalls:[],stopReason:"end_turn"}}formatToolResults(){return{role:"user",content:[]}}formatAssistantWithToolCalls(e){return{role:"assistant",content:e||""}}}function FB(i={}){const e=i.provider||"anthropic";if(e==="anthropic")return new RB(i);if(e==="none")return new NB;throw new Error(`Unsupported provider: ${e}. Supported: anthropic, none`)}class DB{constructor({voiceId:e="default",rate:t=1,pitch:n=1,lang:s="en-US"}={}){this.voiceId=e,this.rate=t,this.pitch=n,this.lang=s,this._queue=[],this._speaking=!1}async speak(e,{onStart:t,onEnd:n}={}){if("speechSynthesis"in window)return new Promise(s=>{const r=new SpeechSynthesisUtterance(e);r.rate=this.rate,r.pitch=this.pitch,r.lang=this.lang;const a=this._pickVoice();a&&(r.voice=a),r.onstart=()=>{this._speaking=!0,t?.()},r.onend=()=>{this._speaking=!1,n?.(),s()},r.onerror=()=>{this._speaking=!1,s()},window.speechSynthesis.speak(r)})}cancel(){"speechSynthesis"in window&&window.speechSynthesis.cancel(),this._speaking=!1}get speaking(){return this._speaking}_pickVoice(){if(!("speechSynthesis"in window))return null;const e=window.speechSynthesis.getVoices();if(this.voiceId&&this.voiceId!=="default"){const t=e.find(n=>n.name===this.voiceId||n.voiceURI===this.voiceId);if(t)return t}return e.find(t=>t.lang?.startsWith(this.lang.slice(0,2)))||null}}class LB{constructor({language:e="en-US",continuous:t=!1,interimResults:n=!0}={}){this.language=e,this.continuous=t,this.interimResults=n,this._recognition=null,this._listening=!1}_ensure(){if(this._recognition)return this._recognition;const e=window.SpeechRecognition||window.webkitSpeechRecognition;if(!e)return null;const t=new e;return t.lang=this.language,t.continuous=this.continuous,t.interimResults=this.interimResults,this._recognition=t,t}async listen({onInterim:e,onFinal:t}={}){const n=this._ensure();if(!n)throw new Error("SpeechRecognition unavailable in this browser");return new Promise((s,r)=>{let a="";n.onresult=o=>{for(let c=o.resultIndex;c<o.results.length;c++){const l=o.results[c],h=l[0].transcript;l.isFinal?(a+=h,t?.(h)):e?.(h)}},n.onerror=o=>{this._listening=!1,r(o.error)},n.onend=()=>{this._listening=!1,s(a.trim())},this._listening=!0;try{n.start()}catch(o){this._listening=!1,r(o)}})}stop(){this._recognition&&this._listening&&this._recognition.stop()}get listening(){return this._listening}}class PB{constructor({voiceId:e,modelId:t="eleven_turbo_v2_5",apiKey:n=null,proxyURL:s=null,rate:r=1,pitch:a=1,lang:o="en-US",stability:c=.5,similarityBoost:l=.75,useSpeakerBoost:h=!0}={}){if(!e)throw new Error("ElevenLabsTTS requires voiceId");this.voiceId=e,this.modelId=t,this.apiKey=n,this.proxyURL=s,this.rate=r,this.pitch=a,this.lang=o,this.stability=c,this.similarityBoost=l,this.useSpeakerBoost=h,this._speaking=!1,this._abort=null,this._audio=null,this._mediaSourceURL=null,this._onEnd=null}async speak(e,{onStart:t,onEnd:n}={}){if(this.cancel(),!e)return;this._abort=new AbortController,this._speaking=!0;const s=this.proxyURL||`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(this.voiceId)}/stream`,r={"content-type":"application/json",accept:"audio/mpeg"};!this.proxyURL&&this.apiKey&&(r["xi-api-key"]=this.apiKey);const a=Math.min(1.5,Math.max(.5,this.rate)),o=Math.min(1,Math.max(0,(a-.5)/1)),c=JSON.stringify({text:e,model_id:this.modelId,voice_settings:{stability:this.stability,similarity_boost:this.similarityBoost,style:o,use_speaker_boost:this.useSpeakerBoost},voiceId:this.voiceId,modelId:this.modelId});let l;try{l=await fetch(s,{method:"POST",headers:r,body:c,signal:this._abort.signal})}catch(d){if(this._speaking=!1,d.name==="AbortError")return;throw d}if(!l.ok)throw this._speaking=!1,new Error(`ElevenLabs TTS HTTP ${l.status}`);const h=typeof MediaSource<"u"&&MediaSource.isTypeSupported("audio/mpeg"),u=d=>{this._startedFired||(this._startedFired=!0,d?.())};return this._startedFired=!1,new Promise(d=>{this._onEnd=()=>{this._speaking=!1,this._cleanupAudio(),n?.(),this._onEnd=null,d()};const f=()=>{this._onEnd&&this._onEnd()};h&&l.body?this._playStreamingMSE(l.body,()=>u(t),f):this._playBuffered(l,()=>u(t),f)})}cancel(){if(this._abort){try{this._abort.abort()}catch{}this._abort=null}this._cleanupAudio(),this._speaking=!1,this._onEnd&&this._onEnd()}get speaking(){return this._speaking}_playStreamingMSE(e,t,n){const s=new MediaSource;this._mediaSourceURL=URL.createObjectURL(s);const r=new Audio(this._mediaSourceURL);this._audio=r,r.preload="auto",r.addEventListener("playing",t,{once:!0}),r.addEventListener("ended",()=>this._onEnd?.(),{once:!0}),r.addEventListener("error",()=>n?.(),{once:!0}),s.addEventListener("sourceopen",async()=>{let a;try{a=s.addSourceBuffer("audio/mpeg")}catch{n?.();return}const o=e.getReader(),c=[];let l=!0;const h=()=>{if(!l||a.updating)return;const u=c.shift();if(u)try{a.appendBuffer(u)}catch{l=!1;try{s.endOfStream()}catch{}}};a.addEventListener("updateend",h);try{for(;l;){const{value:u,done:d}=await o.read();if(d){l=!1;const f=()=>{if(a.updating||c.length)setTimeout(f,30);else try{s.endOfStream()}catch{}};f();break}c.push(u),h()}}catch(u){u.name!=="AbortError"&&n?.()}}),r.play().catch(n)}async _playBuffered(e,t,n){try{const s=await e.blob(),r=URL.createObjectURL(s);this._mediaSourceURL=r;const a=new Audio(r);this._audio=a,a.addEventListener("playing",t,{once:!0}),a.addEventListener("ended",()=>this._onEnd?.(),{once:!0}),a.addEventListener("error",()=>n?.(),{once:!0}),await a.play()}catch(s){s.name!=="AbortError"&&n?.()}}_cleanupAudio(){if(this._audio){try{this._audio.pause()}catch{}this._audio.src="",this._audio=null}if(this._mediaSourceURL){try{URL.revokeObjectURL(this._mediaSourceURL)}catch{}this._mediaSourceURL=null}this._startedFired=!1}}function kB(i={}){const e=i.provider||"browser";if(e==="none")return null;if(e==="browser")return new DB(i);if(e==="elevenlabs")return new PB(i);throw new Error(`TTS provider "${e}" not implemented yet`)}function UB(i={}){const e=i.provider||"browser";if(e==="none")return null;if(e==="browser")return new LB(i);throw new Error(`STT provider "${e}" not implemented yet`)}const Zm=[{name:"wave",description:"Wave at the user. Use for greetings, farewells, or acknowledgments.",input_schema:{type:"object",properties:{duration_ms:{type:"integer",minimum:500,maximum:5e3,default:1500}}}},{name:"lookAt",description:"Direct the agent's gaze toward a target.",input_schema:{type:"object",properties:{target:{type:"string",enum:["user","camera","center"],description:"Where to look"}},required:["target"]}},{name:"play_clip",description:"Play a named animation clip from the loaded body.",input_schema:{type:"object",properties:{name:{type:"string"},loop:{type:"boolean",default:!1},fade_ms:{type:"integer",default:200}},required:["name"]}},{name:"setExpression",description:"Set facial expression via morph target preset.",input_schema:{type:"object",properties:{preset:{type:"string",enum:["neutral","happy","sad","surprised","confused","focused"]},intensity:{type:"number",minimum:0,maximum:1,default:1}},required:["preset"]}},{name:"speak",description:"Say something out loud via TTS. Use this instead of plain text when voice is on.",input_schema:{type:"object",properties:{text:{type:"string"}},required:["text"]}},{name:"remember",description:"Save a durable memory about the user, a feedback rule, a project fact, or a reference.",input_schema:{type:"object",properties:{key:{type:"string",description:'short snake_case filename, e.g. "user_role"'},name:{type:"string"},description:{type:"string"},type:{type:"string",enum:["user","feedback","project","reference"]},body:{type:"string"}},required:["key","name","description","type","body"]}}],OB={async wave(i,e){const t=i.duration_ms||1500;return await e.viewer.playAnimationByHint?.("wave",{duration:t}),e.memory.note("waved",{duration_ms:t}),{ok:!0}},async lookAt(i,e){const t=i.target||"user";return e.viewer.lookAt?.(t),{ok:!0,target:t}},async play_clip(i,e){const{name:t,loop:n=!1,fade_ms:s=200}=i;return e.viewer.playClipByName?.(t,{loop:n,fade_ms:s})?{ok:!0,name:t}:{ok:!1,error:`No clip named "${t}"`}},async setExpression(i,e){const{preset:t,intensity:n=1}=i;return e.viewer.setExpression?.(t,n),{ok:!0,preset:t}},async speak(i,e){return await e.speak(i.text),{ok:!0}},async remember(i,e){const{key:t,name:n,description:s,type:r,body:a}=i;return e.memory.write(t,{name:n,description:s,type:r,body:a}),{ok:!0,saved:t}},async observe_agents(i,e){return e.stage?{ok:!0,agents:e.stage.getAgents().filter(n=>n.agentId!==e.agentId).map(({agentId:n,name:s,position:r})=>({agentId:n,name:s,position:r}))}:{ok:!1,error:"not on a stage"}},async say_to_agent(i,e){if(!e.stage)return{ok:!1,error:"not on a stage"};const{agentId:t,text:n}=i;if(!t||!n)return{ok:!1,error:"agentId and text required"};const s=e.agentId||"anon";return e.stage.broadcast(s,{kind:"direct",to:t,text:n}),e.stage.routeMessage(s,t,n)}},QB=8;class $m extends EventTarget{constructor({manifest:e,viewer:t,memory:n,skills:s,providerConfig:r={},voiceConfig:a={}}={}){super(),this.manifest=e||{},this.viewer=t,this.memory=n,this.skills=s,this.provider=FB({...this.manifest.brain,...r}),this.tts=kB({...this.manifest.voice?.tts,...a.tts}),this.stt=UB({...this.manifest.voice?.stt,...a.stt}),this.messages=[],this._busy=!1}get systemPrompt(){const e=[];return this.manifest.instructions&&e.push(this.manifest.instructions),this.memory&&e.push(`++<memory>+`+this.memory.contextBlock({maxTokens:this.manifest.memory?.maxTokens||8192})+`+</memory>`),this.skills&&e.push(this.skills.systemPrompt()),e.join("")}get tools(){const e=new Set(this.manifest.tools||Zm.map(s=>s.name)),t=Zm.filter(s=>e.has(s.name)),n=this.skills?this.skills.allTools():[];return[...t,...n]}async send(e,{voice:t=!1}={}){if(this._busy)throw new Error("Runtime busy — wait for current turn to finish");this._busy=!0;try{this.memory?.note("user_said",{text:e}),this.messages.push({role:"user",content:e}),this.dispatchEvent(new CustomEvent("brain:message",{detail:{role:"user",content:e}}));const n=await this._loop();return t&&n.text&&this.tts&&(this.dispatchEvent(new CustomEvent("voice:speech-start",{detail:{text:n.text}})),await this.tts.speak(n.text),this.dispatchEvent(new CustomEvent("voice:speech-end",{}))),n}finally{this._busy=!1}}async _loop(){let e=0,t="";for(;e++<QB;){const n=await this.provider.complete({system:this.systemPrompt,messages:this.messages,tools:this.tools});if(n.thinking&&this.dispatchEvent(new CustomEvent("brain:thinking",{detail:{content:n.thinking}})),!n.toolCalls.length){t=n.text,this.messages.push({role:"assistant",content:n.text}),this.dispatchEvent(new CustomEvent("brain:message",{detail:{role:"assistant",content:n.text}}));break}this.messages.push(this.provider.formatAssistantWithToolCalls(n.text,n.toolCalls)),n.text&&this.dispatchEvent(new CustomEvent("brain:message",{detail:{role:"assistant",content:n.text}}));const s=[];for(const r of n.toolCalls){let a,o=!1;try{a=await this._dispatchTool(r)}catch(c){a={error:c.message||String(c)},o=!0}this.dispatchEvent(new CustomEvent("skill:tool-called",{detail:{tool:r.name,args:r.input,result:a}})),s.push({id:r.id,output:a,isError:o})}this.messages.push(this.provider.formatToolResults(s))}return{text:t}}async _dispatchTool(e){const t=this._context(),n=this.skills?.findSkillForTool(e.name);if(n)return n.invoke(e.name,e.input,t);const s=OB[e.name];if(!s)throw new Error(`Unknown tool: ${e.name}`);return s(e.input,t)}_context(){return this.skills,{viewer:this.viewer,memory:this.memory,llm:{complete:(e,t)=>this.provider.complete({system:t?.system||"",messages:[{role:"user",content:e}],tools:t?.tools})},speak:async e=>{this.tts&&(this.dispatchEvent(new CustomEvent("voice:speech-start",{detail:{text:e}})),await this.tts.speak(e),this.dispatchEvent(new CustomEvent("voice:speech-end",{})))},listen:e=>this.stt?.listen(e),fetch:(e,t)=>fetch(e,t),loadGLB:async e=>this.viewer.loadGLB?.(e),loadClip:async e=>this.viewer.loadClip?.(e),loadJSON:async e=>(await fetch(e)).json(),call:async(e,t)=>this._dispatchTool({name:e,input:t})}}async listen({onInterim:e,onFinal:t}={}){if(!this.stt)throw new Error("STT not configured");return this.dispatchEvent(new CustomEvent("voice:listen-start",{})),await this.stt.listen({onInterim:s=>{this.dispatchEvent(new CustomEvent("voice:transcript",{detail:{text:s,final:!1}})),e?.(s)},onFinal:s=>{this.dispatchEvent(new CustomEvent("voice:transcript",{detail:{text:s,final:!0}})),t?.(s)}})}clearConversation(){this.messages=[]}pause(){this.tts?.cancel(),this.stt?.stop()}destroy(){this.pause(),this.messages=[]}}const Hd=["https://dweb.link/ipfs/","https://cloudflare-ipfs.com/ipfs/","https://ipfs.io/ipfs/"],GB="https://arweave.net/";function Ps(i,e=0){if(!i)return i;const t=i.match(/^ipfs:\/\/(.+)$/i);if(t)return Hd[e%Hd.length]+t[1];const n=i.match(/^ar:\/\/(.+)$/i);return n?GB+n[1]:i}async function e0(i){let e;for(let t=0;t<Hd.length;t++){const n=Ps(i,t);try{const s=await fetch(n);if(s.ok)return s}catch(s){e=s}}throw e||new Error("All IPFS gateways failed for "+i)}const t0={neutral:{},happy:{mouthSmile:1,browInnerUp:.3,cheekSquintL:.4,cheekSquintR:.4},sad:{mouthFrownL:.8,mouthFrownR:.8,browDownL:.6,browDownR:.6},surprised:{jawOpen:.5,eyeWideL:.8,eyeWideR:.8,browInnerUp:.9},confused:{browInnerUp:.5,browOuterUpL:.4,mouthPressL:.3,mouthPressR:.3},focused:{browDownL:.4,browDownR:.4,eyeSquintL:.3,eyeSquintR:.3}};class n0{constructor(e){this.viewer=e,this._loader=new Vu,this._userTarget=new H(0,1.6,2)}get scene(){return this.viewer.scene}get mixer(){return this.viewer.mixer}get clips(){return this.viewer.clips||[]}get content(){return this.viewer.content}async load(e,t="",n=new Map){return this.viewer.load(e,t,n)}playClipByName(e,{loop:t=!1,fade_ms:n=200}={}){const s=this._findClip(e);if(!s||!this.viewer.mixer)return!1;const r=this.viewer.mixer.clipAction(s);return r.reset(),r.setLoop(t?2201:2200),r.clampWhenFinished=!t,r.fadeIn(n/1e3),r.play(),this.viewer.state.actionStates[s.name]=!0,this.viewer.invalidate(),!0}playAnimationByHint(e,t){const n=e.toLowerCase(),s=this.clips.find(r=>r.name.toLowerCase().includes(n));return s?this.playClipByName(s.name,t):!1}stopClip(e){if(!this.viewer.mixer)return;const t=e?this._findClip(e):null;if(t){const n=this.viewer.mixer.existingAction(t);n&&n.fadeOut(.2),this.viewer.state.actionStates[t.name]=!1}else{this.viewer.mixer.stopAllAction();for(const n in this.viewer.state.actionStates)this.viewer.state.actionStates[n]=!1}this.viewer.invalidate()}async play(e,t){if(typeof e=="string")return this.playClipByName(e,t);if(!this.viewer.mixer||!e)return!1;const n=this.viewer.mixer.clipAction(e);return n.reset(),n.fadeIn(t?.blend??.2),n.play(),this.viewer.invalidate(),!0}async loadClip(e){const t=Ps(e);return new Promise((n,s)=>{this._loader.load(t,r=>n(r.animations?.[0]||null),void 0,s)})}async loadGLB(e){const t=Ps(e);return new Promise((n,s)=>{this._loader.load(t,n,void 0,s)})}lookAt(e){const t=this._resolveTarget(e);if(!t||!this.viewer.content)return;const n=this._findBone(["Head","head","mixamorigHead"]);n?n.lookAt(t):this.viewer.content.lookAt(t.x,this.viewer.content.position.y,t.z),this.viewer.invalidate()}_resolveTarget(e){return e instanceof H?e:e==="camera"?this.viewer.activeCamera.position.clone():e==="center"?new H(0,1,0):e==="user"?this.viewer.renderer?.xr?.isPresenting?this.viewer.renderer.xr.getCamera().position.clone():this._userTarget.clone():null}_findBone(e){if(!this.viewer.content)return null;let t=null;return this.viewer.content.traverse(n=>{t||n.isBone&&e.includes(n.name)&&(t=n)}),t}setExpression(e,t=1){const n=t0[e]||t0.neutral;this.viewer.content&&(this.viewer.content.traverse(s=>{if(!(!s.morphTargetDictionary||!s.morphTargetInfluences)){for(let r=0;r<s.morphTargetInfluences.length;r++)s.morphTargetInfluences[r]=0;for(const[r,a]of Object.entries(n)){const o=s.morphTargetDictionary[r];o!==void 0&&(s.morphTargetInfluences[o]=a*t)}}}),this.viewer.invalidate())}moveTo(e,{duration:t=600}={}){if(!this.viewer.content)return;const n=this.viewer.content.position.clone(),s=new H(e.x||0,e.y||n.y,e.z||0),r=performance.now(),a=o=>{const c=performance.now()-r,l=Math.min(c/t,1),h=l<.5?2*l*l:1-Math.pow(-2*l+2,2)/2;this.viewer.content.position.lerpVectors(n,s,h),this.viewer.invalidate(),l>=1&&this._removeHook(a)};this._addHook(a)}_addHook(e){this.viewer._afterAnimateHooks||(this.viewer._afterAnimateHooks=[]),this.viewer._afterAnimateHooks.push(e),this.viewer._animating=!0,this.viewer.invalidate()}_removeHook(e){const t=this.viewer._afterAnimateHooks;if(!t)return;const n=t.indexOf(e);n>=0&&t.splice(n,1)}_findClip(e){if(!this.clips.length)return null;const t=this.clips.find(s=>s.name===e);if(t)return t;const n=e.toLowerCase();return this.clips.find(s=>s.name.toLowerCase()===n)||this.clips.find(s=>s.name.toLowerCase().includes(n))}}function HB(i,e){return/^([a-z]+:|\/)/i.test(e)?e:(i.endsWith("/")||(i+="/"),i+e)}class i0{constructor({uri:e,manifest:t,instructions:n,tools:s,handlers:r}){this.uri=e,this.manifest=t,this.name=t.name,this.version=t.version,this.instructions=n,this.tools=s||[],this.handlers=r||{}}async invoke(e,t,n){const s=this.handlers[e];if(!s)throw new Error(`Skill "${this.name}" has no handler for tool "${e}"`);const r={...n,skillBaseURI:this.uri};return s(t,r)}systemPromptFragment(){return this.instructions?`++<skill name="${this.name}" version="${this.version}">+${this.instructions}+</skill>`:""}}class s0{constructor({fetchFn:e=fetch.bind(globalThis),trust:t="owned-only",ownerAddress:n}={}){this.fetchFn=e,this.trust=t,this.ownerAddress=n?.toLowerCase(),this.skills=new Map}async install(e,{bundleBase:t}={}){const n=this._resolveBundleURI(e.uri,t);if(this.skills.has(n))return this.skills.get(n);const s=await this._fetchJSON(`${n}manifest.json`);this._enforceTrust(s);const[r,a,o]=await Promise.all([this._fetchText(`${n}SKILL.md`).catch(()=>""),this._fetchJSON(`${n}tools.json`).catch(()=>({tools:[]})),this._fetchHandlers(`${n}handlers.js`).catch(()=>null)]),c=new i0({uri:n,manifest:s,instructions:r,tools:a.tools||[],handlers:o||{}});if(s.dependencies)for(const[l,h]of Object.entries(s.dependencies))await this.install({uri:l,version:h});return this.skills.set(n,c),c}uninstall(e){for(const[t,n]of this.skills)if(n.name===e)return this.skills.delete(t),!0;return!1}all(){return Array.from(this.skills.values())}allTools(){const e=new Map;for(const t of this.skills.values())for(const n of t.tools)e.has(n.name)&&console.warn(`[skills] tool "${n.name}" overridden by skill "${t.name}"`),e.set(n.name,{...n,_skill:t.name});return Array.from(e.values())}findSkillForTool(e){for(const t of this.skills.values())if(t.tools.some(n=>n.name===e))return t;return null}systemPrompt(){return this.all().map(e=>e.systemPromptFragment()).join("")}_resolveBundleURI(e,t){let n=e;return!/^([a-z]+:|\/)/i.test(e)&&t&&(n=HB(t,e)),n.endsWith("/")||(n+="/"),(n.startsWith("ipfs://")||n.startsWith("ar://"))&&(n=Ps(n)),n}async _fetchJSON(e){const t=await this.fetchFn(e);if(!t.ok)throw new Error(`Fetch failed: ${e} (${t.status})`);return t.json()}async _fetchText(e){const t=await this.fetchFn(e);if(!t.ok)throw new Error(`Fetch failed: ${e} (${t.status})`);return t.text()}async _fetchHandlers(e){try{return await import(e)}catch(t){return console.warn(`[skills] handlers load failed: ${e}`,t),null}}_enforceTrust(e){if(this.trust!=="any"){if(this.trust==="owned-only"){const t=(e.author||"").toLowerCase();if(t&&this.ownerAddress&&t!==this.ownerAddress)throw new Error(`Skill "${e.name}" author ${t} not trusted under owned-only policy`)}this.trust}}}const zB=/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/;function El(i){const e=i.match(zB);if(!e)return{meta:{},body:i};const t={};for(const n of e[1].split(`+`)){const[s,...r]=n.split(":");s&&(t[s.trim()]=r.join(":").trim())}return{meta:t,body:e[2]}}function VB(i,e){const t=["---"];for(const[n,s]of Object.entries(i))t.push(`${n}: ${s}`);return t.push("---","",e),t.join(`+`)}class xi{constructor({mode:e="local",namespace:t,index:n={},files:s={},timeline:r=[]}={}){this.mode=e,this.namespace=t,this.files=new Map(Object.entries(s)),this.timeline=r,this.indexText=n.text||"",this._dirty=!1}static async load({mode:e="local",namespace:t,manifestURI:n,fetchFn:s}){if(e==="none")return new xi({mode:"none",namespace:t});if(e==="local")return xi._loadLocal(t);if(e==="ipfs"||e==="encrypted-ipfs")return xi._loadIPFS({mode:e,namespace:t,manifestURI:n,fetchFn:s});throw new Error(`Unknown memory mode: ${e}`)}static _loadLocal(e){const t=`agent:${e}:memory`;try{const n=localStorage.getItem(t);if(!n)return new xi({mode:"local",namespace:e});const s=JSON.parse(n);return new xi({mode:"local",namespace:e,...s})}catch{return new xi({mode:"local",namespace:e})}}static async _loadIPFS({mode:e,namespace:t,manifestURI:n,fetchFn:s}){const r=n.replace(/manifest\.json$/,"");try{const a=await s(`${r}memory/MEMORY.md`),o=a.ok?await a.text():"",c={},l=/\[([^\]]+)\]\(([^)]+\.md)\)/g;let h;for(;h=l.exec(o);){const u=h[2];try{const d=await s(`${r}memory/${u}`);d.ok&&(c[u]=await d.text())}catch{}}return new xi({mode:e,namespace:t,index:{text:o},files:c})}catch{return new xi({mode:e,namespace:t})}}read(e){const t=e.endsWith(".md")?e:`${e}.md`,n=this.files.get(t);return n?El(n):null}write(e,{name:t,description:n,type:s,body:r,decay:a}){const o=e.endsWith(".md")?e:`${e}.md`,c=new Date().toISOString().slice(0,10),l=this.files.get(o),h=l&&El(l).meta.created||c,u={name:t,description:n,type:s,created:h,updated:c};a&&(u.decay=a),this.files.set(o,VB(u,r||"")),this._rebuildIndex(),this._dirty=!0,this._persist()}note(e,t){const n={ts:new Date().toISOString(),type:e,...t};this.timeline.push(n),this.timeline.length>1e3&&(this.timeline=this.timeline.slice(-1e3)),this._dirty=!0,this._persist()}async recall(e,{limit:t=5}={}){const n=e.toLowerCase(),s=[];for(const[r,a]of this.files){const{meta:o,body:c}=El(a),l=`${o.name||""} ${o.description||""} ${c}`.toLowerCase();l.includes(n)&&s.push({file:r,meta:o,body:c,score:l.split(n).length-1})}return s.sort((r,a)=>a.score-r.score).slice(0,t)}_rebuildIndex(){const e={user:[],feedback:[],project:[],reference:[]};for(const[s,r]of this.files){const{meta:a}=El(r),o=a.type||"user";e[o]||(e[o]=[]),e[o].push({file:s,name:a.name||s,description:a.description||""})}const t=["# Memory",""],n={user:"## User",feedback:"## Feedback",project:"## Project",reference:"## Reference"};for(const[s,r]of Object.entries(e))if(r.length){t.push(n[s]||`## ${s}`);for(const a of r)t.push(`- [${a.name}](${a.file}) — ${a.description}`);t.push("")}this.indexText=t.join(`+`)}_persist(){if(this.mode!=="local"||!this.namespace)return;const e=`agent:${this.namespace}:memory`,t={index:{text:this.indexText},files:Object.fromEntries(this.files),timeline:this.timeline.slice(-200)};try{localStorage.setItem(e,JSON.stringify(t))}catch(n){console.warn("[memory] persist failed",n)}}contextBlock({maxTokens:e=8192}={}){const t=e*4,n=["# Agent Memory","",this.indexText];let s=n.join(`+`).length;for(const[r,a]of this.files){if(s+a.length>t)break;n.push("",`## ${r}`,a),s+=a.length}if(this.timeline.length){const a=this.timeline.slice(-20).map(o=>JSON.stringify(o)).join(`+`);s+a.length<t&&n.push("","## Recent timeline","```",a,"```")}return n.join(`+`)}async export(){return{version:"memory/0.1",index:this.indexText,files:Object.fromEntries(this.files),timeline:this.timeline}}async import(e,{strategy:t="merge"}={}){if(t==="replace")this.files=new Map(Object.entries(e.files||{})),this.timeline=e.timeline||[];else{for(const[n,s]of Object.entries(e.files||{}))this.files.has(n)||this.files.set(n,s);this.timeline=[...this.timeline,...e.timeline||[]].slice(-1e3)}this._rebuildIndex(),this._persist()}}const WB="6.16.0";function qB(i,e,t){const n=e.split("|").map(r=>r.trim());for(let r=0;r<n.length;r++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof i===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=i,s}async function Fn(i){const e=Object.keys(i);return(await Promise.all(e.map(n=>Promise.resolve(i[n])))).reduce((n,s,r)=>(n[e[r]]=s,n),{})}function Ye(i,e,t){for(let n in e){let s=e[n];const r=t?t[n]:null;r&&qB(s,r,n),Object.defineProperty(i,n,{enumerable:!0,value:s,writable:!1})}}function Ea(i,e){if(i==null)return"null";if(e==null&&(e=new Set),typeof i=="object"){if(e.has(i))return"[Circular]";e.add(i)}if(Array.isArray(i))return"[ "+i.map(t=>Ea(t,e)).join(", ")+" ]";if(i instanceof Uint8Array){const t="0123456789abcdef";let n="0x";for(let s=0;s<i.length;s++)n+=t[i[s]>>4],n+=t[i[s]&15];return n}if(typeof i=="object"&&typeof i.toJSON=="function")return Ea(i.toJSON(),e);switch(typeof i){case"boolean":case"number":case"symbol":return i.toString();case"bigint":return BigInt(i).toString();case"string":return JSON.stringify(i);case"object":{const t=Object.keys(i);return t.sort(),"{ "+t.map(n=>`${Ea(n,e)}: ${Ea(i[n],e)}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function _n(i,e){return i&&i.code===e}function zd(i){return _n(i,"CALL_EXCEPTION")}function Qt(i,e,t){let n=i;{const r=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Ea(t)}`);for(const a in t){if(a==="shortMessage")continue;const o=t[a];r.push(a+"="+Ea(o))}}r.push(`code=${e}`),r.push(`version=${WB}`),r.length&&(i+=" ("+r.join(", ")+")")}let s;switch(e){case"INVALID_ARGUMENT":s=new TypeError(i);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":s=new RangeError(i);break;default:s=new Error(i)}return Ye(s,{code:e}),t&&Object.assign(s,t),s.shortMessage==null&&Ye(s,{shortMessage:n}),s}function pe(i,e,t,n){if(!i)throw Qt(e,t,n)}function V(i,e,t,n){pe(i,e,"INVALID_ARGUMENT",{argument:t,value:n})}function r0(i,e,t){t==null&&(t=""),t&&(t=": "+t),pe(i>=e,"missing argument"+t,"MISSING_ARGUMENT",{count:i,expectedCount:e}),pe(i<=e,"too many arguments"+t,"UNEXPECTED_ARGUMENT",{count:i,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((i,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");i.push(e)}catch{}return i},[]);function _l(i,e,t){if(t==null&&(t=""),i!==e){let n=t,s="new";t&&(n+=".",s+=" "+t),pe(!1,`private constructor; use ${n}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function a0(i,e,t){if(i instanceof Uint8Array)return t?new Uint8Array(i):i;if(typeof i=="string"&&i.length%2===0&&i.match(/^0x[0-9a-f]*$/i)){const n=new Uint8Array((i.length-2)/2);let s=2;for(let r=0;r<n.length;r++)n[r]=parseInt(i.substring(s,s+2),16),s+=2;return n}V(!1,"invalid BytesLike value",e||"value",i)}function lt(i,e){return a0(i,e,!1)}function Dn(i,e){return a0(i,e,!0)}function Ft(i,e){return!(typeof i!="string"||!i.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&i.length!==2+2*e||e===!0&&i.length%2!==0)}function Vd(i){return Ft(i,!0)||i instanceof Uint8Array}const o0="0123456789abcdef";function ve(i){const e=lt(i);let t="0x";for(let n=0;n<e.length;n++){const s=e[n];t+=o0[(s&240)>>4]+o0[s&15]}return t}function Ut(i){return"0x"+i.map(e=>ve(e).substring(2)).join("")}function _a(i){return Ft(i,!0)?(i.length-2)/2:lt(i).length}function Vt(i,e,t){const n=lt(i);return t!=null&&t>n.length&&pe(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:t}),ve(n.slice(e??0,t??n.length))}function c0(i,e,t){const n=lt(i);pe(e>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(n,e-n.length):s.set(n,0),ve(s)}function ts(i,e){return c0(i,e,!0)}function KB(i,e){return c0(i,e,!1)}const Bo=BigInt(0),Ei=BigInt(1),ya=9007199254740991;function XB(i,e){const t=yl(i,"value"),n=BigInt(ht(e,"width"));if(pe(t>>n===Bo,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:i}),t>>n-Ei){const s=(Ei<<n)-Ei;return-((~t&s)+Ei)}return t}function l0(i,e){let t=Re(i,"value");const n=BigInt(ht(e,"width")),s=Ei<<n-Ei;if(t<Bo){t=-t,pe(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:i});const r=(Ei<<n)-Ei;return(~t&r)+Ei}else pe(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:i});return t}function To(i,e){const t=yl(i,"value"),n=BigInt(ht(e,"bits"));return t&(Ei<<n)-Ei}function Re(i,e){switch(typeof i){case"bigint":return i;case"number":return V(Number.isInteger(i),"underflow",e||"value",i),V(i>=-ya&&i<=ya,"overflow",e||"value",i),BigInt(i);case"string":try{if(i==="")throw new Error("empty string");return i[0]==="-"&&i[1]!=="-"?-BigInt(i.substring(1)):BigInt(i)}catch(t){V(!1,`invalid BigNumberish string: ${t.message}`,e||"value",i)}}V(!1,"invalid BigNumberish value",e||"value",i)}function yl(i,e){const t=Re(i,e);return pe(t>=Bo,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:i}),t}const h0="0123456789abcdef";function Wd(i){if(i instanceof Uint8Array){let e="0x0";for(const t of i)e+=h0[t>>4],e+=h0[t&15];return BigInt(e)}return Re(i)}function ht(i,e){switch(typeof i){case"bigint":return V(i>=-ya&&i<=ya,"overflow",e||"value",i),Number(i);case"number":return V(Number.isInteger(i),"underflow",e||"value",i),V(i>=-ya&&i<=ya,"overflow",e||"value",i),i;case"string":try{if(i==="")throw new Error("empty string");return ht(BigInt(i),e)}catch(t){V(!1,`invalid numeric string: ${t.message}`,e||"value",i)}}V(!1,"invalid numeric value",e||"value",i)}function YB(i){return ht(Wd(i))}function ks(i,e){const t=yl(i,"value");let n=t.toString(16);if(e==null)n.length%2&&(n="0"+n);else{const s=ht(e,"width");if(s===0&&t===Bo)return"0x";for(pe(s*2>=n.length,`value exceeds width (${s} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:i});n.length<s*2;)n="0"+n}return"0x"+n}function Zt(i,e){const t=yl(i,"value");if(t===Bo)return new Uint8Array(0);let n=t.toString(16);n.length%2&&(n="0"+n);const s=new Uint8Array(n.length/2);for(let r=0;r<s.length;r++){const a=r*2;s[r]=parseInt(n.substring(a,a+2),16)}return s}function _i(i){let e=ve(Vd(i)?i:Zt(i)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const u0="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const d0=BigInt(58);function jB(i){const e=lt(i);let t=Wd(e),n="";for(;t;)n=u0[Number(t%d0)]+n,t/=d0;for(let s=0;s<e.length&&!e[s];s++)n=u0[0]+n;return n}function JB(i){i=atob(i);const e=new Uint8Array(i.length);for(let t=0;t<i.length;t++)e[t]=i.charCodeAt(t);return lt(e)}function ZB(i){const e=lt(i);let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}class f0{filter;emitter;#e;constructor(e,t,n){this.#e=t,Ye(this,{emitter:e,filter:n})}async removeListener(){this.#e!=null&&await this.emitter.off(this.filter,this.#e)}}function $B(i,e,t,n,s){V(!1,`invalid codepoint at offset ${e}; ${i}`,"bytes",t)}function p0(i,e,t,n,s){if(i==="BAD_PREFIX"||i==="UNEXPECTED_CONTINUE"){let r=0;for(let a=e+1;a<t.length&&t[a]>>6===2;a++)r++;return r}return i==="OVERRUN"?t.length-e-1:0}function eT(i,e,t,n,s){return i==="OVERLONG"?(V(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),n.push(s),0):(n.push(65533),p0(i,e,t))}const tT=Object.freeze({error:$B,ignore:p0,replace:eT});function nT(i,e){e==null&&(e=tT.error);const t=lt(i,"bytes"),n=[];let s=0;for(;s<t.length;){const r=t[s++];if(r>>7===0){n.push(r);continue}let a=null,o=null;if((r&224)===192)a=1,o=127;else if((r&240)===224)a=2,o=2047;else if((r&248)===240)a=3,o=65535;else{(r&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,n):s+=e("BAD_PREFIX",s-1,t,n);continue}if(s-1+a>=t.length){s+=e("OVERRUN",s-1,t,n);continue}let c=r&(1<<8-a-1)-1;for(let l=0;l<a;l++){let h=t[s];if((h&192)!=128){s+=e("MISSING_CONTINUE",s,t,n),c=null;break}c=c<<6|h&63,s++}if(c!==null){if(c>1114111){s+=e("OUT_OF_RANGE",s-1-a,t,n,c);continue}if(c>=55296&&c<=57343){s+=e("UTF16_SURROGATE",s-1-a,t,n,c);continue}if(c<=o){s+=e("OVERLONG",s-1-a,t,n,c);continue}n.push(c)}}return n}function ns(i,e){V(typeof i=="string","invalid string value","str",i);let t=[];for(let n=0;n<i.length;n++){const s=i.charCodeAt(n);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){n++;const r=i.charCodeAt(n);V(n<i.length&&(r&64512)===56320,"invalid surrogate pair","str",i);const a=65536+((s&1023)<<10)+(r&1023);t.push(a>>18|240),t.push(a>>12&63|128),t.push(a>>6&63|128),t.push(a&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function iT(i){return i.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function wl(i,e){return iT(nT(i,e))}function A0(i){async function e(t,n){pe(n==null||!n.cancelled,"request cancelled before sending","CANCELLED");const s=t.url.split(":")[0].toLowerCase();pe(s==="http"||s==="https",`unsupported protocol ${s}`,"UNSUPPORTED_OPERATION",{info:{protocol:s},operation:"request"}),pe(s==="https"||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let r=null;const a=new AbortController,o=setTimeout(()=>{r=Qt("request timeout","TIMEOUT"),a.abort()},t.timeout);n&&n.addListener(()=>{r=Qt("request cancelled","CANCELLED"),a.abort()});const c=Object.assign({},i,{method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:a.signal});let l;try{l=await fetch(t.url,c)}catch(f){throw clearTimeout(o),r||f}clearTimeout(o);const h={};l.headers.forEach((f,m)=>{h[m.toLowerCase()]=f});const u=await l.arrayBuffer(),d=u==null?null:new Uint8Array(u);return{statusCode:l.status,statusMessage:l.statusText,headers:h,body:d}}return e}const sT=12,rT=250;let g0=A0();const aT=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),oT=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let qd=!1;async function m0(i,e){try{const t=i.match(aT);if(!t)throw new Error("invalid data");return new Us(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?JB(t[3]):lT(t[3]))}catch{return new Us(599,"BAD REQUEST (invalid data: URI)",{},null,new Li(i))}}function b0(i){async function e(t,n){try{const s=t.match(oT);if(!s)throw new Error("invalid link");return new Li(`${i}${s[2]}`)}catch{return new Us(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Li(t))}}return e}const Cl={data:m0,ipfs:b0("https://gateway.ipfs.io/ipfs/")},x0=new WeakMap;class cT{#e;#t;constructor(e){this.#e=[],this.#t=!1,x0.set(e,()=>{if(!this.#t){this.#t=!0;for(const t of this.#e)setTimeout(()=>{t()},0);this.#e=[]}})}addListener(e){pe(!this.#t,"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),this.#e.push(e)}get cancelled(){return this.#t}checkSignal(){pe(!this.cancelled,"cancelled","CANCELLED",{})}}function vl(i){if(i==null)throw new Error("missing signal; should not happen");return i.checkSignal(),i}class Li{#e;#t;#n;#i;#s;#a;#r;#o;#f;#l;#p;#A;#c;#h;#u;get url(){return this.#a}set url(e){this.#a=String(e)}get body(){return this.#r==null?null:new Uint8Array(this.#r)}set body(e){if(e==null)this.#r=void 0,this.#o=void 0;else if(typeof e=="string")this.#r=ns(e),this.#o="text/plain";else if(e instanceof Uint8Array)this.#r=e,this.#o="application/octet-stream";else if(typeof e=="object")this.#r=ns(JSON.stringify(e)),this.#o="application/json";else throw new Error("invalid body")}hasBody(){return this.#r!=null}get method(){return this.#i?this.#i:this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),this.#i=String(e).toUpperCase()}get headers(){const e=Object.assign({},this.#n);return this.#f&&(e.authorization=`Basic ${ZB(ns(this.#f))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&this.#o&&(e["content-type"]=this.#o),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){this.#n[String(e).toLowerCase()]=String(t)}clearHeaders(){this.#n={}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const s=t[n++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return this.#f||null}setCredentials(e,t){V(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),this.#f=`${e}:${t}`}get allowGzip(){return this.#t}set allowGzip(e){this.#t=!!e}get allowInsecureAuthentication(){return!!this.#e}set allowInsecureAuthentication(e){this.#e=!!e}get timeout(){return this.#s}set timeout(e){V(e>=0,"timeout must be non-zero","timeout",e),this.#s=e}get preflightFunc(){return this.#l||null}set preflightFunc(e){this.#l=e}get processFunc(){return this.#p||null}set processFunc(e){this.#p=e}get retryFunc(){return this.#A||null}set retryFunc(e){this.#A=e}get getUrlFunc(){return this.#u||g0}set getUrlFunc(e){this.#u=e}constructor(e){this.#a=String(e),this.#e=!1,this.#t=!0,this.#n={},this.#i="",this.#s=3e5,this.#h={slotInterval:rT,maxAttempts:sT},this.#u=null}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${this.#r?ve(this.#r):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(this.#h.slotInterval=e.slotInterval),e.maxAttempts!=null&&(this.#h.maxAttempts=e.maxAttempts)}async#d(e,t,n,s,r){if(e>=this.#h.maxAttempts)return r.makeServerError("exceeded maximum retry limit");pe(E0()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:s}),n>0&&await hT(n);let a=this.clone();const o=(a.url.split(":")[0]||"").toLowerCase();if(o in Cl){const h=await Cl[o](a.url,vl(s.#c));if(h instanceof Us){let u=h;if(this.processFunc){vl(s.#c);try{u=await this.processFunc(a,u)}catch(d){(d.throttle==null||typeof d.stall!="number")&&u.makeServerError("error in post-processing function",d).assertOk()}}return u}a=h}this.preflightFunc&&(a=await this.preflightFunc(a));const c=await this.getUrlFunc(a,vl(s.#c));let l=new Us(c.statusCode,c.statusMessage,c.headers,c.body,s);if(l.statusCode===301||l.statusCode===302){try{const h=l.headers.location||"";return a.redirect(h).#d(e+1,t,0,s,l)}catch{}return l}else if(l.statusCode===429&&(this.retryFunc==null||await this.retryFunc(a,l,e))){const h=l.headers["retry-after"];let u=this.#h.slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof h=="string"&&h.match(/^[1-9][0-9]*$/)&&(u=parseInt(h)),a.clone().#d(e+1,t,u,s,l)}if(this.processFunc){vl(s.#c);try{l=await this.processFunc(a,l)}catch(h){(h.throttle==null||typeof h.stall!="number")&&l.makeServerError("error in post-processing function",h).assertOk();let u=this.#h.slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return h.stall>=0&&(u=h.stall),a.clone().#d(e+1,t,u,s,l)}}return l}send(){return pe(this.#c==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),this.#c=new cT(this),this.#d(0,E0()+this.timeout,0,this,new Us(0,"",{},null,this))}cancel(){pe(this.#c!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=x0.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(e){const t=this.url.split(":")[0].toLowerCase(),n=e.split(":")[0].toLowerCase();pe(this.method==="GET"&&(t!=="https"||n!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const s=new Li(e);return s.method="GET",s.allowGzip=this.allowGzip,s.timeout=this.timeout,s.#n=Object.assign({},this.#n),this.#r&&(s.#r=new Uint8Array(this.#r)),s.#o=this.#o,s}clone(){const e=new Li(this.url);return e.#i=this.#i,this.#r&&(e.#r=this.#r),e.#o=this.#o,e.#n=Object.assign({},this.#n),e.#f=this.#f,this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),e.#l=this.#l,e.#p=this.#p,e.#A=this.#A,e.#h=Object.assign({},this.#h),e.#u=this.#u,e}static lockConfig(){qd=!0}static getGateway(e){return Cl[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(qd)throw new Error("gateways locked");Cl[e]=t}static registerGetUrl(e){if(qd)throw new Error("gateways locked");g0=e}static createGetUrlFunc(e){return A0(e)}static createDataGateway(){return m0}static createIpfsGatewayFunc(e){return b0(e)}}class Us{#e;#t;#n;#i;#s;#a;toString(){return`<FetchResponse status=${this.statusCode} body=${this.#i?ve(this.#i):"null"}>`}get statusCode(){return this.#e}get statusMessage(){return this.#t}get headers(){return Object.assign({},this.#n)}get body(){return this.#i==null?null:new Uint8Array(this.#i)}get bodyText(){try{return this.#i==null?"":wl(this.#i)}catch{pe(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{pe(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const s=t[n++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}constructor(e,t,n,s,r){this.#e=e,this.#t=t,this.#n=Object.keys(n).reduce((a,o)=>(a[o.toLowerCase()]=String(n[o]),a),{}),this.#i=s==null?null:new Uint8Array(s),this.#s=r||null,this.#a={message:""}}makeServerError(e,t){let n;e?n=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,n=`CLIENT ESCALATED SERVER ERROR (${e})`);const s=new Us(599,n,this.headers,this.body,this.#s||void 0);return s.#a={message:e,error:t},s}throwThrottleError(e,t){t==null?t=-1:V(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const n=new Error(e||"throttling requests");throw Ye(n,{stall:t,throttle:!0}),n}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return this.#i!=null}get request(){return this.#s}ok(){return this.#a.message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=this.#a;e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let n=null;this.request&&(n=this.request.url);let s=null;try{this.#i&&(s=wl(this.#i))}catch{}pe(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:n,responseBody:s,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}}function E0(){return new Date().getTime()}function lT(i){return ns(i.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function hT(i){return new Promise(e=>setTimeout(e,i))}function uT(i){let e=i.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function _0(i,e,t){let n=0;for(let s=0;s<t;s++)n=n*256+i[e+s];return n}function y0(i,e,t,n){const s=[];for(;t<e+1+n;){const r=w0(i,t);s.push(r.result),t+=r.consumed,pe(t<=e+1+n,"child data too short","BUFFER_OVERRUN",{buffer:i,length:n,offset:e})}return{consumed:1+n,result:s}}function w0(i,e){pe(i.length!==0,"data too short","BUFFER_OVERRUN",{buffer:i,length:0,offset:1});const t=n=>{pe(n<=i.length,"data short segment too short","BUFFER_OVERRUN",{buffer:i,length:i.length,offset:n})};if(i[e]>=248){const n=i[e]-247;t(e+1+n);const s=_0(i,e+1,n);return t(e+1+n+s),y0(i,e,e+1+n,n+s)}else if(i[e]>=192){const n=i[e]-192;return t(e+1+n),y0(i,e,e+1,n)}else if(i[e]>=184){const n=i[e]-183;t(e+1+n);const s=_0(i,e+1,n);t(e+1+n+s);const r=ve(i.slice(e+1+n,e+1+n+s));return{consumed:1+n+s,result:r}}else if(i[e]>=128){const n=i[e]-128;t(e+1+n);const s=ve(i.slice(e+1,e+1+n));return{consumed:1+n,result:s}}return{consumed:1,result:uT(i[e])}}function Ro(i){const e=lt(i,"data"),t=w0(e,0);return V(t.consumed===e.length,"unexpected junk after rlp payload","data",i),t.result}function C0(i){const e=[];for(;i;)e.unshift(i&255),i>>=8;return e}function v0(i){if(Array.isArray(i)){let n=[];if(i.forEach(function(r){n=n.concat(v0(r))}),n.length<=55)return n.unshift(192+n.length),n;const s=C0(n.length);return s.unshift(247+s.length),s.concat(n)}const e=Array.prototype.slice.call(lt(i,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const t=C0(e.length);return t.unshift(183+t.length),t.concat(e)}const S0="0123456789abcdef";function is(i){let e="0x";for(const t of v0(i))e+=S0[t>>4],e+=S0[t&15];return e}const Ln=32,Kd=new Uint8Array(Ln),dT=["then"],Sl={},I0=new WeakMap;function ur(i){return I0.get(i)}function M0(i,e){I0.set(i,e)}function No(i,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${i}`);throw t.error=e,t}function Xd(i,e,t){return i.indexOf(null)>=0?e.map((n,s)=>n instanceof ss?Xd(ur(n),n,t):n):i.reduce((n,s,r)=>{let a=e.getValue(s);return s in n||(t&&a instanceof ss&&(a=Xd(ur(a),a,t)),n[s]=a),n},{})}class ss extends Array{#e;constructor(...e){const t=e[0];let n=e[1],s=(e[2]||[]).slice(),r=!0;t!==Sl&&(n=e,s=[],r=!1),super(n.length),n.forEach((c,l)=>{this[l]=c});const a=s.reduce((c,l)=>(typeof l=="string"&&c.set(l,(c.get(l)||0)+1),c),new Map);if(M0(this,Object.freeze(n.map((c,l)=>{const h=s[l];return h!=null&&a.get(h)===1?h:null}))),this.#e=[],this.#e==null&&this.#e,!r)return;Object.freeze(this);const o=new Proxy(this,{get:(c,l,h)=>{if(typeof l=="string"){if(l.match(/^[0-9]+$/)){const d=ht(l,"%index");if(d<0||d>=this.length)throw new RangeError("out of result range");const f=c[d];return f instanceof Error&&No(`index ${d}`,f),f}if(dT.indexOf(l)>=0)return Reflect.get(c,l,h);const u=c[l];if(u instanceof Function)return function(...d){return u.apply(this===h?c:this,d)};if(!(l in c))return c.getValue.apply(this===h?c:this,[l])}return Reflect.get(c,l,h)}});return M0(o,ur(this)),o}toArray(e){const t=[];return this.forEach((n,s)=>{n instanceof Error&&No(`index ${s}`,n),e&&n instanceof ss&&(n=n.toArray(e)),t.push(n)}),t}toObject(e){const t=ur(this);return t.reduce((n,s,r)=>(pe(s!=null,`value at index ${r} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),Xd(t,this,e)),{})}slice(e,t){e==null&&(e=0),e<0&&(e+=this.length,e<0&&(e=0)),t==null&&(t=this.length),t<0&&(t+=this.length,t<0&&(t=0)),t>this.length&&(t=this.length);const n=ur(this),s=[],r=[];for(let a=e;a<t;a++)s.push(this[a]),r.push(n[a]);return new ss(Sl,s,r)}filter(e,t){const n=ur(this),s=[],r=[];for(let a=0;a<this.length;a++){const o=this[a];o instanceof Error&&No(`index ${a}`,o),e.call(t,o,a,this)&&(s.push(o),r.push(n[a]))}return new ss(Sl,s,r)}map(e,t){const n=[];for(let s=0;s<this.length;s++){const r=this[s];r instanceof Error&&No(`index ${s}`,r),n.push(e.call(t,r,s,this))}return n}getValue(e){const t=ur(this).indexOf(e);if(t===-1)return;const n=this[t];return n instanceof Error&&No(`property ${JSON.stringify(e)}`,n.error),n}static fromItems(e,t){return new ss(Sl,e,t)}}function B0(i){let e=Zt(i);return pe(e.length<=Ln,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:Ln,offset:e.length}),e.length!==Ln&&(e=Dn(Ut([Kd.slice(e.length%Ln),e]))),e}class rs{name;type;localName;dynamic;constructor(e,t,n,s){Ye(this,{name:e,type:t,localName:n,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){V(!1,e,this.localName,t)}}class Yd{#e;#t;constructor(){this.#e=[],this.#t=0}get data(){return Ut(this.#e)}get length(){return this.#t}#n(e){return this.#e.push(e),this.#t+=e.length,e.length}appendWriter(e){return this.#n(Dn(e.data))}writeBytes(e){let t=Dn(e);const n=t.length%Ln;return n&&(t=Dn(Ut([t,Kd.slice(n)]))),this.#n(t)}writeValue(e){return this.#n(B0(e))}writeUpdatableValue(){const e=this.#e.length;return this.#e.push(Kd),this.#t+=Ln,t=>{this.#e[e]=B0(t)}}}class jd{allowLoose;#e;#t;#n;#i;#s;constructor(e,t,n){Ye(this,{allowLoose:!!t}),this.#e=Dn(e),this.#n=0,this.#i=null,this.#s=n??1024,this.#t=0}get data(){return ve(this.#e)}get dataLength(){return this.#e.length}get consumed(){return this.#t}get bytes(){return new Uint8Array(this.#e)}#a(e){if(this.#i)return this.#i.#a(e);this.#n+=e,pe(this.#s<1||this.#n<=this.#s*this.dataLength,`compressed ABI data exceeds inflation ratio of ${this.#s} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Dn(this.#e),offset:this.#t,length:e,info:{bytesRead:this.#n,dataLength:this.dataLength}})}#r(e,t,n){let s=Math.ceil(t/Ln)*Ln;return this.#t+s>this.#e.length&&(this.allowLoose&&n&&this.#t+t<=this.#e.length?s=t:pe(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Dn(this.#e),length:this.#e.length,offset:this.#t+s})),this.#e.slice(this.#t,this.#t+s)}subReader(e){const t=new jd(this.#e.slice(this.#t+e),this.allowLoose,this.#s);return t.#i=this,t}readBytes(e,t){let n=this.#r(0,e,!!t);return this.#a(e),this.#t+=n.length,n.slice(0,e)}readValue(){return Wd(this.readBytes(Ln))}readIndex(){return YB(this.readBytes(Ln))}}function Il(i){if(!Number.isSafeInteger(i)||i<0)throw new Error(`Wrong positive integer: ${i}`)}function Jd(i,...e){if(!(i instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(i.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${i.length}`)}function fT(i){if(typeof i!="function"||typeof i.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Il(i.outputLen),Il(i.blockLen)}function wa(i,e=!0){if(i.destroyed)throw new Error("Hash instance has been destroyed");if(e&&i.finished)throw new Error("Hash#digest() has already been called")}function T0(i,e){Jd(i);const t=e.outputLen;if(i.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const Zd=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;const R0=i=>i instanceof Uint8Array,pT=i=>new Uint32Array(i.buffer,i.byteOffset,Math.floor(i.byteLength/4)),$d=i=>new DataView(i.buffer,i.byteOffset,i.byteLength),Pi=(i,e)=>i<<32-e|i>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function AT(i){if(typeof i!="string")throw new Error(`utf8ToBytes expected string, got ${typeof i}`);return new Uint8Array(new TextEncoder().encode(i))}function Ml(i){if(typeof i=="string"&&(i=AT(i)),!R0(i))throw new Error(`expected Uint8Array, got ${typeof i}`);return i}function gT(...i){const e=new Uint8Array(i.reduce((n,s)=>n+s.length,0));let t=0;return i.forEach(n=>{if(!R0(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}class ef{clone(){return this._cloneInto()}}function tf(i){const e=n=>i().update(Ml(n)).digest(),t=i();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>i(),e}function mT(i=32){if(Zd&&typeof Zd.getRandomValues=="function")return Zd.getRandomValues(new Uint8Array(i));throw new Error("crypto.getRandomValues must be defined")}class N0 extends ef{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,fT(e);const n=Ml(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,r=new Uint8Array(s);r.set(n.length>s?e.create().update(n).digest():n);for(let a=0;a<r.length;a++)r[a]^=54;this.iHash.update(r),this.oHash=e.create();for(let a=0;a<r.length;a++)r[a]^=106;this.oHash.update(r),r.fill(0)}update(e){return wa(this),this.iHash.update(e),this}digestInto(e){wa(this),Jd(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:s,destroyed:r,blockLen:a,outputLen:o}=this;return e=e,e.finished=s,e.destroyed=r,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const F0=(i,e,t)=>new N0(i,e).update(t).digest();F0.create=(i,e)=>new N0(i,e);function bT(i,e,t,n){if(typeof i.setBigUint64=="function")return i.setBigUint64(e,t,n);const s=BigInt(32),r=BigInt(4294967295),a=Number(t>>s&r),o=Number(t&r),c=n?4:0,l=n?0:4;i.setUint32(e+c,a,n),i.setUint32(e+l,o,n)}class D0 extends ef{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=$d(this.buffer)}update(e){wa(this);const{view:t,buffer:n,blockLen:s}=this;e=Ml(e);const r=e.length;for(let a=0;a<r;){const o=Math.min(s-this.pos,r-a);if(o===s){const c=$d(e);for(;s<=r-a;a+=s)this.process(c,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){wa(this),T0(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:s,isLE:r}=this;let{pos:a}=this;t[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>s-a&&(this.process(n,0),a=0);for(let u=a;u<s;u++)t[u]=0;bT(n,s-8,BigInt(this.length*8),r),this.process(n,0);const o=$d(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)o.setUint32(4*u,h[u],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:s,finished:r,destroyed:a,pos:o}=this;return e.length=s,e.pos=o,e.finished=r,e.destroyed=a,s%t&&e.buffer.set(n),e}}const xT=(i,e,t)=>i&e^~i&t,ET=(i,e,t)=>i&e^i&t^e&t,_T=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Os=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Qs=new Uint32Array(64);class yT extends D0{constructor(){super(64,32,8,!1),this.A=Os[0]|0,this.B=Os[1]|0,this.C=Os[2]|0,this.D=Os[3]|0,this.E=Os[4]|0,this.F=Os[5]|0,this.G=Os[6]|0,this.H=Os[7]|0}get(){const{A:e,B:t,C:n,D:s,E:r,F:a,G:o,H:c}=this;return[e,t,n,s,r,a,o,c]}set(e,t,n,s,r,a,o,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=s|0,this.E=r|0,this.F=a|0,this.G=o|0,this.H=c|0}process(e,t){for(let u=0;u<16;u++,t+=4)Qs[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){const d=Qs[u-15],f=Qs[u-2],m=Pi(d,7)^Pi(d,18)^d>>>3,g=Pi(f,17)^Pi(f,19)^f>>>10;Qs[u]=g+Qs[u-7]+m+Qs[u-16]|0}let{A:n,B:s,C:r,D:a,E:o,F:c,G:l,H:h}=this;for(let u=0;u<64;u++){const d=Pi(o,6)^Pi(o,11)^Pi(o,25),f=h+d+xT(o,c,l)+_T[u]+Qs[u]|0,g=(Pi(n,2)^Pi(n,13)^Pi(n,22))+ET(n,s,r)|0;h=l,l=c,c=o,o=a+f|0,a=r,r=s,s=n,n=f+g|0}n=n+this.A|0,s=s+this.B|0,r=r+this.C|0,a=a+this.D|0,o=o+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,s,r,a,o,c,l,h)}roundClean(){Qs.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const L0=tf(()=>new yT),Bl=BigInt(2**32-1),nf=BigInt(32);function P0(i,e=!1){return e?{h:Number(i&Bl),l:Number(i>>nf&Bl)}:{h:Number(i>>nf&Bl)|0,l:Number(i&Bl)|0}}function k0(i,e=!1){let t=new Uint32Array(i.length),n=new Uint32Array(i.length);for(let s=0;s<i.length;s++){const{h:r,l:a}=P0(i[s],e);[t[s],n[s]]=[r,a]}return[t,n]}const wT=(i,e)=>BigInt(i>>>0)<<nf|BigInt(e>>>0),CT=(i,e,t)=>i>>>t,vT=(i,e,t)=>i<<32-t|e>>>t,ST=(i,e,t)=>i>>>t|e<<32-t,IT=(i,e,t)=>i<<32-t|e>>>t,MT=(i,e,t)=>i<<64-t|e>>>t-32,BT=(i,e,t)=>i>>>t-32|e<<64-t,TT=(i,e)=>e,RT=(i,e)=>i,U0=(i,e,t)=>i<<t|e>>>32-t,O0=(i,e,t)=>e<<t|i>>>32-t,Q0=(i,e,t)=>e<<t-32|i>>>64-t,G0=(i,e,t)=>i<<t-32|e>>>64-t;function NT(i,e,t,n){const s=(e>>>0)+(n>>>0);return{h:i+t+(s/2**32|0)|0,l:s|0}}const ct={fromBig:P0,split:k0,toBig:wT,shrSH:CT,shrSL:vT,rotrSH:ST,rotrSL:IT,rotrBH:MT,rotrBL:BT,rotr32H:TT,rotr32L:RT,rotlSH:U0,rotlSL:O0,rotlBH:Q0,rotlBL:G0,add:NT,add3L:(i,e,t)=>(i>>>0)+(e>>>0)+(t>>>0),add3H:(i,e,t,n)=>e+t+n+(i/2**32|0)|0,add4L:(i,e,t,n)=>(i>>>0)+(e>>>0)+(t>>>0)+(n>>>0),add4H:(i,e,t,n,s)=>e+t+n+s+(i/2**32|0)|0,add5H:(i,e,t,n,s,r)=>e+t+n+s+r+(i/2**32|0)|0,add5L:(i,e,t,n,s)=>(i>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0)},[FT,DT]=ct.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(i=>BigInt(i))),Gs=new Uint32Array(80),Hs=new Uint32Array(80);class LT extends D0{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:s,Ch:r,Cl:a,Dh:o,Dl:c,Eh:l,El:h,Fh:u,Fl:d,Gh:f,Gl:m,Hh:g,Hl:A}=this;return[e,t,n,s,r,a,o,c,l,h,u,d,f,m,g,A]}set(e,t,n,s,r,a,o,c,l,h,u,d,f,m,g,A){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=s|0,this.Ch=r|0,this.Cl=a|0,this.Dh=o|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=m|0,this.Hh=g|0,this.Hl=A|0}process(e,t){for(let b=0;b<16;b++,t+=4)Gs[b]=e.getUint32(t),Hs[b]=e.getUint32(t+=4);for(let b=16;b<80;b++){const _=Gs[b-15]|0,M=Hs[b-15]|0,w=ct.rotrSH(_,M,1)^ct.rotrSH(_,M,8)^ct.shrSH(_,M,7),S=ct.rotrSL(_,M,1)^ct.rotrSL(_,M,8)^ct.shrSL(_,M,7),T=Gs[b-2]|0,v=Hs[b-2]|0,C=ct.rotrSH(T,v,19)^ct.rotrBH(T,v,61)^ct.shrSH(T,v,6),F=ct.rotrSL(T,v,19)^ct.rotrBL(T,v,61)^ct.shrSL(T,v,6),K=ct.add4L(S,F,Hs[b-7],Hs[b-16]),q=ct.add4H(K,w,C,Gs[b-7],Gs[b-16]);Gs[b]=q|0,Hs[b]=K|0}let{Ah:n,Al:s,Bh:r,Bl:a,Ch:o,Cl:c,Dh:l,Dl:h,Eh:u,El:d,Fh:f,Fl:m,Gh:g,Gl:A,Hh:p,Hl:y}=this;for(let b=0;b<80;b++){const _=ct.rotrSH(u,d,14)^ct.rotrSH(u,d,18)^ct.rotrBH(u,d,41),M=ct.rotrSL(u,d,14)^ct.rotrSL(u,d,18)^ct.rotrBL(u,d,41),w=u&f^~u&g,S=d&m^~d&A,T=ct.add5L(y,M,S,DT[b],Hs[b]),v=ct.add5H(T,p,_,w,FT[b],Gs[b]),C=T|0,F=ct.rotrSH(n,s,28)^ct.rotrBH(n,s,34)^ct.rotrBH(n,s,39),K=ct.rotrSL(n,s,28)^ct.rotrBL(n,s,34)^ct.rotrBL(n,s,39),q=n&r^n&o^r&o,$=s&a^s&c^a&c;p=g|0,y=A|0,g=f|0,A=m|0,f=u|0,m=d|0,{h:u,l:d}=ct.add(l|0,h|0,v|0,C|0),l=o|0,h=c|0,o=r|0,c=a|0,r=n|0,a=s|0;const D=ct.add3L(C,K,$);n=ct.add3H(D,v,F,q),s=D|0}({h:n,l:s}=ct.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:r,l:a}=ct.add(this.Bh|0,this.Bl|0,r|0,a|0),{h:o,l:c}=ct.add(this.Ch|0,this.Cl|0,o|0,c|0),{h:l,l:h}=ct.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:u,l:d}=ct.add(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:m}=ct.add(this.Fh|0,this.Fl|0,f|0,m|0),{h:g,l:A}=ct.add(this.Gh|0,this.Gl|0,g|0,A|0),{h:p,l:y}=ct.add(this.Hh|0,this.Hl|0,p|0,y|0),this.set(n,s,r,a,o,c,l,h,u,d,f,m,g,A,p,y)}roundClean(){Gs.fill(0),Hs.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const PT=tf(()=>new LT);function kT(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const H0=kT();H0.crypto||H0.msCrypto;function UT(i){switch(i){case"sha256":return L0.create();case"sha512":return PT.create()}V(!1,"invalid hashing algorithm name","algorithm",i)}const[z0,V0,W0]=[[],[],[]],OT=BigInt(0),Fo=BigInt(1),QT=BigInt(2),GT=BigInt(7),HT=BigInt(256),zT=BigInt(113);for(let i=0,e=Fo,t=1,n=0;i<24;i++){[t,n]=[n,(2*t+3*n)%5],z0.push(2*(5*n+t)),V0.push((i+1)*(i+2)/2%64);let s=OT;for(let r=0;r<7;r++)e=(e<<Fo^(e>>GT)*zT)%HT,e&QT&&(s^=Fo<<(Fo<<BigInt(r))-Fo);W0.push(s)}const[VT,WT]=k0(W0,!0),q0=(i,e,t)=>t>32?Q0(i,e,t):U0(i,e,t),K0=(i,e,t)=>t>32?G0(i,e,t):O0(i,e,t);function qT(i,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let a=0;a<10;a++)t[a]=i[a]^i[a+10]^i[a+20]^i[a+30]^i[a+40];for(let a=0;a<10;a+=2){const o=(a+8)%10,c=(a+2)%10,l=t[c],h=t[c+1],u=q0(l,h,1)^t[o],d=K0(l,h,1)^t[o+1];for(let f=0;f<50;f+=10)i[a+f]^=u,i[a+f+1]^=d}let s=i[2],r=i[3];for(let a=0;a<24;a++){const o=V0[a],c=q0(s,r,o),l=K0(s,r,o),h=z0[a];s=i[h],r=i[h+1],i[h]=c,i[h+1]=l}for(let a=0;a<50;a+=10){for(let o=0;o<10;o++)t[o]=i[a+o];for(let o=0;o<10;o++)i[a+o]^=~t[(o+2)%10]&t[(o+4)%10]}i[0]^=VT[n],i[1]^=WT[n]}t.fill(0)}class sf extends ef{constructor(e,t,n,s=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=s,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Il(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=pT(this.state)}keccak(){qT(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){wa(this);const{blockLen:t,state:n}=this;e=Ml(e);const s=e.length;for(let r=0;r<s;){const a=Math.min(t-this.pos,s-r);for(let o=0;o<a;o++)n[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:s}=this;e[n]^=t,(t&128)!==0&&n===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){wa(this,!1),Jd(e),this.finish();const t=this.state,{blockLen:n}=this;for(let s=0,r=e.length;s<r;){this.posOut>=n&&this.keccak();const a=Math.min(n-this.posOut,r-s);e.set(t.subarray(this.posOut,this.posOut+a),s),this.posOut+=a,s+=a}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Il(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(T0(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:s,rounds:r,enableXOF:a}=this;return e||(e=new sf(t,n,s,a,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=n,e.outputLen=s,e.enableXOF=a,e.destroyed=this.destroyed,e}}const KT=((i,e,t)=>tf(()=>new sf(e,i,t)))(1,136,256/8);let X0=!1;const Y0=function(i){return KT(i)};let j0=Y0;function $t(i){const e=lt(i,"data");return ve(j0(e))}$t._=Y0,$t.lock=function(){X0=!0},$t.register=function(i){if(X0)throw new TypeError("keccak256 is locked");j0=i},Object.freeze($t);const J0=function(i){return UT("sha256").update(i).digest()};let Z0=J0,$0=!1;function Ca(i){const e=lt(i,"data");return ve(Z0(e))}Ca._=J0,Ca.lock=function(){$0=!0},Ca.register=function(i){if($0)throw new Error("sha256 is locked");Z0=i},Object.freeze(Ca),Object.freeze(Ca);BigInt(0);const XT=BigInt(1),YT=BigInt(2),Tl=i=>i instanceof Uint8Array,jT=Array.from({length:256},(i,e)=>e.toString(16).padStart(2,"0"));function va(i){if(!Tl(i))throw new Error("Uint8Array expected");let e="";for(let t=0;t<i.length;t++)e+=jT[i[t]];return e}function rf(i){if(typeof i!="string")throw new Error("hex string expected, got "+typeof i);return BigInt(i===""?"0":`0x${i}`)}function Do(i){if(typeof i!="string")throw new Error("hex string expected, got "+typeof i);const e=i.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let n=0;n<t.length;n++){const s=n*2,r=i.slice(s,s+2),a=Number.parseInt(r,16);if(Number.isNaN(a)||a<0)throw new Error("Invalid byte sequence");t[n]=a}return t}function dr(i){return rf(va(i))}function af(i){if(!Tl(i))throw new Error("Uint8Array expected");return rf(va(Uint8Array.from(i).reverse()))}function Sa(i,e){return Do(i.toString(16).padStart(e*2,"0"))}function of(i,e){return Sa(i,e).reverse()}function yi(i,e,t){let n;if(typeof e=="string")try{n=Do(e)}catch(r){throw new Error(`${i} must be valid hex string, got "${e}". Cause: ${r}`)}else if(Tl(e))n=Uint8Array.from(e);else throw new Error(`${i} must be hex string or Uint8Array`);const s=n.length;if(typeof t=="number"&&s!==t)throw new Error(`${i} expected ${t} bytes, got ${s}`);return n}function Lo(...i){const e=new Uint8Array(i.reduce((n,s)=>n+s.length,0));let t=0;return i.forEach(n=>{if(!Tl(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}const cf=i=>(YT<<BigInt(i-1))-XT,lf=i=>new Uint8Array(i),eb=i=>Uint8Array.from(i);function tb(i,e,t){if(typeof i!="number"||i<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=lf(i),s=lf(i),r=0;const a=()=>{n.fill(1),s.fill(0),r=0},o=(...u)=>t(s,n,...u),c=(u=lf())=>{s=o(eb([0]),u),n=o(),u.length!==0&&(s=o(eb([1]),u),n=o())},l=()=>{if(r++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const d=[];for(;u<e;){n=o();const f=n.slice();d.push(f),u+=n.length}return Lo(...d)};return(u,d)=>{a(),c(u);let f;for(;!(f=d(l()));)c();return a(),f}}const JT={bigint:i=>typeof i=="bigint",function:i=>typeof i=="function",boolean:i=>typeof i=="boolean",string:i=>typeof i=="string",stringOrUint8Array:i=>typeof i=="string"||i instanceof Uint8Array,isSafeInteger:i=>Number.isSafeInteger(i),array:i=>Array.isArray(i),field:(i,e)=>e.Fp.isValid(i),hash:i=>typeof i=="function"&&Number.isSafeInteger(i.outputLen)};function Po(i,e,t={}){const n=(s,r,a)=>{const o=JT[r];if(typeof o!="function")throw new Error(`Invalid validator "${r}", expected function`);const c=i[s];if(!(a&&c===void 0)&&!o(c,i))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${r}`)};for(const[s,r]of Object.entries(e))n(s,r,!1);for(const[s,r]of Object.entries(t))n(s,r,!0);return i}const ZT=Object.freeze(Object.defineProperty({__proto__:null,bitMask:cf,bytesToHex:va,bytesToNumberBE:dr,bytesToNumberLE:af,concatBytes:Lo,createHmacDrbg:tb,ensureBytes:yi,hexToBytes:Do,hexToNumber:rf,numberToBytesBE:Sa,numberToBytesLE:of,validateObject:Po},Symbol.toStringTag,{value:"Module"}));const An=BigInt(0),Xt=BigInt(1),fr=BigInt(2),$T=BigInt(3),hf=BigInt(4),nb=BigInt(5),ib=BigInt(8);BigInt(9),BigInt(16);function Gn(i,e){const t=i%e;return t>=An?t:e+t}function eR(i,e,t){if(t<=An||e<An)throw new Error("Expected power/modulo > 0");if(t===Xt)return An;let n=Xt;for(;e>An;)e&Xt&&(n=n*i%t),i=i*i%t,e>>=Xt;return n}function ii(i,e,t){let n=i;for(;e-- >An;)n*=n,n%=t;return n}function uf(i,e){if(i===An||e<=An)throw new Error(`invert: expected positive integers, got n=${i} mod=${e}`);let t=Gn(i,e),n=e,s=An,r=Xt;for(;t!==An;){const o=n/t,c=n%t,l=s-r*o;n=t,t=c,s=r,r=l}if(n!==Xt)throw new Error("invert: does not exist");return Gn(s,e)}function tR(i){const e=(i-Xt)/fr;let t,n,s;for(t=i-Xt,n=0;t%fr===An;t/=fr,n++);for(s=fr;s<i&&eR(s,e,i)!==i-Xt;s++);if(n===1){const a=(i+Xt)/hf;return function(c,l){const h=c.pow(l,a);if(!c.eql(c.sqr(h),l))throw new Error("Cannot find square root");return h}}const r=(t+Xt)/fr;return function(o,c){if(o.pow(c,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let l=n,h=o.pow(o.mul(o.ONE,s),t),u=o.pow(c,r),d=o.pow(c,t);for(;!o.eql(d,o.ONE);){if(o.eql(d,o.ZERO))return o.ZERO;let f=1;for(let g=o.sqr(d);f<l&&!o.eql(g,o.ONE);f++)g=o.sqr(g);const m=o.pow(h,Xt<<BigInt(l-f-1));h=o.sqr(m),u=o.mul(u,m),d=o.mul(d,h),l=f}return u}}function nR(i){if(i%hf===$T){const e=(i+Xt)/hf;return function(n,s){const r=n.pow(s,e);if(!n.eql(n.sqr(r),s))throw new Error("Cannot find square root");return r}}if(i%ib===nb){const e=(i-nb)/ib;return function(n,s){const r=n.mul(s,fr),a=n.pow(r,e),o=n.mul(s,a),c=n.mul(n.mul(o,fr),a),l=n.mul(o,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return tR(i)}const iR=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function sR(i){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=iR.reduce((n,s)=>(n[s]="function",n),e);return Po(i,t)}function rR(i,e,t){if(t<An)throw new Error("Expected power > 0");if(t===An)return i.ONE;if(t===Xt)return e;let n=i.ONE,s=e;for(;t>An;)t&Xt&&(n=i.mul(n,s)),s=i.sqr(s),t>>=Xt;return n}function aR(i,e){const t=new Array(e.length),n=e.reduce((r,a,o)=>i.is0(a)?r:(t[o]=r,i.mul(r,a)),i.ONE),s=i.inv(n);return e.reduceRight((r,a,o)=>i.is0(a)?r:(t[o]=i.mul(r,t[o]),i.mul(r,a)),s),t}function sb(i,e){const t=e!==void 0?e:i.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function oR(i,e,t=!1,n={}){if(i<=An)throw new Error(`Expected Field ORDER > 0, got ${i}`);const{nBitLength:s,nByteLength:r}=sb(i,e);if(r>2048)throw new Error("Field lengths over 2048 bytes are not supported");const a=nR(i),o=Object.freeze({ORDER:i,BITS:s,BYTES:r,MASK:cf(s),ZERO:An,ONE:Xt,create:c=>Gn(c,i),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return An<=c&&c<i},is0:c=>c===An,isOdd:c=>(c&Xt)===Xt,neg:c=>Gn(-c,i),eql:(c,l)=>c===l,sqr:c=>Gn(c*c,i),add:(c,l)=>Gn(c+l,i),sub:(c,l)=>Gn(c-l,i),mul:(c,l)=>Gn(c*l,i),pow:(c,l)=>rR(o,c,l),div:(c,l)=>Gn(c*uf(l,i),i),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>uf(c,i),sqrt:n.sqrt||(c=>a(o,c)),invertBatch:c=>aR(o,c),cmov:(c,l,h)=>h?l:c,toBytes:c=>t?of(c,r):Sa(c,r),fromBytes:c=>{if(c.length!==r)throw new Error(`Fp.fromBytes: expected ${r}, got ${c.length}`);return t?af(c):dr(c)}});return Object.freeze(o)}function rb(i){if(typeof i!="bigint")throw new Error("field order must be bigint");const e=i.toString(2).length;return Math.ceil(e/8)}function ab(i){const e=rb(i);return e+Math.ceil(e/2)}function cR(i,e,t=!1){const n=i.length,s=rb(e),r=ab(e);if(n<16||n<r||n>1024)throw new Error(`expected ${r}-1024 bytes of input, got ${n}`);const a=t?dr(i):af(i),o=Gn(a,e-Xt)+Xt;return t?of(o,s):Sa(o,s)}const lR=BigInt(0),df=BigInt(1);function hR(i,e){const t=(s,r)=>{const a=r.negate();return s?a:r},n=s=>{const r=Math.ceil(e/s)+1,a=2**(s-1);return{windows:r,windowSize:a}};return{constTimeNegate:t,unsafeLadder(s,r){let a=i.ZERO,o=s;for(;r>lR;)r&df&&(a=a.add(o)),o=o.double(),r>>=df;return a},precomputeWindow(s,r){const{windows:a,windowSize:o}=n(r),c=[];let l=s,h=l;for(let u=0;u<a;u++){h=l,c.push(h);for(let d=1;d<o;d++)h=h.add(l),c.push(h);l=h.double()}return c},wNAF(s,r,a){const{windows:o,windowSize:c}=n(s);let l=i.ZERO,h=i.BASE;const u=BigInt(2**s-1),d=2**s,f=BigInt(s);for(let m=0;m<o;m++){const g=m*c;let A=Number(a&u);a>>=f,A>c&&(A-=d,a+=df);const p=g,y=g+Math.abs(A)-1,b=m%2!==0,_=A<0;A===0?h=h.add(t(b,r[p])):l=l.add(t(_,r[y]))}return{p:l,f:h}},wNAFCached(s,r,a,o){const c=s._WINDOW_SIZE||1;let l=r.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&r.set(s,o(l))),this.wNAF(c,l,a)}}}function ob(i){return sR(i.Fp),Po(i,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...sb(i.n,i.nBitLength),...i,p:i.Fp.ORDER})}function uR(i){const e=ob(i);Po(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:n,a:s}=e;if(t){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:dR,hexToBytes:fR}=ZT,pr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(i){const{Err:e}=pr;if(i.length<2||i[0]!==2)throw new e("Invalid signature integer tag");const t=i[1],n=i.subarray(2,t+2);if(!t||n.length!==t)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:dR(n),l:i.subarray(t+2)}},toSig(i){const{Err:e}=pr,t=typeof i=="string"?fR(i):i;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:s,l:r}=pr._parseInt(t.subarray(2)),{d:a,l:o}=pr._parseInt(r);if(o.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:a}},hexFromSig(i){const e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,t=l=>{const h=l.toString(16);return h.length&1?`0${h}`:h},n=e(t(i.s)),s=e(t(i.r)),r=n.length/2,a=s.length/2,o=t(r),c=t(a);return`30${t(a+r+4)}02${c}${s}02${o}${n}`}},as=BigInt(0),si=BigInt(1);BigInt(2);const cb=BigInt(3);BigInt(4);function pR(i){const e=uR(i),{Fp:t}=e,n=e.toBytes||((m,g,A)=>{const p=g.toAffine();return Lo(Uint8Array.from([4]),t.toBytes(p.x),t.toBytes(p.y))}),s=e.fromBytes||(m=>{const g=m.subarray(1),A=t.fromBytes(g.subarray(0,t.BYTES)),p=t.fromBytes(g.subarray(t.BYTES,2*t.BYTES));return{x:A,y:p}});function r(m){const{a:g,b:A}=e,p=t.sqr(m),y=t.mul(p,m);return t.add(t.add(y,t.mul(m,g)),A)}if(!t.eql(t.sqr(e.Gy),r(e.Gx)))throw new Error("bad generator point: equation left != right");function a(m){return typeof m=="bigint"&&as<m&&m<e.n}function o(m){if(!a(m))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(m){const{allowedPrivateKeyLengths:g,nByteLength:A,wrapPrivateKey:p,n:y}=e;if(g&&typeof m!="bigint"){if(m instanceof Uint8Array&&(m=va(m)),typeof m!="string"||!g.includes(m.length))throw new Error("Invalid key");m=m.padStart(A*2,"0")}let b;try{b=typeof m=="bigint"?m:dr(yi("private key",m,A))}catch{throw new Error(`private key must be ${A} bytes, hex or bigint, not ${typeof m}`)}return p&&(b=Gn(b,y)),o(b),b}const l=new Map;function h(m){if(!(m instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(g,A,p){if(this.px=g,this.py=A,this.pz=p,g==null||!t.isValid(g))throw new Error("x required");if(A==null||!t.isValid(A))throw new Error("y required");if(p==null||!t.isValid(p))throw new Error("z required")}static fromAffine(g){const{x:A,y:p}=g||{};if(!g||!t.isValid(A)||!t.isValid(p))throw new Error("invalid affine point");if(g instanceof u)throw new Error("projective point not allowed");const y=b=>t.eql(b,t.ZERO);return y(A)&&y(p)?u.ZERO:new u(A,p,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){const A=t.invertBatch(g.map(p=>p.pz));return g.map((p,y)=>p.toAffine(A[y])).map(u.fromAffine)}static fromHex(g){const A=u.fromAffine(s(yi("pointHex",g)));return A.assertValidity(),A}static fromPrivateKey(g){return u.BASE.multiply(c(g))}_setWindowSize(g){this._WINDOW_SIZE=g,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:g,y:A}=this.toAffine();if(!t.isValid(g)||!t.isValid(A))throw new Error("bad point: x or y not FE");const p=t.sqr(A),y=r(g);if(!t.eql(p,y))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:g}=this.toAffine();if(t.isOdd)return!t.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){h(g);const{px:A,py:p,pz:y}=this,{px:b,py:_,pz:M}=g,w=t.eql(t.mul(A,M),t.mul(b,y)),S=t.eql(t.mul(p,M),t.mul(_,y));return w&&S}negate(){return new u(this.px,t.neg(this.py),this.pz)}double(){const{a:g,b:A}=e,p=t.mul(A,cb),{px:y,py:b,pz:_}=this;let M=t.ZERO,w=t.ZERO,S=t.ZERO,T=t.mul(y,y),v=t.mul(b,b),C=t.mul(_,_),F=t.mul(y,b);return F=t.add(F,F),S=t.mul(y,_),S=t.add(S,S),M=t.mul(g,S),w=t.mul(p,C),w=t.add(M,w),M=t.sub(v,w),w=t.add(v,w),w=t.mul(M,w),M=t.mul(F,M),S=t.mul(p,S),C=t.mul(g,C),F=t.sub(T,C),F=t.mul(g,F),F=t.add(F,S),S=t.add(T,T),T=t.add(S,T),T=t.add(T,C),T=t.mul(T,F),w=t.add(w,T),C=t.mul(b,_),C=t.add(C,C),T=t.mul(C,F),M=t.sub(M,T),S=t.mul(C,v),S=t.add(S,S),S=t.add(S,S),new u(M,w,S)}add(g){h(g);const{px:A,py:p,pz:y}=this,{px:b,py:_,pz:M}=g;let w=t.ZERO,S=t.ZERO,T=t.ZERO;const v=e.a,C=t.mul(e.b,cb);let F=t.mul(A,b),K=t.mul(p,_),q=t.mul(y,M),$=t.add(A,p),D=t.add(b,_);$=t.mul($,D),D=t.add(F,K),$=t.sub($,D),D=t.add(A,y);let O=t.add(b,M);return D=t.mul(D,O),O=t.add(F,q),D=t.sub(D,O),O=t.add(p,y),w=t.add(_,M),O=t.mul(O,w),w=t.add(K,q),O=t.sub(O,w),T=t.mul(v,D),w=t.mul(C,q),T=t.add(w,T),w=t.sub(K,T),T=t.add(K,T),S=t.mul(w,T),K=t.add(F,F),K=t.add(K,F),q=t.mul(v,q),D=t.mul(C,D),K=t.add(K,q),q=t.sub(F,q),q=t.mul(v,q),D=t.add(D,q),F=t.mul(K,D),S=t.add(S,F),F=t.mul(O,D),w=t.mul($,w),w=t.sub(w,F),F=t.mul($,K),T=t.mul(O,T),T=t.add(T,F),new u(w,S,T)}subtract(g){return this.add(g.negate())}is0(){return this.equals(u.ZERO)}wNAF(g){return f.wNAFCached(this,l,g,A=>{const p=t.invertBatch(A.map(y=>y.pz));return A.map((y,b)=>y.toAffine(p[b])).map(u.fromAffine)})}multiplyUnsafe(g){const A=u.ZERO;if(g===as)return A;if(o(g),g===si)return this;const{endo:p}=e;if(!p)return f.unsafeLadder(this,g);let{k1neg:y,k1:b,k2neg:_,k2:M}=p.splitScalar(g),w=A,S=A,T=this;for(;b>as||M>as;)b&si&&(w=w.add(T)),M&si&&(S=S.add(T)),T=T.double(),b>>=si,M>>=si;return y&&(w=w.negate()),_&&(S=S.negate()),S=new u(t.mul(S.px,p.beta),S.py,S.pz),w.add(S)}multiply(g){o(g);let A=g,p,y;const{endo:b}=e;if(b){const{k1neg:_,k1:M,k2neg:w,k2:S}=b.splitScalar(A);let{p:T,f:v}=this.wNAF(M),{p:C,f:F}=this.wNAF(S);T=f.constTimeNegate(_,T),C=f.constTimeNegate(w,C),C=new u(t.mul(C.px,b.beta),C.py,C.pz),p=T.add(C),y=v.add(F)}else{const{p:_,f:M}=this.wNAF(A);p=_,y=M}return u.normalizeZ([p,y])[0]}multiplyAndAddUnsafe(g,A,p){const y=u.BASE,b=(M,w)=>w===as||w===si||!M.equals(y)?M.multiplyUnsafe(w):M.multiply(w),_=b(this,A).add(b(g,p));return _.is0()?void 0:_}toAffine(g){const{px:A,py:p,pz:y}=this,b=this.is0();g==null&&(g=b?t.ONE:t.inv(y));const _=t.mul(A,g),M=t.mul(p,g),w=t.mul(y,g);if(b)return{x:t.ZERO,y:t.ZERO};if(!t.eql(w,t.ONE))throw new Error("invZ was invalid");return{x:_,y:M}}isTorsionFree(){const{h:g,isTorsionFree:A}=e;if(g===si)return!0;if(A)return A(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:g,clearCofactor:A}=e;return g===si?this:A?A(u,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return this.assertValidity(),n(u,this,g)}toHex(g=!0){return va(this.toRawBytes(g))}}u.BASE=new u(e.Gx,e.Gy,t.ONE),u.ZERO=new u(t.ZERO,t.ONE,t.ZERO);const d=e.nBitLength,f=hR(u,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:r,isWithinCurveOrder:a}}function AR(i){const e=ob(i);return Po(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function gR(i){const e=AR(i),{Fp:t,n}=e,s=t.BYTES+1,r=2*t.BYTES+1;function a(D){return as<D&&D<t.ORDER}function o(D){return Gn(D,n)}function c(D){return uf(D,n)}const{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:u,isWithinCurveOrder:d}=pR({...e,toBytes(D,O,j){const Q=O.toAffine(),J=t.toBytes(Q.x),ee=Lo;return j?ee(Uint8Array.from([O.hasEvenY()?2:3]),J):ee(Uint8Array.from([4]),J,t.toBytes(Q.y))},fromBytes(D){const O=D.length,j=D[0],Q=D.subarray(1);if(O===s&&(j===2||j===3)){const J=dr(Q);if(!a(J))throw new Error("Point is not on curve");const ee=u(J);let ae=t.sqrt(ee);const ye=(ae&si)===si;return(j&1)===1!==ye&&(ae=t.neg(ae)),{x:J,y:ae}}else if(O===r&&j===4){const J=t.fromBytes(Q.subarray(0,t.BYTES)),ee=t.fromBytes(Q.subarray(t.BYTES,2*t.BYTES));return{x:J,y:ee}}else throw new Error(`Point of length ${O} was invalid. Expected ${s} compressed bytes or ${r} uncompressed bytes`)}}),f=D=>va(Sa(D,e.nByteLength));function m(D){const O=n>>si;return D>O}function g(D){return m(D)?o(-D):D}const A=(D,O,j)=>dr(D.slice(O,j));class p{constructor(O,j,Q){this.r=O,this.s=j,this.recovery=Q,this.assertValidity()}static fromCompact(O){const j=e.nByteLength;return O=yi("compactSignature",O,j*2),new p(A(O,0,j),A(O,j,2*j))}static fromDER(O){const{r:j,s:Q}=pr.toSig(yi("DER",O));return new p(j,Q)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(O){return new p(this.r,this.s,O)}recoverPublicKey(O){const{r:j,s:Q,recovery:J}=this,ee=S(yi("msgHash",O));if(J==null||![0,1,2,3].includes(J))throw new Error("recovery id invalid");const ae=J===2||J===3?j+e.n:j;if(ae>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const ye=(J&1)===0?"02":"03",Me=l.fromHex(ye+f(ae)),se=c(ae),me=o(-ee*se),be=o(Q*se),xe=l.BASE.multiplyAndAddUnsafe(Me,me,be);if(!xe)throw new Error("point at infinify");return xe.assertValidity(),xe}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new p(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Do(this.toDERHex())}toDERHex(){return pr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Do(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const y={isValidPrivateKey(D){try{return h(D),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const D=ab(e.n);return cR(e.randomBytes(D),e.n)},precompute(D=8,O=l.BASE){return O._setWindowSize(D),O.multiply(BigInt(3)),O}};function b(D,O=!0){return l.fromPrivateKey(D).toRawBytes(O)}function _(D){const O=D instanceof Uint8Array,j=typeof D=="string",Q=(O||j)&&D.length;return O?Q===s||Q===r:j?Q===2*s||Q===2*r:D instanceof l}function M(D,O,j=!0){if(_(D))throw new Error("first arg must be private key");if(!_(O))throw new Error("second arg must be public key");return l.fromHex(O).multiply(h(D)).toRawBytes(j)}const w=e.bits2int||function(D){const O=dr(D),j=D.length*8-e.nBitLength;return j>0?O>>BigInt(j):O},S=e.bits2int_modN||function(D){return o(w(D))},T=cf(e.nBitLength);function v(D){if(typeof D!="bigint")throw new Error("bigint expected");if(!(as<=D&&D<T))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Sa(D,e.nByteLength)}function C(D,O,j=F){if(["recovered","canonical"].some($e=>$e in j))throw new Error("sign() legacy options not supported");const{hash:Q,randomBytes:J}=e;let{lowS:ee,prehash:ae,extraEntropy:ye}=j;ee==null&&(ee=!0),D=yi("msgHash",D),ae&&(D=yi("prehashed msgHash",Q(D)));const Me=S(D),se=h(O),me=[v(se),v(Me)];if(ye!=null){const $e=ye===!0?J(t.BYTES):ye;me.push(yi("extraEntropy",$e))}const be=Lo(...me),xe=Me;function Pe($e){const Qe=w($e);if(!d(Qe))return;const St=c(Qe),ut=l.BASE.multiply(Qe).toAffine(),Je=o(ut.x);if(Je===as)return;const G=o(St*o(xe+Je*se));if(G===as)return;let mn=(ut.x===Je?0:2)|Number(ut.y&si),dt=G;return ee&&m(G)&&(dt=g(G),mn^=1),new p(Je,dt,mn)}return{seed:be,k2sig:Pe}}const F={lowS:e.lowS,prehash:!1},K={lowS:e.lowS,prehash:!1};function q(D,O,j=F){const{seed:Q,k2sig:J}=C(D,O,j),ee=e;return tb(ee.hash.outputLen,ee.nByteLength,ee.hmac)(Q,J)}l.BASE._setWindowSize(8);function $(D,O,j,Q=K){const J=D;if(O=yi("msgHash",O),j=yi("publicKey",j),"strict"in Q)throw new Error("options.strict was renamed to lowS");const{lowS:ee,prehash:ae}=Q;let ye,Me;try{if(typeof J=="string"||J instanceof Uint8Array)try{ye=p.fromDER(J)}catch(ut){if(!(ut instanceof pr.Err))throw ut;ye=p.fromCompact(J)}else if(typeof J=="object"&&typeof J.r=="bigint"&&typeof J.s=="bigint"){const{r:ut,s:Je}=J;ye=new p(ut,Je)}else throw new Error("PARSE");Me=l.fromHex(j)}catch(ut){if(ut.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(ee&&ye.hasHighS())return!1;ae&&(O=e.hash(O));const{r:se,s:me}=ye,be=S(O),xe=c(me),Pe=o(be*xe),$e=o(se*xe),Qe=l.BASE.multiplyAndAddUnsafe(Me,Pe,$e)?.toAffine();return Qe?o(Qe.x)===se:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:M,sign:q,verify:$,ProjectivePoint:l,Signature:p,utils:y}}function mR(i){return{hash:i,hmac:(e,...t)=>F0(i,e,gT(...t)),randomBytes:mT}}function bR(i,e){const t=n=>gR({...i,...mR(n)});return Object.freeze({...t(e),create:t})}const lb=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),hb=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),xR=BigInt(1),ff=BigInt(2),ub=(i,e)=>(i+e/ff)/e;function ER(i){const e=lb,t=BigInt(3),n=BigInt(6),s=BigInt(11),r=BigInt(22),a=BigInt(23),o=BigInt(44),c=BigInt(88),l=i*i*i%e,h=l*l*i%e,u=ii(h,t,e)*h%e,d=ii(u,t,e)*h%e,f=ii(d,ff,e)*l%e,m=ii(f,s,e)*f%e,g=ii(m,r,e)*m%e,A=ii(g,o,e)*g%e,p=ii(A,c,e)*A%e,y=ii(p,o,e)*g%e,b=ii(y,t,e)*h%e,_=ii(b,a,e)*m%e,M=ii(_,n,e)*l%e,w=ii(M,ff,e);if(!pf.eql(pf.sqr(w),i))throw new Error("Cannot find square root");return w}const pf=oR(lb,void 0,void 0,{sqrt:ER}),zs=bR({a:BigInt(0),b:BigInt(7),Fp:pf,n:hb,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:i=>{const e=hb,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-xR*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),r=t,a=BigInt("0x100000000000000000000000000000000"),o=ub(r*i,e),c=ub(-n*i,e);let l=Gn(i-o*t-c*s,e),h=Gn(-o*n-c*r,e);const u=l>a,d=h>a;if(u&&(l=e-l),d&&(h=e-h),l>a||h>a)throw new Error("splitScalar: Endomorphism failed, k="+i);return{k1neg:u,k1:l,k2neg:d,k2:h}}}},L0);BigInt(0),zs.ProjectivePoint;const ko="0x0000000000000000000000000000000000000000",db="0x0000000000000000000000000000000000000000000000000000000000000000",fb=BigInt(0),pb=BigInt(1),Af=BigInt(2),Ab=BigInt(27),gb=BigInt(28),Rl=BigInt(35),mb=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_R=mb/Af,yR=Symbol.for("nodejs.util.inspect.custom"),Ar={};function gf(i){return ts(Zt(i),32)}class Gt{#e;#t;#n;#i;get r(){return this.#e}set r(e){V(_a(e)===32,"invalid r","value",e),this.#e=ve(e)}get s(){return V(parseInt(this.#t.substring(0,3))<8,"non-canonical s; use ._s","s",this.#t),this.#t}set s(e){V(_a(e)===32,"invalid s","value",e),this.#t=ve(e)}get _s(){return this.#t}isValid(){return BigInt(this.#t)<=_R}get v(){return this.#n}set v(e){const t=ht(e,"value");V(t===27||t===28,"invalid v","v",e),this.#n=t}get networkV(){return this.#i}get legacyChainId(){const e=this.networkV;return e==null?null:Gt.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=lt(this.s);return this.yParity&&(e[0]|=128),ve(e)}get compactSerialized(){return Ut([this.r,this.yParityAndS])}get serialized(){return Ut([this.r,this.s,this.yParity?"0x1c":"0x1b"])}constructor(e,t,n,s){_l(e,Ar,"Signature"),this.#e=t,this.#t=n,this.#n=s,this.#i=null}getCanonical(){if(this.isValid())return this;const e=mb-BigInt(this._s),t=55-this.v,n=new Gt(Ar,this.r,gf(e),t);return this.networkV&&(n.#i=this.networkV),n}clone(){const e=new Gt(Ar,this.r,this._s,this.v);return this.networkV&&(e.#i=this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this._s,v:this.v}}[yR](){return this.toString()}toString(){return this.isValid()?`Signature { r: ${this.r}, s: ${this._s}, v: ${this.v} }`:`Signature { r: ${this.r}, s: ${this._s}, v: ${this.v}, valid: false }`}static getChainId(e){const t=Re(e,"v");return t==Ab||t==gb?fb:(V(t>=Rl,"invalid EIP-155 v","v",e),(t-Rl)/Af)}static getChainIdV(e,t){return Re(e)*Af+BigInt(35+t-27)}static getNormalizedV(e){const t=Re(e);return t===fb||t===Ab?27:t===pb||t===gb?28:(V(t>=Rl,"invalid v","v",e),t&pb?27:28)}static from(e){function t(l,h){V(l,h,"signature",e)}if(e==null)return new Gt(Ar,db,db,27);if(typeof e=="string"){const l=lt(e,"signature");if(l.length===64){const h=ve(l.slice(0,32)),u=l.slice(32,64),d=u[0]&128?28:27;return u[0]&=127,new Gt(Ar,h,ve(u),d)}if(l.length===65){const h=ve(l.slice(0,32)),u=ve(l.slice(32,64)),d=Gt.getNormalizedV(l[64]);return new Gt(Ar,h,u,d)}t(!1,"invalid raw signature length")}if(e instanceof Gt)return e.clone();const n=e.r;t(n!=null,"missing r");const s=gf(n),r=(function(l,h){if(l!=null)return gf(l);if(h!=null){t(Ft(h,32),"invalid yParityAndS");const u=lt(h);return u[0]&=127,ve(u)}t(!1,"missing s")})(e.s,e.yParityAndS),{networkV:a,v:o}=(function(l,h,u){if(l!=null){const d=Re(l);return{networkV:d>=Rl?d:void 0,v:Gt.getNormalizedV(d)}}if(h!=null)return t(Ft(h,32),"invalid yParityAndS"),{v:lt(h)[0]&128?28:27};if(u!=null){switch(ht(u,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}t(!1,"invalid yParity")}t(!1,"missing v")})(e.v,e.yParityAndS,e.yParity),c=new Gt(Ar,s,r,o);return a&&(c.#i=a),t(e.yParity==null||ht(e.yParity,"sig.yParity")===c.yParity,"yParity mismatch"),t(e.yParityAndS==null||e.yParityAndS===c.yParityAndS,"yParityAndS mismatch"),c}}class os{#e;constructor(e){V(_a(e)===32,"invalid private key","privateKey","[REDACTED]"),this.#e=ve(e)}get privateKey(){return this.#e}get publicKey(){return os.computePublicKey(this.#e)}get compressedPublicKey(){return os.computePublicKey(this.#e,!0)}sign(e){V(_a(e)===32,"invalid digest length","digest",e);const t=zs.sign(Dn(e),Dn(this.#e),{lowS:!0});return Gt.from({r:ks(t.r,32),s:ks(t.s,32),v:t.recovery?28:27})}computeSharedSecret(e){const t=os.computePublicKey(e);return ve(zs.getSharedSecret(Dn(this.#e),lt(t),!1))}static computePublicKey(e,t){let n=lt(e,"key");if(n.length===32){const r=zs.getPublicKey(n,!!t);return ve(r)}if(n.length===64){const r=new Uint8Array(65);r[0]=4,r.set(n,1),n=r}const s=zs.ProjectivePoint.fromHex(n);return ve(s.toRawBytes(t))}static recoverPublicKey(e,t){V(_a(e)===32,"invalid digest length","digest",e);const n=Gt.from(t);let s=zs.Signature.fromCompact(Dn(Ut([n.r,n.s])));s=s.addRecoveryBit(n.yParity);const r=s.recoverPublicKey(Dn(e));return V(r!=null,"invalid signature for digest","signature",t),"0x"+r.toHex(!1)}static addPoints(e,t,n){const s=zs.ProjectivePoint.fromHex(os.computePublicKey(e).substring(2)),r=zs.ProjectivePoint.fromHex(os.computePublicKey(t).substring(2));return"0x"+s.add(r).toHex(!!n)}}const wR=BigInt(0),CR=BigInt(36);function bb(i){i=i.toLowerCase();const e=i.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const n=lt($t(t));for(let s=0;s<40;s+=2)n[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(n[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const mf={};for(let i=0;i<10;i++)mf[String(i)]=String(i);for(let i=0;i<26;i++)mf[String.fromCharCode(65+i)]=String(10+i);const xb=15;function vR(i){i=i.toUpperCase(),i=i.substring(4)+i.substring(0,2)+"00";let e=i.split("").map(n=>mf[n]).join("");for(;e.length>=xb;){let n=e.substring(0,xb);e=parseInt(n,10)%97+e.substring(n.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const SR=(function(){const i={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];i[t]=BigInt(e)}return i})();function IR(i){i=i.toLowerCase();let e=wR;for(let t=0;t<i.length;t++)e=e*CR+SR[i[t]];return e}function vt(i){if(V(typeof i=="string","invalid address","address",i),i.match(/^(0x)?[0-9a-fA-F]{40}$/)){i.startsWith("0x")||(i="0x"+i);const e=bb(i);return V(!i.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===i,"bad address checksum","address",i),e}if(i.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){V(i.substring(2,4)===vR(i),"bad icap checksum","address",i);let e=IR(i.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return bb("0x"+e)}V(!1,"invalid address","address",i)}function MR(i){const e=vt(i.from);let n=Re(i.nonce,"tx.nonce").toString(16);return n==="0"?n="0x":n.length%2?n="0x0"+n:n="0x"+n,vt(Vt($t(is([e,n])),12))}function Eb(i){return i&&typeof i.getAddress=="function"}async function bf(i,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(pe(typeof i!="string","unconfigured name","UNCONFIGURED_NAME",{value:i}),V(!1,"invalid AddressLike value; did not resolve to a value address","target",i)),vt(t)}function Pn(i,e){if(typeof i=="string")return i.match(/^0x[0-9a-f]{40}$/i)?vt(i):(pe(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),bf(i,e.resolveName(i)));if(Eb(i))return bf(i,i.getAddress());if(i&&typeof i.then=="function")return bf(i,i);V(!1,"unsupported addressable value","target",i)}const cs={};function Be(i,e){let t=!1;return e<0&&(t=!0,e*=-1),new Wt(cs,`${t?"":"u"}int${e}`,i,{signed:t,width:e})}function xt(i,e){return new Wt(cs,`bytes${e||""}`,i,{size:e})}const _b=Symbol.for("_ethers_typed");class Wt{type;value;#e;_typedSymbol;constructor(e,t,n,s){s==null&&(s=null),_l(cs,e,"Typed"),Ye(this,{_typedSymbol:_b,type:t,value:n}),this.#e=s,this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return this.#e}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return this.#e===!0?-1:this.#e===!1?this.value.length:null}static from(e,t){return new Wt(cs,e,t)}static uint8(e){return Be(e,8)}static uint16(e){return Be(e,16)}static uint24(e){return Be(e,24)}static uint32(e){return Be(e,32)}static uint40(e){return Be(e,40)}static uint48(e){return Be(e,48)}static uint56(e){return Be(e,56)}static uint64(e){return Be(e,64)}static uint72(e){return Be(e,72)}static uint80(e){return Be(e,80)}static uint88(e){return Be(e,88)}static uint96(e){return Be(e,96)}static uint104(e){return Be(e,104)}static uint112(e){return Be(e,112)}static uint120(e){return Be(e,120)}static uint128(e){return Be(e,128)}static uint136(e){return Be(e,136)}static uint144(e){return Be(e,144)}static uint152(e){return Be(e,152)}static uint160(e){return Be(e,160)}static uint168(e){return Be(e,168)}static uint176(e){return Be(e,176)}static uint184(e){return Be(e,184)}static uint192(e){return Be(e,192)}static uint200(e){return Be(e,200)}static uint208(e){return Be(e,208)}static uint216(e){return Be(e,216)}static uint224(e){return Be(e,224)}static uint232(e){return Be(e,232)}static uint240(e){return Be(e,240)}static uint248(e){return Be(e,248)}static uint256(e){return Be(e,256)}static uint(e){return Be(e,256)}static int8(e){return Be(e,-8)}static int16(e){return Be(e,-16)}static int24(e){return Be(e,-24)}static int32(e){return Be(e,-32)}static int40(e){return Be(e,-40)}static int48(e){return Be(e,-48)}static int56(e){return Be(e,-56)}static int64(e){return Be(e,-64)}static int72(e){return Be(e,-72)}static int80(e){return Be(e,-80)}static int88(e){return Be(e,-88)}static int96(e){return Be(e,-96)}static int104(e){return Be(e,-104)}static int112(e){return Be(e,-112)}static int120(e){return Be(e,-120)}static int128(e){return Be(e,-128)}static int136(e){return Be(e,-136)}static int144(e){return Be(e,-144)}static int152(e){return Be(e,-152)}static int160(e){return Be(e,-160)}static int168(e){return Be(e,-168)}static int176(e){return Be(e,-176)}static int184(e){return Be(e,-184)}static int192(e){return Be(e,-192)}static int200(e){return Be(e,-200)}static int208(e){return Be(e,-208)}static int216(e){return Be(e,-216)}static int224(e){return Be(e,-224)}static int232(e){return Be(e,-232)}static int240(e){return Be(e,-240)}static int248(e){return Be(e,-248)}static int256(e){return Be(e,-256)}static int(e){return Be(e,-256)}static bytes1(e){return xt(e,1)}static bytes2(e){return xt(e,2)}static bytes3(e){return xt(e,3)}static bytes4(e){return xt(e,4)}static bytes5(e){return xt(e,5)}static bytes6(e){return xt(e,6)}static bytes7(e){return xt(e,7)}static bytes8(e){return xt(e,8)}static bytes9(e){return xt(e,9)}static bytes10(e){return xt(e,10)}static bytes11(e){return xt(e,11)}static bytes12(e){return xt(e,12)}static bytes13(e){return xt(e,13)}static bytes14(e){return xt(e,14)}static bytes15(e){return xt(e,15)}static bytes16(e){return xt(e,16)}static bytes17(e){return xt(e,17)}static bytes18(e){return xt(e,18)}static bytes19(e){return xt(e,19)}static bytes20(e){return xt(e,20)}static bytes21(e){return xt(e,21)}static bytes22(e){return xt(e,22)}static bytes23(e){return xt(e,23)}static bytes24(e){return xt(e,24)}static bytes25(e){return xt(e,25)}static bytes26(e){return xt(e,26)}static bytes27(e){return xt(e,27)}static bytes28(e){return xt(e,28)}static bytes29(e){return xt(e,29)}static bytes30(e){return xt(e,30)}static bytes31(e){return xt(e,31)}static bytes32(e){return xt(e,32)}static address(e){return new Wt(cs,"address",e)}static bool(e){return new Wt(cs,"bool",!!e)}static bytes(e){return new Wt(cs,"bytes",e)}static string(e){return new Wt(cs,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Wt(cs,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===_b}static dereference(e,t){if(Wt.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}}class BR extends rs{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let n=Wt.dereference(t,"string");try{n=vt(n)}catch(s){return this._throwError(s.message,t)}return e.writeValue(n)}decode(e){return vt(ks(e.readValue(),20))}}class TR extends rs{coder;constructor(e){super(e.name,e.type,"_",e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}function yb(i,e,t){let n=[];if(Array.isArray(t))n=t;else if(t&&typeof t=="object"){let c={};n=e.map(l=>{const h=l.localName;return pe(h,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),pe(!c[h],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:l},value:t}),c[h]=!0,t[h]})}else V(!1,"invalid tuple value","tuple",t);V(e.length===n.length,"types/value length mismatch","tuple",t);let s=new Yd,r=new Yd,a=[];e.forEach((c,l)=>{let h=n[l];if(c.dynamic){let u=r.length;c.encode(r,h);let d=s.writeUpdatableValue();a.push(f=>{d(f+u)})}else c.encode(s,h)}),a.forEach(c=>{c(s.length)});let o=i.appendWriter(s);return o+=i.appendWriter(r),o}function wb(i,e){let t=[],n=[],s=i.subReader(0);return e.forEach(r=>{let a=null;if(r.dynamic){let o=i.readIndex(),c=s.subReader(o);try{a=r.decode(c)}catch(l){if(_n(l,"BUFFER_OVERRUN"))throw l;a=l,a.baseType=r.name,a.name=r.localName,a.type=r.type}}else try{a=r.decode(i)}catch(o){if(_n(o,"BUFFER_OVERRUN"))throw o;a=o,a.baseType=r.name,a.name=r.localName,a.type=r.type}if(a==null)throw new Error("investigate");t.push(a),n.push(r.localName||null)}),ss.fromItems(t,n)}class RR extends rs{coder;length;constructor(e,t,n){const s=e.type+"["+(t>=0?t:"")+"]",r=t===-1||e.dynamic;super("array",s,n,r),Ye(this,{coder:e,length:t})}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let n=0;n<this.length;n++)t.push(e);return t}encode(e,t){const n=Wt.dereference(t,"array");Array.isArray(n)||this._throwError("expected array value",n);let s=this.length;s===-1&&(s=n.length,e.writeValue(n.length)),r0(n.length,s,"coder array"+(this.localName?" "+this.localName:""));let r=[];for(let a=0;a<n.length;a++)r.push(this.coder);return yb(e,r,n)}decode(e){let t=this.length;t===-1&&(t=e.readIndex(),pe(t*Ln<=e.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:e.bytes,offset:t*Ln,length:e.dataLength}));let n=[];for(let s=0;s<t;s++)n.push(new TR(this.coder));return wb(e,n)}}class NR extends rs{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const n=Wt.dereference(t,"bool");return e.writeValue(n?1:0)}decode(e){return!!e.readValue()}}class Cb extends rs{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Dn(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readIndex(),!0)}}class FR extends Cb{constructor(e){super("bytes",e)}decode(e){return ve(super.decode(e))}}class DR extends rs{size;constructor(e,t){let n="bytes"+String(e);super(n,n,t,!1),Ye(this,{size:e},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(e,t){let n=Dn(Wt.dereference(t,this.type));return n.length!==this.size&&this._throwError("incorrect data length",t),e.writeBytes(n)}decode(e){return ve(e.readBytes(this.size))}}const LR=new Uint8Array([]);class PR extends rs{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(LR)}decode(e){return e.readBytes(0),null}}const kR=BigInt(0),UR=BigInt(1),OR=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class QR extends rs{size;signed;constructor(e,t,n){const s=(t?"int":"uint")+e*8;super(s,s,n,!1),Ye(this,{size:e,signed:t},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(e,t){let n=Re(Wt.dereference(t,this.type)),s=To(OR,Ln*8);if(this.signed){let r=To(s,this.size*8-1);(n>r||n<-(r+UR))&&this._throwError("value out-of-bounds",t),n=l0(n,8*Ln)}else(n<kR||n>To(s,this.size*8))&&this._throwError("value out-of-bounds",t);return e.writeValue(n)}decode(e){let t=To(e.readValue(),this.size*8);return this.signed&&(t=XB(t,this.size*8)),t}}class GR extends Cb{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,ns(Wt.dereference(t,"string")))}decode(e){return wl(super.decode(e))}}class Nl extends rs{coders;constructor(e,t){let n=!1;const s=[];e.forEach(a=>{a.dynamic&&(n=!0),s.push(a.type)});const r="tuple("+s.join(",")+")";super("tuple",r,t,n),Ye(this,{coders:Object.freeze(e.slice())})}defaultValue(){const e=[];this.coders.forEach(n=>{e.push(n.defaultValue())});const t=this.coders.reduce((n,s)=>{const r=s.localName;return r&&(n[r]||(n[r]=0),n[r]++),n},{});return this.coders.forEach((n,s)=>{let r=n.localName;!r||t[r]!==1||(r==="length"&&(r="_length"),e[r]==null&&(e[r]=e[s]))}),Object.freeze(e)}encode(e,t){const n=Wt.dereference(t,"tuple");return yb(e,this.coders,n)}decode(e){return wb(e,this.coders)}}function xf(i,e){return{address:vt(i),storageKeys:e.map((t,n)=>(V(Ft(t,32),"invalid slot",`storageKeys[${n}]`,t),t.toLowerCase()))}}function gr(i){if(Array.isArray(i))return i.map((t,n)=>Array.isArray(t)?(V(t.length===2,"invalid slot set",`value[${n}]`,t),xf(t[0],t[1])):(V(t!=null&&typeof t=="object","invalid address-slot set","value",i),xf(t.address,t.storageKeys)));V(i!=null&&typeof i=="object","invalid access list","value",i);const e=Object.keys(i).map(t=>{const n=i[t].reduce((s,r)=>(s[r]=!0,s),{});return xf(t,Object.keys(n).sort())});return e.sort((t,n)=>t.address.localeCompare(n.address)),e}function vb(i){return{address:vt(i.address),nonce:Re(i.nonce!=null?i.nonce:0),chainId:Re(i.chainId!=null?i.chainId:0),signature:Gt.from(i.signature)}}function HR(i){let e;return typeof i=="string"?e=os.computePublicKey(i,!1):e=i.publicKey,vt($t("0x"+e.substring(4)).substring(26))}function zR(i,e){return HR(os.recoverPublicKey(i,e))}const gn=BigInt(0),VR=BigInt(2),WR=BigInt(27),qR=BigInt(28),KR=BigInt(35),XR=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),YR=Symbol.for("nodejs.util.inspect.custom"),Ef=4096*32,Fl=128;function jR(i){return{blobToKzgCommitment:n=>{if("computeBlobProof"in i){if("blobToKzgCommitment"in i&&typeof i.blobToKzgCommitment=="function")return lt(i.blobToKzgCommitment(ve(n)))}else if("blobToKzgCommitment"in i&&typeof i.blobToKzgCommitment=="function")return lt(i.blobToKzgCommitment(n));if("blobToKZGCommitment"in i&&typeof i.blobToKZGCommitment=="function")return lt(i.blobToKZGCommitment(ve(n)));V(!1,"unsupported KZG library","kzg",i)},computeBlobKzgProof:(n,s)=>{if("computeBlobProof"in i&&typeof i.computeBlobProof=="function")return lt(i.computeBlobProof(ve(n),ve(s)));if("computeBlobKzgProof"in i&&typeof i.computeBlobKzgProof=="function")return i.computeBlobKzgProof(n,s);if("computeBlobKZGProof"in i&&typeof i.computeBlobKZGProof=="function")return lt(i.computeBlobKZGProof(ve(n),ve(s)));V(!1,"unsupported KZG library","kzg",i)}}}function Sb(i,e){let t=i.toString(16);for(;t.length<2;)t="0"+t;return t+=Ca(e).substring(4),"0x"+t}function Ia(i){return i==="0x"?null:vt(i)}function Dl(i,e){try{return gr(i)}catch(t){V(!1,t.message,e,i)}}function JR(i,e){try{if(!Array.isArray(i))throw new Error("authorizationList: invalid array");const t=[];for(let n=0;n<i.length;n++){const s=i[n];if(!Array.isArray(s))throw new Error(`authorization[${n}]: invalid array`);if(s.length!==6)throw new Error(`authorization[${n}]: wrong length`);if(!s[1])throw new Error(`authorization[${n}]: null address`);t.push({address:Ia(s[1]),nonce:Tt(s[2],"nonce"),chainId:Tt(s[0],"chainId"),signature:Gt.from({yParity:mr(s[3],"yParity"),r:ts(s[4],32),s:ts(s[5],32)})})}return t}catch(t){V(!1,t.message,e,i)}}function mr(i,e){return i==="0x"?0:ht(i,e)}function Tt(i,e){if(i==="0x")return gn;const t=Re(i,e);return V(t<=XR,"value exceeds uint size",e,t),t}function gt(i,e){const t=Re(i,"value"),n=Zt(t);return V(n.length<=32,"value too large",`tx.${e}`,t),n}function Ll(i){return gr(i).map(e=>[e.address,e.storageKeys])}function ZR(i){return i.map(e=>[gt(e.chainId,"chainId"),e.address,gt(e.nonce,"nonce"),gt(e.signature.yParity,"yParity"),Zt(e.signature.r),Zt(e.signature._s)])}function $R(i,e){V(Array.isArray(i),`invalid ${e}`,"value",i);for(let t=0;t<i.length;t++)V(Ft(i[t],32),"invalid ${ param } hash",`value[${t}]`,i[t]);return i}function eN(i){const e=Ro(i);V(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",i);const t={type:0,nonce:mr(e[0],"nonce"),gasPrice:Tt(e[1],"gasPrice"),gasLimit:Tt(e[2],"gasLimit"),to:Ia(e[3]),value:Tt(e[4],"value"),data:ve(e[5]),chainId:gn};if(e.length===6)return t;const n=Tt(e[6],"v"),s=Tt(e[7],"r"),r=Tt(e[8],"s");if(s===gn&&r===gn)t.chainId=n;else{let a=(n-KR)/VR;a<gn&&(a=gn),t.chainId=a,V(a!==gn||n===WR||n===qR,"non-canonical legacy v","v",e[6]),t.signature=Gt.from({r:ts(e[7],32),s:ts(e[8],32),v:n})}return t}function tN(i,e){const t=[gt(i.nonce,"nonce"),gt(i.gasPrice||0,"gasPrice"),gt(i.gasLimit,"gasLimit"),i.to||"0x",gt(i.value,"value"),i.data];let n=gn;if(i.chainId!=gn)n=Re(i.chainId,"tx.chainId"),V(!e||e.networkV==null||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(i.signature){const r=i.signature.legacyChainId;r!=null&&(n=r)}if(!e)return n!==gn&&(t.push(Zt(n)),t.push("0x"),t.push("0x")),is(t);let s=BigInt(27+e.yParity);return n!==gn?s=Gt.getChainIdV(n,e.v):BigInt(e.v)!==s&&V(!1,"tx.chainId/sig.v mismatch","sig",e),t.push(Zt(s)),t.push(Zt(e.r)),t.push(Zt(e._s)),is(t)}function Pl(i,e){let t;try{if(t=mr(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{V(!1,"invalid yParity","yParity",e[0])}const n=ts(e[1],32),s=ts(e[2],32),r=Gt.from({r:n,s,yParity:t});i.signature=r}function nN(i){const e=Ro(lt(i).slice(1));V(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",ve(i));const t={type:2,chainId:Tt(e[0],"chainId"),nonce:mr(e[1],"nonce"),maxPriorityFeePerGas:Tt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Tt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Tt(e[4],"gasLimit"),to:Ia(e[5]),value:Tt(e[6],"value"),data:ve(e[7]),accessList:Dl(e[8],"accessList")};return e.length===9||Pl(t,e.slice(9)),t}function iN(i,e){const t=[gt(i.chainId,"chainId"),gt(i.nonce,"nonce"),gt(i.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),gt(i.maxFeePerGas||0,"maxFeePerGas"),gt(i.gasLimit,"gasLimit"),i.to||"0x",gt(i.value,"value"),i.data,Ll(i.accessList||[])];return e&&(t.push(gt(e.yParity,"yParity")),t.push(Zt(e.r)),t.push(Zt(e.s))),Ut(["0x02",is(t)])}function sN(i){const e=Ro(lt(i).slice(1));V(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",ve(i));const t={type:1,chainId:Tt(e[0],"chainId"),nonce:mr(e[1],"nonce"),gasPrice:Tt(e[2],"gasPrice"),gasLimit:Tt(e[3],"gasLimit"),to:Ia(e[4]),value:Tt(e[5],"value"),data:ve(e[6]),accessList:Dl(e[7],"accessList")};return e.length===8||Pl(t,e.slice(8)),t}function rN(i,e){const t=[gt(i.chainId,"chainId"),gt(i.nonce,"nonce"),gt(i.gasPrice||0,"gasPrice"),gt(i.gasLimit,"gasLimit"),i.to||"0x",gt(i.value,"value"),i.data,Ll(i.accessList||[])];return e&&(t.push(gt(e.yParity,"recoveryParam")),t.push(Zt(e.r)),t.push(Zt(e.s))),Ut(["0x01",is(t)])}function aN(i){let e=Ro(lt(i).slice(1)),t="3",n=null,s=null;if(e.length===4&&Array.isArray(e[0])){t="3 (network format)";const a=e[1],o=e[2],c=e[3];V(Array.isArray(a),"invalid network format: blobs not an array","fields[1]",a),V(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),V(Array.isArray(c),"invalid network format: proofs not an array","fields[3]",c),V(a.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),V(a.length===c.length,"invalid network format: blobs/proofs length mismatch","fields",e),s=[];for(let l=0;l<e[1].length;l++)s.push({data:a[l],commitment:o[l],proof:c[l]});e=e[0]}else if(e.length===5&&Array.isArray(e[0])){t="3 (EIP-7594 network format)",n=ht(e[1]);const a=e[2],o=e[3],c=e[4];V(n===1,`unsupported EIP-7594 network format version: ${n}`,"fields[1]",n),V(Array.isArray(a),"invalid EIP-7594 network format: blobs not an array","fields[2]",a),V(Array.isArray(o),"invalid EIP-7594 network format: commitments not an array","fields[3]",o),V(Array.isArray(c),"invalid EIP-7594 network format: proofs not an array","fields[4]",c),V(a.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),V(a.length*Fl===c.length,"invalid network format: blobs/proofs length mismatch","fields",e),s=[];for(let l=0;l<a.length;l++){const h=[];for(let u=0;u<Fl;u++)h.push(c[l*Fl+u]);s.push({data:a[l],commitment:o[l],proof:Ut(h)})}e=e[0]}V(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${t}`,"data",ve(i));const r={type:3,chainId:Tt(e[0],"chainId"),nonce:mr(e[1],"nonce"),maxPriorityFeePerGas:Tt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Tt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Tt(e[4],"gasLimit"),to:Ia(e[5]),value:Tt(e[6],"value"),data:ve(e[7]),accessList:Dl(e[8],"accessList"),maxFeePerBlobGas:Tt(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10],blobWrapperVersion:n};s&&(r.blobs=s),V(r.to!=null,`invalid address for transaction type: ${t}`,"data",i),V(Array.isArray(r.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",i);for(let a=0;a<r.blobVersionedHashes.length;a++)V(Ft(r.blobVersionedHashes[a],32),`invalid blobVersionedHash at index ${a}: must be length 32`,"data",i);return e.length===11||Pl(r,e.slice(11)),r}function oN(i,e,t){const n=[gt(i.chainId,"chainId"),gt(i.nonce,"nonce"),gt(i.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),gt(i.maxFeePerGas||0,"maxFeePerGas"),gt(i.gasLimit,"gasLimit"),i.to||ko,gt(i.value,"value"),i.data,Ll(i.accessList||[]),gt(i.maxFeePerBlobGas||0,"maxFeePerBlobGas"),$R(i.blobVersionedHashes||[],"blobVersionedHashes")];if(e&&(n.push(gt(e.yParity,"yParity")),n.push(Zt(e.r)),n.push(Zt(e.s)),t)){if(i.blobWrapperVersion!=null){const s=Zt(i.blobWrapperVersion),r=[];for(const{proof:a}of t){const o=lt(a),c=o.length/Fl;for(let l=0;l<o.length;l+=c)r.push(o.subarray(l,l+c))}return Ut(["0x03",is([n,s,t.map(a=>a.data),t.map(a=>a.commitment),r])])}return Ut(["0x03",is([n,t.map(s=>s.data),t.map(s=>s.commitment),t.map(s=>s.proof)])])}return Ut(["0x03",is(n)])}function cN(i){const e=Ro(lt(i).slice(1));V(Array.isArray(e)&&(e.length===10||e.length===13),"invalid field count for transaction type: 4","data",ve(i));const t={type:4,chainId:Tt(e[0],"chainId"),nonce:mr(e[1],"nonce"),maxPriorityFeePerGas:Tt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Tt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Tt(e[4],"gasLimit"),to:Ia(e[5]),value:Tt(e[6],"value"),data:ve(e[7]),accessList:Dl(e[8],"accessList"),authorizationList:JR(e[9],"authorizationList")};return e.length===10||Pl(t,e.slice(10)),t}function lN(i,e){const t=[gt(i.chainId,"chainId"),gt(i.nonce,"nonce"),gt(i.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),gt(i.maxFeePerGas||0,"maxFeePerGas"),gt(i.gasLimit,"gasLimit"),i.to||"0x",gt(i.value,"value"),i.data,Ll(i.accessList||[]),ZR(i.authorizationList||[])];return e&&(t.push(gt(e.yParity,"yParity")),t.push(Zt(e.r)),t.push(Zt(e.s))),Ut(["0x04",is(t)])}class wi{#e;#t;#n;#i;#s;#a;#r;#o;#f;#l;#p;#A;#c;#h;#u;#d;#b;#g;get type(){return this.#e}set type(e){switch(e){case null:this.#e=null;break;case 0:case"legacy":this.#e=0;break;case 1:case"berlin":case"eip-2930":this.#e=1;break;case 2:case"london":case"eip-1559":this.#e=2;break;case 3:case"cancun":case"eip-4844":this.#e=3;break;case 4:case"pectra":case"eip-7702":this.#e=4;break;default:V(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844";case 4:return"eip-7702"}return null}get to(){const e=this.#t;return e==null&&this.type===3?ko:e}set to(e){this.#t=e==null?null:vt(e)}get nonce(){return this.#i}set nonce(e){this.#i=ht(e,"value")}get gasLimit(){return this.#s}set gasLimit(e){this.#s=Re(e)}get gasPrice(){const e=this.#a;return e==null&&(this.type===0||this.type===1)?gn:e}set gasPrice(e){this.#a=e==null?null:Re(e,"gasPrice")}get maxPriorityFeePerGas(){const e=this.#r;return e??(this.type===2||this.type===3?gn:null)}set maxPriorityFeePerGas(e){this.#r=e==null?null:Re(e,"maxPriorityFeePerGas")}get maxFeePerGas(){const e=this.#o;return e??(this.type===2||this.type===3?gn:null)}set maxFeePerGas(e){this.#o=e==null?null:Re(e,"maxFeePerGas")}get data(){return this.#n}set data(e){this.#n=ve(e)}get value(){return this.#f}set value(e){this.#f=Re(e,"value")}get chainId(){return this.#l}set chainId(e){this.#l=Re(e)}get signature(){return this.#p||null}set signature(e){this.#p=e==null?null:Gt.from(e)}isValid(){const e=this.signature;if(e&&!e.isValid())return!1;const t=this.authorizationList;if(t){for(const n of t)if(!n.signature.isValid())return!1}return!0}get accessList(){const e=this.#A||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){this.#A=e==null?null:gr(e)}get authorizationList(){const e=this.#b||null;return e==null&&this.type===4?[]:e}set authorizationList(e){this.#b=e==null?null:e.map(t=>vb(t))}get maxFeePerBlobGas(){const e=this.#c;return e==null&&this.type===3?gn:e}set maxFeePerBlobGas(e){this.#c=e==null?null:Re(e,"maxFeePerBlobGas")}get blobVersionedHashes(){let e=this.#h;return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){V(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let t=0;t<e.length;t++)V(Ft(e[t],32),"invalid blobVersionedHash",`value[${t}]`,e[t])}this.#h=e}get blobs(){return this.#d==null?null:this.#d.map(e=>Object.assign({},e))}set blobs(e){if(e==null){this.#d=null;return}const t=[],n=[];for(let s=0;s<e.length;s++){const r=e[s];if(Vd(r)){pe(this.#u,"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let a=lt(r);if(V(a.length<=Ef,"blob is too large",`blobs[${s}]`,r),a.length!==Ef){const l=new Uint8Array(Ef);l.set(a),a=l}const o=this.#u.blobToKzgCommitment(a),c=ve(this.#u.computeBlobKzgProof(a,o));t.push({data:ve(a),commitment:ve(o),proof:c}),n.push(Sb(1,o))}else{const a=ve(r.data),o=ve(r.commitment),c=ve(r.proof);t.push({data:a,commitment:o,proof:c}),n.push(Sb(1,o))}}this.#d=t,this.#h=n}get kzg(){return this.#u}set kzg(e){e==null?this.#u=null:this.#u=jR(e)}get blobWrapperVersion(){return this.#g}set blobWrapperVersion(e){this.#g=e}constructor(){this.#e=null,this.#t=null,this.#i=0,this.#s=gn,this.#a=null,this.#r=null,this.#o=null,this.#n="0x",this.#f=gn,this.#l=gn,this.#p=null,this.#A=null,this.#c=null,this.#h=null,this.#u=null,this.#d=null,this.#b=null,this.#g=null}get hash(){return this.signature==null?null:$t(this.#m(!0,!1))}get unsignedHash(){return $t(this.unsignedSerialized)}get from(){return this.signature==null?null:zR(this.unsignedHash,this.signature.getCanonical())}get fromPublicKey(){return this.signature==null?null:os.recoverPublicKey(this.unsignedHash,this.signature.getCanonical())}isSigned(){return this.signature!=null}#m(e,t){pe(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const n=e?this.signature:null;switch(this.inferType()){case 0:return tN(this,n);case 1:return rN(this,n);case 2:return iN(this,n);case 3:return oN(this,n,t?this.blobs:null);case 4:return lN(this,n)}pe(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})}get serialized(){return this.#m(!0,!0)}get unsignedSerialized(){return this.#m(!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,n=this.accessList!=null,s=this.#c!=null||this.#h;this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&pe(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),pe(!t||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),pe(this.type!==0||!n,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const r=[];return this.type!=null?r.push(this.type):this.authorizationList&&this.authorizationList.length?r.push(4):t?r.push(2):e?(r.push(1),n||r.push(0)):n?(r.push(1),r.push(2)):(s&&this.to||(r.push(0),r.push(1),r.push(2)),r.push(3)),r.sort(),r}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return wi.from(this)}toJSON(){const e=t=>t==null?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}[YR](){return this.toString()}toString(){const e=[],t=s=>{let r=this[s];typeof r=="string"&&(r=JSON.stringify(r)),e.push(`${s}: ${r}`)};this.type&&t("type"),t("to"),t("data"),t("nonce"),t("gasLimit"),t("value"),this.chainId!=null&&t("chainId"),this.signature&&(t("from"),e.push(`signature: ${this.signature.toString()}`));const n=this.authorizationList;if(n){const s=[];for(const r of n){const a=[];a.push(`address: ${JSON.stringify(r.address)}`),r.nonce!=null&&a.push(`nonce: ${r.nonce}`),r.chainId!=null&&a.push(`chainId: ${r.chainId}`),r.signature&&a.push(`signature: ${r.signature.toString()}`),s.push(`Authorization { ${a.join(", ")} }`)}e.push(`authorizations: [ ${s.join(", ")} ]`)}return`Transaction { ${e.join(", ")} }`}static from(e){if(e==null)return new wi;if(typeof e=="string"){const n=lt(e);if(n[0]>=127)return wi.from(eN(n));switch(n[0]){case 1:return wi.from(sN(n));case 2:return wi.from(nN(n));case 3:return wi.from(aN(n));case 4:return wi.from(cN(n))}pe(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const t=new wi;return e.type!=null&&(t.type=e.type),e.to!=null&&(t.to=e.to),e.nonce!=null&&(t.nonce=e.nonce),e.gasLimit!=null&&(t.gasLimit=e.gasLimit),e.gasPrice!=null&&(t.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(t.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(t.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(t.data=e.data),e.value!=null&&(t.value=e.value),e.chainId!=null&&(t.chainId=e.chainId),e.signature!=null&&(t.signature=Gt.from(e.signature)),e.accessList!=null&&(t.accessList=e.accessList),e.authorizationList!=null&&(t.authorizationList=e.authorizationList),e.blobVersionedHashes!=null&&(t.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(t.kzg=e.kzg),e.blobWrapperVersion!=null&&(t.blobWrapperVersion=e.blobWrapperVersion),e.blobs!=null&&(t.blobs=e.blobs),e.hash!=null&&(V(t.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),V(t.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(V(t.isSigned(),"unsigned transaction cannot define '.from'","tx",e),V(t.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),t}}function br(i){return $t(ns(i))}var hN="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";const Ib=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),Mb=4;function uN(i){let e=0;function t(){return i[e++]<<8|i[e++]}let n=t(),s=1,r=[0,1];for(let M=1;M<n;M++)r.push(s+=t());let a=t(),o=e;e+=a;let c=0,l=0;function h(){return c==0&&(l=l<<8|i[e++],c=8),l>>--c&1}const u=31,d=2**u,f=d>>>1,m=f>>1,g=d-1;let A=0;for(let M=0;M<u;M++)A=A<<1|h();let p=[],y=0,b=d;for(;;){let M=Math.floor(((A-y+1)*s-1)/b),w=0,S=n;for(;S-w>1;){let C=w+S>>>1;M<r[C]?S=C:w=C}if(w==0)break;p.push(w);let T=y+Math.floor(b*r[w]/s),v=y+Math.floor(b*r[w+1]/s)-1;for(;((T^v)&f)==0;)A=A<<1&g|h(),T=T<<1&g,v=v<<1&g|1;for(;T&~v&m;)A=A&f|A<<1&g>>>1|h(),T=T<<1^f,v=(v^f)<<1|f|1;y=T,b=1+v-T}let _=n-4;return p.map(M=>{switch(M-_){case 3:return _+65792+(i[o++]<<16|i[o++]<<8|i[o++]);case 2:return _+256+(i[o++]<<8|i[o++]);case 1:return _+i[o++];default:return M-1}})}function dN(i){let e=0;return()=>i[e++]}function Bb(i){return dN(uN(fN(i)))}function fN(i){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((s,r)=>e[s.charCodeAt(0)]=r);let t=i.length,n=new Uint8Array(6*t>>3);for(let s=0,r=0,a=0,o=0;s<t;s++)o=o<<6|e[i.charCodeAt(s)],a+=6,a>=8&&(n[r++]=o>>(a-=8));return n}function pN(i){return i&1?~i>>1:i>>1}function AN(i,e){let t=Array(i);for(let n=0,s=0;n<i;n++)t[n]=s+=pN(e());return t}function Uo(i,e=0){let t=[];for(;;){let n=i(),s=i();if(!s)break;e+=n;for(let r=0;r<s;r++)t.push(e+r);e+=s+1}return t}function Tb(i){return Oo(()=>{let e=Uo(i);if(e.length)return e})}function Rb(i){let e=[];for(;;){let t=i();if(t==0)break;e.push(gN(t,i))}for(;;){let t=i()-1;if(t<0)break;e.push(mN(t,i))}return e.flat()}function Oo(i){let e=[];for(;;){let t=i(e.length);if(!t)break;e.push(t)}return e}function Nb(i,e,t){let n=Array(i).fill().map(()=>[]);for(let s=0;s<e;s++)AN(i,t).forEach((r,a)=>n[a].push(r));return n}function gN(i,e){let t=1+e(),n=e(),s=Oo(e);return Nb(s.length,1+i,e).flatMap((a,o)=>{let[c,...l]=a;return Array(s[o]).fill().map((h,u)=>{let d=u*n;return[c+u*t,l.map(f=>f+d)]})})}function mN(i,e){let t=1+e();return Nb(t,1+i,e).map(s=>[s[0],s.slice(1)])}function bN(i){let e=[],t=Uo(i);return s(n([]),[]),e;function n(r){let a=i(),o=Oo(()=>{let c=Uo(i).map(l=>t[l]);if(c.length)return n(c)});return{S:a,B:o,Q:r}}function s({S:r,B:a},o,c){if(!(r&4&&c===o[o.length-1])){r&2&&(c=o[o.length-1]),r&1&&e.push(o);for(let l of a)for(let h of l.Q)s(l,[...o,h],c)}}}function xN(i){return i.toString(16).toUpperCase().padStart(2,"0")}function Fb(i){return`{${xN(i)}}`}function EN(i){let e=[];for(let t=0,n=i.length;t<n;){let s=i.codePointAt(t);t+=s<65536?1:2,e.push(s)}return e}function Ma(i){let t=i.length;if(t<4096)return String.fromCodePoint(...i);let n=[];for(let s=0;s<t;)n.push(String.fromCodePoint(...i.slice(s,s+=4096)));return n.join("")}function _N(i,e){let t=i.length,n=t-e.length;for(let s=0;n==0&&s<t;s++)n=i[s]-e[s];return n}var yN="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";const Qo=44032,kl=4352,Ul=4449,Ol=4519,Db=19,Lb=21,Ba=28,Ql=Lb*Ba,wN=Db*Ql,CN=Qo+wN,vN=kl+Db,SN=Ul+Lb,IN=Ol+Ba;function Go(i){return i>>24&255}function Pb(i){return i&16777215}let _f,kb,yf,Gl;function MN(){let i=Bb(yN);_f=new Map(Tb(i).flatMap((e,t)=>e.map(n=>[n,t+1<<24]))),kb=new Set(Uo(i)),yf=new Map,Gl=new Map;for(let[e,t]of Rb(i)){if(!kb.has(e)&&t.length==2){let[n,s]=t,r=Gl.get(n);r||(r=new Map,Gl.set(n,r)),r.set(s,e)}yf.set(e,t.reverse())}}function Ub(i){return i>=Qo&&i<CN}function BN(i,e){if(i>=kl&&i<vN&&e>=Ul&&e<SN)return Qo+(i-kl)*Ql+(e-Ul)*Ba;if(Ub(i)&&e>Ol&&e<IN&&(i-Qo)%Ba==0)return i+(e-Ol);{let t=Gl.get(i);return t&&(t=t.get(e),t)?t:-1}}function Ob(i){_f||MN();let e=[],t=[],n=!1;function s(r){let a=_f.get(r);a&&(n=!0,r|=a),e.push(r)}for(let r of i)for(;;){if(r<128)e.push(r);else if(Ub(r)){let a=r-Qo,o=a/Ql|0,c=a%Ql/Ba|0,l=a%Ba;s(kl+o),s(Ul+c),l>0&&s(Ol+l)}else{let a=yf.get(r);a?t.push(...a):s(r)}if(!t.length)break;r=t.pop()}if(n&&e.length>1){let r=Go(e[0]);for(let a=1;a<e.length;a++){let o=Go(e[a]);if(o==0||r<=o){r=o;continue}let c=a-1;for(;;){let l=e[c+1];if(e[c+1]=e[c],e[c]=l,!c||(r=Go(e[--c]),r<=o))break}r=Go(e[a])}}return e}function TN(i){let e=[],t=[],n=-1,s=0;for(let r of i){let a=Go(r),o=Pb(r);if(n==-1)a==0?n=o:e.push(o);else if(s>0&&s>=a)a==0?(e.push(n,...t),t.length=0,n=o):t.push(o),s=a;else{let c=BN(n,o);c>=0?n=c:s==0&&a==0?(e.push(n),n=o):(t.push(o),s=a)}}return n>=0&&e.push(n,...t),e}function Qb(i){return Ob(i).map(Pb)}function RN(i){return TN(Ob(i))}const Gb=45,Hb=".",zb=65039,Vb=1,Hl=i=>Array.from(i);function Ho(i,e){return i.P.has(e)||i.Q.has(e)}class NN extends Array{get is_emoji(){return!0}}let wf,Wb,xr,Cf,qb,Ta,vf,Ra,Er,Kb,Sf;function If(){if(wf)return;let i=Bb(hN);const e=()=>Uo(i),t=()=>new Set(e()),n=(h,u)=>u.forEach(d=>h.add(d));wf=new Map(Rb(i)),Wb=t(),xr=e(),Cf=new Set(e().map(h=>xr[h])),xr=new Set(xr),qb=t(),t();let s=Tb(i),r=i();const a=()=>{let h=new Set;return e().forEach(u=>n(h,s[u])),n(h,e()),h};Ta=Oo(h=>{let u=Oo(i).map(d=>d+96);if(u.length){let d=h>=r;u[0]-=32,u=Ma(u),d&&(u=`Restricted[${u}]`);let f=a(),m=a(),g=!i();return{N:u,P:f,Q:m,M:g,R:d}}}),vf=t(),Ra=new Map;let o=e().concat(Hl(vf)).sort((h,u)=>h-u);o.forEach((h,u)=>{let d=i(),f=o[u]=d?o[u-d]:{V:[],M:new Map};f.V.push(h),vf.has(h)||Ra.set(h,f)});for(let{V:h,M:u}of new Set(Ra.values())){let d=[];for(let m of h){let g=Ta.filter(p=>Ho(p,m)),A=d.find(({G:p})=>g.some(y=>p.has(y)));A||(A={G:new Set,V:[]},d.push(A)),A.V.push(m),n(A.G,g)}let f=d.flatMap(m=>Hl(m.G));for(let{G:m,V:g}of d){let A=new Set(f.filter(p=>!m.has(p)));for(let p of g)u.set(p,A)}}Er=new Set;let c=new Set;const l=h=>Er.has(h)?c.add(h):Er.add(h);for(let h of Ta){for(let u of h.P)l(u);for(let u of h.Q)l(u)}for(let h of Er)!Ra.has(h)&&!c.has(h)&&Ra.set(h,Vb);n(Er,Qb(Er)),Kb=bN(i).map(h=>NN.from(h)).sort(_N),Sf=new Map;for(let h of Kb){let u=[Sf];for(let d of h){let f=u.map(m=>{let g=m.get(d);return g||(g=new Map,m.set(d,g)),g});d===zb?u.push(...f):u=f}for(let d of u)d.V=h}}function Mf(i){return(Xb(i)?"":`${Bf(zl([i]))} `)+Fb(i)}function Bf(i){return`"${i}"`}function FN(i){if(i.length>=4&&i[2]==Gb&&i[3]==Gb)throw new Error(`invalid label extension: "${Ma(i.slice(0,4))}"`)}function DN(i){for(let t=i.lastIndexOf(95);t>0;)if(i[--t]!==95)throw new Error("underscore allowed only at start")}function LN(i){let e=i[0],t=Ib.get(e);if(t)throw zo(`leading ${t}`);let n=i.length,s=-1;for(let r=1;r<n;r++){e=i[r];let a=Ib.get(e);if(a){if(s==r)throw zo(`${t} + ${a}`);s=r+1,t=a}}if(s==n)throw zo(`trailing ${t}`)}function zl(i,e=1/0,t=Fb){let n=[];PN(i[0])&&n.push("◌"),i.length>e&&(e>>=1,i=[...i.slice(0,e),8230,...i.slice(-e)]);let s=0,r=i.length;for(let a=0;a<r;a++){let o=i[a];Xb(o)&&(n.push(Ma(i.slice(s,a))),n.push(t(o)),s=a+1)}return n.push(Ma(i.slice(s,r))),n.join("")}function PN(i){return If(),xr.has(i)}function Xb(i){return If(),qb.has(i)}function kN(i){return GN(UN(i,RN,VN))}function UN(i,e,t){if(!i)return[];If();let n=0;return i.split(Hb).map(s=>{let r=EN(s),a={input:r,offset:n};n+=r.length+1;try{let o=a.tokens=zN(r,e,t),c=o.length,l;if(!c)throw new Error("empty label");let h=a.output=o.flat();if(DN(h),!(a.emoji=c>1||o[0].is_emoji)&&h.every(d=>d<128))FN(h),l="ASCII";else{let d=o.flatMap(f=>f.is_emoji?[]:f);if(!d.length)l="Emoji";else{if(xr.has(h[0]))throw zo("leading combining mark");for(let g=1;g<c;g++){let A=o[g];if(!A.is_emoji&&xr.has(A[0]))throw zo(`emoji + combining mark: "${Ma(o[g-1])} + ${zl([A[0]])}"`)}LN(h);let f=Hl(new Set(d)),[m]=QN(f);HN(m,d),ON(m,f),l=m.N}}a.type=l}catch(o){a.error=o}return a})}function ON(i,e){let t,n=[];for(let s of e){let r=Ra.get(s);if(r===Vb)return;if(r){let a=r.M.get(s);if(t=t?t.filter(o=>a.has(o)):Hl(a),!t.length)return}else n.push(s)}if(t){for(let s of t)if(n.every(r=>Ho(s,r)))throw new Error(`whole-script confusable: ${i.N}/${s.N}`)}}function QN(i){let e=Ta;for(let t of i){let n=e.filter(s=>Ho(s,t));if(!n.length)throw Ta.some(s=>Ho(s,t))?jb(e[0],t):Yb(t);if(e=n,n.length==1)break}return e}function GN(i){return i.map(({input:e,error:t,output:n})=>{if(t){let s=t.message;throw new Error(i.length==1?s:`Invalid label ${Bf(zl(e,63))}: ${s}`)}return Ma(n)}).join(Hb)}function Yb(i){return new Error(`disallowed character: ${Mf(i)}`)}function jb(i,e){let t=Mf(e),n=Ta.find(s=>s.P.has(e));return n&&(t=`${n.N} ${t}`),new Error(`illegal mixture: ${i.N} + ${t}`)}function zo(i){return new Error(`illegal placement: ${i}`)}function HN(i,e){for(let t of e)if(!Ho(i,t))throw jb(i,t);if(i.M){let t=Qb(e);for(let n=1,s=t.length;n<s;n++)if(Cf.has(t[n])){let r=n+1;for(let a;r<s&&Cf.has(a=t[r]);r++)for(let o=n;o<r;o++)if(t[o]==a)throw new Error(`duplicate non-spacing marks: ${Mf(a)}`);if(r-n>Mb)throw new Error(`excessive non-spacing marks: ${Bf(zl(t.slice(n-1,r)))} (${r-n}/${Mb})`);n=r}}}function zN(i,e,t){let n=[],s=[];for(i=i.slice().reverse();i.length;){let r=WN(i);if(r)s.length&&(n.push(e(s)),s=[]),n.push(t(r));else{let a=i.pop();if(Er.has(a))s.push(a);else{let o=wf.get(a);if(o)s.push(...o);else if(!Wb.has(a))throw Yb(a)}}}return s.length&&n.push(e(s)),n}function VN(i){return i.filter(e=>e!=zb)}function WN(i,e){let t=Sf,n,s=i.length;for(;s&&(t=t.get(i[--s]),!!t);){let{V:r}=t;r&&(n=r,i.length=s)}return n}const Jb=new Uint8Array(32);Jb.fill(0);function Zb(i){return V(i.length!==0,"invalid ENS name; empty component","comp",i),i}function $b(i){const e=ns(qN(i)),t=[];if(i.length===0)return t;let n=0;for(let s=0;s<e.length;s++)e[s]===46&&(t.push(Zb(e.slice(n,s))),n=s+1);return V(n<e.length,"invalid ENS name; empty component","name",i),t.push(Zb(e.slice(n))),t}function qN(i){try{if(i.length===0)throw new Error("empty label");return kN(i)}catch(e){V(!1,`invalid ENS name (${e.message})`,"name",i)}}function Tf(i){V(typeof i=="string","invalid ENS name; not a string","name",i),V(i.length,"invalid ENS name (empty label)","name",i);let e=Jb;const t=$b(i);for(;t.length;)e=$t(Ut([e,$t(t.pop())]));return ve(e)}function KN(i,e){const t=e;return V(t<=255,"DNS encoded label cannot exceed 255","length",t),ve(Ut($b(i).map(n=>{V(n.length<=t,`label ${JSON.stringify(i)} exceeds ${t} bytes`,"name",i);const s=new Uint8Array(n.length+1);return s.set(n,1),s[0]=s.length-1,s})))+"00"}const ex=new Uint8Array(32);ex.fill(0);const XN=BigInt(-1),tx=BigInt(0),nx=BigInt(1),YN=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function jN(i){const e=lt(i),t=e.length%32;return t?Ut([e,ex.slice(t)]):ve(e)}const JN=ks(nx,32),ZN=ks(tx,32),ix={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Rf=["name","version","chainId","verifyingContract","salt"];function sx(i){return function(e){return V(typeof e=="string",`invalid domain value for ${JSON.stringify(i)}`,`domain.${i}`,e),e}}const $N={name:sx("name"),version:sx("version"),chainId:function(i){const e=Re(i,"domain.chainId");return V(e>=0,"invalid chain ID","domain.chainId",i),Number.isSafeInteger(e)?Number(e):_i(e)},verifyingContract:function(i){try{return vt(i).toLowerCase()}catch{}V(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",i)},salt:function(i){const e=lt(i,"domain.salt");return V(e.length===32,'invalid domain value "salt"',"domain.salt",i),ve(e)}};function Nf(i){{const e=i.match(/^(u?)int(\d+)$/);if(e){const t=e[1]==="",n=parseInt(e[2]);V(n%8===0&&n!==0&&n<=256&&e[2]===String(n),"invalid numeric width","type",i);const s=To(YN,t?n-1:n),r=t?(s+nx)*XN:tx;return function(a){const o=Re(a,"value");return V(o>=r&&o<=s,`value out-of-bounds for ${i}`,"value",o),ks(t?l0(o,256):o,32)}}}{const e=i.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return V(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",i),function(n){const s=lt(n);return V(s.length===t,`invalid length for ${i}`,"value",n),jN(n)}}}switch(i){case"address":return function(e){return ts(vt(e),32)};case"bool":return function(e){return e?JN:ZN};case"bytes":return function(e){return $t(e)};case"string":return function(e){return br(e)}}return null}function rx(i,e){return`${i}(${e.map(({name:t,type:n})=>n+" "+t).join(",")})`}function Vl(i){const e=i.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:i}}class Kn{primaryType;#e;get types(){return JSON.parse(this.#e)}#t;#n;constructor(e){this.#t=new Map,this.#n=new Map;const t=new Map,n=new Map,s=new Map,r={};Object.keys(e).forEach(c=>{r[c]=e[c].map(({name:l,type:h})=>{let{base:u,index:d}=Vl(h);return u==="int"&&!e.int&&(u="int256"),u==="uint"&&!e.uint&&(u="uint256"),{name:l,type:u+(d||"")}}),t.set(c,new Set),n.set(c,[]),s.set(c,new Set)}),this.#e=JSON.stringify(r);for(const c in r){const l=new Set;for(const h of r[c]){V(!l.has(h.name),`duplicate variable name ${JSON.stringify(h.name)} in ${JSON.stringify(c)}`,"types",e),l.add(h.name);const u=Vl(h.type).base;V(u!==c,`circular type reference to ${JSON.stringify(u)}`,"types",e),!Nf(u)&&(V(n.has(u),`unknown type ${JSON.stringify(u)}`,"types",e),n.get(u).push(c),t.get(c).add(u))}}const a=Array.from(n.keys()).filter(c=>n.get(c).length===0);V(a.length!==0,"missing primary type","types",e),V(a.length===1,`ambiguous primary types or unused types: ${a.map(c=>JSON.stringify(c)).join(", ")}`,"types",e),Ye(this,{primaryType:a[0]});function o(c,l){V(!l.has(c),`circular type reference to ${JSON.stringify(c)}`,"types",e),l.add(c);for(const h of t.get(c))if(n.has(h)){o(h,l);for(const u of l)s.get(u).add(h)}l.delete(c)}o(this.primaryType,new Set);for(const[c,l]of s){const h=Array.from(l);h.sort(),this.#t.set(c,rx(c,r[c])+h.map(u=>rx(u,r[u])).join(""))}}getEncoder(e){let t=this.#n.get(e);return t||(t=this.#i(e),this.#n.set(e,t)),t}#i(e){{const s=Nf(e);if(s)return s}const t=Vl(e).array;if(t){const s=t.prefix,r=this.getEncoder(s);return a=>{V(t.count===-1||t.count===a.length,`array length mismatch; expected length ${t.count}`,"value",a);let o=a.map(r);return this.#t.has(s)&&(o=o.map($t)),$t(Ut(o))}}const n=this.types[e];if(n){const s=br(this.#t.get(e));return r=>{const a=n.map(({name:o,type:c})=>{const l=this.getEncoder(c)(r[o]);return this.#t.has(c)?$t(l):l});return a.unshift(s),Ut(a)}}V(!1,`unknown type: ${e}`,"type",e)}encodeType(e){const t=this.#t.get(e);return V(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return $t(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,n){if(Nf(e))return n(e,t);const s=Vl(e).array;if(s)return V(s.count===-1||s.count===t.length,`array length mismatch; expected length ${s.count}`,"value",t),t.map(a=>this._visit(s.prefix,a,n));const r=this.types[e];if(r)return r.reduce((a,{name:o,type:c})=>(a[o]=this._visit(c,t[o],n),a),{});V(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new Kn(e)}static getPrimaryType(e){return Kn.from(e).primaryType}static hashStruct(e,t,n){return Kn.from(t).hashStruct(e,n)}static hashDomain(e){const t=[];for(const n in e){if(e[n]==null)continue;const s=ix[n];V(s,`invalid typed-data domain key: ${JSON.stringify(n)}`,"domain",e),t.push({name:n,type:s})}return t.sort((n,s)=>Rf.indexOf(n.name)-Rf.indexOf(s.name)),Kn.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,n){return Ut(["0x1901",Kn.hashDomain(e),Kn.from(t).hash(n)])}static hash(e,t,n){return $t(Kn.encode(e,t,n))}static async resolveNames(e,t,n,s){e=Object.assign({},e);for(const o in e)e[o]==null&&delete e[o];const r={};e.verifyingContract&&!Ft(e.verifyingContract,20)&&(r[e.verifyingContract]="0x");const a=Kn.from(t);a.visit(n,(o,c)=>(o==="address"&&!Ft(c,20)&&(r[c]="0x"),c));for(const o in r)r[o]=await s(o);return e.verifyingContract&&r[e.verifyingContract]&&(e.verifyingContract=r[e.verifyingContract]),n=a.visit(n,(o,c)=>o==="address"&&r[c]?r[c]:c),{domain:e,value:n}}static getPayload(e,t,n){Kn.hashDomain(e);const s={},r=[];Rf.forEach(c=>{const l=e[c];l!=null&&(s[c]=$N[c](l),r.push({name:c,type:ix[c]}))});const a=Kn.from(t);t=a.types;const o=Object.assign({},t);return V(o.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),o.EIP712Domain=r,a.encode(n),{types:o,domain:s,primaryType:a.primaryType,message:a.visit(n,(c,l)=>{if(c.match(/^bytes(\d*)/))return ve(lt(l));if(c.match(/^u?int/))return Re(l).toString();switch(c){case"address":return l.toLowerCase();case"bool":return!!l;case"string":return V(typeof l=="string","invalid string","value",l),l}V(!1,"unsupported type","type",c)})}}}function kn(i){const e=new Set;return i.forEach(t=>e.add(t)),Object.freeze(e)}const eF=kn("external public payable override".split(" ")),ax="constant external internal payable private public pure view override",tF=kn(ax.split(" ")),ox="constructor error event fallback function receive struct",cx=kn(ox.split(" ")),lx="calldata memory storage payable indexed",nF=kn(lx.split(" ")),iF=[ox,lx,"tuple returns",ax].join(" "),sF=kn(iF.split(" ")),rF={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},aF=new RegExp("^(\\s*)"),oF=new RegExp("^([0-9]+)"),cF=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),hx=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),ux=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");class ri{#e;#t;get offset(){return this.#e}get length(){return this.#t.length-this.#e}constructor(e){this.#e=0,this.#t=e.slice()}clone(){return new ri(this.#t)}reset(){this.#e=0}#n(e=0,t=0){return new ri(this.#t.slice(e,t).map(n=>Object.freeze(Object.assign({},n,{match:n.match-e,linkBack:n.linkBack-e,linkNext:n.linkNext-e}))))}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=this.#n(this.#e+1,e.match+1);return this.#e=e.match+1,t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;this.#e<e.match-1;){const n=this.peek().linkNext;t.push(this.#n(this.#e+1,n)),this.#e=n}return this.#e=e.match+1,t}peek(){if(this.#e>=this.#t.length)throw new Error("out-of-bounds");return this.#t[this.#e]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return this.#e++,e}toString(){const e=[];for(let t=this.#e;t<this.#t.length;t++){const n=this.#t[t];e.push(`${n.type}:${n.text}`)}return`<TokenString ${e.join(" ")}>`}}function Vs(i){const e=[],t=a=>{const o=r<i.length?JSON.stringify(i[r]):"$EOI";throw new Error(`invalid token ${o} at ${r}: ${a}`)};let n=[],s=[],r=0;for(;r<i.length;){let a=i.substring(r),o=a.match(aF);o&&(r+=o[1].length,a=i.substring(r));const c={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:r,value:-1};e.push(c);let l=rF[a[0]]||"";if(l){if(c.type=l,c.text=a[0],r++,l==="OPEN_PAREN")n.push(e.length-1),s.push(e.length-1);else if(l=="CLOSE_PAREN")n.length===0&&t("no matching open bracket"),c.match=n.pop(),e[c.match].match=e.length-1,c.depth--,c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1;else if(l==="COMMA")c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(l==="OPEN_BRACKET")c.type="BRACKET";else if(l==="CLOSE_BRACKET"){let h=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const u=e.pop().text;h=u+h,e[e.length-1].value=ht(u)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=h}continue}if(o=a.match(cF),o){if(c.text=o[1],r+=c.text.length,sF.has(c.text)){c.type="KEYWORD";continue}if(c.text.match(ux)){c.type="TYPE";continue}c.type="ID";continue}if(o=a.match(oF),o){c.text=o[1],c.type="NUMBER",r+=c.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(a[0])} at position ${r}`)}return new ri(e.map(a=>Object.freeze(a)))}function dx(i,e){let t=[];for(const n in e.keys())i.has(n)&&t.push(n);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function Wl(i,e){if(e.peekKeyword(cx)){const t=e.pop().text;if(t!==i)throw new Error(`expected ${i}, got ${t}`)}return e.popType("ID")}function ls(i,e){const t=new Set;for(;;){const n=i.peekType("KEYWORD");if(n==null||e&&!e.has(n))break;if(i.pop(),t.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);t.add(n)}return Object.freeze(t)}function fx(i){let e=ls(i,tF);return dx(e,kn("constant payable nonpayable".split(" "))),dx(e,kn("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function hs(i,e){return i.popParams().map(t=>Dt.from(t,e))}function px(i){if(i.peekType("AT")){if(i.pop(),i.peekType("NUMBER"))return Re(i.pop().text);throw new Error("invalid gas")}return null}function _r(i){if(i.length)throw new Error(`unexpected tokens at offset ${i.offset}: ${i.toString()}`)}const lF=new RegExp(/^(.*)\[([0-9]*)\]$/);function Ax(i){const e=i.match(ux);if(V(e,"invalid type","type",i),i==="uint")return"uint256";if(i==="int")return"int256";if(e[2]){const t=parseInt(e[2]);V(t!==0&&t<=32,"invalid bytes length","type",i)}else if(e[3]){const t=parseInt(e[3]);V(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",i)}return i}const Ht={},Hn=Symbol.for("_ethers_internal"),gx="_ParamTypeInternal",mx="_ErrorInternal",bx="_EventInternal",xx="_ConstructorInternal",Ex="_FallbackInternal",_x="_FunctionInternal",yx="_StructInternal";class Dt{name;type;baseType;indexed;components;arrayLength;arrayChildren;constructor(e,t,n,s,r,a,o,c){if(_l(e,Ht,"ParamType"),Object.defineProperty(this,Hn,{value:gx}),a&&(a=Object.freeze(a.slice())),s==="array"){if(o==null||c==null)throw new Error("")}else if(o!=null||c!=null)throw new Error("");if(s==="tuple"){if(a==null)throw new Error("")}else if(a!=null)throw new Error("");Ye(this,{name:t,type:n,baseType:s,indexed:r,components:a,arrayLength:o,arrayChildren:c})}format(e){if(e==null&&(e="sighash"),e==="json"){const n=this.name||"";if(this.isArray()){const r=JSON.parse(this.arrayChildren.format("json"));return r.name=n,r.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(r)}const s={type:this.baseType==="tuple"?"tuple":this.type,name:n};return typeof this.indexed=="boolean"&&(s.indexed=this.indexed),this.isTuple()&&(s.components=this.components.map(r=>JSON.parse(r.format(e)))),JSON.stringify(s)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(n=>n.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return e.map(s=>n.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const n=this;return e.map((s,r)=>n.components[r].walk(s,t))}return t(this.type,e)}#e(e,t,n,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const a=this.arrayChildren,o=t.slice();o.forEach((c,l)=>{a.#e(e,c,n,h=>{o[l]=h})}),s(o);return}if(this.isTuple()){const a=this.components;let o;if(Array.isArray(t))o=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");o=a.map(c=>{if(!c.name)throw new Error("cannot use object value with unnamed components");if(!(c.name in t))throw new Error(`missing value for component ${c.name}`);return t[c.name]})}if(o.length!==this.components.length)throw new Error("array is wrong length");o.forEach((c,l)=>{a[l].#e(e,c,n,h=>{o[l]=h})}),s(o);return}const r=n(this.type,t);r.then?e.push((async function(){s(await r)})()):s(r)}async walkAsync(e,t){const n=[],s=[e];return this.#e(n,e,t,r=>{s[0]=r}),n.length&&await Promise.all(n),s[0]}static from(e,t){if(Dt.isParamType(e))return e;if(typeof e=="string")try{return Dt.from(Vs(e),t)}catch{V(!1,"invalid param type","obj",e)}else if(e instanceof ri){let o="",c="",l=null;ls(e,kn(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(c="tuple",l=e.popParams().map(g=>Dt.from(g)),o=`tuple(${l.map(g=>g.format()).join(",")})`):(o=Ax(e.popType("TYPE")),c=o);let h=null,u=null;for(;e.length&&e.peekType("BRACKET");){const g=e.pop();h=new Dt(Ht,"",o,c,null,l,u,h),u=g.value,o+=g.text,c="array",l=null}let d=null;if(ls(e,nF).has("indexed")){if(!t)throw new Error("");d=!0}const m=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new Dt(Ht,m,o,c,d,l,u,h)}const n=e.name;V(!n||typeof n=="string"&&n.match(hx),"invalid name","obj.name",n);let s=e.indexed;s!=null&&(V(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let r=e.type,a=r.match(lF);if(a){const o=parseInt(a[2]||"-1"),c=Dt.from({type:a[1],components:e.components});return new Dt(Ht,n||"",r,"array",s,null,o,c)}if(r==="tuple"||r.startsWith("tuple(")||r.startsWith("(")){const o=e.components!=null?e.components.map(l=>Dt.from(l)):null;return new Dt(Ht,n||"",r,"tuple",s,o,null,null)}return r=Ax(e.type),new Dt(Ht,n||"",r,r,s,null,null,null)}static isParamType(e){return e&&e[Hn]===gx}}class yr{type;inputs;constructor(e,t,n){_l(e,Ht,"Fragment"),n=Object.freeze(n.slice()),Ye(this,{type:t,inputs:n})}static from(e){if(typeof e=="string"){try{yr.from(JSON.parse(e))}catch{}return yr.from(Vs(e))}if(e instanceof ri)switch(e.peekKeyword(cx)){case"constructor":return us.from(e);case"error":return zn.from(e);case"event":return ki.from(e);case"fallback":case"receive":return ds.from(e);case"function":return Ui.from(e);case"struct":return wr.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return us.from(e);case"error":return zn.from(e);case"event":return ki.from(e);case"fallback":case"receive":return ds.from(e);case"function":return Ui.from(e);case"struct":return wr.from(e)}pe(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}V(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return us.isFragment(e)}static isError(e){return zn.isFragment(e)}static isEvent(e){return ki.isFragment(e)}static isFunction(e){return Ui.isFragment(e)}static isStruct(e){return wr.isFragment(e)}}class ql extends yr{name;constructor(e,t,n,s){super(e,t,s),V(typeof n=="string"&&n.match(hx),"invalid identifier","name",n),s=Object.freeze(s.slice()),Ye(this,{name:n})}}function Vo(i,e){return"("+e.map(t=>t.format(i)).join(i==="full"?", ":",")+")"}class zn extends ql{constructor(e,t,n){super(e,"error",t,n),Object.defineProperty(this,Hn,{value:mx})}get selector(){return br(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+Vo(e,this.inputs)),t.join(" ")}static from(e){if(zn.isFragment(e))return e;if(typeof e=="string")return zn.from(Vs(e));if(e instanceof ri){const t=Wl("error",e),n=hs(e);return _r(e),new zn(Ht,t,n)}return new zn(Ht,e.name,e.inputs?e.inputs.map(Dt.from):[])}static isFragment(e){return e&&e[Hn]===mx}}class ki extends ql{anonymous;constructor(e,t,n,s){super(e,"event",t,n),Object.defineProperty(this,Hn,{value:bx}),Ye(this,{anonymous:s})}get topicHash(){return br(this.format("sighash"))}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});const t=[];return e!=="sighash"&&t.push("event"),t.push(this.name+Vo(e,this.inputs)),e!=="sighash"&&this.anonymous&&t.push("anonymous"),t.join(" ")}static getTopicHash(e,t){return t=(t||[]).map(s=>Dt.from(s)),new ki(Ht,e,t,!1).topicHash}static from(e){if(ki.isFragment(e))return e;if(typeof e=="string")try{return ki.from(Vs(e))}catch{V(!1,"invalid event fragment","obj",e)}else if(e instanceof ri){const t=Wl("event",e),n=hs(e,!0),s=!!ls(e,kn(["anonymous"])).has("anonymous");return _r(e),new ki(Ht,t,n,s)}return new ki(Ht,e.name,e.inputs?e.inputs.map(t=>Dt.from(t,!0)):[],!!e.anonymous)}static isFragment(e){return e&&e[Hn]===bx}}class us extends yr{payable;gas;constructor(e,t,n,s,r){super(e,t,n),Object.defineProperty(this,Hn,{value:xx}),Ye(this,{payable:s,gas:r})}format(e){if(pe(e!=null&&e!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),e==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(e)))});const t=[`constructor${Vo(e,this.inputs)}`];return this.payable&&t.push("payable"),this.gas!=null&&t.push(`@${this.gas.toString()}`),t.join(" ")}static from(e){if(us.isFragment(e))return e;if(typeof e=="string")try{return us.from(Vs(e))}catch{V(!1,"invalid constuctor fragment","obj",e)}else if(e instanceof ri){ls(e,kn(["constructor"]));const t=hs(e),n=!!ls(e,eF).has("payable"),s=px(e);return _r(e),new us(Ht,"constructor",t,n,s)}return new us(Ht,"constructor",e.inputs?e.inputs.map(Dt.from):[],!!e.payable,e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[Hn]===xx}}class ds extends yr{payable;constructor(e,t,n){super(e,"fallback",t),Object.defineProperty(this,Hn,{value:Ex}),Ye(this,{payable:n})}format(e){const t=this.inputs.length===0?"receive":"fallback";if(e==="json"){const n=this.payable?"payable":"nonpayable";return JSON.stringify({type:t,stateMutability:n})}return`${t}()${this.payable?" payable":""}`}static from(e){if(ds.isFragment(e))return e;if(typeof e=="string")try{return ds.from(Vs(e))}catch{V(!1,"invalid fallback fragment","obj",e)}else if(e instanceof ri){const t=e.toString(),n=e.peekKeyword(kn(["fallback","receive"]));if(V(n,"type must be fallback or receive","obj",t),e.popKeyword(kn(["fallback","receive"]))==="receive"){const o=hs(e);return V(o.length===0,"receive cannot have arguments","obj.inputs",o),ls(e,kn(["payable"])),_r(e),new ds(Ht,[],!0)}let r=hs(e);r.length?V(r.length===1&&r[0].type==="bytes","invalid fallback inputs","obj.inputs",r.map(o=>o.format("minimal")).join(", ")):r=[Dt.from("bytes")];const a=fx(e);if(V(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),ls(e,kn(["returns"])).has("returns")){const o=hs(e);V(o.length===1&&o[0].type==="bytes","invalid fallback outputs","obj.outputs",o.map(c=>c.format("minimal")).join(", "))}return _r(e),new ds(Ht,r,a==="payable")}if(e.type==="receive")return new ds(Ht,[],!0);if(e.type==="fallback"){const t=[Dt.from("bytes")],n=e.stateMutability==="payable";return new ds(Ht,t,n)}V(!1,"invalid fallback description","obj",e)}static isFragment(e){return e&&e[Hn]===Ex}}class Ui extends ql{constant;outputs;stateMutability;payable;gas;constructor(e,t,n,s,r,a){super(e,"function",t,s),Object.defineProperty(this,Hn,{value:_x}),r=Object.freeze(r.slice()),Ye(this,{constant:n==="view"||n==="pure",gas:a,outputs:r,payable:n==="payable",stateMutability:n})}get selector(){return br(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(n=>JSON.parse(n.format(e))),outputs:this.outputs.map(n=>JSON.parse(n.format(e)))});const t=[];return e!=="sighash"&&t.push("function"),t.push(this.name+Vo(e,this.inputs)),e!=="sighash"&&(this.stateMutability!=="nonpayable"&&t.push(this.stateMutability),this.outputs&&this.outputs.length&&(t.push("returns"),t.push(Vo(e,this.outputs))),this.gas!=null&&t.push(`@${this.gas.toString()}`)),t.join(" ")}static getSelector(e,t){return t=(t||[]).map(s=>Dt.from(s)),new Ui(Ht,e,"view",t,[],null).selector}static from(e){if(Ui.isFragment(e))return e;if(typeof e=="string")try{return Ui.from(Vs(e))}catch{V(!1,"invalid function fragment","obj",e)}else if(e instanceof ri){const n=Wl("function",e),s=hs(e),r=fx(e);let a=[];ls(e,kn(["returns"])).has("returns")&&(a=hs(e));const o=px(e);return _r(e),new Ui(Ht,n,r,s,a,o)}let t=e.stateMutability;return t==null&&(t="payable",typeof e.constant=="boolean"?(t="view",e.constant||(t="payable",typeof e.payable=="boolean"&&!e.payable&&(t="nonpayable"))):typeof e.payable=="boolean"&&!e.payable&&(t="nonpayable")),new Ui(Ht,e.name,t,e.inputs?e.inputs.map(Dt.from):[],e.outputs?e.outputs.map(Dt.from):[],e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[Hn]===_x}}class wr extends ql{constructor(e,t,n){super(e,"struct",t,n),Object.defineProperty(this,Hn,{value:yx})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return wr.from(Vs(e))}catch{V(!1,"invalid struct fragment","obj",e)}else if(e instanceof ri){const t=Wl("struct",e),n=hs(e);return _r(e),new wr(Ht,t,n)}return new wr(Ht,e.name,e.inputs?e.inputs.map(Dt.from):[])}static isFragment(e){return e&&e[Hn]===yx}}const Ci=new Map;Ci.set(0,"GENERIC_PANIC"),Ci.set(1,"ASSERT_FALSE"),Ci.set(17,"OVERFLOW"),Ci.set(18,"DIVIDE_BY_ZERO"),Ci.set(33,"ENUM_RANGE_ERROR"),Ci.set(34,"BAD_STORAGE_DATA"),Ci.set(49,"STACK_UNDERFLOW"),Ci.set(50,"ARRAY_RANGE_ERROR"),Ci.set(65,"OUT_OF_MEMORY"),Ci.set(81,"UNINITIALIZED_FUNCTION_CALL");const hF=new RegExp(/^bytes([0-9]*)$/),uF=new RegExp(/^(u?int)([0-9]*)$/);let Ff=null,wx=1024;function dF(i,e,t,n){let s="missing revert data",r=null;const a=null;let o=null;if(t){s="execution reverted";const l=lt(t);if(t=ve(t),l.length===0)s+=" (no data present; likely require(false) occurred",r="require(false)";else if(l.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(ve(l.slice(0,4))==="0x08c379a0")try{r=n.decode(["string"],l.slice(4))[0],o={signature:"Error(string)",name:"Error",args:[r]},s+=`: ${JSON.stringify(r)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(ve(l.slice(0,4))==="0x4e487b71")try{const h=Number(n.decode(["uint256"],l.slice(4))[0]);o={signature:"Panic(uint256)",name:"Panic",args:[h]},r=`Panic due to ${Ci.get(h)||"UNKNOWN"}(${h})`,s+=`: ${r}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const c={to:e.to?vt(e.to):null,data:e.data||"0x"};return e.from&&(c.from=vt(e.from)),Qt(s,"CALL_EXCEPTION",{action:i,data:t,reason:r,transaction:c,invocation:a,revert:o})}class Na{#e(e){if(e.isArray())return new RR(this.#e(e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new Nl(e.components.map(n=>this.#e(n)),e.name);switch(e.baseType){case"address":return new BR(e.name);case"bool":return new NR(e.name);case"string":return new GR(e.name);case"bytes":return new FR(e.name);case"":return new PR(e.name)}let t=e.type.match(uF);if(t){let n=parseInt(t[2]||"256");return V(n!==0&&n<=256&&n%8===0,"invalid "+t[1]+" bit length","param",e),new QR(n/8,t[1]==="int",e.name)}if(t=e.type.match(hF),t){let n=parseInt(t[1]);return V(n!==0&&n<=32,"invalid bytes length","param",e),new DR(n,e.name)}V(!1,"invalid type","type",e.type)}getDefaultValue(e){const t=e.map(s=>this.#e(Dt.from(s)));return new Nl(t,"_").defaultValue()}encode(e,t){r0(t.length,e.length,"types/values length mismatch");const n=e.map(a=>this.#e(Dt.from(a))),s=new Nl(n,"_"),r=new Yd;return s.encode(r,t),r.data}decode(e,t,n){const s=e.map(a=>this.#e(Dt.from(a)));return new Nl(s,"_").decode(new jd(t,n,wx))}static _setDefaultMaxInflation(e){V(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),wx=e}static defaultAbiCoder(){return Ff==null&&(Ff=new Na),Ff}static getBuiltinCallException(e,t,n){return dF(e,t,n,Na.defaultAbiCoder())}}class fF{fragment;name;signature;topic;args;constructor(e,t,n){const s=e.name,r=e.format();Ye(this,{fragment:e,name:s,signature:r,topic:t,args:n})}}class pF{fragment;name;args;signature;selector;value;constructor(e,t,n,s){const r=e.name,a=e.format();Ye(this,{fragment:e,name:r,args:n,signature:a,selector:t,value:s})}}class AF{fragment;name;args;signature;selector;constructor(e,t,n){const s=e.name,r=e.format();Ye(this,{fragment:e,name:s,args:n,signature:r,selector:t})}}class Cx{hash;_isIndexed;static isIndexed(e){return!!(e&&e._isIndexed)}constructor(e){Ye(this,{hash:e,_isIndexed:!0})}}const vx={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},Sx={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:i=>`reverted with reason string ${JSON.stringify(i)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:i=>{let e="unknown panic code";return i>=0&&i<=255&&vx[i.toString()]&&(e=vx[i.toString()]),`reverted with panic code 0x${i.toString(16)} (${e})`}}};class Cr{fragments;deploy;fallback;receive;#e;#t;#n;#i;constructor(e){let t=[];typeof e=="string"?t=JSON.parse(e):t=e,this.#n=new Map,this.#e=new Map,this.#t=new Map;const n=[];for(const a of t)try{n.push(yr.from(a))}catch(o){console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`,o.message)}Ye(this,{fragments:Object.freeze(n)});let s=null,r=!1;this.#i=this.getAbiCoder(),this.fragments.forEach((a,o)=>{let c;switch(a.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}Ye(this,{deploy:a});return;case"fallback":a.inputs.length===0?r=!0:(V(!s||a.payable!==s.payable,"conflicting fallback fragments",`fragments[${o}]`,a),s=a,r=s.payable);return;case"function":c=this.#n;break;case"event":c=this.#t;break;case"error":c=this.#e;break;default:return}const l=a.format();c.has(l)||c.set(l,a)}),this.deploy||Ye(this,{deploy:us.from("constructor()")}),Ye(this,{fallback:s,receive:r})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return Na.defaultAbiCoder()}#s(e,t,n){if(Ft(e)){const r=e.toLowerCase();for(const a of this.#n.values())if(r===a.selector)return a;return null}if(e.indexOf("(")===-1){const r=[];for(const[a,o]of this.#n)a.split("(")[0]===e&&r.push(o);if(t){const a=t.length>0?t[t.length-1]:null;let o=t.length,c=!0;Wt.isTyped(a)&&a.type==="overrides"&&(c=!1,o--);for(let l=r.length-1;l>=0;l--){const h=r[l].inputs.length;h!==o&&(!c||h!==o-1)&&r.splice(l,1)}for(let l=r.length-1;l>=0;l--){const h=r[l].inputs;for(let u=0;u<t.length;u++)if(Wt.isTyped(t[u])){if(u>=h.length){if(t[u].type==="overrides")continue;r.splice(l,1);break}if(t[u].type!==h[u].baseType){r.splice(l,1);break}}}}if(r.length===1&&t&&t.length!==r[0].inputs.length){const a=t[t.length-1];(a==null||Array.isArray(a)||typeof a!="object")&&r.splice(0,1)}if(r.length===0)return null;if(r.length>1&&n){const a=r.map(o=>JSON.stringify(o.format())).join(", ");V(!1,`ambiguous function description (i.e. matches ${a})`,"key",e)}return r[0]}const s=this.#n.get(Ui.from(e).format());return s||null}getFunctionName(e){const t=this.#s(e,null,!1);return V(t,"no matching function","key",e),t.name}hasFunction(e){return!!this.#s(e,null,!1)}getFunction(e,t){return this.#s(e,t||null,!0)}forEachFunction(e){const t=Array.from(this.#n.keys());t.sort((n,s)=>n.localeCompare(s));for(let n=0;n<t.length;n++){const s=t[n];e(this.#n.get(s),n)}}#a(e,t,n){if(Ft(e)){const r=e.toLowerCase();for(const a of this.#t.values())if(r===a.topicHash)return a;return null}if(e.indexOf("(")===-1){const r=[];for(const[a,o]of this.#t)a.split("(")[0]===e&&r.push(o);if(t){for(let a=r.length-1;a>=0;a--)r[a].inputs.length<t.length&&r.splice(a,1);for(let a=r.length-1;a>=0;a--){const o=r[a].inputs;for(let c=0;c<t.length;c++)if(Wt.isTyped(t[c])&&t[c].type!==o[c].baseType){r.splice(a,1);break}}}if(r.length===0)return null;if(r.length>1&&n){const a=r.map(o=>JSON.stringify(o.format())).join(", ");V(!1,`ambiguous event description (i.e. matches ${a})`,"key",e)}return r[0]}const s=this.#t.get(ki.from(e).format());return s||null}getEventName(e){const t=this.#a(e,null,!1);return V(t,"no matching event","key",e),t.name}hasEvent(e){return!!this.#a(e,null,!1)}getEvent(e,t){return this.#a(e,t||null,!0)}forEachEvent(e){const t=Array.from(this.#t.keys());t.sort((n,s)=>n.localeCompare(s));for(let n=0;n<t.length;n++){const s=t[n];e(this.#t.get(s),n)}}getError(e,t){if(Ft(e)){const s=e.toLowerCase();if(Sx[s])return zn.from(Sx[s].signature);for(const r of this.#e.values())if(s===r.selector)return r;return null}if(e.indexOf("(")===-1){const s=[];for(const[r,a]of this.#e)r.split("(")[0]===e&&s.push(a);if(s.length===0)return e==="Error"?zn.from("error Error(string)"):e==="Panic"?zn.from("error Panic(uint256)"):null;if(s.length>1){const r=s.map(a=>JSON.stringify(a.format())).join(", ");V(!1,`ambiguous error description (i.e. ${r})`,"name",e)}return s[0]}if(e=zn.from(e).format(),e==="Error(string)")return zn.from("error Error(string)");if(e==="Panic(uint256)")return zn.from("error Panic(uint256)");const n=this.#e.get(e);return n||null}forEachError(e){const t=Array.from(this.#e.keys());t.sort((n,s)=>n.localeCompare(s));for(let n=0;n<t.length;n++){const s=t[n];e(this.#e.get(s),n)}}_decodeParams(e,t){return this.#i.decode(e,t)}_encodeParams(e,t){return this.#i.encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);V(n,"unknown error","fragment",e),e=n}return V(Vt(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,Vt(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const n=this.getError(e);V(n,"unknown error","fragment",e),e=n}return Ut([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);V(n,"unknown function","fragment",e),e=n}return V(Vt(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,Vt(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const n=this.getFunction(e);V(n,"unknown function","fragment",e),e=n}return Ut([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}let n="invalid length for result data";const s=Dn(t);if(s.length%32===0)try{return this.#i.decode(e.outputs,s)}catch{n="could not decode result data"}pe(!1,n,"BAD_DATA",{value:ve(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const n=lt(e,"data"),s=Na.getBuiltinCallException("call",t,n);if(s.message.startsWith("execution reverted (unknown custom error)")){const o=ve(n.slice(0,4)),c=this.getError(o);if(c)try{const l=this.#i.decode(c.inputs,n.slice(4));s.revert={name:c.name,signature:c.format(),args:l},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const a=this.parseTransaction(t);return a&&(s.invocation={method:a.name,signature:a.signature,args:a.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const n=this.getFunction(e);V(n,"unknown function","fragment",e),e=n}return ve(this.#i.encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const r=this.getEvent(e);V(r,"unknown event","eventFragment",e),e=r}pe(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const n=[];e.anonymous||n.push(e.topicHash);const s=(r,a)=>r.type==="string"?br(a):r.type==="bytes"?$t(ve(a)):(r.type==="bool"&&typeof a=="boolean"?a=a?"0x01":"0x00":r.type.match(/^u?int/)?a=ks(a):r.type.match(/^bytes/)?a=KB(a,32):r.type==="address"&&this.#i.encode(["address"],[a]),ts(ve(a),32));for(t.forEach((r,a)=>{const o=e.inputs[a];if(!o.indexed){V(r==null,"cannot filter non-indexed parameters; must be null","contract."+o.name,r);return}r==null?n.push(null):o.baseType==="array"||o.baseType==="tuple"?V(!1,"filtering with tuples or arrays not supported","contract."+o.name,r):Array.isArray(r)?n.push(r.map(c=>s(o,c))):n.push(s(o,r))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(e,t){if(typeof e=="string"){const a=this.getEvent(e);V(a,"unknown event","eventFragment",e),e=a}const n=[],s=[],r=[];return e.anonymous||n.push(e.topicHash),V(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((a,o)=>{const c=t[o];if(a.indexed)if(a.type==="string")n.push(br(c));else if(a.type==="bytes")n.push($t(c));else{if(a.baseType==="tuple"||a.baseType==="array")throw new Error("not implemented");n.push(this.#i.encode([a.type],[c]))}else s.push(a),r.push(c)}),{data:this.#i.encode(s,r),topics:n}}decodeEventLog(e,t,n){if(typeof e=="string"){const f=this.getEvent(e);V(f,"unknown event","eventFragment",e),e=f}if(n!=null&&!e.anonymous){const f=e.topicHash;V(Ft(n[0],32)&&n[0].toLowerCase()===f,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const s=[],r=[],a=[];e.inputs.forEach((f,m)=>{f.indexed?f.type==="string"||f.type==="bytes"||f.baseType==="tuple"||f.baseType==="array"?(s.push(Dt.from({type:"bytes32",name:f.name})),a.push(!0)):(s.push(f),a.push(!1)):(r.push(f),a.push(!1))});const o=n!=null?this.#i.decode(s,Ut(n)):null,c=this.#i.decode(r,t,!0),l=[],h=[];let u=0,d=0;return e.inputs.forEach((f,m)=>{let g=null;if(f.indexed)if(o==null)g=new Cx(null);else if(a[m])g=new Cx(o[d++]);else try{g=o[d++]}catch(A){g=A}else try{g=c[u++]}catch(A){g=A}l.push(g),h.push(f.name||null)}),ss.fromItems(l,h)}parseTransaction(e){const t=lt(e.data,"tx.data"),n=Re(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(ve(t.slice(0,4)));if(!s)return null;const r=this.#i.decode(s.inputs,t.slice(4));return new pF(s,s.selector,r,n)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new fF(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=ve(e),n=this.getError(Vt(t,0,4));if(!n)return null;const s=this.#i.decode(n.inputs,Vt(t,4));return new AF(n,n.selector,s)}static from(e){return e instanceof Cr?e:typeof e=="string"?new Cr(JSON.parse(e)):typeof e.formatJson=="function"?new Cr(e.formatJson()):typeof e.format=="function"?new Cr(e.format("json")):new Cr(e)}}const Ix=BigInt(0);function Fa(i){return i??null}function Yt(i){return i==null?null:i.toString()}class Mx{gasPrice;maxFeePerGas;maxPriorityFeePerGas;constructor(e,t,n){Ye(this,{gasPrice:Fa(e),maxFeePerGas:Fa(t),maxPriorityFeePerGas:Fa(n)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:n}=this;return{_type:"FeeData",gasPrice:Yt(e),maxFeePerGas:Yt(t),maxPriorityFeePerGas:Yt(n)}}}function Kl(i){const e={};i.to&&(e.to=i.to),i.from&&(e.from=i.from),i.data&&(e.data=ve(i.data));const t="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in i)||i[s]==null||(e[s]=Re(i[s],`request.${s}`));const n="type,nonce".split(/,/);for(const s of n)!(s in i)||i[s]==null||(e[s]=ht(i[s],`request.${s}`));return i.accessList&&(e.accessList=gr(i.accessList)),i.authorizationList&&(e.authorizationList=i.authorizationList.slice()),"blockTag"in i&&(e.blockTag=i.blockTag),"enableCcipRead"in i&&(e.enableCcipRead=!!i.enableCcipRead),"customData"in i&&(e.customData=i.customData),"blobVersionedHashes"in i&&i.blobVersionedHashes&&(e.blobVersionedHashes=i.blobVersionedHashes.slice()),"kzg"in i&&(e.kzg=i.kzg),"blobWrapperVersion"in i&&(e.blobWrapperVersion=i.blobWrapperVersion),"blobs"in i&&i.blobs&&(e.blobs=i.blobs.map(s=>Vd(s)?ve(s):Object.assign({},s))),e}class gF{provider;number;hash;timestamp;parentHash;parentBeaconBlockRoot;nonce;difficulty;gasLimit;gasUsed;stateRoot;receiptsRoot;blobGasUsed;excessBlobGas;miner;prevRandao;extraData;baseFeePerGas;#e;constructor(e,t){this.#e=e.transactions.map(n=>typeof n!="string"?new qo(n,t):n),Ye(this,{provider:t,hash:Fa(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:Fa(e.prevRandao),extraData:e.extraData,baseFeePerGas:Fa(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return this.#e.map(e=>typeof e=="string"?e:e.hash)}get prefetchedTransactions(){const e=this.#e.slice();return e.length===0?[]:(pe(typeof e[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),e)}toJSON(){const{baseFeePerGas:e,difficulty:t,extraData:n,gasLimit:s,gasUsed:r,hash:a,miner:o,prevRandao:c,nonce:l,number:h,parentHash:u,parentBeaconBlockRoot:d,stateRoot:f,receiptsRoot:m,timestamp:g,transactions:A}=this;return{_type:"Block",baseFeePerGas:Yt(e),difficulty:Yt(t),extraData:n,gasLimit:Yt(s),gasUsed:Yt(r),blobGasUsed:Yt(this.blobGasUsed),excessBlobGas:Yt(this.excessBlobGas),hash:a,miner:o,prevRandao:c,nonce:l,number:h,parentHash:u,timestamp:g,parentBeaconBlockRoot:d,stateRoot:f,receiptsRoot:m,transactions:A}}[Symbol.iterator](){let e=0;const t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return this.#e.length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e=="number")t=this.#e[e];else{const n=e.toLowerCase();for(const s of this.#e)if(typeof s=="string"){if(s!==n)continue;t=s;break}else{if(s.hash!==n)continue;t=s;break}}if(t==null)throw new Error("no such tx");return typeof t=="string"?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){const t=this.prefetchedTransactions;if(typeof e=="number")return t[e];e=e.toLowerCase();for(const n of t)if(n.hash===e)return n;V(!1,"no matching transaction","indexOrHash",e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return mF(this)}}class Wo{provider;transactionHash;blockHash;blockNumber;removed;address;data;topics;index;transactionIndex;constructor(e,t){this.provider=t;const n=Object.freeze(e.topics.slice());Ye(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:n,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:n,data:s,index:r,removed:a,topics:o,transactionHash:c,transactionIndex:l}=this;return{_type:"log",address:e,blockHash:t,blockNumber:n,data:s,index:r,removed:a,topics:o,transactionHash:c,transactionIndex:l}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return pe(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return pe(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return pe(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return bF(this)}}class Bx{provider;to;from;contractAddress;hash;index;blockHash;blockNumber;logsBloom;gasUsed;blobGasUsed;cumulativeGasUsed;gasPrice;blobGasPrice;type;status;root;#e;constructor(e,t){this.#e=Object.freeze(e.logs.map(s=>new Wo(s,t)));let n=Ix;e.effectiveGasPrice!=null?n=e.effectiveGasPrice:e.gasPrice!=null&&(n=e.gasPrice),Ye(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:n,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return this.#e}toJSON(){const{to:e,from:t,contractAddress:n,hash:s,index:r,blockHash:a,blockNumber:o,logsBloom:c,logs:l,status:h,root:u}=this;return{_type:"TransactionReceipt",blockHash:a,blockNumber:o,contractAddress:n,cumulativeGasUsed:Yt(this.cumulativeGasUsed),from:t,gasPrice:Yt(this.gasPrice),blobGasUsed:Yt(this.blobGasUsed),blobGasPrice:Yt(this.blobGasPrice),gasUsed:Yt(this.gasUsed),hash:s,index:r,logs:l,logsBloom:c,root:u,status:h,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return Rx(this)}reorderedEvent(e){return pe(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),Tx(this,e)}}class qo{provider;blockNumber;blockHash;index;hash;type;to;from;nonce;gasLimit;gasPrice;maxPriorityFeePerGas;maxFeePerGas;maxFeePerBlobGas;data;value;chainId;signature;accessList;blobVersionedHashes;authorizationList;#e;constructor(e,t){this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.maxFeePerBlobGas=e.maxFeePerBlobGas!=null?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,this.blobVersionedHashes=e.blobVersionedHashes!=null?e.blobVersionedHashes:null,this.authorizationList=e.authorizationList!=null?e.authorizationList:null,this.#e=-1}toJSON(){const{blockNumber:e,blockHash:t,index:n,hash:s,type:r,to:a,from:o,nonce:c,data:l,signature:h,accessList:u,blobVersionedHashes:d}=this;return{_type:"TransactionResponse",accessList:u,blockNumber:e,blockHash:t,blobVersionedHashes:d,chainId:Yt(this.chainId),data:l,from:o,gasLimit:Yt(this.gasLimit),gasPrice:Yt(this.gasPrice),hash:s,maxFeePerGas:Yt(this.maxFeePerGas),maxPriorityFeePerGas:Yt(this.maxPriorityFeePerGas),maxFeePerBlobGas:Yt(this.maxFeePerBlobGas),nonce:c,signature:h,to:a,index:n,type:r,value:Yt(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const n=await this.getTransaction();n&&(e=n.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:t,blockNumber:n}=await Fn({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return t==null||t.blockNumber==null?0:n-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){const n=e??1,s=t??0;let r=this.#e,a=-1,o=r===-1;const c=async()=>{if(o)return null;const{blockNumber:d,nonce:f}=await Fn({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(f<this.nonce){r=d;return}if(o)return null;const m=await this.getTransaction();if(!(m&&m.blockNumber!=null))for(a===-1&&(a=r-3,a<this.#e&&(a=this.#e));a<=d;){if(o)return null;const g=await this.provider.getBlock(a,!0);if(g==null)return;for(const A of g)if(A===this.hash)return;for(let A=0;A<g.length;A++){const p=await g.getTransaction(A);if(p.from===this.from&&p.nonce===this.nonce){if(o)return null;const y=await this.provider.getTransactionReceipt(p.hash);if(y==null||d-y.blockNumber+1<n)return;let b="replaced";p.data===this.data&&p.to===this.to&&p.value===this.value?b="repriced":p.data==="0x"&&p.from===p.to&&p.value===Ix&&(b="cancelled"),pe(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:b==="replaced"||b==="cancelled",reason:b,replacement:p.replaceableTransaction(r),hash:p.hash,receipt:y})}}a++}},l=d=>{if(d==null||d.status!==0)return d;pe(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:d.to,from:d.from,data:""},receipt:d})},h=await this.provider.getTransactionReceipt(this.hash);if(n===0)return l(h);if(h){if(n===1||await h.confirmations()>=n)return l(h)}else if(await c(),n===0)return null;return await new Promise((d,f)=>{const m=[],g=()=>{m.forEach(p=>p())};if(m.push(()=>{o=!0}),s>0){const p=setTimeout(()=>{g(),f(Qt("wait for transaction timeout","TIMEOUT"))},s);m.push(()=>{clearTimeout(p)})}const A=async p=>{if(await p.confirmations()>=n){g();try{d(l(p))}catch(y){f(y)}}};if(m.push(()=>{this.provider.off(this.hash,A)}),this.provider.on(this.hash,A),r>=0){const p=async()=>{try{await c()}catch(y){if(_n(y,"TRANSACTION_REPLACED")){g(),f(y);return}}o||this.provider.once("block",p)};m.push(()=>{this.provider.off("block",p)}),this.provider.once("block",p)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return pe(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Rx(this)}reorderedEvent(e){return pe(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),pe(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Tx(this,e)}replaceableTransaction(e){V(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new qo(this,this.provider);return t.#e=e,t}}function mF(i){return{orphan:"drop-block",hash:i.hash,number:i.number}}function Tx(i,e){return{orphan:"reorder-transaction",tx:i,other:e}}function Rx(i){return{orphan:"drop-transaction",tx:i}}function bF(i){return{orphan:"drop-log",log:{transactionHash:i.transactionHash,blockHash:i.blockHash,blockNumber:i.blockNumber,address:i.address,data:i.data,topics:Object.freeze(i.topics.slice()),index:i.index}}}class Df extends Wo{interface;fragment;args;constructor(e,t,n){super(e,e.provider);const s=t.decodeEventLog(n,e.data,e.topics);Ye(this,{args:s,fragment:n,interface:t})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Nx extends Wo{error;constructor(e,t){super(e,e.provider),Ye(this,{error:t})}}class xF extends Bx{#e;constructor(e,t,n){super(n,t),this.#e=e}get logs(){return super.logs.map(e=>{const t=e.topics.length?this.#e.getEvent(e.topics[0]):null;if(t)try{return new Df(e,this.#e,t)}catch(n){return new Nx(e,n)}return e})}}class Lf extends qo{#e;constructor(e,t,n){super(n,t),this.#e=e}async wait(e,t){const n=await super.wait(e,t);return n==null?null:new xF(this.#e,this.provider,n)}}class Fx extends f0{log;constructor(e,t,n,s){super(e,t,n),Ye(this,{log:s})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class EF extends Fx{constructor(e,t,n,s,r){super(e,t,n,new Df(r,e.interface,s));const a=e.interface.decodeEventLog(s,this.log.data,this.log.topics);Ye(this,{args:a,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Dx=BigInt(0);function Lx(i){return i&&typeof i.call=="function"}function Px(i){return i&&typeof i.estimateGas=="function"}function Xl(i){return i&&typeof i.resolveName=="function"}function kx(i){return i&&typeof i.sendTransaction=="function"}function Ux(i){if(i!=null){if(Xl(i))return i;if(i.provider)return i.provider}}class _F{#e;fragment;constructor(e,t,n){if(Ye(this,{fragment:t}),t.inputs.length<n.length)throw new Error("too many arguments");const s=vr(e.runner,"resolveName"),r=Xl(s)?s:null;this.#e=(async function(){const a=await Promise.all(t.inputs.map((o,c)=>n[c]==null?null:o.walkAsync(n[c],(h,u)=>h==="address"?Array.isArray(u)?Promise.all(u.map(d=>Pn(d,r))):Pn(u,r):u)));return e.interface.encodeFilterTopics(t,a)})()}getTopicFilter(){return this.#e}}function vr(i,e){return i==null?null:typeof i[e]=="function"?i:i.provider&&typeof i.provider[e]=="function"?i.provider:null}function Sr(i){return i==null?null:i.provider||null}async function Ox(i,e){const t=Wt.dereference(i,"overrides");V(typeof t=="object","invalid overrides parameter","overrides",i);const n=Kl(t);return V(n.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),V(n.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}async function yF(i,e,t){const n=vr(i,"resolveName"),s=Xl(n)?n:null;return await Promise.all(e.map((r,a)=>r.walkAsync(t[a],(o,c)=>(c=Wt.dereference(c,o),o==="address"?Pn(c,s):c))))}function wF(i){const e=async function(a){const o=await Ox(a,["data"]);o.to=await i.getAddress(),o.from&&(o.from=await Pn(o.from,Ux(i.runner)));const c=i.interface,l=Re(o.value||Dx,"overrides.value")===Dx,h=(o.data||"0x")==="0x";c.fallback&&!c.fallback.payable&&c.receive&&!h&&!l&&V(!1,"cannot send data to receive or send value to non-payable fallback","overrides",a),V(c.fallback||h,"cannot send data to receive-only contract","overrides.data",o.data);const u=c.receive||c.fallback&&c.fallback.payable;return V(u||l,"cannot send value to non-payable fallback","overrides.value",o.value),V(c.fallback||h,"cannot send data to receive-only contract","overrides.data",o.data),o},t=async function(a){const o=vr(i.runner,"call");pe(Lx(o),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const c=await e(a);try{return await o.call(c)}catch(l){throw zd(l)&&l.data?i.interface.makeError(l.data,c):l}},n=async function(a){const o=i.runner;pe(kx(o),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const c=await o.sendTransaction(await e(a)),l=Sr(i.runner);return new Lf(i.interface,l,c)},s=async function(a){const o=vr(i.runner,"estimateGas");return pe(Px(o),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await o.estimateGas(await e(a))},r=async a=>await n(a);return Ye(r,{_contract:i,estimateGas:s,populateTransaction:e,send:n,staticCall:t}),r}function CF(i,e){const t=function(...l){const h=i.interface.getFunction(e,l);return pe(h,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:l}}),h},n=async function(...l){const h=t(...l);let u={};if(h.inputs.length+1===l.length&&(u=await Ox(l.pop()),u.from&&(u.from=await Pn(u.from,Ux(i.runner)))),h.inputs.length!==l.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const d=await yF(i.runner,h.inputs,l);return Object.assign({},u,await Fn({to:i.getAddress(),data:i.interface.encodeFunctionData(h,d)}))},s=async function(...l){const h=await o(...l);return h.length===1?h[0]:h},r=async function(...l){const h=i.runner;pe(kx(h),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const u=await h.sendTransaction(await n(...l)),d=Sr(i.runner);return new Lf(i.interface,d,u)},a=async function(...l){const h=vr(i.runner,"estimateGas");return pe(Px(h),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await h.estimateGas(await n(...l))},o=async function(...l){const h=vr(i.runner,"call");pe(Lx(h),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const u=await n(...l);let d="0x";try{d=await h.call(u)}catch(m){throw zd(m)&&m.data?i.interface.makeError(m.data,u):m}const f=t(...l);return i.interface.decodeFunctionResult(f,d)},c=async(...l)=>t(...l).constant?await s(...l):await r(...l);return Ye(c,{name:i.interface.getFunctionName(e),_contract:i,_key:e,getFragment:t,estimateGas:a,populateTransaction:n,send:r,staticCall:s,staticCallResult:o}),Object.defineProperty(c,"fragment",{configurable:!1,enumerable:!0,get:()=>{const l=i.interface.getFunction(e);return pe(l,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),l}}),c}function vF(i,e){const t=function(...s){const r=i.interface.getEvent(e,s);return pe(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:s}}),r},n=function(...s){return new _F(i,t(...s),s)};return Ye(n,{name:i.interface.getEventName(e),_contract:i,_key:e,getFragment:t}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const s=i.interface.getEvent(e);return pe(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),s}}),n}const Yl=Symbol.for("_ethersInternal_contract"),Qx=new WeakMap;function SF(i,e){Qx.set(i[Yl],e)}function Xn(i){return Qx.get(i[Yl])}function IF(i){return i&&typeof i=="object"&&"getTopicFilter"in i&&typeof i.getTopicFilter=="function"&&i.fragment}async function Pf(i,e){let t,n=null;if(Array.isArray(e)){const r=function(a){if(Ft(a,32))return a;const o=i.interface.getEvent(a);return V(o,"unknown fragment","name",a),o.topicHash};t=e.map(a=>a==null?null:Array.isArray(a)?a.map(r):r(a))}else e==="*"?t=[null]:typeof e=="string"?Ft(e,32)?t=[e]:(n=i.interface.getEvent(e),V(n,"unknown fragment","event",e),t=[n.topicHash]):IF(e)?t=await e.getTopicFilter():"fragment"in e?(n=e.fragment,t=[n.topicHash]):V(!1,"unknown event name","event",e);t=t.map(r=>{if(r==null)return null;if(Array.isArray(r)){const a=Array.from(new Set(r.map(o=>o.toLowerCase())).values());return a.length===1?a[0]:(a.sort(),a)}return r.toLowerCase()});const s=t.map(r=>r==null?"null":Array.isArray(r)?r.join("|"):r).join("&");return{fragment:n,tag:s,topics:t}}async function Ko(i,e){const{subs:t}=Xn(i);return t.get((await Pf(i,e)).tag)||null}async function Gx(i,e,t){const n=Sr(i.runner);pe(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:r,topics:a}=await Pf(i,t),{addr:o,subs:c}=Xn(i);let l=c.get(r);if(!l){const u={address:o||i,topics:a},d=A=>{let p=s;if(p==null)try{p=i.interface.getEvent(A.topics[0])}catch{}if(p){const y=p,b=s?i.interface.decodeEventLog(s,A.data,A.topics):[];Uf(i,t,b,_=>new EF(i,_,t,y,A))}else Uf(i,t,[],y=>new Fx(i,y,t,A))};let f=[];l={tag:r,listeners:[],start:()=>{f.length||f.push(n.on(u,d))},stop:async()=>{if(f.length==0)return;let A=f;f=[],await Promise.all(A),n.off(u,d)}},c.set(r,l)}return l}let kf=Promise.resolve();async function MF(i,e,t,n){await kf;const s=await Ko(i,e);if(!s)return!1;const r=s.listeners.length;return s.listeners=s.listeners.filter(({listener:a,once:o})=>{const c=Array.from(t);n&&c.push(n(o?null:a));try{a.call(i,...c)}catch{}return!o}),s.listeners.length===0&&(s.stop(),Xn(i).subs.delete(s.tag)),r>0}async function Uf(i,e,t,n){try{await kf}catch{}const s=MF(i,e,t,n);return kf=s,await s}const jl=["then"];class Xo{target;interface;runner;filters;[Yl];fallback;constructor(e,t,n,s){V(typeof e=="string"||Eb(e),"invalid value for Contract target","target",e),n==null&&(n=null);const r=Cr.from(t);Ye(this,{target:e,runner:n,interface:r}),Object.defineProperty(this,Yl,{value:{}});let a,o=null,c=null;if(s){const u=Sr(n);c=new Lf(this.interface,u,s)}let l=new Map;if(typeof e=="string")if(Ft(e))o=e,a=Promise.resolve(e);else{const u=vr(n,"resolveName");if(!Xl(u))throw Qt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});a=u.resolveName(e).then(d=>{if(d==null)throw Qt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return Xn(this).addr=d,d})}else a=e.getAddress().then(u=>{if(u==null)throw new Error("TODO");return Xn(this).addr=u,u});SF(this,{addrPromise:a,addr:o,deployTx:c,subs:l});const h=new Proxy({},{get:(u,d,f)=>{if(typeof d=="symbol"||jl.indexOf(d)>=0)return Reflect.get(u,d,f);try{return this.getEvent(d)}catch(m){if(!_n(m,"INVALID_ARGUMENT")||m.argument!=="key")throw m}},has:(u,d)=>jl.indexOf(d)>=0?Reflect.has(u,d):Reflect.has(u,d)||this.interface.hasEvent(String(d))});return Ye(this,{filters:h}),Ye(this,{fallback:r.receive||r.fallback?wF(this):null}),new Proxy(this,{get:(u,d,f)=>{if(typeof d=="symbol"||d in u||jl.indexOf(d)>=0)return Reflect.get(u,d,f);try{return u.getFunction(d)}catch(m){if(!_n(m,"INVALID_ARGUMENT")||m.argument!=="key")throw m}},has:(u,d)=>typeof d=="symbol"||d in u||jl.indexOf(d)>=0?Reflect.has(u,d):u.interface.hasFunction(d)})}connect(e){return new Xo(this.target,this.interface,e)}attach(e){return new Xo(e,this.interface,this.runner)}async getAddress(){return await Xn(this).addrPromise}async getDeployedCode(){const e=Sr(this.runner);pe(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const n=Sr(this.runner);return pe(n!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,r)=>{const a=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);n.once("block",a)}catch(o){r(o)}};a()})}deploymentTransaction(){return Xn(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),CF(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),vF(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,n){t==null&&(t=0),n==null&&(n="latest");const{addr:s,addrPromise:r}=Xn(this),a=s||await r,{fragment:o,topics:c}=await Pf(this,e),l={address:a,topics:c,fromBlock:t,toBlock:n},h=Sr(this.runner);return pe(h,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await h.getLogs(l)).map(u=>{let d=o;if(d==null)try{d=this.interface.getEvent(u.topics[0])}catch{}if(d)try{return new Df(u,this.interface,d)}catch(f){return new Nx(u,f)}return new Wo(u,h)})}async on(e,t){const n=await Gx(this,"on",e);return n.listeners.push({listener:t,once:!1}),n.start(),this}async once(e,t){const n=await Gx(this,"once",e);return n.listeners.push({listener:t,once:!0}),n.start(),this}async emit(e,...t){return await Uf(this,e,t,null)}async listenerCount(e){if(e){const s=await Ko(this,e);return s?s.listeners.length:0}const{subs:t}=Xn(this);let n=0;for(const{listeners:s}of t.values())n+=s.length;return n}async listeners(e){if(e){const s=await Ko(this,e);return s?s.listeners.map(({listener:r})=>r):[]}const{subs:t}=Xn(this);let n=[];for(const{listeners:s}of t.values())n=n.concat(s.map(({listener:r})=>r));return n}async off(e,t){const n=await Ko(this,e);if(!n)return this;if(t){const s=n.listeners.map(({listener:r})=>r).indexOf(t);s>=0&&n.listeners.splice(s,1)}return(t==null||n.listeners.length===0)&&(n.stop(),Xn(this).subs.delete(n.tag)),this}async removeAllListeners(e){if(e){const t=await Ko(this,e);if(!t)return this;t.stop(),Xn(this).subs.delete(t.tag)}else{const{subs:t}=Xn(this);for(const{tag:n,stop:s}of t.values())s(),t.delete(n)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends Xo{constructor(s,r=null){super(s,e,r)}}return t}static from(e,t,n){return n==null&&(n=null),new this(e,t,n)}}function BF(){return Xo}class Da extends BF(){}function Of(i){return i.match(/^ipfs:\/\/ipfs\//i)?i=i.substring(12):i.match(/^ipfs:\/\//i)?i=i.substring(7):V(!1,"unsupported IPFS format","link",i),`https://gateway.ipfs.io/ipfs/${i}`}class TF{name;constructor(e){Ye(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw new Error("unsupported coin")}async decodeAddress(e,t){throw new Error("unsupported coin")}}const Hx=new RegExp("^(ipfs)://(.*)$","i"),zx=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),Hx,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];class La{provider;address;name;#e;#t;constructor(e,t,n){Ye(this,{provider:e,address:t,name:n}),this.#e=null,this.#t=new Da(t,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],e)}async supportsWildcard(){return this.#e==null&&(this.#e=(async()=>{try{return await this.#t.supportsInterface("0x9061b923")}catch(e){if(_n(e,"CALL_EXCEPTION"))return!1;throw this.#e=null,e}})()),await this.#e}async#n(e,t){t=(t||[]).slice();const n=this.#t.interface;t.unshift(Tf(this.name));let s=null;await this.supportsWildcard()&&(s=n.getFunction(e),pe(s,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[KN(this.name,255),n.encodeFunctionData(s,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const r=await this.#t[e](...t);return s?n.decodeFunctionResult(s,r)[0]:r}catch(r){if(!_n(r,"CALL_EXCEPTION"))throw r}return null}async getAddress(e){if(e==null&&(e=60),e===60)try{const r=await this.#n("addr(bytes32)");return r==null||r===ko?null:r}catch(r){if(_n(r,"CALL_EXCEPTION"))return null;throw r}if(e>=0&&e<2147483648){let r=e+2147483648;const a=await this.#n("addr(bytes32,uint)",[r]);if(Ft(a,20))return vt(a)}let t=null;for(const r of this.provider.plugins)if(r instanceof TF&&r.supportsCoinType(e)){t=r;break}if(t==null)return null;const n=await this.#n("addr(bytes32,uint)",[e]);if(n==null||n==="0x")return null;const s=await t.decodeAddress(e,n);if(s!=null)return s;pe(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${e})`,info:{coinType:e,data:n}})}async getText(e){const t=await this.#n("text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await this.#n("contenthash(bytes32)");if(e==null||e==="0x")return null;const t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const s=t[1]==="e3010170"?"ipfs":"ipns",r=parseInt(t[4],16);if(t[5].length===r*2)return`${s}://${jB("0x"+t[2])}`}const n=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(n&&n[1].length===64)return`bzz://${n[1]}`;pe(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const e=[{type:"name",value:this.name}];try{const t=await this.getText("avatar");if(t==null)return e.push({type:"!avatar",value:""}),{url:null,linkage:e};e.push({type:"avatar",value:t});for(let n=0;n<zx.length;n++){const s=t.match(zx[n]);if(s==null)continue;const r=s[1].toLowerCase();switch(r){case"https":case"data":return e.push({type:"url",value:t}),{linkage:e,url:t};case"ipfs":{const a=Of(t);return e.push({type:"ipfs",value:t}),e.push({type:"url",value:a}),{linkage:e,url:a}}case"erc721":case"erc1155":{const a=r==="erc721"?"tokenURI(uint256)":"uri(uint256)";e.push({type:r,value:t});const o=await this.getAddress();if(o==null)return e.push({type:"!owner",value:""}),{url:null,linkage:e};const c=(s[2]||"").split("/");if(c.length!==2)return e.push({type:`!${r}caip`,value:s[2]||""}),{url:null,linkage:e};const l=c[1],h=new Da(c[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(r==="erc721"){const g=await h.ownerOf(l);if(o!==g)return e.push({type:"!owner",value:g}),{url:null,linkage:e};e.push({type:"owner",value:g})}else if(r==="erc1155"){const g=await h.balanceOf(o,l);if(!g)return e.push({type:"!balance",value:"0"}),{url:null,linkage:e};e.push({type:"balance",value:g.toString()})}let u=await h[a](l);if(u==null||u==="0x")return e.push({type:"!metadata-url",value:""}),{url:null,linkage:e};e.push({type:"metadata-url-base",value:u}),r==="erc1155"&&(u=u.replace("{id}",ks(l,32).substring(2)),e.push({type:"metadata-url-expanded",value:u})),u.match(/^ipfs:/i)&&(u=Of(u)),e.push({type:"metadata-url",value:u});let d={};const f=await new Li(u).send();f.assertOk();try{d=f.bodyJson}catch{try{e.push({type:"!metadata",value:f.bodyText})}catch{const p=f.body;return p&&e.push({type:"!metadata",value:ve(p)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!d)return e.push({type:"!metadata",value:""}),{url:null,linkage:e};e.push({type:"metadata",value:JSON.stringify(d)});let m=d.image;if(typeof m!="string")return e.push({type:"!imageUrl",value:""}),{url:null,linkage:e};if(!m.match(/^(https:\/\/|data:)/i)){if(m.match(Hx)==null)return e.push({type:"!imageUrl-ipfs",value:m}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:m}),m=Of(m)}return e.push({type:"url",value:m}),{linkage:e,url:m}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){const t=await e.getNetwork(),n=t.getPlugin("org.ethers.plugins.network.Ens");return pe(n,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:t}}),n.address}static async#i(e,t){const n=await La.getEnsAddress(e);try{const r=await new Da(n,["function resolver(bytes32) view returns (address)"],e).resolver(Tf(t),{enableCcipRead:!0});return r===ko?null:r}catch(s){throw s}return null}static async fromName(e,t){let n=t;for(;;){if(n===""||n==="."||t!=="eth"&&n==="eth")return null;const s=await La.#i(e,n);if(s!=null){const r=new La(e,s,t);return n!==t&&!await r.supportsWildcard()?null:r}n=n.split(".").slice(1).join(".")}}}const Vx=BigInt(0);function mt(i,e){return(function(t){return t==null?e:i(t)})}function Yo(i,e){return(t=>{if(e&&t==null)return null;if(!Array.isArray(t))throw new Error("not an array");return t.map(n=>i(n))})}function jo(i,e){return(t=>{const n={};for(const s in i){let r=s;if(e&&s in e&&!(r in t)){for(const a of e[s])if(a in t){r=a;break}}try{const a=i[s](t[r]);a!==void 0&&(n[s]=a)}catch(a){const o=a instanceof Error?a.message:"not-an-error";pe(!1,`invalid value for value.${s} (${o})`,"BAD_DATA",{value:t})}}return n})}function RF(i){switch(i){case!0:case"true":return!0;case!1:case"false":return!1}V(!1,`invalid boolean; ${JSON.stringify(i)}`,"value",i)}function Pa(i){return V(Ft(i,!0),"invalid data","value",i),i}function yn(i){return V(Ft(i,32),"invalid hash","value",i),i}const NF=jo({address:vt,blockHash:yn,blockNumber:ht,data:Pa,index:ht,removed:mt(RF,!1),topics:Yo(yn),transactionHash:yn,transactionIndex:ht},{index:["logIndex"]});function FF(i){return NF(i)}const DF=jo({hash:mt(yn),parentHash:yn,parentBeaconBlockRoot:mt(yn,null),number:ht,timestamp:ht,nonce:mt(Pa),difficulty:Re,gasLimit:Re,gasUsed:Re,stateRoot:mt(yn,null),receiptsRoot:mt(yn,null),blobGasUsed:mt(Re,null),excessBlobGas:mt(Re,null),miner:mt(vt),prevRandao:mt(yn,null),extraData:Pa,baseFeePerGas:mt(Re)},{prevRandao:["mixHash"]});function LF(i){const e=DF(i);return e.transactions=i.transactions.map(t=>typeof t=="string"?t:Wx(t)),e}const PF=jo({transactionIndex:ht,blockNumber:ht,transactionHash:yn,address:vt,topics:Yo(yn),data:Pa,index:ht,blockHash:yn},{index:["logIndex"]});function kF(i){return PF(i)}const UF=jo({to:mt(vt,null),from:mt(vt,null),contractAddress:mt(vt,null),index:ht,root:mt(ve),gasUsed:Re,blobGasUsed:mt(Re,null),logsBloom:mt(Pa),blockHash:yn,hash:yn,logs:Yo(kF),blockNumber:ht,cumulativeGasUsed:Re,effectiveGasPrice:mt(Re),blobGasPrice:mt(Re,null),status:mt(ht),type:mt(ht,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function OF(i){return UF(i)}function Wx(i){i.to&&Re(i.to)===Vx&&(i.to="0x0000000000000000000000000000000000000000");const e=jo({hash:yn,index:mt(ht,void 0),type:t=>t==="0x"||t==null?0:ht(t),accessList:mt(gr,null),blobVersionedHashes:mt(Yo(yn,!0),null),authorizationList:mt(Yo(t=>{let n;if(t.signature)n=t.signature;else{let s=t.yParity;s==="0x1b"?s=0:s==="0x1c"&&(s=1),n=Object.assign({},t,{yParity:s})}return{address:vt(t.address),chainId:Re(t.chainId),nonce:Re(t.nonce),signature:Gt.from(n)}},!1),null),blockHash:mt(yn,null),blockNumber:mt(ht,null),transactionIndex:mt(ht,null),from:vt,gasPrice:mt(Re),maxPriorityFeePerGas:mt(Re),maxFeePerGas:mt(Re),maxFeePerBlobGas:mt(Re,null),gasLimit:Re,to:mt(vt,null),value:Re,nonce:ht,data:Pa,creates:mt(vt,null),chainId:mt(Re,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(i);if(e.to==null&&e.creates==null&&(e.creates=MR(e)),(i.type===1||i.type===2)&&i.accessList==null&&(e.accessList=[]),i.signature?e.signature=Gt.from(i.signature):e.signature=Gt.from(i),e.chainId==null){const t=e.signature.legacyChainId;t!=null&&(e.chainId=t)}return e.blockHash&&Re(e.blockHash)===Vx&&(e.blockHash=null),e}const QF="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class Jo{name;constructor(e){Ye(this,{name:e})}clone(){return new Jo(this.name)}}class Jl extends Jo{effectiveBlock;txBase;txCreate;txDataZero;txDataNonzero;txAccessListStorageKey;txAccessListAddress;constructor(e,t){e==null&&(e=0),super(`org.ethers.network.plugins.GasCost#${e||0}`);const n={effectiveBlock:e};function s(r,a){let o=(t||{})[r];o==null&&(o=a),V(typeof o=="number",`invalud value for ${r}`,"costs",t),n[r]=o}s("txBase",21e3),s("txCreate",32e3),s("txDataZero",4),s("txDataNonzero",16),s("txAccessListStorageKey",1900),s("txAccessListAddress",2400),Ye(this,n)}clone(){return new Jl(this.effectiveBlock,this)}}class Zl extends Jo{address;targetNetwork;constructor(e,t){super("org.ethers.plugins.network.Ens"),Ye(this,{address:e||QF,targetNetwork:t??1})}clone(){return new Zl(this.address,this.targetNetwork)}}class GF extends Jo{#e;#t;get url(){return this.#e}get processFunc(){return this.#t}constructor(e,t){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin"),this.#e=e,this.#t=t}clone(){return this}}const Qf=new Map;class Yn{#e;#t;#n;constructor(e,t){this.#e=e,this.#t=Re(t),this.#n=new Map}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return this.#e}set name(e){this.#e=e}get chainId(){return this.#t}set chainId(e){this.#t=Re(e,"chainId")}matches(e){if(e==null)return!1;if(typeof e=="string"){try{return this.chainId===Re(e)}catch{}return this.name===e}if(typeof e=="number"||typeof e=="bigint"){try{return this.chainId===Re(e)}catch{}return!1}if(typeof e=="object"){if(e.chainId!=null){try{return this.chainId===Re(e.chainId)}catch{}return!1}return e.name!=null?this.name===e.name:!1}return!1}get plugins(){return Array.from(this.#n.values())}attachPlugin(e){if(this.#n.get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return this.#n.set(e.name,e.clone()),this}getPlugin(e){return this.#n.get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split("#")[0]===e)}clone(){const e=new Yn(this.name,this.chainId);return this.plugins.forEach(t=>{e.attachPlugin(t.clone())}),e}computeIntrinsicGas(e){const t=this.getPlugin("org.ethers.plugins.network.GasCost")||new Jl;let n=t.txBase;if(e.to==null&&(n+=t.txCreate),e.data)for(let s=2;s<e.data.length;s+=2)e.data.substring(s,s+2)==="00"?n+=t.txDataZero:n+=t.txDataNonzero;if(e.accessList){const s=gr(e.accessList);for(const r in s)n+=t.txAccessListAddress+t.txAccessListStorageKey*s[r].storageKeys.length}return n}static from(e){if(HF(),e==null)return Yn.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=Qf.get(e);if(t)return t();if(typeof e=="bigint")return new Yn("unknown",e);V(!1,"unknown network","network",e)}if(typeof e.clone=="function")return e.clone();if(typeof e=="object"){V(typeof e.name=="string"&&typeof e.chainId=="number","invalid network object name or chainId","network",e);const t=new Yn(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new Zl(e.ensAddress,e.ensNetwork)),t}V(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const n=Qf.get(e);n&&V(!1,`conflicting network for ${JSON.stringify(n.name)}`,"nameOrChainId",e),Qf.set(e,t)}}function qx(i,e){const t=String(i);if(!t.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${i}`);const n=t.split(".");if(n.length===1&&n.push(""),n.length!==2)throw new Error(`invalid gwei value: ${i}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let s=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||s++,n[1]=s.toString()}return BigInt(n[0]+n[1])}function Kx(i){return new GF(i,async(e,t,n)=>{n.setHeader("User-Agent","ethers");let s;try{const[r,a]=await Promise.all([n.send(),e()]);s=r;const o=s.bodyJson.standard;return{gasPrice:a.gasPrice,maxFeePerGas:qx(o.maxFee,9),maxPriorityFeePerGas:qx(o.maxPriorityFee,9)}}catch(r){pe(!1,`error encountered with polygon gas station (${JSON.stringify(n.url)})`,"SERVER_ERROR",{request:n,response:s,error:r})}})}let Xx=!1;function HF(){if(Xx)return;Xx=!0;function i(e,t,n){const s=function(){const r=new Yn(e,t);return n.ensNetwork!=null&&r.attachPlugin(new Zl(null,n.ensNetwork)),r.attachPlugin(new Jl),(n.plugins||[]).forEach(a=>{r.attachPlugin(a)}),r};Yn.register(e,s),Yn.register(t,s),n.altNames&&n.altNames.forEach(r=>{Yn.register(r,s)})}i("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),i("ropsten",3,{ensNetwork:3}),i("rinkeby",4,{ensNetwork:4}),i("goerli",5,{ensNetwork:5}),i("kovan",42,{ensNetwork:42}),i("sepolia",11155111,{ensNetwork:11155111}),i("holesky",17e3,{ensNetwork:17e3}),i("classic",61,{}),i("classicKotti",6,{}),i("arbitrum",42161,{ensNetwork:1}),i("arbitrum-goerli",421613,{}),i("arbitrum-sepolia",421614,{}),i("base",8453,{ensNetwork:1}),i("base-goerli",84531,{}),i("base-sepolia",84532,{}),i("bnb",56,{ensNetwork:1}),i("bnbt",97,{}),i("filecoin",314,{}),i("filecoin-calibration",314159,{}),i("linea",59144,{ensNetwork:1}),i("linea-goerli",59140,{}),i("linea-sepolia",59141,{}),i("matic",137,{ensNetwork:1,plugins:[Kx("https://gasstation.polygon.technology/v2")]}),i("matic-amoy",80002,{}),i("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[Kx("https://gasstation-testnet.polygon.technology/v2")]}),i("optimism",10,{ensNetwork:1,plugins:[]}),i("optimism-goerli",420,{}),i("optimism-sepolia",11155420,{}),i("xdai",100,{ensNetwork:1})}function Gf(i){return JSON.parse(JSON.stringify(i))}class zF{#e;#t;#n;#i;constructor(e){this.#e=e,this.#t=null,this.#n=4e3,this.#i=-2}get pollingInterval(){return this.#n}set pollingInterval(e){this.#n=e}async#s(){try{const e=await this.#e.getBlockNumber();if(this.#i===-2){this.#i=e;return}if(e!==this.#i){for(let t=this.#i+1;t<=e;t++){if(this.#t==null)return;await this.#e.emit("block",t)}this.#i=e}}catch{}this.#t!=null&&(this.#t=this.#e._setTimeout(this.#s.bind(this),this.#n))}start(){this.#t||(this.#t=this.#e._setTimeout(this.#s.bind(this),this.#n),this.#s())}stop(){this.#t&&(this.#e._clearTimeout(this.#t),this.#t=null)}pause(e){this.stop(),e&&(this.#i=-2)}resume(){this.start()}}class Hf{#e;#t;#n;constructor(e){this.#e=e,this.#n=!1,this.#t=t=>{this._poll(t,this.#e)}}async _poll(e,t){throw new Error("sub-classes must override this")}start(){this.#n||(this.#n=!0,this.#t(-2),this.#e.on("block",this.#t))}stop(){this.#n&&(this.#n=!1,this.#e.off("block",this.#t))}pause(e){this.stop()}resume(){this.start()}}class VF extends Hf{#e;#t;constructor(e,t){super(e),this.#e=t,this.#t=-2}pause(e){e&&(this.#t=-2),super.pause(e)}async _poll(e,t){const n=await t.getBlock(this.#e);n!=null&&(this.#t===-2?this.#t=n.number:n.number>this.#t&&(t.emit(this.#e,n.number),this.#t=n.number))}}class WF extends Hf{#e;constructor(e,t){super(e),this.#e=Gf(t)}async _poll(e,t){throw new Error("@TODO")}}class qF extends Hf{#e;constructor(e,t){super(e),this.#e=t}async _poll(e,t){const n=await t.getTransactionReceipt(this.#e);n&&t.emit(this.#e,n)}}class zf{#e;#t;#n;#i;#s;constructor(e,t){this.#e=e,this.#t=Gf(t),this.#n=this.#a.bind(this),this.#i=!1,this.#s=-2}async#a(e){if(this.#s===-2)return;const t=Gf(this.#t);t.fromBlock=this.#s+1,t.toBlock=e;const n=await this.#e.getLogs(t);if(n.length===0){this.#s<e-60&&(this.#s=e-60);return}for(const s of n)this.#e.emit(this.#t,s),this.#s=s.blockNumber}start(){this.#i||(this.#i=!0,this.#s===-2&&this.#e.getBlockNumber().then(e=>{this.#s=e}),this.#e.on("block",this.#n))}stop(){this.#i&&(this.#i=!1,this.#e.off("block",this.#n))}pause(e){this.stop(),e&&(this.#s=-2)}resume(){this.start()}}const KF=BigInt(2),XF=10;function $l(i){return i&&typeof i.then=="function"}function eh(i,e){return i+":"+JSON.stringify(e,(t,n)=>{if(n==null)return"null";if(typeof n=="bigint")return`bigint:${n.toString()}`;if(typeof n=="string")return n.toLowerCase();if(typeof n=="object"&&!Array.isArray(n)){const s=Object.keys(n);return s.sort(),s.reduce((r,a)=>(r[a]=n[a],r),{})}return n})}class Yx{name;constructor(e){Ye(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function YF(i){return JSON.parse(JSON.stringify(i))}function Vf(i){return i=Array.from(new Set(i).values()),i.sort(),i}async function Wf(i,e){if(i==null)throw new Error("invalid event");if(Array.isArray(i)&&(i={topics:i}),typeof i=="string")switch(i){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:i,tag:i}}if(Ft(i,32)){const t=i.toLowerCase();return{type:"transaction",tag:eh("tx",{hash:t}),hash:t}}if(i.orphan){const t=i;return{type:"orphan",tag:eh("orphan",t),filter:YF(t)}}if(i.address||i.topics){const t=i,n={topics:(t.topics||[]).map(s=>s==null?null:Array.isArray(s)?Vf(s.map(r=>r.toLowerCase())):s.toLowerCase())};if(t.address){const s=[],r=[],a=o=>{Ft(o)?s.push(o):r.push((async()=>{s.push(await Pn(o,e))})())};Array.isArray(t.address)?t.address.forEach(a):a(t.address),r.length&&await Promise.all(r),n.address=Vf(s.map(o=>o.toLowerCase()))}return{filter:n,tag:eh("event",n),type:"event"}}V(!1,"unknown ProviderEvent","event",i)}function qf(){return new Date().getTime()}const jF={cacheTimeout:250,pollingInterval:4e3};class JF{#e;#t;#n;#i;#s;#a;#r;#o;#f;#l;#p;#A;constructor(e,t){if(this.#A=Object.assign({},jF,t||{}),e==="any")this.#a=!0,this.#s=null;else if(e){const n=Yn.from(e);this.#a=!1,this.#s=Promise.resolve(n),setTimeout(()=>{this.emit("network",n,null)},0)}else this.#a=!1,this.#s=null;this.#o=-1,this.#r=new Map,this.#e=new Map,this.#t=new Map,this.#n=null,this.#i=!1,this.#f=1,this.#l=new Map,this.#p=!1}get pollingInterval(){return this.#A.pollingInterval}get provider(){return this}get plugins(){return Array.from(this.#t.values())}attachPlugin(e){if(this.#t.get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return this.#t.set(e.name,e.connect(this)),this}getPlugin(e){return this.#t.get(e)||null}get disableCcipRead(){return this.#p}set disableCcipRead(e){this.#p=!!e}async#c(e){const t=this.#A.cacheTimeout;if(t<0)return await this._perform(e);const n=eh(e.method,e);let s=this.#r.get(n);return s||(s=this._perform(e),this.#r.set(n,s),setTimeout(()=>{this.#r.get(n)===s&&this.#r.delete(n)},t)),await s}async ccipReadFetch(e,t,n){if(this.disableCcipRead||n.length===0||e.to==null)return null;const s=e.to.toLowerCase(),r=t.toLowerCase(),a=[];for(let o=0;o<n.length;o++){const c=n[o],l=c.replace("{sender}",s).replace("{data}",r),h=new Li(l);c.indexOf("{data}")===-1&&(h.body={data:r,sender:s}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:h,index:o,urls:n});let u="unknown error",d;try{d=await h.send()}catch(f){a.push(f.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:{error:f}});continue}try{const f=d.bodyJson;if(f.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:h,result:f}),f.data;f.message&&(u=f.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:h,result:f})}catch{}pe(d.statusCode<400||d.statusCode>=500,`response not found during CCIP fetch: ${u}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:e,info:{url:c,errorMessage:u}}),a.push(u)}pe(!1,`error encountered during CCIP fetch: ${a.map(o=>JSON.stringify(o)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:e,info:{urls:n,errorMessages:a}})}_wrapBlock(e,t){return new gF(LF(e),this)}_wrapLog(e,t){return new Wo(FF(e),this)}_wrapTransactionReceipt(e,t){return new Bx(OF(e),this)}_wrapTransactionResponse(e,t){return new qo(Wx(e),this)}_detectNetwork(){pe(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(e){pe(!1,`unsupported method: ${e.method}`,"UNSUPPORTED_OPERATION",{operation:e.method,info:e})}async getBlockNumber(){const e=ht(await this.#c({method:"getBlockNumber"}),"%response");return this.#o>=0&&(this.#o=e),e}_getAddress(e){return Pn(e,this)}_getBlockTag(e){if(e==null)return"latest";switch(e){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return e}if(Ft(e))return Ft(e,32)?e:_i(e);if(typeof e=="bigint"&&(e=ht(e,"blockTag")),typeof e=="number")return e>=0?_i(e):this.#o>=0?_i(this.#o+e):this.getBlockNumber().then(t=>_i(t+e));V(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(c=>c==null?null:Array.isArray(c)?Vf(c.map(l=>l.toLowerCase())):c.toLowerCase()),n="blockHash"in e?e.blockHash:void 0,s=(c,l,h)=>{let u;switch(c.length){case 0:break;case 1:u=c[0];break;default:c.sort(),u=c}if(n&&(l!=null||h!=null))throw new Error("invalid filter");const d={};return u&&(d.address=u),t.length&&(d.topics=t),l&&(d.fromBlock=l),h&&(d.toBlock=h),n&&(d.blockHash=n),d};let r=[];if(e.address)if(Array.isArray(e.address))for(const c of e.address)r.push(this._getAddress(c));else r.push(this._getAddress(e.address));let a;"fromBlock"in e&&(a=this._getBlockTag(e.fromBlock));let o;return"toBlock"in e&&(o=this._getBlockTag(e.toBlock)),r.filter(c=>typeof c!="string").length||a!=null&&typeof a!="string"||o!=null&&typeof o!="string"?Promise.all([Promise.all(r),a,o]).then(c=>s(c[0],c[1],c[2])):s(r,a,o)}_getTransactionRequest(e){const t=Kl(e),n=[];if(["to","from"].forEach(s=>{if(t[s]==null)return;const r=Pn(t[s],this);$l(r)?n.push((async function(){t[s]=await r})()):t[s]=r}),t.blockTag!=null){const s=this._getBlockTag(t.blockTag);$l(s)?n.push((async function(){t.blockTag=await s})()):t.blockTag=s}return n.length?(async function(){return await Promise.all(n),t})():t}async getNetwork(){if(this.#s==null){const s=(async()=>{try{const r=await this._detectNetwork();return this.emit("network",r,null),r}catch(r){throw this.#s===s&&(this.#s=null),r}})();return this.#s=s,(await s).clone()}const e=this.#s,[t,n]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==n.chainId&&(this.#a?(this.emit("network",n,t),this.#s===e&&(this.#s=Promise.resolve(n))):pe(!1,`network changed: ${t.chainId} => ${n.chainId} `,"NETWORK_ERROR",{event:"changed"})),t.clone()}async getFeeData(){const e=await this.getNetwork(),t=async()=>{const{_block:s,gasPrice:r,priorityFee:a}=await Fn({_block:this.#b("latest",!1),gasPrice:(async()=>{try{const h=await this.#c({method:"getGasPrice"});return Re(h,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const h=await this.#c({method:"getPriorityFee"});return Re(h,"%response")}catch{}return null})()});let o=null,c=null;const l=this._wrapBlock(s,e);return l&&l.baseFeePerGas&&(c=a??BigInt("1000000000"),o=l.baseFeePerGas*KF+c),new Mx(r,o,c)},n=e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(n){const s=new Li(n.url),r=await n.processFunc(t,this,s);return new Mx(r.gasPrice,r.maxFeePerGas,r.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return $l(t)&&(t=await t),Re(await this.#c({method:"estimateGas",transaction:t}),"%response")}async#h(e,t,n){pe(n<XF,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const s=Kl(e);try{return ve(await this._perform({method:"call",transaction:s,blockTag:t}))}catch(r){if(!this.disableCcipRead&&zd(r)&&r.data&&n>=0&&t==="latest"&&s.to!=null&&Vt(r.data,0,4)==="0x556f1830"){const a=r.data,o=await Pn(s.to,this);let c;try{c=nD(Vt(r.data,4))}catch(u){pe(!1,u.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:s,info:{data:a}})}pe(c.sender.toLowerCase()===o.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:a,reason:"OffchainLookup",transaction:s,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:c.errorArgs}});const l=await this.ccipReadFetch(s,c.calldata,c.urls);pe(l!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:s,info:{data:r.data,errorArgs:c.errorArgs}});const h={to:o,data:Ut([c.selector,tD([l,c.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:h});try{const u=await this.#h(h,t,n+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},h),result:u}),u}catch(u){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},h),error:u}),u}}throw r}}async#u(e){const{value:t}=await Fn({network:this.getNetwork(),value:e});return t}async call(e){const{tx:t,blockTag:n}=await Fn({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await this.#u(this.#h(t,n,e.enableCcipRead?0:-1))}async#d(e,t,n){let s=this._getAddress(t),r=this._getBlockTag(n);return(typeof s!="string"||typeof r!="string")&&([s,r]=await Promise.all([s,r])),await this.#u(this.#c(Object.assign(e,{address:s,blockTag:r})))}async getBalance(e,t){return Re(await this.#d({method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return ht(await this.#d({method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return ve(await this.#d({method:"getCode"},e,t))}async getStorage(e,t,n){const s=Re(t,"position");return ve(await this.#d({method:"getStorage",position:s},e,n))}async broadcastTransaction(e){const{blockNumber:t,hash:n,network:s}=await Fn({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:e}),network:this.getNetwork()}),r=wi.from(e);if(r.hash!==n)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(r,s).replaceableTransaction(t)}async#b(e,t){if(Ft(e,32))return await this.#c({method:"getBlock",blockHash:e,includeTransactions:t});let n=this._getBlockTag(e);return typeof n!="string"&&(n=await n),await this.#c({method:"getBlock",blockTag:n,includeTransactions:t})}async getBlock(e,t){const{network:n,params:s}=await Fn({network:this.getNetwork(),params:this.#b(e,!!t)});return s==null?null:this._wrapBlock(s,n)}async getTransaction(e){const{network:t,params:n}=await Fn({network:this.getNetwork(),params:this.#c({method:"getTransaction",hash:e})});return n==null?null:this._wrapTransactionResponse(n,t)}async getTransactionReceipt(e){const{network:t,params:n}=await Fn({network:this.getNetwork(),params:this.#c({method:"getTransactionReceipt",hash:e})});if(n==null)return null;if(n.gasPrice==null&&n.effectiveGasPrice==null){const s=await this.#c({method:"getTransaction",hash:e});if(s==null)throw new Error("report this; could not find tx or effectiveGasPrice");n.effectiveGasPrice=s.gasPrice}return this._wrapTransactionReceipt(n,t)}async getTransactionResult(e){const{result:t}=await Fn({network:this.getNetwork(),result:this.#c({method:"getTransactionResult",hash:e})});return t==null?null:ve(t)}async getLogs(e){let t=this._getFilter(e);$l(t)&&(t=await t);const{network:n,params:s}=await Fn({network:this.getNetwork(),params:this.#c({method:"getLogs",filter:t})});return s.map(r=>this._wrapLog(r,n))}_getProvider(e){pe(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(e){return await La.fromName(this,e)}async getAvatar(e){const t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){const t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=vt(e);const t=Tf(e.substring(2).toLowerCase()+".addr.reverse");try{const n=await La.getEnsAddress(this),r=await new Da(n,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(r==null||r===ko)return null;const o=await new Da(r,["function name(bytes32) view returns (string)"],this).name(t);return await this.resolveName(o)!==e?null:o}catch(n){if(_n(n,"BAD_DATA")&&n.value==="0x"||_n(n,"CALL_EXCEPTION"))return null;throw n}return null}async waitForTransaction(e,t,n){const s=t??1;return s===0?this.getTransactionReceipt(e):new Promise(async(r,a)=>{let o=null;const c=(async l=>{try{const h=await this.getTransactionReceipt(e);if(h!=null&&l-h.blockNumber+1>=s){r(h),o&&(clearTimeout(o),o=null);return}}catch(h){console.log("EEE",h)}this.once("block",c)});n!=null&&(o=setTimeout(()=>{o!=null&&(o=null,this.off("block",c),a(Qt("timeout","TIMEOUT",{reason:"timeout"})))},n)),c(await this.getBlockNumber())})}async waitForBlock(e){pe(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(e){const t=this.#l.get(e);t&&(t.timer&&clearTimeout(t.timer),this.#l.delete(e))}_setTimeout(e,t){t==null&&(t=0);const n=this.#f++,s=()=>{this.#l.delete(n),e()};if(this.paused)this.#l.set(n,{timer:null,func:s,time:t});else{const r=setTimeout(s,t);this.#l.set(n,{timer:r,func:s,time:qf()})}return n}_forEachSubscriber(e){for(const t of this.#e.values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case"debug":case"error":case"network":return new Yx(e.type);case"block":{const t=new zF(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new VF(this,e.type);case"event":return new zf(this,e.filter);case"transaction":return new qF(this,e.hash);case"orphan":return new WF(this,e.filter)}throw new Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(const n of this.#e.values())if(n.subscriber===e){n.started&&n.subscriber.stop(),n.subscriber=t,n.started&&t.start(),this.#n!=null&&t.pause(this.#n);break}}async#g(e,t){let n=await Wf(e,this);return n.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(n=await Wf({orphan:"drop-log",log:t[0]},this)),this.#e.get(n.tag)||null}async#m(e){const t=await Wf(e,this),n=t.tag;let s=this.#e.get(n);return s||(s={subscriber:this._getSubscriber(t),tag:n,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},this.#e.set(n,s)),s}async on(e,t){const n=await this.#m(e);return n.listeners.push({listener:t,once:!1}),n.started||(n.subscriber.start(),n.started=!0,this.#n!=null&&n.subscriber.pause(this.#n)),this}async once(e,t){const n=await this.#m(e);return n.listeners.push({listener:t,once:!0}),n.started||(n.subscriber.start(),n.started=!0,this.#n!=null&&n.subscriber.pause(this.#n)),this}async emit(e,...t){const n=await this.#g(e,t);if(!n||n.listeners.length===0)return!1;const s=n.listeners.length;return n.listeners=n.listeners.filter(({listener:r,once:a})=>{const o=new f0(this,a?null:r,e);try{r.call(this,...t,o)}catch{}return!a}),n.listeners.length===0&&(n.started&&n.subscriber.stop(),this.#e.delete(n.tag)),s>0}async listenerCount(e){if(e){const n=await this.#g(e);return n?n.listeners.length:0}let t=0;for(const{listeners:n}of this.#e.values())t+=n.length;return t}async listeners(e){if(e){const n=await this.#g(e);return n?n.listeners.map(({listener:s})=>s):[]}let t=[];for(const{listeners:n}of this.#e.values())t=t.concat(n.map(({listener:s})=>s));return t}async off(e,t){const n=await this.#g(e);if(!n)return this;if(t){const s=n.listeners.map(({listener:r})=>r).indexOf(t);s>=0&&n.listeners.splice(s,1)}return(!t||n.listeners.length===0)&&(n.started&&n.subscriber.stop(),this.#e.delete(n.tag)),this}async removeAllListeners(e){if(e){const{tag:t,started:n,subscriber:s}=await this.#m(e);n&&s.stop(),this.#e.delete(t)}else for(const[t,{started:n,subscriber:s}]of this.#e)n&&s.stop(),this.#e.delete(t);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return this.#i}destroy(){this.removeAllListeners();for(const e of this.#l.keys())this._clearTimeout(e);this.#i=!0}get paused(){return this.#n!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(this.#o=-1,this.#n!=null){if(this.#n==!!e)return;pe(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(t=>t.pause(e)),this.#n=!!e;for(const t of this.#l.values())t.timer&&clearTimeout(t.timer),t.time=qf()-t.time}resume(){if(this.#n!=null){this._forEachSubscriber(e=>e.resume()),this.#n=null;for(const e of this.#l.values()){let t=e.time;t<0&&(t=0),e.time=qf(),setTimeout(e.func,t)}}}}function ZF(i,e){try{const t=Kf(i,e);if(t)return wl(t)}catch{}return null}function Kf(i,e){if(i==="0x")return null;try{const t=ht(Vt(i,e,e+32)),n=ht(Vt(i,t,t+32));return Vt(i,t+32,t+32+n)}catch{}return null}function jx(i){const e=Zt(i);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function $F(i){if(i.length%32===0)return i;const e=new Uint8Array(Math.ceil(i.length/32)*32);return e.set(i),e}const eD=new Uint8Array([]);function tD(i){const e=[];let t=0;for(let n=0;n<i.length;n++)e.push(eD),t+=32;for(let n=0;n<i.length;n++){const s=lt(i[n]);e[n]=jx(t),e.push(jx(s.length)),e.push($F(s)),t+=32+Math.ceil(s.length/32)*32}return Ut(e)}const Jx="0x0000000000000000000000000000000000000000000000000000000000000000";function nD(i){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};pe(_a(i)>=160,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=Vt(i,0,32);pe(Vt(t,0,12)===Vt(Jx,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=Vt(t,12);try{const n=[],s=ht(Vt(i,32,64)),r=ht(Vt(i,s,s+32)),a=Vt(i,s+32);for(let o=0;o<r;o++){const c=ZF(a,o*32);if(c==null)throw new Error("abort");n.push(c)}e.urls=n}catch{pe(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const n=Kf(i,64);if(n==null)throw new Error("abort");e.calldata=n}catch{pe(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}pe(Vt(i,100,128)===Vt(Jx,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=Vt(i,96,100);try{const n=Kf(i,128);if(n==null)throw new Error("abort");e.extraData=n}catch{pe(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(n=>e[n]),e}function Ir(i,e){if(i.provider)return i.provider;pe(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function Zx(i,e){let t=Kl(e);if(t.to!=null&&(t.to=Pn(t.to,i)),t.from!=null){const n=t.from;t.from=Promise.all([i.getAddress(),Pn(n,i)]).then(([s,r])=>(V(s.toLowerCase()===r.toLowerCase(),"transaction from mismatch","tx.from",r),s))}else t.from=i.getAddress();return await Fn(t)}class iD{provider;constructor(e){Ye(this,{provider:e||null})}async getNonce(e){return Ir(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await Zx(this,e)}async populateTransaction(e){const t=Ir(this,"populateTransaction"),n=await Zx(this,e);n.nonce==null&&(n.nonce=await this.getNonce("pending")),n.gasLimit==null&&(n.gasLimit=await this.estimateGas(n));const s=await this.provider.getNetwork();if(n.chainId!=null){const a=Re(n.chainId);V(a===s.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else n.chainId=s.chainId;const r=n.maxFeePerGas!=null||n.maxPriorityFeePerGas!=null;if(n.gasPrice!=null&&(n.type===2||r)?V(!1,"eip-1559 transaction do not support gasPrice","tx",e):(n.type===0||n.type===1)&&r&&V(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(n.type===2||n.type==null)&&n.maxFeePerGas!=null&&n.maxPriorityFeePerGas!=null)n.type=2;else if(n.type===0||n.type===1){const a=await t.getFeeData();pe(a.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),n.gasPrice==null&&(n.gasPrice=a.gasPrice)}else{const a=await t.getFeeData();if(n.type==null)if(a.maxFeePerGas!=null&&a.maxPriorityFeePerGas!=null)if(n.authorizationList&&n.authorizationList.length?n.type=4:n.type=2,n.gasPrice!=null){const o=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=o,n.maxPriorityFeePerGas=o}else n.maxFeePerGas==null&&(n.maxFeePerGas=a.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=a.maxPriorityFeePerGas);else a.gasPrice!=null?(pe(!r,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),n.gasPrice==null&&(n.gasPrice=a.gasPrice),n.type=0):pe(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(n.type===2||n.type===3||n.type===4)&&(n.maxFeePerGas==null&&(n.maxFeePerGas=a.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=a.maxPriorityFeePerGas))}return await Fn(n)}async populateAuthorization(e){const t=Object.assign({},e);return t.chainId==null&&(t.chainId=(await Ir(this,"getNetwork").getNetwork()).chainId),t.nonce==null&&(t.nonce=await this.getNonce()),t}async estimateGas(e){return Ir(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return Ir(this,"call").call(await this.populateCall(e))}async resolveName(e){return await Ir(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=Ir(this,"sendTransaction"),n=await this.populateTransaction(e);delete n.from;const s=wi.from(n);return await t.broadcastTransaction(await this.signTransaction(s))}authorize(e){pe(!1,"authorization not implemented for this signer","UNSUPPORTED_OPERATION",{operation:"authorize"})}}function sD(i){return JSON.parse(JSON.stringify(i))}class $x{#e;#t;#n;#i;#s;#a;constructor(e){this.#e=e,this.#t=null,this.#n=this.#r.bind(this),this.#i=!1,this.#s=null,this.#a=!1}_subscribe(e){throw new Error("subclasses must override this")}_emitResults(e,t){throw new Error("subclasses must override this")}_recover(e){throw new Error("subclasses must override this")}async#r(e){try{this.#t==null&&(this.#t=this._subscribe(this.#e));let t=null;try{t=await this.#t}catch(r){if(!_n(r,"UNSUPPORTED_OPERATION")||r.operation!=="eth_newFilter")throw r}if(t==null){this.#t=null,this.#e._recoverSubscriber(this,this._recover(this.#e));return}const n=await this.#e.getNetwork();if(this.#s||(this.#s=n),this.#s.chainId!==n.chainId)throw new Error("chaid changed");if(this.#a)return;const s=await this.#e.send("eth_getFilterChanges",[t]);await this._emitResults(this.#e,s)}catch(t){console.log("@TODO",t)}this.#e.once("block",this.#n)}#o(){const e=this.#t;e&&(this.#t=null,e.then(t=>{this.#e.destroyed||this.#e.send("eth_uninstallFilter",[t])}))}start(){this.#i||(this.#i=!0,this.#r(-2))}stop(){this.#i&&(this.#i=!1,this.#a=!0,this.#o(),this.#e.off("block",this.#n))}pause(e){e&&this.#o(),this.#e.off("block",this.#n)}resume(){this.start()}}class rD extends $x{#e;constructor(e,t){super(e),this.#e=sD(t)}_recover(e){return new zf(e,this.#e)}async _subscribe(e){return await e.send("eth_newFilter",[this.#e])}async _emitResults(e,t){for(const n of t)e.emit(this.#e,e._wrapLog(n,e._network))}}class aD extends $x{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const n of t)e.emit("pending",n)}}const oD="bigint,boolean,function,number,string,symbol".split(/,/g);function th(i){if(i==null||oD.indexOf(typeof i)>=0||typeof i.getAddress=="function")return i;if(Array.isArray(i))return i.map(th);if(typeof i=="object")return Object.keys(i).reduce((e,t)=>(e[t]=i[t],e),{});throw new Error(`should not happen: ${i} (${typeof i})`)}function cD(i){return new Promise(e=>{setTimeout(e,i)})}function ka(i){return i&&i.toLowerCase()}function eE(i){return i&&typeof i.pollingInterval=="number"}const tE={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class Xf extends iD{address;constructor(e,t){super(e),t=vt(t),Ye(this,{address:t})}connect(e){pe(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(e){return await this.populateCall(e)}async sendUncheckedTransaction(e){const t=th(e),n=[];if(t.from){const r=t.from;n.push((async()=>{const a=await Pn(r,this.provider);V(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",e),t.from=a})())}else t.from=this.address;if(t.gasLimit==null&&n.push((async()=>{t.gasLimit=await this.provider.estimateGas({...t,from:this.address})})()),t.to!=null){const r=t.to;n.push((async()=>{t.to=await Pn(r,this.provider)})())}n.length&&await Promise.all(n);const s=this.provider.getRpcTransaction(t);return this.provider.send("eth_sendTransaction",[s])}async sendTransaction(e){const t=await this.provider.getBlockNumber(),n=await this.sendUncheckedTransaction(e);return await new Promise((s,r)=>{const a=[1e3,100];let o=0;const c=async()=>{try{const l=await this.provider.getTransaction(n);if(l!=null){s(l.replaceableTransaction(t));return}}catch(l){if(_n(l,"CANCELLED")||_n(l,"BAD_DATA")||_n(l,"NETWORK_ERROR")||_n(l,"UNSUPPORTED_OPERATION")){l.info==null&&(l.info={}),l.info.sendTransactionHash=n,r(l);return}if(_n(l,"INVALID_ARGUMENT")&&(o++,l.info==null&&(l.info={}),l.info.sendTransactionHash=n,o>10)){r(l);return}this.provider.emit("error",Qt("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:l}))}this.provider._setTimeout(()=>{c()},a.pop()||4e3)};c()})}async signTransaction(e){const t=th(e);if(t.from){const s=await Pn(t.from,this.provider);V(s!=null&&s.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",e),t.from=s}else t.from=this.address;const n=this.provider.getRpcTransaction(t);return await this.provider.send("eth_signTransaction",[n])}async signMessage(e){const t=typeof e=="string"?ns(e):e;return await this.provider.send("personal_sign",[ve(t),this.address.toLowerCase()])}async signTypedData(e,t,n){const s=th(n),r=await Kn.resolveNames(e,t,s,async a=>{const o=await Pn(a);return V(o!=null,"TypedData does not support null address","value",a),o});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(Kn.getPayload(r.domain,t,r.value))])}async unlock(e){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),e,null])}async _legacySignMessage(e){const t=typeof e=="string"?ns(e):e;return await this.provider.send("eth_sign",[this.address.toLowerCase(),ve(t)])}}class lD extends JF{#e;#t;#n;#i;#s;#a;#r;#o(){if(this.#i)return;const e=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");this.#i=setTimeout(()=>{this.#i=null;const t=this.#n;for(this.#n=[];t.length;){const n=[t.shift()];for(;t.length&&n.length!==this.#e.batchMaxCount;)if(n.push(t.shift()),JSON.stringify(n.map(r=>r.payload)).length>this.#e.batchMaxSize){t.unshift(n.pop());break}(async()=>{const s=n.length===1?n[0].payload:n.map(r=>r.payload);this.emit("debug",{action:"sendRpcPayload",payload:s});try{const r=await this._send(s);this.emit("debug",{action:"receiveRpcResult",result:r});for(const{resolve:a,reject:o,payload:c}of n){if(this.destroyed){o(Qt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:c.method}));continue}const l=r.filter(h=>h.id===c.id)[0];if(l==null){const h=Qt("missing response for request","BAD_DATA",{value:r,info:{payload:c}});this.emit("error",h),o(h);continue}if("error"in l){o(this.getRpcError(c,l));continue}a(l.result)}}catch(r){this.emit("debug",{action:"receiveRpcError",error:r});for(const{reject:a}of n)a(r)}})()}},e)}constructor(e,t){super(e,t),this.#t=1,this.#e=Object.assign({},tE,t||{}),this.#n=[],this.#i=null,this.#a=null,this.#r=null;{let s=null;const r=new Promise(a=>{s=a});this.#s={promise:r,resolve:s}}const n=this._getOption("staticNetwork");typeof n=="boolean"?(V(!n||e!=="any","staticNetwork cannot be used on special network 'any'","options",t),n&&e!=null&&(this.#a=Yn.from(e))):n&&(V(e==null||n.matches(e),"staticNetwork MUST match network object","options",t),this.#a=n)}_getOption(e){return this.#e[e]}get _network(){return pe(this.#a,"network is not available yet","NETWORK_ERROR"),this.#a}async _perform(e){if(e.method==="call"||e.method==="estimateGas"){let n=e.transaction;if(n&&n.type!=null&&Re(n.type)&&n.maxFeePerGas==null&&n.maxPriorityFeePerGas==null){const s=await this.getFeeData();s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null&&(e=Object.assign({},e,{transaction:Object.assign({},n,{type:void 0})}))}}const t=this.getRpcRequest(e);return t!=null?await this.send(t.method,t.args):super._perform(e)}async _detectNetwork(){const e=this._getOption("staticNetwork");if(e)if(e===!0){if(this.#a)return this.#a}else return e;return this.#r?await this.#r:this.ready?(this.#r=(async()=>{try{const t=Yn.from(Re(await this.send("eth_chainId",[])));return this.#r=null,t}catch(t){throw this.#r=null,t}})(),await this.#r):(this.#r=(async()=>{const t={id:this.#t++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:t});let n;try{n=(await this._send(t))[0],this.#r=null}catch(s){throw this.#r=null,this.emit("debug",{action:"receiveRpcError",error:s}),s}if(this.emit("debug",{action:"receiveRpcResult",result:n}),"result"in n)return Yn.from(Re(n.result));throw this.getRpcError(t,n)})(),await this.#r)}_start(){this.#s==null||this.#s.resolve==null||(this.#s.resolve(),this.#s=null,(async()=>{for(;this.#a==null&&!this.destroyed;)try{this.#a=await this._detectNetwork()}catch(e){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Qt("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:e}})),await cD(1e3)}this.#o()})())}async _waitUntilReady(){if(this.#s!=null)return await this.#s.promise}_getSubscriber(e){return e.type==="pending"?new aD(this):e.type==="event"?this._getOption("polling")?new zf(this,e.filter):new rD(this,e.filter):e.type==="orphan"&&e.filter.orphan==="drop-log"?new Yx("orphan"):super._getSubscriber(e)}get ready(){return this.#s==null}getRpcTransaction(e){const t={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(n=>{if(e[n]==null)return;let s=n;n==="gasLimit"&&(s="gas"),t[s]=_i(Re(e[n],`tx.${n}`))}),["from","to","data"].forEach(n=>{e[n]!=null&&(t[n]=ve(e[n]))}),e.accessList&&(t.accessList=gr(e.accessList)),e.blobVersionedHashes&&(t.blobVersionedHashes=e.blobVersionedHashes.map(n=>n.toLowerCase())),e.authorizationList&&(t.authorizationList=e.authorizationList.map(n=>{const s=vb(n);return{address:s.address,nonce:_i(s.nonce),chainId:_i(s.chainId),yParity:_i(s.signature.yParity),r:_i(s.signature.r),s:_i(s.signature.s)}})),t}getRpcRequest(e){switch(e.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[ka(e.address),e.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[ka(e.address),e.blockTag]};case"getCode":return{method:"eth_getCode",args:[ka(e.address),e.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[ka(e.address),"0x"+e.position.toString(16),e.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[e.signedTransaction]};case"getBlock":if("blockTag"in e)return{method:"eth_getBlockByNumber",args:[e.blockTag,!!e.includeTransactions]};if("blockHash"in e)return{method:"eth_getBlockByHash",args:[e.blockHash,!!e.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[e.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[e.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(e.transaction),e.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(e.transaction)]};case"getLogs":return e.filter&&e.filter.address!=null&&(Array.isArray(e.filter.address)?e.filter.address=e.filter.address.map(ka):e.filter.address=ka(e.filter.address)),{method:"eth_getLogs",args:[e.filter]}}return null}getRpcError(e,t){const{method:n}=e,{error:s}=t;if(n==="eth_estimateGas"&&s.message){const o=s.message;if(!o.match(/revert/i)&&o.match(/insufficient funds/i))return Qt("insufficient funds","INSUFFICIENT_FUNDS",{transaction:e.params[0],info:{payload:e,error:s}});if(o.match(/nonce/i)&&o.match(/too low/i))return Qt("nonce has already been used","NONCE_EXPIRED",{transaction:e.params[0],info:{payload:e,error:s}})}if(n==="eth_call"||n==="eth_estimateGas"){const o=Yf(s),c=Na.getBuiltinCallException(n==="eth_call"?"call":"estimateGas",e.params[0],o?o.data:null);return c.info={error:s,payload:e},c}const r=JSON.stringify(dD(s));if(typeof s.message=="string"&&s.message.match(/user denied|ethers-user-denied/i))return Qt("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[n]||"unknown",reason:"rejected",info:{payload:e,error:s}});if(n==="eth_sendRawTransaction"||n==="eth_sendTransaction"){const o=e.params[0];if(r.match(/insufficient funds|base fee exceeds gas limit/i))return Qt("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:o,info:{error:s}});if(r.match(/nonce/i)&&r.match(/too low/i))return Qt("nonce has already been used","NONCE_EXPIRED",{transaction:o,info:{error:s}});if(r.match(/replacement transaction/i)&&r.match(/underpriced/i))return Qt("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:o,info:{error:s}});if(r.match(/only replay-protected/i))return Qt("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:n,info:{transaction:o,info:{error:s}}})}let a=!!r.match(/the method .* does not exist/i);return a||s&&s.details&&s.details.startsWith("Unauthorized method:")&&(a=!0),a?Qt("unsupported operation","UNSUPPORTED_OPERATION",{operation:e.method,info:{error:s,payload:e}}):Qt("could not coalesce error","UNKNOWN_ERROR",{error:s,payload:e})}send(e,t){if(this.destroyed)return Promise.reject(Qt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:e}));const n=this.#t++,s=new Promise((r,a)=>{this.#n.push({resolve:r,reject:a,payload:{method:e,params:t,id:n,jsonrpc:"2.0"}})});return this.#o(),s}async getSigner(e){e==null&&(e=0);const t=this.send("eth_accounts",[]);if(typeof e=="number"){const s=await t;if(e>=s.length)throw new Error("no such account");return new Xf(this,s[e])}const{accounts:n}=await Fn({network:this.getNetwork(),accounts:t});e=vt(e);for(const s of n)if(vt(s)===e)return new Xf(this,e);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(t=>new Xf(this,t))}destroy(){this.#i&&(clearTimeout(this.#i),this.#i=null);for(const{payload:e,reject:t}of this.#n)t(Qt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:e.method}));this.#n=[],super.destroy()}}class hD extends lD{#e;constructor(e,t){super(e,t);let n=this._getOption("pollingInterval");n==null&&(n=tE.pollingInterval),this.#e=n}_getSubscriber(e){const t=super._getSubscriber(e);return eE(t)&&(t.pollingInterval=this.#e),t}get pollingInterval(){return this.#e}set pollingInterval(e){if(!Number.isInteger(e)||e<0)throw new Error("invalid interval");this.#e=e,this._forEachSubscriber(t=>{eE(t)&&(t.pollingInterval=this.#e)})}}class uD extends hD{#e;constructor(e,t,n){e==null&&(e="http://localhost:8545"),super(t,n),typeof e=="string"?this.#e=new Li(e):this.#e=e.clone()}_getConnection(){return this.#e.clone()}async send(e,t){return await this._start(),await super.send(e,t)}async _send(e){const t=this._getConnection();t.body=JSON.stringify(e),t.setHeader("content-type","application/json");const n=await t.send();n.assertOk();let s=n.bodyJson;return Array.isArray(s)||(s=[s]),s}}function Yf(i){if(i==null)return null;if(typeof i.message=="string"&&i.message.match(/revert/i)&&Ft(i.data))return{message:i.message,data:i.data};if(typeof i=="object"){for(const e in i){const t=Yf(i[e]);if(t)return t}return null}if(typeof i=="string")try{return Yf(JSON.parse(i))}catch{}return null}function jf(i,e){if(i!=null){if(typeof i.message=="string"&&e.push(i.message),typeof i=="object")for(const t in i)jf(i[t],e);if(typeof i=="string")try{return jf(JSON.parse(i),e)}catch{}}}function dD(i){const e=[];return jf(i,e),e}const fD=["function register() external returns (uint256 agentId)","function register(string agentURI) external returns (uint256 agentId)","function register(string agentURI, tuple(string metadataKey, bytes metadataValue)[] metadata) external returns (uint256 agentId)","function setAgentURI(uint256 agentId, string newURI) external","function tokenURI(uint256 tokenId) external view returns (string)","function setMetadata(uint256 agentId, string metadataKey, bytes metadataValue) external","function getMetadata(uint256 agentId, string metadataKey) external view returns (bytes)","function getAgentWallet(uint256 agentId) external view returns (address)","function ownerOf(uint256 tokenId) external view returns (address)","function balanceOf(address owner) external view returns (uint256)","function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256)","function totalSupply() external view returns (uint256)","function name() external view returns (string)","function symbol() external view returns (string)","function getVersion() external pure returns (string)","event Registered(uint256 indexed agentId, string agentURI, address indexed owner)","event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"],Mr={identityRegistry:"0x8004A818BFB912233c491871b3d84c89A494BD9e",reputationRegistry:"0x8004B663056A597Dffe9eCcC1965A193B7388713",validationRegistry:"0x8004Cb1BF31DAf7788923b405b754f57acEB4272"},Un={identityRegistry:"0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",reputationRegistry:"0x8004BAa17C55a88189AE136b182e5fdA19dE9b63",validationRegistry:""},pD={1:Un,10:Un,56:Un,100:Un,137:Un,250:Un,324:Un,1284:Un,5e3:Un,8453:Un,42161:Un,42220:Un,43114:Un,59144:Un,534352:Un,97:Mr,11155111:Mr,84532:Mr,421614:Mr,11155420:Mr,80002:Mr,43113:Mr},AD={base:8453,"base-mainnet":8453,"base-sepolia":84532,ethereum:1,mainnet:1},gD={8453:"https://mainnet.base.org",84532:"https://sepolia.base.org",1:"https://eth.llamarpc.com"};async function Jf(i,{rpcURL:e,registry:t}={}){if(!i)throw new Error("loadManifest: source required");if(i.startsWith("agent://"))return mD(i,{rpcURL:e,registryOverride:t});if(i.startsWith("ipfs://")||i.startsWith("ar://")){const n=Ps(i),s=await Zf(n);return nh(s,{baseURI:$f(n)})}if(i.startsWith("http")){const n=await Zf(i);return nh(n,{baseURI:$f(i)})}throw new Error(`Unsupported manifest source: ${i}`)}async function mD(i,{rpcURL:e,registryOverride:t}){const n=i.match(/^agent:\/\/([^/]+)\/(\d+)$/);if(!n)throw new Error(`Malformed agent URI: ${i}`);const[,s,r]=n,a=AD[s.toLowerCase()]||Number(s);if(!a)throw new Error(`Unknown chain: ${s}`);const o=pD[a],c=t||o?.identityRegistry;if(!c)throw new Error(`No registry deployed on chain ${a}. Pass registry= override.`);const l=new uD(e||gD[a]),h=new Da(c,fD,l),u=BigInt(r),d=await h.tokenURI(u);if(!d)throw new Error(`Agent ${r} on chain ${a} has no URI`);const f=Ps(d),m=await Zf(f),g=nh(m,{baseURI:$f(f)});return g.id={...g.id,chain:s,chainId:a,registry:c,agentId:r},g}async function Zf(i){let e;try{e=await fetch(i)}catch{e=await e0(i)}if(!e.ok)throw new Error(`Manifest fetch failed: ${i} (${e.status})`);return e.json()}function nh(i,{baseURI:e=""}={}){if(i.spec&&i.spec.startsWith("agent-manifest/")){const t={...i,_baseURI:e};return t.body=t.body||{},!t.body.uri&&t.image&&(t.body.uri=t.image),t}if(i.type&&i.type.includes("eip-8004")){const t=i.registrations?.[0]||{};return{spec:"agent-manifest/0.1",_baseURI:e,_source:"erc8004-registration",id:{agentId:t.agentId?.toString()},name:i.name,description:i.description,image:i.image,body:{uri:i.image,format:"gltf-binary"},brain:{provider:"none"},voice:{tts:{provider:"browser"},stt:{provider:"browser"}},skills:[],memory:{mode:"local"},tools:["wave","lookAt","play_clip","setExpression"],version:"0.1.0"}}return{spec:"agent-manifest/0.1",_baseURI:e,name:i.name||"Unnamed agent",description:i.description||"",body:{uri:i.body?.uri||i.image||i.model||"",format:i.body?.format||"gltf-binary"},brain:i.brain||{provider:"none"},voice:i.voice||{tts:{provider:"browser"},stt:{provider:"browser"}},skills:i.skills||[],memory:i.memory||{mode:"local"},tools:i.tools||["wave","lookAt","play_clip","setExpression"],version:i.version||"0.1.0"}}function $f(i){const e=i.lastIndexOf("/");return e>=0?i.slice(0,e+1):i}async function nE(i,e){if(!i._baseURI)return null;try{const t=new URL(e,i._baseURI).href,n=await fetch(t);return n.ok?n.text():null}catch{return null}}class fs extends Error{constructor(e,t,{status:n}={}){super(t),this.name="AgentResolveError",this.code=e,n!==void 0&&(this.status=n)}}async function iE(i,{fetchFn:e}){let t;try{t=await e(i,{credentials:"include"})}catch(n){throw new fs("network",`network error fetching ${i}: ${n.message||n}`)}if(t.status===401||t.status===403)throw new fs("unauthorized",`unauthorized fetching ${i} (${t.status})`,{status:t.status});if(t.status===404)throw new fs("not_found",`resource not found: ${i}`,{status:404});if(!t.ok)throw new fs("network",`request failed: ${i} (${t.status})`,{status:t.status});try{return await t.json()}catch(n){throw new fs("network",`invalid JSON from ${i}: ${n.message||n}`)}}async function bD(i,{origin:e=typeof location<"u"?location.origin:"",fetchFn:t=fetch}={}){if(!i)throw new fs("not_found","agentId required");const n=t.bind(typeof globalThis<"u"?globalThis:void 0),r=(await iE(`${e}/api/agents/${encodeURIComponent(i)}`,{fetchFn:n}))?.agent;if(!r)throw new fs("not_found",`agent ${i} not found`);if(!r.avatar_id)throw new fs("no_avatar",`agent ${i} has no avatar bound`);const o=(await iE(`${e}/api/avatars/${encodeURIComponent(r.avatar_id)}`,{fetchFn:n}))?.avatar;if(!o||!o.url)throw new fs("no_avatar",`avatar ${r.avatar_id} has no url`);const c=Array.isArray(r.skills)?r.skills.map(l=>typeof l=="string"?{name:l}:l).filter(Boolean):[];return{spec:"agent-manifest/0.1",name:r.name||"Agent",description:r.description||"",id:{agentId:r.id,owner:r.wallet_address,chainId:r.chain_id,walletAddress:r.wallet_address},body:{uri:o.url,format:"gltf-binary"},brain:{},voice:{tts:{provider:"browser"},stt:{provider:"browser"}},skills:c,memory:{mode:"remote",namespace:r.id},tools:["wave","lookAt","play_clip","setExpression","speak","remember"],version:"0.1.0",_baseURI:`${e}/agent/${r.id}/`,_source:"agent-id"}}const xD=["inline","floating","section","fullscreen"],ED=`+ :host {+ display: block;+ position: relative;+ width: 100%;+ height: 480px;+ --agent-bubble-radius: 16px;+ --agent-accent: #3b82f6;+ --agent-surface: rgba(17, 24, 39, 0.92);+ --agent-on-surface: #f9fafb;+ --agent-chat-font: system-ui, -apple-system, sans-serif;+ --agent-mic-glow: #22c55e;+ --agent-shadow: 0 20px 60px rgba(0,0,0,0.3);+ contain: layout style;+ }+ :host([mode="floating"]) {+ position: fixed;+ z-index: 2147483000;+ width: var(--agent-width, 320px);+ height: var(--agent-height, 420px);+ border-radius: var(--agent-bubble-radius);+ overflow: hidden;+ box-shadow: var(--agent-shadow);+ }+ :host([mode="fullscreen"]) {+ position: fixed;+ inset: 0;+ width: 100vw;+ height: 100vh;+ z-index: 2147483000;+ }+ :host([hidden]) { display: none; }+ .stage {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ }+ .stage canvas { display: block; }+ .chrome {+ position: absolute;+ left: 12px;+ right: 12px;+ bottom: 12px;+ display: flex;+ gap: 8px;+ align-items: flex-end;+ pointer-events: none;+ }+ .chrome > * { pointer-events: auto; }+ .chat {+ flex: 1;+ max-height: 40%;+ overflow-y: auto;+ background: var(--agent-surface);+ color: var(--agent-on-surface);+ font: 14px/1.4 var(--agent-chat-font);+ border-radius: 12px;+ padding: 10px 12px;+ backdrop-filter: blur(12px);+ }+ .chat:empty { display: none; }+ .msg { margin: 4px 0; }+ .msg .role { opacity: 0.55; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }+ .input-row {+ display: flex;+ gap: 6px;+ background: var(--agent-surface);+ border-radius: 999px;+ padding: 4px 4px 4px 14px;+ backdrop-filter: blur(12px);+ flex: 1;+ }+ .input-row input {+ flex: 1;+ background: transparent;+ border: 0;+ color: var(--agent-on-surface);+ font: 14px var(--agent-chat-font);+ outline: none;+ }+ button.icon {+ width: 36px;+ height: 36px;+ border-radius: 50%;+ border: 0;+ background: var(--agent-accent);+ color: white;+ cursor: pointer;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ }+ button.icon.mic[data-listening="true"] { box-shadow: 0 0 0 4px var(--agent-mic-glow); }+ .poster {+ position: absolute;+ inset: 0;+ background-size: contain;+ background-position: center;+ background-repeat: no-repeat;+ transition: opacity 0.4s;+ pointer-events: none;+ }+ .loading {+ position: absolute;+ left: 50%;+ top: 50%;+ transform: translate(-50%, -50%);+ color: var(--agent-on-surface);+ font: 14px var(--agent-chat-font);+ background: var(--agent-surface);+ padding: 8px 14px;+ border-radius: 999px;+ }+ .error {+ position: absolute;+ inset: 16px;+ display: grid;+ place-items: center;+ color: var(--agent-on-surface);+ background: var(--agent-surface);+ border-radius: 12px;+ padding: 16px;+ font: 14px var(--agent-chat-font);+ }+`;class ep extends HTMLElement{static get observedAttributes(){return["src","manifest","body","agent-id","mode","position","width","height","voice","api-key","key-proxy"]}constructor(){super(),this.attachShadow({mode:"open"}),this._viewer=null,this._scene=null,this._runtime=null,this._memory=null,this._skills=null,this._manifest=null,this._mounted=!1,this._booting=!1,this._listening=!1}connectedCallback(){this._renderShell(),this._applyLayout(),this._observeViewport(),this.hasAttribute("eager")&&this._boot()}disconnectedCallback(){this._teardown()}attributeChangedCallback(e,t,n){this._mounted&&(["mode","position","width","height"].includes(e)&&this._applyLayout(),["src","manifest","body","agent-id"].includes(e)&&(this._teardown(),this._boot()))}_renderShell(){const e=document.createElement("style");e.textContent=ED,this.shadowRoot.appendChild(e);const t=document.createElement("div");t.className="stage",t.part="stage",this.shadowRoot.appendChild(t),this._stageEl=t;const n=document.createElement("div");n.className="poster",this.getAttribute("poster")&&(n.style.backgroundImage=`url(${this.getAttribute("poster")})`),this.shadowRoot.appendChild(n),this._posterEl=n;const s=document.createElement("div");if(s.className="loading",s.textContent="Loading...",s.hidden=!0,this.shadowRoot.appendChild(s),this._loadingEl=s,!this.hasAttribute("kiosk")){const r=document.createElement("div");r.className="chrome",r.part="chrome";const a=document.createElement("div");a.className="chat",a.part="chat";const o=document.createElement("div");o.className="input-row";const c=document.createElement("input");c.type="text",c.placeholder="Say something...",c.addEventListener("keydown",h=>{if(h.key==="Enter"&&c.value.trim()){const u=c.value.trim();c.value="",this.say(u)}});const l=document.createElement("button");l.className="icon mic",l.title="Push to talk",l.innerHTML="🎙",l.addEventListener("click",()=>this._toggleMic()),o.appendChild(c),o.appendChild(l),r.appendChild(a),r.appendChild(o),this.shadowRoot.appendChild(r),this._chatEl=a,this._inputEl=c,this._micEl=l}}_applyLayout(){const e=this.getAttribute("mode")||"inline";if(!xD.includes(e))return;if(e==="floating"){const s=this.getAttribute("position")||"bottom-right",r=(this.getAttribute("offset")||"24px 24px").split(/\s+/),[a,o]=[r[0],r[1]||r[0]];this.style.top=this.style.bottom=this.style.left=this.style.right="",s.includes("top")?this.style.top=a:this.style.bottom=a,s.includes("left")?this.style.left=o:s.includes("right")?this.style.right=o:s.includes("center")&&(this.style.left="50%",this.style.transform="translateX(-50%)")}else this.style.top=this.style.bottom=this.style.left=this.style.right=this.style.transform="";const t=this.getAttribute("width"),n=this.getAttribute("height");t&&this.style.setProperty("--agent-width",t),n&&this.style.setProperty("--agent-height",n),e==="inline"&&(t&&(this.style.width=t),n&&(this.style.height=n))}_observeViewport(){if(!this.hasAttribute("eager")){if(typeof IntersectionObserver>"u"){this._boot();return}this._io=new IntersectionObserver(e=>{e.some(t=>t.isIntersecting)&&(this._io.disconnect(),this._boot())}),this._io.observe(this)}}async _boot(){if(!(this._booting||this._mounted)){this._booting=!0;try{this._loadingEl.hidden=!1,this.dispatchEvent(new CustomEvent("agent:load-progress",{detail:{phase:"manifest",pct:.1}}));const e=await this._resolveManifest();if(this._manifest=e,this.dispatchEvent(new CustomEvent("agent:load-progress",{detail:{phase:"manifest",pct:.3}})),typeof e.brain?.instructions=="string"&&e.brain.instructions.endsWith(".md")){const c=await nE(e,e.brain.instructions);c&&(e.instructions=_D(c))}else e.brain?.instructions&&(e.instructions=e.brain.instructions);this.dispatchEvent(new CustomEvent("agent:load-progress",{detail:{phase:"body",pct:.45}}));const t=new Gd(this._stageEl,{kiosk:this.hasAttribute("kiosk")});this._viewer=t;const n=Ps(e.body?.uri);n&&await t.load(n,"",new Map),this._scene=new n0(t),this.dispatchEvent(new CustomEvent("agent:load-progress",{detail:{phase:"memory",pct:.6}}));const s=e.id?.agentId||this.getAttribute("memory-key")||e.name||"anon";this._memory=await xi.load({mode:this.getAttribute("memory")||e.memory?.mode||"local",namespace:s,manifestURI:e._baseURI+"manifest.json",fetchFn:fetch.bind(globalThis)}),this.dispatchEvent(new CustomEvent("agent:load-progress",{detail:{phase:"skills",pct:.75}})),this._skills=new s0({trust:this.getAttribute("skill-trust")||"owned-only",ownerAddress:e.id?.owner});const r=e.skills||[];for(const c of r)try{const l=await this._skills.install(c,{bundleBase:e._baseURI});this.dispatchEvent(new CustomEvent("skill:loaded",{detail:{name:l.name,uri:l.uri}}))}catch(l){console.warn("[agent-3d] skill load failed",c,l)}this.dispatchEvent(new CustomEvent("agent:load-progress",{detail:{phase:"brain",pct:.9}}));const a={apiKey:this.getAttribute("api-key")||void 0,proxyURL:this.getAttribute("key-proxy")||void 0},o=this._parseTTSAttribute();o&&(e.voice=e.voice||{},e.voice.tts={...e.voice.tts||{},...o}),this._runtime=new $m({manifest:e,viewer:this._scene,memory:this._memory,skills:this._skills,providerConfig:a});for(const c of["brain:thinking","brain:message","skill:tool-called","voice:speech-start","voice:speech-end","voice:transcript","voice:listen-start","memory:write"])this._runtime.addEventListener(c,l=>{this.dispatchEvent(new CustomEvent(c,{detail:l.detail,bubbles:!0,composed:!0})),c==="brain:message"&&this._chatEl&&this._renderMessage(l.detail)});this._mounted=!0,this._loadingEl.hidden=!0,this._posterEl.style.opacity="0",this.dispatchEvent(new CustomEvent("agent:ready",{detail:{agent:this,manifest:e},bubbles:!0,composed:!0}))}catch(e){console.error("[agent-3d] boot failed",e),this._loadingEl.hidden=!0,this._showError(e),this.dispatchEvent(new CustomEvent("agent:error",{detail:{phase:"boot",error:e},bubbles:!0,composed:!0}))}finally{this._booting=!1}}}async _resolveManifest(){const e=this.getAttribute("src"),t=this.getAttribute("manifest"),n=this.getAttribute("body"),s=this.getAttribute("agent-id");if(e)return s&&console.warn("[agent-3d] both src and agent-id provided; using src"),Jf(e,{rpcURL:this.getAttribute("rpc-url"),registry:this.getAttribute("registry")});if(s)return bD(s);if(t)return Jf(t);if(n){const r=this.getAttribute("instructions");return{spec:"agent-manifest/0.1",_baseURI:"",name:this.getAttribute("name")||"Agent",body:{uri:n,format:"gltf-binary"},brain:{provider:this.getAttribute("brain")?"anthropic":"none",model:this.getAttribute("brain")||void 0,instructions:r||"You are an embodied 3D agent."},instructions:r||"You are an embodied 3D agent.",voice:{tts:{provider:"browser"},stt:{provider:"browser"}},skills:(this.getAttribute("skills")||"").split(",").map(a=>a.trim()).filter(Boolean).map(a=>({uri:a})),memory:{mode:this.getAttribute("memory")||"local"},tools:["wave","lookAt","play_clip","setExpression","speak","remember"],version:"0.1.0"}}throw new Error("<agent-3d> requires src=, manifest=, or body= attribute")}_renderMessage({role:e,content:t}){if(!this._chatEl||!t)return;const n=document.createElement("div");n.className="msg",n.innerHTML=`<div class="role">${e}</div><div class="body"></div>`,n.querySelector(".body").textContent=t,this._chatEl.appendChild(n),this._chatEl.scrollTop=this._chatEl.scrollHeight}_showError(e){const t=document.createElement("div");t.className="error",t.textContent=`Couldn't load agent: ${e.message||e}`,this.shadowRoot.appendChild(t)}async _toggleMic(){if(this._runtime){if(this._listening){this._runtime.stt?.stop(),this._listening=!1,this._micEl.dataset.listening="false";return}this._listening=!0,this._micEl.dataset.listening="true";try{const e=await this._runtime.listen();e&&await this.say(e,{voice:!0})}catch(e){console.warn("[agent-3d] listen failed",e)}finally{this._listening=!1,this._micEl.dataset.listening="false"}}}_teardown(){try{this._io?.disconnect()}catch{}try{this._runtime?.destroy()}catch{}try{this._viewer?.dispose?.()}catch{}this._mounted=!1,this._runtime=this._viewer=this._scene=this._memory=this._skills=null}async say(e,t={}){return this._runtime||await this._waitForReady(),this._runtime.send(e,{voice:t.voice??this.hasAttribute("voice")})}async ask(e,t={}){return(await this.say(e,t))?.text||""}clearConversation(){this._runtime?.clearConversation()}async wave(e){return this._scene?.playAnimationByHint("wave",e)}async lookAt(e){return this._scene?.lookAt(e)}async play(e,t){return this._scene?.playClipByName(e,t)}async installSkill(e){if(!this._skills)throw new Error("Agent not mounted");return this._skills.install({uri:e})}uninstallSkill(e){return this._skills?.uninstall(e)}get skills(){return this._skills?.all()||[]}get memory(){return this._memory}get manifest(){return this._manifest}get runtime(){return this._runtime}setMode(e){this.setAttribute("mode",e)}setPosition(e,t){this.setAttribute("position",e),t&&this.setAttribute("offset",t)}setSize(e,t){this.setAttribute("width",e),this.setAttribute("height",t)}pause(){this._runtime?.pause()}resume(){}destroy(){this._teardown()}_waitForReady(){return this._mounted?Promise.resolve():new Promise(e=>{const t=()=>{this.removeEventListener("agent:ready",t),e()};this.addEventListener("agent:ready",t),this._booting||this._boot()})}}function _D(i){const e=i.match(/^---\n[\s\S]*?\n---\n?([\s\S]*)$/);return e?e[1]:i}customElements.get("agent-3d")||customElements.define("agent-3d",ep);const yD=["row","circle","freeform"],wD=`+ :host {+ display: block;+ position: relative;+ width: 100%;+ height: 480px;+ contain: layout style;+ }+ :host([hidden]) { display: none; }+ .stage-canvas {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ }+ .stage-canvas canvas { display: block; }+ ::slotted(agent-3d) {+ position: absolute;+ pointer-events: none;+ }+`;class sE extends HTMLElement{static get observedAttributes(){return["formation"]}constructor(){super(),this.attachShadow({mode:"open"}),this._viewer=null,this._agents=[],this._initialized=!1}connectedCallback(){this._renderShell(),this._initViewer(),this._mo=new MutationObserver(()=>this._repositionAll()),this._mo.observe(this,{childList:!0})}disconnectedCallback(){try{this._mo?.disconnect()}catch{}for(const e of[...this._agents])this.unregisterAgent(e.element);try{this._viewer?.dispose?.()}catch{}this._viewer=null,this._initialized=!1}attributeChangedCallback(e){e==="formation"&&this._repositionAll()}get formation(){const e=this.getAttribute("formation")||"row";return yD.includes(e)?e:"row"}get viewer(){return this._viewer}_renderShell(){const e=document.createElement("style");e.textContent=wD,this.shadowRoot.appendChild(e);const t=document.createElement("div");t.className="stage-canvas",t.part="stage",this.shadowRoot.appendChild(t),this._canvasBox=t;const n=document.createElement("slot");this.shadowRoot.appendChild(n)}_initViewer(){if(!this._initialized){this._viewer=new Gd(this._canvasBox,{kiosk:!0}),this._viewer.defaultCamera.position.set(0,1.55,3.4),this._viewer.defaultCamera.lookAt(0,1.2,0),this._viewer.controls.target.set(0,1.2,0),this._viewer.controls.update();try{this._viewer.updateLights?.()}catch{}try{this._viewer.updateEnvironment?.()}catch{}this._viewer.invalidate(),this._initialized=!0}}registerAgent(e,{id:t,group:n,manifest:s}){const r=this._uniqueId(t||s?.name||"agent"),a={id:r,element:e,group:n,manifest:s};return this._agents.push(a),this._viewer?.scene.add(n),this._repositionAll(),this.dispatchEvent(new CustomEvent("stage:agent-joined",{detail:{agentId:r,element:e,manifest:s},bubbles:!0,composed:!0})),r}unregisterAgent(e){const t=this._agents.findIndex(s=>s.element===e);if(t<0)return;const[n]=this._agents.splice(t,1);try{this._viewer?.scene.remove(n.group)}catch{}CD(n.group),this._repositionAll(),this.dispatchEvent(new CustomEvent("stage:agent-left",{detail:{agentId:n.id,element:n.element},bubbles:!0,composed:!0}))}_uniqueId(e){let t=e,n=1;const s=new Set(this._agents.map(r=>r.id));for(;s.has(t);)t=`${e}-${n++}`;return t}getAgents(){return this._agents.map(({id:e,group:t,manifest:n,element:s})=>({agentId:e,name:n?.name||e,position:[+t.position.x.toFixed(3),+t.position.y.toFixed(3),+t.position.z.toFixed(3)],element:s}))}broadcast(e,t){const n={from:e,event:t};for(const s of this._agents)s.id!==e&&s.element.dispatchEvent(new CustomEvent("stage:message",{detail:n}));this.dispatchEvent(new CustomEvent("stage:message",{detail:n,bubbles:!0,composed:!0}))}async routeMessage(e,t,n){const s=this._agents.find(r=>r.id===t);if(!s)return{ok:!1,error:`No agent "${t}" on stage`};try{return{ok:!0,reply:(await s.element.say(`[from ${e}] ${n}`))?.text||""}}catch(r){return{ok:!1,error:r?.message||String(r)}}}async addAgent(e){const t=document.createElement("agent-3d");return e&&typeof e=="object"&&(t._inlineManifest=e),t.hasAttribute("eager")||t.setAttribute("eager",""),this.appendChild(t),t}removeAgent(e){const t=this._agents.find(n=>n.id===e);t&&t.element.remove()}_repositionAll(){const e=this._agents.length;if(!(!e||!this._viewer)){for(let t=0;t<e;t++){const{element:n,group:s,manifest:r}=this._agents[t],a=this._slotFor(t,e);s.position.copy(a.world),s.lookAt(0,a.world.y+1,a.world.z+5),n.style.position="absolute",n.style.left=a.dom.left,n.style.top=a.dom.top,n.style.width=a.dom.width,n.style.height=a.dom.height,n.style.pointerEvents="none"}this._viewer.invalidate()}}_slotFor(e,t){const n=this.formation,s=1/Math.max(t,1);if(n==="circle"){const o=e/t*Math.PI*2,c=Math.max(.8,.4*t);return{world:new H(Math.sin(o)*c,0,-Math.cos(o)*c+c*.5),dom:{left:`${e*s*100}%`,top:"0",width:`${s*100}%`,height:"100%"}}}if(n==="freeform")return{world:new H(0,0,0),dom:{left:"0",top:"0",width:"100%",height:"100%"}};const a=(e-(t-1)/2)*1.1;return{world:new H(a,0,0),dom:{left:`${e*s*100}%`,top:"0",width:`${s*100}%`,height:"100%"}}}}function CD(i){i.traverse(e=>{if(e.geometry)try{e.geometry.dispose()}catch{}if(e.material){const t=Array.isArray(e.material)?e.material:[e.material];for(const n of t){for(const s of Object.keys(n)){const r=n[s];if(r&&r.isTexture)try{r.dispose()}catch{}}try{n.dispose()}catch{}}}}),i.parent&&i.parent.remove(i)}customElements.get("agent-stage")||customElements.define("agent-stage",sE);const vD=(i="agent-3d")=>{customElements.get(i)||customElements.define(i,ep)};en.Agent3DElement=ep,en.AgentStageElement=sE,en.Memory=xi,en.Runtime=$m,en.SceneController=n0,en.Skill=i0,en.SkillRegistry=s0,en.Viewer=Gd,en.defineElement=vD,en.fetchRelative=nE,en.fetchWithFallback=e0,en.loadManifest=Jf,en.normalize=nh,en.resolveURI=Ps,Object.defineProperty(en,Symbol.toStringTag,{value:"Module"})}));diff --git a/public/dashboard/dashboard.js b/public/dashboard/dashboard.jsindex 69f2c7f0f..6c6e800db 100644--- a/public/dashboard/dashboard.js+++ b/public/dashboard/dashboard.js@@ -97,6 +97,7 @@ function avatarCard(a) {<select data-vis>${['private','unlisted','public'].map((v) => `<option ${v===a.visibility?'selected':''} value="${v}">${v}</option>`).join('')}</select><div class="row" style="gap:6px"><a class="btn sec" href="#edit/${encodeURIComponent(a.id)}">Edit</a>+ <button class="btn sec" data-replace>Replace GLB</button><button class="btn sec" data-del>Delete</button></div></div>@@ -113,6 +114,7 @@ function avatarCard(a) {el.remove();} catch (err) { alert(err.message); }});+ el.querySelector('[data-replace]').addEventListener('click', () => replaceGlbFlow(a, el));return el;}diff --git a/src/runtime/scene.js b/src/runtime/scene.jsindex 25131427d..984ad7686 100644--- a/src/runtime/scene.js+++ b/src/runtime/scene.js@@ -6,6 +6,7 @@import { Vector3 } from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';import { resolveURI } from '../ipfs.js';+import { resolveSlot } from './animation-slots.js';const EXPRESSION_MAP = {neutral: { /* reset all */ },@@ -21,6 +22,7 @@ export class SceneController {this.viewer = viewer;this._loader = new GLTFLoader();this._userTarget = new Vector3(0, 1.6, 2); // approx user head position+ this._animationMap = {};}// Expose the underlying Three.js handles skills may need@@ -29,6 +31,24 @@ export class SceneController {get clips() { return this.viewer.clips || []; }get content() { return this.viewer.content; }+ /**+ * Set the agent's animation slot override map (from meta.edits.animations).+ * @param {Object|null} map — { slotName: clipName, … }+ */+ setAnimationMap(map) {+ this._animationMap = map || {};+ }++ /**+ * Resolve a slot name (e.g. 'celebrate') to the actual clip name.+ * Falls back to DEFAULT_ANIMATION_MAP, then the slot name itself.+ * @param {string} name+ * @returns {string}+ */+ resolveAnimationSlot(name) {+ return resolveSlot(name, this._animationMap);+ }+// Delegate raw load for ad-hoc casesasync load(url, rootPath = '', assetMap = new Map()) {return this.viewer.load(url, rootPath, assetMap);@@ -37,24 +57,41 @@ export class SceneController {// --- Animation ---playClipByName(name, { loop = false, fade_ms = 200 } = {}) {+ // Try embedded clips (viewer.clips / viewer.mixer) firstconst clip = this._findClip(name);- if (!clip || !this.viewer.mixer) return false;- const action = this.viewer.mixer.clipAction(clip);- action.reset();- action.setLoop(loop ? 2201 /* LoopRepeat */ : 2200 /* LoopOnce */);- action.clampWhenFinished = !loop;- action.fadeIn(fade_ms / 1000);- action.play();- this.viewer.state.actionStates[clip.name] = true;- this.viewer.invalidate();+ if (clip && this.viewer.mixer) {+ const action = this.viewer.mixer.clipAction(clip);+ action.reset();+ action.setLoop(loop ? 2201 /* LoopRepeat */ : 2200 /* LoopOnce */);+ action.clampWhenFinished = !loop;+ action.fadeIn(fade_ms / 1000);+ action.play();+ this.viewer.state.actionStates[clip.name] = true;+ this.viewer.invalidate();+ return true;+ }+ // Fall back to animation manager (external clips from manifest)+ const am = this.viewer?.animationManager;+ if (!am?.isLoaded(name)) return false;+ if (loop) am.crossfadeTo(name, fade_ms / 1000);+ else am.play(name);return true;}playAnimationByHint(hint, opts) {const lower = hint.toLowerCase();+ // Search embedded clipsconst match = this.clips.find((c) => c.name.toLowerCase().includes(lower));if (match) return this.playClipByName(match.name, opts);- // Fallback — skills can ship their own clips via loadClip+ // Search external clips in animation manager+ const am = this.viewer?.animationManager;+ if (am) {+ for (const name of am.clips.keys()) {+ if (name.toLowerCase().includes(lower)) {+ return this.playClipByName(name, opts);+ }+ }+ }return false;}diff --git a/src/skills/sandbox-host.js b/src/skills/sandbox-host.jsindex f2864feeb..f66e1671c 100644--- a/src/skills/sandbox-host.js+++ b/src/skills/sandbox-host.js@@ -1,12 +1,14 @@// Sandbox host — manages the shared Web Worker that executes skill handlers.// One worker instance is shared across all skills in a session.-// ?worker&inline tells Vite to bundle and inline the worker, avoiding a-// separate chunk (required for the UMD lib build which can't code-split).-import SandboxWorkerCtor from './sandbox-worker.js?worker&inline';+// ?raw imports the worker source as a plain string — no Vite worker plugin,+// no code-split chunk, compatible with both ES and UMD lib builds.+// The worker is created at runtime as a classic-script blob: URL.+import _workerSrc from './sandbox-worker.js?raw';/** @type {Worker | null} */let _worker = null;+let _workerBlobUrl = null;/** @type {Map<string, Promise<void>>} skillURI → install promise */const _installPromises = new Map();@@ -46,7 +48,11 @@ function _resolveArgs(args) {function _getWorker() {if (!_worker) {- _worker = new SandboxWorkerCtor();+ if (!_workerBlobUrl) {+ const blob = new Blob([_workerSrc], { type: 'text/javascript' });+ _workerBlobUrl = URL.createObjectURL(blob);+ }+ _worker = new Worker(_workerBlobUrl);_worker.onmessage = _onMessage;_worker.onerror = _onError;}@@ -208,6 +214,10 @@ function _terminate() {if (!_worker) return;_worker.terminate();_worker = null;+ if (_workerBlobUrl) {+ URL.revokeObjectURL(_workerBlobUrl);+ _workerBlobUrl = null;+ }_installPromises.clear();_installCallbacks.clear();_handles.clear();