@memori.ai/memori-webcomponent 2.0.6 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/memori-webcomponent.js +2 -2
- package/package.json +2 -2
|
@@ -100,7 +100,7 @@ r.version="2.29.4",i(Jn),r.fn=lo,r.min=$n,r.max=er,r.now=tr,r.utc=p,r.unix=co,r.
|
|
|
100
100
|
* Copyright 2010-2022 Three.js Authors
|
|
101
101
|
* SPDX-License-Identifier: MIT
|
|
102
102
|
*/
|
|
103
|
-
const cw="144",uw={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},dw={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},fw=0,hw=1,pw=2,mw=3,gw=0,vw=1,yw=2,bw=3,ww=0,xw=1,Sw=2,Mw=0,_w=1,Aw=2,Ew=3,Cw=4,kw=5,Tw=100,Iw=101,Ow=102,Rw=103,Pw=104,Nw=200,Lw=201,Dw=202,Bw=203,jw=204,Fw=205,Uw=206,zw=207,Hw=208,Vw=209,Ww=210,Gw=0,qw=1,Kw=2,Yw=3,Jw=4,Qw=5,Xw=6,Zw=7,$w=0,ex=1,tx=2,nx=0,rx=1,ix=2,ox=3,ax=4,sx=5,lx=300,cx=301,ux=302,dx=303,fx=304,hx=306,px=1e3,mx=1001,gx=1002,vx=1003,yx=1004,bx=1004,wx=1005,xx=1005,Sx=1006,Mx=1007,_x=1007,Ax=1008,Ex=1008,Cx=1009,kx=1010,Tx=1011,Ix=1012,Ox=1013,Rx=1014,Px=1015,Nx=1016,Lx=1017,Dx=1018,Bx=1020,jx=1021,Fx=1022,Ux=1023,zx=1024,Hx=1025,Vx=1026,Wx=1027,Gx=1028,qx=1029,Kx=1030,Yx=1031,Jx=1033,Qx=33776,Xx=33777,Zx=33778,$x=33779,eS=35840,tS=35841,nS=35842,rS=35843,iS=36196,oS=37492,aS=37496,sS=37808,lS=37809,cS=37810,uS=37811,dS=37812,fS=37813,hS=37814,pS=37815,mS=37816,gS=37817,vS=37818,yS=37819,bS=37820,wS=37821,xS=36492,SS=2200,MS=2201,_S=2202,AS=2300,ES=2301,CS=2302,kS=2400,TS=2401,IS=2402,OS=2500,RS=2501,PS=0,NS=1,LS=2,DS=3e3,BS=3001,jS=3200,FS=3201,US=0,zS=1,HS="",VS="srgb",WS="srgb-linear",GS=0,qS=7680,KS=7681,YS=7682,JS=7683,QS=34055,XS=34056,ZS=5386,$S=512,eM=513,tM=514,nM=515,rM=516,iM=517,oM=518,aM=519,sM=35044,lM=35048,cM=35040,uM=35045,dM=35049,fM=35041,hM=35046,pM=35050,mM=35042,gM="100",vM="300 es",yM=1035;class bM{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,r=n.length;t<r;t++)n[t].call(this,e);e.target=null}}}const wM=["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 xM=1234567;const SM=Math.PI/180,MM=180/Math.PI;function _M(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(wM[255&e]+wM[e>>8&255]+wM[e>>16&255]+wM[e>>24&255]+"-"+wM[255&t]+wM[t>>8&255]+"-"+wM[t>>16&15|64]+wM[t>>24&255]+"-"+wM[63&n|128]+wM[n>>8&255]+"-"+wM[n>>16&255]+wM[n>>24&255]+wM[255&r]+wM[r>>8&255]+wM[r>>16&255]+wM[r>>24&255]).toLowerCase()}function AM(e,t,n){return Math.max(t,Math.min(n,e))}function EM(e,t){return(e%t+t)%t}function CM(e,t,n){return(1-n)*e+n*t}function kM(e){return 0==(e&e-1)&&0!==e}function TM(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function IM(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function OM(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function RM(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}var PM=Object.freeze({__proto__:null,DEG2RAD:SM,RAD2DEG:MM,generateUUID:_M,clamp:AM,euclideanModulo:EM,mapLinear:function(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:CM,damp:function(e,t,n,r){return CM(e,t,1-Math.exp(-n*r))},pingpong:function(e,t=1){return t-Math.abs(EM(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(xM=e);let t=xM+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*SM},radToDeg:function(e){return e*MM},isPowerOfTwo:kM,ceilPowerOfTwo:TM,floorPowerOfTwo:IM,setQuaternionFromProperEuler:function(e,t,n,r,i){const o=Math.cos,a=Math.sin,s=o(n/2),l=a(n/2),c=o((t+r)/2),u=a((t+r)/2),d=o((t-r)/2),f=a((t-r)/2),h=o((r-t)/2),p=a((r-t)/2);switch(i){case"XYX":e.set(s*u,l*d,l*f,s*c);break;case"YZY":e.set(l*f,s*u,l*d,s*c);break;case"ZXZ":e.set(l*d,l*f,s*u,s*c);break;case"XZX":e.set(s*u,l*p,l*h,s*c);break;case"YXY":e.set(l*h,s*u,l*p,s*c);break;case"ZYZ":e.set(l*p,l*h,s*u,s*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}},normalize:RM,denormalize:OM});class NM{constructor(e=0,t=0){NM.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,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}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),r=Math.sin(t),i=this.x-e.x,o=this.y-e.y;return this.x=i*n-o*r+e.x,this.y=i*r+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class LM{constructor(){LM.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,n,r,i,o,a,s,l){const c=this.elements;return c[0]=e,c[1]=r,c[2]=a,c[3]=t,c[4]=i,c[5]=s,c[6]=n,c[7]=o,c[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,r=t.elements,i=this.elements,o=n[0],a=n[3],s=n[6],l=n[1],c=n[4],u=n[7],d=n[2],f=n[5],h=n[8],p=r[0],m=r[3],g=r[6],v=r[1],y=r[4],b=r[7],w=r[2],x=r[5],S=r[8];return i[0]=o*p+a*v+s*w,i[3]=o*m+a*y+s*x,i[6]=o*g+a*b+s*S,i[1]=l*p+c*v+u*w,i[4]=l*m+c*y+u*x,i[7]=l*g+c*b+u*S,i[2]=d*p+f*v+h*w,i[5]=d*m+f*y+h*x,i[8]=d*g+f*b+h*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],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8];return t*o*c-t*a*l-n*i*c+n*a*s+r*i*l-r*o*s}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],u=c*o-a*l,d=a*s-c*i,f=l*i-o*s,h=t*u+n*d+r*f;if(0===h)return this.set(0,0,0,0,0,0,0,0,0);const p=1/h;return e[0]=u*p,e[1]=(r*l-c*n)*p,e[2]=(a*n-r*o)*p,e[3]=d*p,e[4]=(c*t-r*s)*p,e[5]=(r*i-a*t)*p,e[6]=f*p,e[7]=(n*s-l*t)*p,e[8]=(o*t-n*i)*p,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,r,i,o,a){const s=Math.cos(i),l=Math.sin(i);return this.set(n*s,n*l,-n*(s*o+l*a)+o+e,-r*l,r*s,-r*(-l*o+s*a)+a+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),r=this.elements,i=r[0],o=r[3],a=r[6],s=r[1],l=r[4],c=r[7];return r[0]=t*i+n*s,r[3]=t*o+n*l,r[6]=t*a+n*c,r[1]=-n*i+t*s,r[4]=-n*o+t*l,r[7]=-n*a+t*c,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])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)}}function DM(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}const BM={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function jM(e,t){return new BM[e](t)}function FM(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function UM(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function zM(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const HM={[VS]:{[WS]:UM},[WS]:{[VS]:zM}},VM={legacyMode:!0,get workingColorSpace(){return WS},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(this.legacyMode||t===n||!t||!n)return e;if(HM[t]&&void 0!==HM[t][n]){const r=HM[t][n];return e.r=r(e.r),e.g=r(e.g),e.b=r(e.b),e}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}},WM={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},GM={r:0,g:0,b:0},qM={h:0,s:0,l:0},KM={h:0,s:0,l:0};function YM(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function JM(e,t){return t.r=e.r,t.g=e.g,t.b=e.b,t}class QM{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=VS){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,VM.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=WS){return this.r=e,this.g=t,this.b=n,VM.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=WS){if(e=EM(e,1),t=AM(t,0,1),n=AM(n,0,1),0===t)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=YM(i,r,e+1/3),this.g=YM(i,r,e),this.b=YM(i,r,e-1/3)}return VM.toWorkingColorSpace(this,r),this}setStyle(e,t=VS){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const i=r[1],o=r[2];switch(i){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,VM.toWorkingColorSpace(this,t),n(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,VM.toWorkingColorSpace(this,t),n(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){const r=parseFloat(e[1])/360,i=parseFloat(e[2])/100,o=parseFloat(e[3])/100;return n(e[4]),this.setHSL(r,i,o,t)}}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=r[1],n=e.length;if(3===n)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,VM.toWorkingColorSpace(this,t),this;if(6===n)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,VM.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=VS){const n=WM[e.toLowerCase()];return void 0!==n?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=UM(e.r),this.g=UM(e.g),this.b=UM(e.b),this}copyLinearToSRGB(e){return this.r=zM(e.r),this.g=zM(e.g),this.b=zM(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=VS){return VM.fromWorkingColorSpace(JM(this,GM),e),AM(255*GM.r,0,255)<<16^AM(255*GM.g,0,255)<<8^AM(255*GM.b,0,255)<<0}getHexString(e=VS){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=WS){VM.fromWorkingColorSpace(JM(this,GM),t);const n=GM.r,r=GM.g,i=GM.b,o=Math.max(n,r,i),a=Math.min(n,r,i);let s,l;const c=(a+o)/2;if(a===o)s=0,l=0;else{const e=o-a;switch(l=c<=.5?e/(o+a):e/(2-o-a),o){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4}s/=6}return e.h=s,e.s=l,e.l=c,e}getRGB(e,t=WS){return VM.fromWorkingColorSpace(JM(this,GM),t),e.r=GM.r,e.g=GM.g,e.b=GM.b,e}getStyle(e=VS){return VM.fromWorkingColorSpace(JM(this,GM),e),e!==VS?`color(${e} ${GM.r} ${GM.g} ${GM.b})`:`rgb(${255*GM.r|0},${255*GM.g|0},${255*GM.b|0})`}offsetHSL(e,t,n){return this.getHSL(qM),qM.h+=e,qM.s+=t,qM.l+=n,this.setHSL(qM.h,qM.s,qM.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(qM),e.getHSL(KM);const n=CM(qM.h,KM.h,t),r=CM(qM.s,KM.s,t),i=CM(qM.l,KM.l,t);return this.setHSL(n,r,i),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}let XM;QM.NAMES=WM;class ZM{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===XM&&(XM=FM("canvas")),XM.width=e.width,XM.height=e.height;const n=XM.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=XM}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=FM("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=255*UM(i[e]/255);return n.putImageData(r,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*UM(t[e]/255)):t[e]=UM(t[e]);return{data:t,width:e.width,height:e.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}class $M{constructor(e=null){this.isSource=!0,this.uuid=_M(),this.data=e,this.version=0}set needsUpdate(e){!0===e&&this.version++}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(null!==r){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(e_(r[t].image)):e.push(e_(r[t]))}else e=e_(r);n.url=e}return t||(e.images[this.uuid]=n),n}}function e_(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?ZM.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let t_=0;class n_ extends bM{constructor(e=n_.DEFAULT_IMAGE,t=n_.DEFAULT_MAPPING,n=mx,r=mx,i=Sx,o=Ax,a=Ux,s=Cx,l=1,c=DS){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:t_++}),this.uuid=_M(),this.name="",this.source=new $M(e),this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=s,this.offset=new NM(0,0),this.repeat=new NM(1,1),this.center=new NM(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new LM,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}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.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.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,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,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==lx)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case px:e.x=e.x-Math.floor(e.x);break;case mx:e.x=e.x<0?0:1;break;case gx:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case px:e.y=e.y-Math.floor(e.y);break;case mx:e.y=e.y<0?0:1;break;case gx:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}}n_.DEFAULT_IMAGE=null,n_.DEFAULT_MAPPING=lx;class r_{constructor(e=0,t=0,n=0,r=1){r_.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}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,r){return this.x=e,this.y=t,this.z=n,this.w=r,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=void 0!==e.w?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,r=this.z,i=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r+o[12]*i,this.y=o[1]*t+o[5]*n+o[9]*r+o[13]*i,this.z=o[2]*t+o[6]*n+o[10]*r+o[14]*i,this.w=o[3]*t+o[7]*n+o[11]*r+o[15]*i,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,r,i;const o=.01,a=.1,s=e.elements,l=s[0],c=s[4],u=s[8],d=s[1],f=s[5],h=s[9],p=s[2],m=s[6],g=s[10];if(Math.abs(c-d)<o&&Math.abs(u-p)<o&&Math.abs(h-m)<o){if(Math.abs(c+d)<a&&Math.abs(u+p)<a&&Math.abs(h+m)<a&&Math.abs(l+f+g-3)<a)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,s=(f+1)/2,v=(g+1)/2,y=(c+d)/4,b=(u+p)/4,w=(h+m)/4;return e>s&&e>v?e<o?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=y/n,i=b/n):s>v?s<o?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=y/r,i=w/r):v<o?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(v),n=b/i,r=w/i),this.set(n,r,i,t),this}let v=Math.sqrt((m-h)*(m-h)+(u-p)*(u-p)+(d-c)*(d-c));return Math.abs(v)<.001&&(v=1),this.x=(m-h)/v,this.y=(u-p)/v,this.z=(d-c)/v,this.w=Math.acos((l+f+g-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class i_ extends bM{constructor(e,t,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new r_(0,0,e,t),this.scissorTest=!1,this.viewport=new r_(0,0,e,t);const r={width:e,height:t,depth:1};this.texture=new n_(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.internalFormat=void 0!==n.internalFormat?n.internalFormat:null,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:Sx,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null,this.samples=void 0!==n.samples?n.samples:0}setSize(e,t,n=1){this.width===e&&this.height===t&&this.depth===n||(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new $M(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class o_ extends n_{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=vx,this.minFilter=vx,this.wrapR=mx,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class a_ extends i_{constructor(e,t,n){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new o_(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class s_ extends n_{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=vx,this.minFilter=vx,this.wrapR=mx,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class l_ extends i_{constructor(e,t,n){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new s_(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class c_ extends i_{constructor(e,t,n,r={}){super(e,t,r),this.isWebGLMultipleRenderTargets=!0;const i=this.texture;this.texture=[];for(let e=0;e<n;e++)this.texture[e]=i.clone(),this.texture[e].isRenderTargetTexture=!0}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.texture.length;r<i;r++)this.texture[r].image.width=e,this.texture[r].image.height=t,this.texture[r].image.depth=n;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.texture.length=0;for(let t=0,n=e.texture.length;t<n;t++)this.texture[t]=e.texture[t].clone(),this.texture[t].isRenderTargetTexture=!0;return this}}class u_{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,o,a){let s=n[r+0],l=n[r+1],c=n[r+2],u=n[r+3];const d=i[o+0],f=i[o+1],h=i[o+2],p=i[o+3];if(0===a)return e[t+0]=s,e[t+1]=l,e[t+2]=c,void(e[t+3]=u);if(1===a)return e[t+0]=d,e[t+1]=f,e[t+2]=h,void(e[t+3]=p);if(u!==p||s!==d||l!==f||c!==h){let e=1-a;const t=s*d+l*f+c*h+u*p,n=t>=0?1:-1,r=1-t*t;if(r>Number.EPSILON){const i=Math.sqrt(r),o=Math.atan2(i,t*n);e=Math.sin(e*o)/i,a=Math.sin(a*o)/i}const i=a*n;if(s=s*e+d*i,l=l*e+f*i,c=c*e+h*i,u=u*e+p*i,e===1-a){const e=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=e,l*=e,c*=e,u*=e}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,o){const a=n[r],s=n[r+1],l=n[r+2],c=n[r+3],u=i[o],d=i[o+1],f=i[o+2],h=i[o+3];return e[t]=a*h+c*u+s*f-l*d,e[t+1]=s*h+c*d+l*u-a*f,e[t+2]=l*h+c*f+a*d-s*u,e[t+3]=c*h-a*u-s*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,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,r=e._y,i=e._z,o=e._order,a=Math.cos,s=Math.sin,l=a(n/2),c=a(r/2),u=a(i/2),d=s(n/2),f=s(r/2),h=s(i/2);switch(o){case"XYZ":this._x=d*c*u+l*f*h,this._y=l*f*u-d*c*h,this._z=l*c*h+d*f*u,this._w=l*c*u-d*f*h;break;case"YXZ":this._x=d*c*u+l*f*h,this._y=l*f*u-d*c*h,this._z=l*c*h-d*f*u,this._w=l*c*u+d*f*h;break;case"ZXY":this._x=d*c*u-l*f*h,this._y=l*f*u+d*c*h,this._z=l*c*h+d*f*u,this._w=l*c*u-d*f*h;break;case"ZYX":this._x=d*c*u-l*f*h,this._y=l*f*u+d*c*h,this._z=l*c*h-d*f*u,this._w=l*c*u+d*f*h;break;case"YZX":this._x=d*c*u+l*f*h,this._y=l*f*u+d*c*h,this._z=l*c*h-d*f*u,this._w=l*c*u-d*f*h;break;case"XZY":this._x=d*c*u-l*f*h,this._y=l*f*u-d*c*h,this._z=l*c*h+d*f*u,this._w=l*c*u+d*f*h;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],i=t[8],o=t[1],a=t[5],s=t[9],l=t[2],c=t[6],u=t[10],d=n+a+u;if(d>0){const e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(c-s)*e,this._y=(i-l)*e,this._z=(o-r)*e}else if(n>a&&n>u){const e=2*Math.sqrt(1+n-a-u);this._w=(c-s)/e,this._x=.25*e,this._y=(r+o)/e,this._z=(i+l)/e}else if(a>u){const e=2*Math.sqrt(1+a-n-u);this._w=(i-l)/e,this._x=(r+o)/e,this._y=.25*e,this._z=(s+c)/e}else{const e=2*Math.sqrt(1+u-n-a);this._w=(o-r)/e,this._x=(i+l)/e,this._y=(s+c)/e,this._z=.25*e}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(AM(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const r=Math.min(1,t/n);return this.slerp(e,r),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 0===e?(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,r=e._y,i=e._z,o=e._w,a=t._x,s=t._y,l=t._z,c=t._w;return this._x=n*c+o*a+r*l-i*s,this._y=r*c+o*s+i*a-n*l,this._z=i*c+o*l+n*s-r*a,this._w=o*c-n*a-r*s-i*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,r=this._y,i=this._z,o=this._w;let a=o*e._w+n*e._x+r*e._y+i*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=r,this._z=i,this;const s=1-a*a;if(s<=Number.EPSILON){const e=1-t;return this._w=e*o+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),c=Math.atan2(l,a),u=Math.sin((1-t)*c)/l,d=Math.sin(t*c)/l;return this._w=o*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),r=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(t*Math.cos(r),n*Math.sin(i),n*Math.cos(i),t*Math.sin(r))}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}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class d_{constructor(e=0,t=0,n=0){d_.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(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(h_.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(h_.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=e.elements,o=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*o,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*o,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,i=e.x,o=e.y,a=e.z,s=e.w,l=s*t+o*r-a*n,c=s*n+a*t-i*r,u=s*r+i*n-o*t,d=-i*t-o*n-a*r;return this.x=l*s+d*-i+c*-a-u*-o,this.y=c*s+d*-o+u*-i-l*-a,this.z=u*s+d*-a+l*-o-c*-i,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,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,i=e.z,o=t.x,a=t.y,s=t.z;return this.x=r*s-i*a,this.y=i*o-n*s,this.z=n*a-r*o,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return f_.copy(this).projectOnVector(e),this.sub(f_)}reflect(e){return this.sub(f_.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(AM(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}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 r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*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(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,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=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const f_=new d_,h_=new u_;class p_{constructor(e=new d_(1/0,1/0,1/0),t=new d_(-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){let t=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0;for(let s=0,l=e.length;s<l;s+=3){const l=e[s],c=e[s+1],u=e[s+2];l<t&&(t=l),c<n&&(n=c),u<r&&(r=u),l>i&&(i=l),c>o&&(o=c),u>a&&(a=u)}return this.min.set(t,n,r),this.max.set(i,o,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0;for(let s=0,l=e.count;s<l;s++){const l=e.getX(s),c=e.getY(s),u=e.getZ(s);l<t&&(t=l),c<n&&(n=c),u<r&&(r=u),l>i&&(i=l),c>o&&(o=c),u>a&&(a=u)}return this.min.set(t,n,r),this.max.set(i,o,a),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=g_.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(void 0!==n)if(t&&null!=n.attributes&&void 0!==n.attributes.position){const t=n.attributes.position;for(let n=0,r=t.count;n<r;n++)g_.fromBufferAttribute(t,n).applyMatrix4(e.matrixWorld),this.expandByPoint(g_)}else null===n.boundingBox&&n.computeBoundingBox(),v_.copy(n.boundingBox),v_.applyMatrix4(e.matrixWorld),this.union(v_);const r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],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,g_),g_.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(__),A_.subVectors(this.max,__),y_.subVectors(e.a,__),b_.subVectors(e.b,__),w_.subVectors(e.c,__),x_.subVectors(b_,y_),S_.subVectors(w_,b_),M_.subVectors(y_,w_);let t=[0,-x_.z,x_.y,0,-S_.z,S_.y,0,-M_.z,M_.y,x_.z,0,-x_.x,S_.z,0,-S_.x,M_.z,0,-M_.x,-x_.y,x_.x,0,-S_.y,S_.x,0,-M_.y,M_.x,0];return!!k_(t,y_,b_,w_,A_)&&(t=[1,0,0,0,1,0,0,0,1],!!k_(t,y_,b_,w_,A_)&&(E_.crossVectors(x_,S_),t=[E_.x,E_.y,E_.z],k_(t,y_,b_,w_,A_)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return g_.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(g_).length(),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()||(m_[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),m_[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),m_[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),m_[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),m_[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),m_[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),m_[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),m_[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(m_)),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 m_=[new d_,new d_,new d_,new d_,new d_,new d_,new d_,new d_],g_=new d_,v_=new p_,y_=new d_,b_=new d_,w_=new d_,x_=new d_,S_=new d_,M_=new d_,__=new d_,A_=new d_,E_=new d_,C_=new d_;function k_(e,t,n,r,i){for(let o=0,a=e.length-3;o<=a;o+=3){C_.fromArray(e,o);const a=i.x*Math.abs(C_.x)+i.y*Math.abs(C_.y)+i.z*Math.abs(C_.z),s=t.dot(C_),l=n.dot(C_),c=r.dot(C_);if(Math.max(-Math.max(s,l,c),Math.min(s,l,c))>a)return!1}return!0}const T_=new p_,I_=new d_,O_=new d_,R_=new d_;class P_{constructor(e=new d_,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):T_.setFromPoints(e).getCenter(n);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),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){R_.subVectors(e,this.center);const t=R_.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.add(R_.multiplyScalar(n/e)),this.radius+=n}return this}union(e){return!0===this.center.equals(e.center)?O_.set(0,0,1).multiplyScalar(e.radius):O_.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(I_.copy(e.center).add(O_)),this.expandByPoint(I_.copy(e.center).sub(O_)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const N_=new d_,L_=new d_,D_=new d_,B_=new d_,j_=new d_,F_=new d_,U_=new d_;class z_{constructor(e=new d_,t=new d_(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.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,N_)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=N_.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(N_.copy(this.direction).multiplyScalar(t).add(this.origin),N_.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){L_.copy(e).add(t).multiplyScalar(.5),D_.copy(t).sub(e).normalize(),B_.copy(this.origin).sub(L_);const i=.5*e.distanceTo(t),o=-this.direction.dot(D_),a=B_.dot(this.direction),s=-B_.dot(D_),l=B_.lengthSq(),c=Math.abs(1-o*o);let u,d,f,h;if(c>0)if(u=o*s-a,d=o*a-s,h=i*c,u>=0)if(d>=-h)if(d<=h){const e=1/c;u*=e,d*=e,f=u*(u+o*d+2*a)+d*(o*u+d+2*s)+l}else d=i,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*s)+l;else d=-i,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*s)+l;else d<=-h?(u=Math.max(0,-(-o*i+a)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+l):d<=h?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+l):(u=Math.max(0,-(o*i+a)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+l);else d=o>0?-i:i,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*s)+l;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),r&&r.copy(D_).multiplyScalar(d).add(L_),f}intersectSphere(e,t){N_.subVectors(e.center,this.origin);const n=N_.dot(this.direction),r=N_.dot(N_)-n*n,i=e.radius*e.radius;if(r>i)return null;const o=Math.sqrt(i-r),a=n-o,s=n+o;return a<0&&s<0?null:a<0?this.at(s,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?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 null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,o,a,s;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),c>=0?(i=(e.min.y-d.y)*c,o=(e.max.y-d.y)*c):(i=(e.max.y-d.y)*c,o=(e.min.y-d.y)*c),n>o||i>r?null:((i>n||n!=n)&&(n=i),(o<r||r!=r)&&(r=o),u>=0?(a=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||a>r?null:((a>n||n!=n)&&(n=a),(s<r||r!=r)&&(r=s),r<0?null:this.at(n>=0?n:r,t)))}intersectsBox(e){return null!==this.intersectBox(e,N_)}intersectTriangle(e,t,n,r,i){j_.subVectors(t,e),F_.subVectors(n,e),U_.crossVectors(j_,F_);let o,a=this.direction.dot(U_);if(a>0){if(r)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}B_.subVectors(this.origin,e);const s=o*this.direction.dot(F_.crossVectors(B_,F_));if(s<0)return null;const l=o*this.direction.dot(j_.cross(B_));if(l<0)return null;if(s+l>a)return null;const c=-o*B_.dot(U_);return c<0?null:this.at(c/a,i)}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 H_{constructor(){H_.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,n,r,i,o,a,s,l,c,u,d,f,h,p,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=l,g[6]=c,g[10]=u,g[14]=d,g[3]=f,g[7]=h,g[11]=p,g[15]=m,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 H_).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,r=1/V_.setFromMatrixColumn(e,0).length(),i=1/V_.setFromMatrixColumn(e,1).length(),o=1/V_.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,i=e.z,o=Math.cos(n),a=Math.sin(n),s=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i);if("XYZ"===e.order){const e=o*c,n=o*u,r=a*c,i=a*u;t[0]=s*c,t[4]=-s*u,t[8]=l,t[1]=n+r*l,t[5]=e-i*l,t[9]=-a*s,t[2]=i-e*l,t[6]=r+n*l,t[10]=o*s}else if("YXZ"===e.order){const e=s*c,n=s*u,r=l*c,i=l*u;t[0]=e+i*a,t[4]=r*a-n,t[8]=o*l,t[1]=o*u,t[5]=o*c,t[9]=-a,t[2]=n*a-r,t[6]=i+e*a,t[10]=o*s}else if("ZXY"===e.order){const e=s*c,n=s*u,r=l*c,i=l*u;t[0]=e-i*a,t[4]=-o*u,t[8]=r+n*a,t[1]=n+r*a,t[5]=o*c,t[9]=i-e*a,t[2]=-o*l,t[6]=a,t[10]=o*s}else if("ZYX"===e.order){const e=o*c,n=o*u,r=a*c,i=a*u;t[0]=s*c,t[4]=r*l-n,t[8]=e*l+i,t[1]=s*u,t[5]=i*l+e,t[9]=n*l-r,t[2]=-l,t[6]=a*s,t[10]=o*s}else if("YZX"===e.order){const e=o*s,n=o*l,r=a*s,i=a*l;t[0]=s*c,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=o*c,t[9]=-a*c,t[2]=-l*c,t[6]=n*u+r,t[10]=e-i*u}else if("XZY"===e.order){const e=o*s,n=o*l,r=a*s,i=a*l;t[0]=s*c,t[4]=-u,t[8]=l*c,t[1]=e*u+i,t[5]=o*c,t[9]=n*u-r,t[2]=r*u-n,t[6]=a*c,t[10]=i*u+e}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(G_,e,q_)}lookAt(e,t,n){const r=this.elements;return J_.subVectors(e,t),0===J_.lengthSq()&&(J_.z=1),J_.normalize(),K_.crossVectors(n,J_),0===K_.lengthSq()&&(1===Math.abs(n.z)?J_.x+=1e-4:J_.z+=1e-4,J_.normalize(),K_.crossVectors(n,J_)),K_.normalize(),Y_.crossVectors(J_,K_),r[0]=K_.x,r[4]=Y_.x,r[8]=J_.x,r[1]=K_.y,r[5]=Y_.y,r[9]=J_.y,r[2]=K_.z,r[6]=Y_.z,r[10]=J_.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,o=n[0],a=n[4],s=n[8],l=n[12],c=n[1],u=n[5],d=n[9],f=n[13],h=n[2],p=n[6],m=n[10],g=n[14],v=n[3],y=n[7],b=n[11],w=n[15],x=r[0],S=r[4],M=r[8],_=r[12],A=r[1],E=r[5],C=r[9],k=r[13],T=r[2],I=r[6],O=r[10],R=r[14],P=r[3],N=r[7],L=r[11],D=r[15];return i[0]=o*x+a*A+s*T+l*P,i[4]=o*S+a*E+s*I+l*N,i[8]=o*M+a*C+s*O+l*L,i[12]=o*_+a*k+s*R+l*D,i[1]=c*x+u*A+d*T+f*P,i[5]=c*S+u*E+d*I+f*N,i[9]=c*M+u*C+d*O+f*L,i[13]=c*_+u*k+d*R+f*D,i[2]=h*x+p*A+m*T+g*P,i[6]=h*S+p*E+m*I+g*N,i[10]=h*M+p*C+m*O+g*L,i[14]=h*_+p*k+m*R+g*D,i[3]=v*x+y*A+b*T+w*P,i[7]=v*S+y*E+b*I+w*N,i[11]=v*M+y*C+b*O+w*L,i[15]=v*_+y*k+b*R+w*D,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],o=e[1],a=e[5],s=e[9],l=e[13],c=e[2],u=e[6],d=e[10],f=e[14];return e[3]*(+i*s*u-r*l*u-i*a*d+n*l*d+r*a*f-n*s*f)+e[7]*(+t*s*f-t*l*d+i*o*d-r*o*f+r*l*c-i*s*c)+e[11]*(+t*l*u-t*a*f-i*o*u+n*o*f+i*a*c-n*l*c)+e[15]*(-r*a*c-t*s*u+t*a*d+r*o*u-n*o*d+n*s*c)}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 r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],u=e[9],d=e[10],f=e[11],h=e[12],p=e[13],m=e[14],g=e[15],v=u*m*l-p*d*l+p*s*f-a*m*f-u*s*g+a*d*g,y=h*d*l-c*m*l-h*s*f+o*m*f+c*s*g-o*d*g,b=c*p*l-h*u*l+h*a*f-o*p*f-c*a*g+o*u*g,w=h*u*s-c*p*s-h*a*d+o*p*d+c*a*m-o*u*m,x=t*v+n*y+r*b+i*w;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/x;return e[0]=v*S,e[1]=(p*d*i-u*m*i-p*r*f+n*m*f+u*r*g-n*d*g)*S,e[2]=(a*m*i-p*s*i+p*r*l-n*m*l-a*r*g+n*s*g)*S,e[3]=(u*s*i-a*d*i-u*r*l+n*d*l+a*r*f-n*s*f)*S,e[4]=y*S,e[5]=(c*m*i-h*d*i+h*r*f-t*m*f-c*r*g+t*d*g)*S,e[6]=(h*s*i-o*m*i-h*r*l+t*m*l+o*r*g-t*s*g)*S,e[7]=(o*d*i-c*s*i+c*r*l-t*d*l-o*r*f+t*s*f)*S,e[8]=b*S,e[9]=(h*u*i-c*p*i-h*n*f+t*p*f+c*n*g-t*u*g)*S,e[10]=(o*p*i-h*a*i+h*n*l-t*p*l-o*n*g+t*a*g)*S,e[11]=(c*a*i-o*u*i-c*n*l+t*u*l+o*n*f-t*a*f)*S,e[12]=w*S,e[13]=(c*p*r-h*u*r+h*n*d-t*p*d-c*n*m+t*u*m)*S,e[14]=(h*a*r-o*p*r-h*n*s+t*p*s+o*n*m-t*a*m)*S,e[15]=(o*u*r-c*a*r+c*n*s-t*u*s-o*n*d+t*a*d)*S,this}scale(e){const t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,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],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return 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),r=Math.sin(t),i=1-n,o=e.x,a=e.y,s=e.z,l=i*o,c=i*a;return this.set(l*o+n,l*a-r*s,l*s+r*a,0,l*a+r*s,c*a+n,c*s-r*o,0,l*s-r*a,c*s+r*o,i*s*s+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,r,i,o){return this.set(1,n,i,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,i=t._x,o=t._y,a=t._z,s=t._w,l=i+i,c=o+o,u=a+a,d=i*l,f=i*c,h=i*u,p=o*c,m=o*u,g=a*u,v=s*l,y=s*c,b=s*u,w=n.x,x=n.y,S=n.z;return r[0]=(1-(p+g))*w,r[1]=(f+b)*w,r[2]=(h-y)*w,r[3]=0,r[4]=(f-b)*x,r[5]=(1-(d+g))*x,r[6]=(m+v)*x,r[7]=0,r[8]=(h+y)*S,r[9]=(m-v)*S,r[10]=(1-(d+p))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let i=V_.set(r[0],r[1],r[2]).length();const o=V_.set(r[4],r[5],r[6]).length(),a=V_.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],W_.copy(this);const s=1/i,l=1/o,c=1/a;return W_.elements[0]*=s,W_.elements[1]*=s,W_.elements[2]*=s,W_.elements[4]*=l,W_.elements[5]*=l,W_.elements[6]*=l,W_.elements[8]*=c,W_.elements[9]*=c,W_.elements[10]*=c,t.setFromRotationMatrix(W_),n.x=i,n.y=o,n.z=a,this}makePerspective(e,t,n,r,i,o){const a=this.elements,s=2*i/(t-e),l=2*i/(n-r),c=(t+e)/(t-e),u=(n+r)/(n-r),d=-(o+i)/(o-i),f=-2*o*i/(o-i);return a[0]=s,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=l,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,r,i,o){const a=this.elements,s=1/(t-e),l=1/(n-r),c=1/(o-i),u=(t+e)*s,d=(n+r)*l,f=(o+i)*c;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])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 V_=new d_,W_=new H_,G_=new d_(0,0,0),q_=new d_(1,1,1),K_=new d_,Y_=new d_,J_=new d_,Q_=new H_,X_=new u_;class Z_{constructor(e=0,t=0,n=0,r=Z_.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}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,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,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 r=e.elements,i=r[0],o=r[4],a=r[8],s=r[1],l=r[5],c=r[9],u=r[2],d=r[6],f=r[10];switch(t){case"XYZ":this._y=Math.asin(AM(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,f),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-AM(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(s,l)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(AM(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(s,i));break;case"ZYX":this._y=Math.asin(-AM(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(AM(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-AM(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,i)):(this._x=Math.atan2(-c,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Q_.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Q_,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return X_.setFromEuler(this),this.setFromQuaternion(X_,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],void 0!==e[3]&&(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}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}Z_.DefaultOrder="XYZ",Z_.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class $_{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 0!=(this.mask&e.mask)}isEnabled(e){return 0!=(this.mask&(1<<e|0))}}let eA=0;const tA=new d_,nA=new u_,rA=new H_,iA=new d_,oA=new d_,aA=new d_,sA=new u_,lA=new d_(1,0,0),cA=new d_(0,1,0),uA=new d_(0,0,1),dA={type:"added"},fA={type:"removed"};class hA extends bM{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:eA++}),this.uuid=_M(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=hA.DefaultUp.clone();const e=new d_,t=new Z_,n=new u_,r=new d_(1,1,1);t._onChange((function(){n.setFromEuler(t,!1)})),n._onChange((function(){t.setFromQuaternion(n,void 0,!1)})),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:r},modelViewMatrix:{value:new H_},normalMatrix:{value:new LM}}),this.matrix=new H_,this.matrixWorld=new H_,this.matrixAutoUpdate=hA.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=hA.DefaultMatrixWorldAutoUpdate,this.layers=new $_,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return nA.setFromAxisAngle(e,t),this.quaternion.multiply(nA),this}rotateOnWorldAxis(e,t){return nA.setFromAxisAngle(e,t),this.quaternion.premultiply(nA),this}rotateX(e){return this.rotateOnAxis(lA,e)}rotateY(e){return this.rotateOnAxis(cA,e)}rotateZ(e){return this.rotateOnAxis(uA,e)}translateOnAxis(e,t){return tA.copy(e).applyQuaternion(this.quaternion),this.position.add(tA.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(lA,e)}translateY(e){return this.translateOnAxis(cA,e)}translateZ(e){return this.translateOnAxis(uA,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(rA.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?iA.copy(e):iA.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),oA.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?rA.lookAt(oA,iA,this.up):rA.lookAt(iA,oA,this.up),this.quaternion.setFromRotationMatrix(rA),r&&(rA.extractRotation(r.matrixWorld),nA.setFromRotationMatrix(rA),this.quaternion.premultiply(nA.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);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?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(dA)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(fA)),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(fA)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),rA.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),rA.multiply(e.parent.matrixWorld)),e.applyMatrix4(rA),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const r=this.children[n].getObjectByProperty(e,t);if(void 0!==r)return r}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(oA,e,aA),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(oA,sA,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,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(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)&&(null===this.parent?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,r=t.length;n<r;n++){const r=t[n];!0!==r.matrixWorldAutoUpdate&&!0!==e||r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(!0===e&&null!==n&&!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){const e=this.children;for(let t=0,n=e.length;t<n;t++){const n=e[t];!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=void 0===e||"string"==typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const r={};function i(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),!0===this.castShadow&&(r.castShadow=!0),!0===this.receiveShadow&&(r.receiveShadow=!0),!1===this.visible&&(r.visible=!1),!1===this.frustumCulled&&(r.frustumCulled=!1),0!==this.renderOrder&&(r.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(r.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){const r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){const n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){const t=o(e.geometries),r=o(e.materials),i=o(e.textures),a=o(e.images),s=o(e.shapes),l=o(e.skeletons),c=o(e.animations),u=o(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),a.length>0&&(n.images=a),s.length>0&&(n.shapes=s),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),u.length>0&&(n.nodes=u)}return n.object=r,n;function o(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){const n=e.children[t];this.add(n.clone())}return this}}hA.DefaultUp=new d_(0,1,0),hA.DefaultMatrixAutoUpdate=!0,hA.DefaultMatrixWorldAutoUpdate=!0;const pA=new d_,mA=new d_,gA=new d_,vA=new d_,yA=new d_,bA=new d_,wA=new d_,xA=new d_,SA=new d_,MA=new d_;class _A{constructor(e=new d_,t=new d_,n=new d_){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),pA.subVectors(e,t),r.cross(pA);const i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){pA.subVectors(r,t),mA.subVectors(n,t),gA.subVectors(e,t);const o=pA.dot(pA),a=pA.dot(mA),s=pA.dot(gA),l=mA.dot(mA),c=mA.dot(gA),u=o*l-a*a;if(0===u)return i.set(-2,-1,-1);const d=1/u,f=(l*s-a*c)*d,h=(o*c-a*s)*d;return i.set(1-f-h,h,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,vA),vA.x>=0&&vA.y>=0&&vA.x+vA.y<=1}static getUV(e,t,n,r,i,o,a,s){return this.getBarycoord(e,t,n,r,vA),s.set(0,0),s.addScaledVector(i,vA.x),s.addScaledVector(o,vA.y),s.addScaledVector(a,vA.z),s}static isFrontFacing(e,t,n,r){return pA.subVectors(n,t),mA.subVectors(e,t),pA.cross(mA).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),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 pA.subVectors(this.c,this.b),mA.subVectors(this.a,this.b),.5*pA.cross(mA).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return _A.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return _A.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,r,i){return _A.getUV(e,this.a,this.b,this.c,t,n,r,i)}containsPoint(e){return _A.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return _A.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,i=this.c;let o,a;yA.subVectors(r,n),bA.subVectors(i,n),xA.subVectors(e,n);const s=yA.dot(xA),l=bA.dot(xA);if(s<=0&&l<=0)return t.copy(n);SA.subVectors(e,r);const c=yA.dot(SA),u=bA.dot(SA);if(c>=0&&u<=c)return t.copy(r);const d=s*u-c*l;if(d<=0&&s>=0&&c<=0)return o=s/(s-c),t.copy(n).addScaledVector(yA,o);MA.subVectors(e,i);const f=yA.dot(MA),h=bA.dot(MA);if(h>=0&&f<=h)return t.copy(i);const p=f*l-s*h;if(p<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(bA,a);const m=c*h-f*u;if(m<=0&&u-c>=0&&f-h>=0)return wA.subVectors(i,r),a=(u-c)/(u-c+(f-h)),t.copy(r).addScaledVector(wA,a);const g=1/(m+p+d);return o=p*g,a=d*g,t.copy(n).addScaledVector(yA,o).addScaledVector(bA,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let AA=0;class EA extends bM{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:AA++}),this.uuid=_M(),this.name="",this.type="Material",this.blending=_w,this.side=ww,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=jw,this.blendDst=Fw,this.blendEquation=Tw,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Yw,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=aM,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=qS,this.stencilZFail=qS,this.stencilZPass=qS,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}const r=this[t];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(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()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(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.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,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==_w&&(n.blending=this.blending),this.side!==ww&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t){const t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let r=0;r!==e;++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.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,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){!0===e&&this.version++}}class CA extends EA{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new QM(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$w,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const kA=new d_,TA=new NM;class IA{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===n,this.usage=sM,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,n=this.count;t<n;t++)TA.fromBufferAttribute(this,t),TA.applyMatrix3(e),this.setXY(t,TA.x,TA.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)kA.fromBufferAttribute(this,t),kA.applyMatrix3(e),this.setXYZ(t,kA.x,kA.y,kA.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)kA.fromBufferAttribute(this,t),kA.applyMatrix4(e),this.setXYZ(t,kA.x,kA.y,kA.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)kA.fromBufferAttribute(this,t),kA.applyNormalMatrix(e),this.setXYZ(t,kA.x,kA.y,kA.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)kA.fromBufferAttribute(this,t),kA.transformDirection(e),this.setXYZ(t,kA.x,kA.y,kA.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=OM(t,this.array)),t}setX(e,t){return this.normalized&&(t=RM(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=OM(t,this.array)),t}setY(e,t){return this.normalized&&(t=RM(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=OM(t,this.array)),t}setZ(e,t){return this.normalized&&(t=RM(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=OM(t,this.array)),t}setW(e,t){return this.normalized&&(t=RM(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=RM(t,this.array),n=RM(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=RM(t,this.array),n=RM(n,this.array),r=RM(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=RM(t,this.array),n=RM(n,this.array),r=RM(r,this.array),i=RM(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,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!==sM&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}}class OA extends IA{constructor(e,t,n){super(new Int8Array(e),t,n)}}class RA extends IA{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class PA extends IA{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class NA extends IA{constructor(e,t,n){super(new Int16Array(e),t,n)}}class LA extends IA{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class DA extends IA{constructor(e,t,n){super(new Int32Array(e),t,n)}}class BA extends IA{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class jA extends IA{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}}class FA extends IA{constructor(e,t,n){super(new Float32Array(e),t,n)}}class UA extends IA{constructor(e,t,n){super(new Float64Array(e),t,n)}}let zA=0;const HA=new H_,VA=new hA,WA=new d_,GA=new p_,qA=new p_,KA=new d_;class YA extends bM{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:zA++}),this.uuid=_M(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(DM(e)?BA:LA)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}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;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const t=(new LM).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(e),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return HA.makeRotationFromQuaternion(e),this.applyMatrix4(HA),this}rotateX(e){return HA.makeRotationX(e),this.applyMatrix4(HA),this}rotateY(e){return HA.makeRotationY(e),this.applyMatrix4(HA),this}rotateZ(e){return HA.makeRotationZ(e),this.applyMatrix4(HA),this}translate(e,t,n){return HA.makeTranslation(e,t,n),this.applyMatrix4(HA),this}scale(e,t,n){return HA.makeScale(e,t,n),this.applyMatrix4(HA),this}lookAt(e){return VA.lookAt(e),VA.updateMatrix(),this.applyMatrix4(VA.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(WA).negate(),this.translate(WA.x,WA.y,WA.z),this}setFromPoints(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new FA(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new p_);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new d_(-1/0,-1/0,-1/0),new d_(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];GA.setFromBufferAttribute(n),this.morphTargetsRelative?(KA.addVectors(this.boundingBox.min,GA.min),this.boundingBox.expandByPoint(KA),KA.addVectors(this.boundingBox.max,GA.max),this.boundingBox.expandByPoint(KA)):(this.boundingBox.expandByPoint(GA.min),this.boundingBox.expandByPoint(GA.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(){null===this.boundingSphere&&(this.boundingSphere=new P_);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new d_,1/0);if(e){const n=this.boundingSphere.center;if(GA.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];qA.setFromBufferAttribute(n),this.morphTargetsRelative?(KA.addVectors(GA.min,qA.min),GA.expandByPoint(KA),KA.addVectors(GA.max,qA.max),GA.expandByPoint(KA)):(GA.expandByPoint(qA.min),GA.expandByPoint(qA.max))}GA.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)KA.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(KA));if(t)for(let i=0,o=t.length;i<o;i++){const o=t[i],a=this.morphTargetsRelative;for(let t=0,i=o.count;t<i;t++)KA.fromBufferAttribute(o,t),a&&(WA.fromBufferAttribute(e,t),KA.add(WA)),r=Math.max(r,n.distanceToSquared(KA))}this.boundingSphere.radius=Math.sqrt(r),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(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.array,r=t.position.array,i=t.normal.array,o=t.uv.array,a=r.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new IA(new Float32Array(4*a),4));const s=this.getAttribute("tangent").array,l=[],c=[];for(let e=0;e<a;e++)l[e]=new d_,c[e]=new d_;const u=new d_,d=new d_,f=new d_,h=new NM,p=new NM,m=new NM,g=new d_,v=new d_;function y(e,t,n){u.fromArray(r,3*e),d.fromArray(r,3*t),f.fromArray(r,3*n),h.fromArray(o,2*e),p.fromArray(o,2*t),m.fromArray(o,2*n),d.sub(u),f.sub(u),p.sub(h),m.sub(h);const i=1/(p.x*m.y-m.x*p.y);isFinite(i)&&(g.copy(d).multiplyScalar(m.y).addScaledVector(f,-p.y).multiplyScalar(i),v.copy(f).multiplyScalar(p.x).addScaledVector(d,-m.x).multiplyScalar(i),l[e].add(g),l[t].add(g),l[n].add(g),c[e].add(v),c[t].add(v),c[n].add(v))}let b=this.groups;0===b.length&&(b=[{start:0,count:n.length}]);for(let e=0,t=b.length;e<t;++e){const t=b[e],r=t.start;for(let e=r,i=r+t.count;e<i;e+=3)y(n[e+0],n[e+1],n[e+2])}const w=new d_,x=new d_,S=new d_,M=new d_;function _(e){S.fromArray(i,3*e),M.copy(S);const t=l[e];w.copy(t),w.sub(S.multiplyScalar(S.dot(t))).normalize(),x.crossVectors(M,t);const n=x.dot(c[e])<0?-1:1;s[4*e]=w.x,s[4*e+1]=w.y,s[4*e+2]=w.z,s[4*e+3]=n}for(let e=0,t=b.length;e<t;++e){const t=b[e],r=t.start;for(let e=r,i=r+t.count;e<i;e+=3)_(n[e+0]),_(n[e+1]),_(n[e+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let n=this.getAttribute("normal");if(void 0===n)n=new IA(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);const r=new d_,i=new d_,o=new d_,a=new d_,s=new d_,l=new d_,c=new d_,u=new d_;if(e)for(let d=0,f=e.count;d<f;d+=3){const f=e.getX(d+0),h=e.getX(d+1),p=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,h),o.fromBufferAttribute(t,p),c.subVectors(o,i),u.subVectors(r,i),c.cross(u),a.fromBufferAttribute(n,f),s.fromBufferAttribute(n,h),l.fromBufferAttribute(n,p),a.add(c),s.add(c),l.add(c),n.setXYZ(f,a.x,a.y,a.z),n.setXYZ(h,s.x,s.y,s.z),n.setXYZ(p,l.x,l.y,l.z)}else for(let e=0,a=t.count;e<a;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),o.fromBufferAttribute(t,e+2),c.subVectors(o,i),u.subVectors(r,i),c.cross(u),n.setXYZ(e+0,c.x,c.y,c.z),n.setXYZ(e+1,c.x,c.y,c.z),n.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeBufferGeometries() instead."),this}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)KA.fromBufferAttribute(e,t),KA.normalize(),e.setXYZ(t,KA.x,KA.y,KA.z)}toNonIndexed(){function e(e,t){const n=e.array,r=e.itemSize,i=e.normalized,o=new n.constructor(t.length*r);let a=0,s=0;for(let i=0,l=t.length;i<l;i++){a=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)o[s++]=n[a++]}return new IA(o,r,i)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new YA,n=this.index.array,r=this.attributes;for(const i in r){const o=e(r[i],n);t.setAttribute(i,o)}const i=this.morphAttributes;for(const r in i){const o=[],a=i[r];for(let t=0,r=a.length;t<r;t++){const r=e(a[t],n);o.push(r)}t.morphAttributes[r]=o}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let e=0,n=o.length;e<n;e++){const n=o[e];t.addGroup(n.start,n.count,n.materialIndex)}return t}toJSON(){const e={metadata:{version:4.5,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),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const r=n[t];e.data.attributes[t]=r.toJSON(e.data)}const r={};let i=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],o=[];for(let t=0,r=n.length;t<r;t++){const r=n[t];o.push(r.toJSON(e.data))}o.length>0&&(r[t]=o,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const r=e.attributes;for(const e in r){const n=r[e];this.setAttribute(e,n.clone(t))}const i=e.morphAttributes;for(const e in i){const n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let e=0,t=o.length;e<t;e++){const t=o[e];this.addGroup(t.start,t.count,t.materialIndex)}const a=e.boundingBox;null!==a&&(this.boundingBox=a.clone());const s=e.boundingSphere;return null!==s&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,void 0!==e.parameters&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}const JA=new H_,QA=new z_,XA=new P_,ZA=new d_,$A=new d_,eE=new d_,tE=new d_,nE=new d_,rE=new d_,iE=new d_,oE=new d_,aE=new d_,sE=new NM,lE=new NM,cE=new NM,uE=new d_,dE=new d_;class fE extends hA{constructor(e=new YA,t=new CA){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}raycast(e,t){const n=this.geometry,r=this.material,i=this.matrixWorld;if(void 0===r)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),XA.copy(n.boundingSphere),XA.applyMatrix4(i),!1===e.ray.intersectsSphere(XA))return;if(JA.copy(i).invert(),QA.copy(e.ray).applyMatrix4(JA),null!==n.boundingBox&&!1===QA.intersectsBox(n.boundingBox))return;let o;const a=n.index,s=n.attributes.position,l=n.morphAttributes.position,c=n.morphTargetsRelative,u=n.attributes.uv,d=n.attributes.uv2,f=n.groups,h=n.drawRange;if(null!==a)if(Array.isArray(r))for(let n=0,i=f.length;n<i;n++){const i=f[n],p=r[i.materialIndex];for(let n=Math.max(i.start,h.start),r=Math.min(a.count,Math.min(i.start+i.count,h.start+h.count));n<r;n+=3){const r=a.getX(n),f=a.getX(n+1),h=a.getX(n+2);o=hE(this,p,e,QA,s,l,c,u,d,r,f,h),o&&(o.faceIndex=Math.floor(n/3),o.face.materialIndex=i.materialIndex,t.push(o))}}else{for(let n=Math.max(0,h.start),i=Math.min(a.count,h.start+h.count);n<i;n+=3){const i=a.getX(n),f=a.getX(n+1),h=a.getX(n+2);o=hE(this,r,e,QA,s,l,c,u,d,i,f,h),o&&(o.faceIndex=Math.floor(n/3),t.push(o))}}else if(void 0!==s)if(Array.isArray(r))for(let n=0,i=f.length;n<i;n++){const i=f[n],a=r[i.materialIndex];for(let n=Math.max(i.start,h.start),r=Math.min(s.count,Math.min(i.start+i.count,h.start+h.count));n<r;n+=3){o=hE(this,a,e,QA,s,l,c,u,d,n,n+1,n+2),o&&(o.faceIndex=Math.floor(n/3),o.face.materialIndex=i.materialIndex,t.push(o))}}else{for(let n=Math.max(0,h.start),i=Math.min(s.count,h.start+h.count);n<i;n+=3){o=hE(this,r,e,QA,s,l,c,u,d,n,n+1,n+2),o&&(o.faceIndex=Math.floor(n/3),t.push(o))}}}}function hE(e,t,n,r,i,o,a,s,l,c,u,d){ZA.fromBufferAttribute(i,c),$A.fromBufferAttribute(i,u),eE.fromBufferAttribute(i,d);const f=e.morphTargetInfluences;if(o&&f){iE.set(0,0,0),oE.set(0,0,0),aE.set(0,0,0);for(let e=0,t=o.length;e<t;e++){const t=f[e],n=o[e];0!==t&&(tE.fromBufferAttribute(n,c),nE.fromBufferAttribute(n,u),rE.fromBufferAttribute(n,d),a?(iE.addScaledVector(tE,t),oE.addScaledVector(nE,t),aE.addScaledVector(rE,t)):(iE.addScaledVector(tE.sub(ZA),t),oE.addScaledVector(nE.sub($A),t),aE.addScaledVector(rE.sub(eE),t)))}ZA.add(iE),$A.add(oE),eE.add(aE)}e.isSkinnedMesh&&(e.boneTransform(c,ZA),e.boneTransform(u,$A),e.boneTransform(d,eE));const h=function(e,t,n,r,i,o,a,s){let l;if(l=t.side===xw?r.intersectTriangle(a,o,i,!0,s):r.intersectTriangle(i,o,a,t.side!==Sw,s),null===l)return null;dE.copy(s),dE.applyMatrix4(e.matrixWorld);const c=n.ray.origin.distanceTo(dE);return c<n.near||c>n.far?null:{distance:c,point:dE.clone(),object:e}}(e,t,n,r,ZA,$A,eE,uE);if(h){s&&(sE.fromBufferAttribute(s,c),lE.fromBufferAttribute(s,u),cE.fromBufferAttribute(s,d),h.uv=_A.getUV(uE,ZA,$A,eE,sE,lE,cE,new NM)),l&&(sE.fromBufferAttribute(l,c),lE.fromBufferAttribute(l,u),cE.fromBufferAttribute(l,d),h.uv2=_A.getUV(uE,ZA,$A,eE,sE,lE,cE,new NM));const e={a:c,b:u,c:d,normal:new d_,materialIndex:0};_A.getNormal(ZA,$A,eE,e.normal),h.face=e}return h}class pE extends YA{constructor(e=1,t=1,n=1,r=1,i=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:o};const a=this;r=Math.floor(r),i=Math.floor(i),o=Math.floor(o);const s=[],l=[],c=[],u=[];let d=0,f=0;function h(e,t,n,r,i,o,h,p,m,g,v){const y=o/m,b=h/g,w=o/2,x=h/2,S=p/2,M=m+1,_=g+1;let A=0,E=0;const C=new d_;for(let o=0;o<_;o++){const a=o*b-x;for(let s=0;s<M;s++){const d=s*y-w;C[e]=d*r,C[t]=a*i,C[n]=S,l.push(C.x,C.y,C.z),C[e]=0,C[t]=0,C[n]=p>0?1:-1,c.push(C.x,C.y,C.z),u.push(s/m),u.push(1-o/g),A+=1}}for(let e=0;e<g;e++)for(let t=0;t<m;t++){const n=d+t+M*e,r=d+t+M*(e+1),i=d+(t+1)+M*(e+1),o=d+(t+1)+M*e;s.push(n,r,o),s.push(r,i,o),E+=6}a.addGroup(f,E,v),f+=E,d+=A}h("z","y","x",-1,-1,n,t,e,o,i,0),h("z","y","x",1,-1,n,t,-e,o,i,1),h("x","z","y",1,1,e,n,t,r,o,2),h("x","z","y",1,-1,e,n,-t,r,o,3),h("x","y","z",1,-1,e,t,n,r,i,4),h("x","y","z",-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute("position",new FA(l,3)),this.setAttribute("normal",new FA(c,3)),this.setAttribute("uv",new FA(u,2))}static fromJSON(e){return new pE(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function mE(e){const t={};for(const n in e){t[n]={};for(const r in e[n]){const i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}}return t}function gE(e){const t={};for(let n=0;n<e.length;n++){const r=mE(e[n]);for(const e in r)t[e]=r[e]}return t}const vE={clone:mE,merge:gE};class yE extends EA{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=mE(e.uniforms),this.uniformsGroups=function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}(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 n in this.uniforms){const r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:"m4",value:r.toArray()}:t.uniforms[n]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class bE extends hA{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new H_,this.projectionMatrix=new H_,this.projectionMatrixInverse=new H_}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class wE extends bE{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,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=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*MM*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*SM*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*MM*Math.atan(Math.tan(.5*SM*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,r,i,o){this.aspect=e/t,null===this.view&&(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=r,this.view.width=i,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*SM*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r;const o=this.view;if(null!==this.view&&this.view.enabled){const e=o.fullWidth,a=o.fullHeight;i+=o.offsetX*r/e,t-=o.offsetY*n/a,r*=o.width/e,n*=o.height/a}const a=this.filmOffset;0!==a&&(i+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far),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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const xE=90;class SE extends hA{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n;const r=new wE(xE,1,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new d_(1,0,0)),this.add(r);const i=new wE(xE,1,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new d_(-1,0,0)),this.add(i);const o=new wE(xE,1,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new d_(0,1,0)),this.add(o);const a=new wE(xE,1,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new d_(0,-1,0)),this.add(a);const s=new wE(xE,1,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new d_(0,0,1)),this.add(s);const l=new wE(xE,1,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new d_(0,0,-1)),this.add(l)}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[r,i,o,a,s,l]=this.children,c=e.getRenderTarget(),u=e.toneMapping,d=e.xr.enabled;e.toneMapping=nx,e.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,r),e.setRenderTarget(n,1),e.render(t,i),e.setRenderTarget(n,2),e.render(t,o),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=f,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(c),e.toneMapping=u,e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class ME extends n_{constructor(e,t,n,r,i,o,a,s,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:cx,n,r,i,o,a,s,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class _E extends i_{constructor(e,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new ME(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:Sx}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},r=new pE(5,5,5),i=new yE({name:"CubemapFromEquirect",uniforms:mE(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:xw,blending:Mw});i.uniforms.tEquirect.value=t;const o=new fE(r,i),a=t.minFilter;t.minFilter===Ax&&(t.minFilter=Sx);return new SE(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,r){const i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}}const AE=new d_,EE=new d_,CE=new LM;class kE{constructor(e=new d_(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,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=AE.subVectors(n,t).cross(EE.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,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(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const n=e.delta(AE),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(n).multiplyScalar(i).add(e.start)}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||CE.getNormalMatrix(e),r=this.coplanarPoint(AE).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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 TE=new P_,IE=new d_;class OE{constructor(e=new kE,t=new kE,n=new kE,r=new kE,i=new kE,o=new kE){this.planes=[e,t,n,r,i,o]}set(e,t,n,r,i,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(r),a[4].copy(i),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],c=n[6],u=n[7],d=n[8],f=n[9],h=n[10],p=n[11],m=n[12],g=n[13],v=n[14],y=n[15];return t[0].setComponents(a-r,u-s,p-d,y-m).normalize(),t[1].setComponents(a+r,u+s,p+d,y+m).normalize(),t[2].setComponents(a+i,u+l,p+f,y+g).normalize(),t[3].setComponents(a-i,u-l,p-f,y-g).normalize(),t[4].setComponents(a-o,u-c,p-h,y-v).normalize(),t[5].setComponents(a+o,u+c,p+h,y+v).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),TE.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(TE)}intersectsSprite(e){return TE.center.set(0,0,0),TE.radius=.7071067811865476,TE.applyMatrix4(e.matrixWorld),this.intersectsSphere(TE)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)<r)return!1}return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(IE.x=r.normal.x>0?e.max.x:e.min.x,IE.y=r.normal.y>0?e.max.y:e.min.y,IE.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(IE)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function RE(){let e=null,t=!1,n=null,r=null;function i(t,o){n(t,o),r=e.requestAnimationFrame(i)}return{start:function(){!0!==t&&null!==n&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function PE(e,t){const n=t.isWebGL2,r=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),r.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=r.get(t);n&&(e.deleteBuffer(n.buffer),r.delete(t))},update:function(t,i){if(t.isGLBufferAttribute){const e=r.get(t);return void((!e||e.version<t.version)&&r.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const o=r.get(t);void 0===o?r.set(t,function(t,r){const i=t.array,o=t.usage,a=e.createBuffer();let s;if(e.bindBuffer(r,a),e.bufferData(r,i,o),t.onUploadCallback(),i instanceof Float32Array)s=5126;else if(i instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!n)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");s=5131}else s=5123;else if(i instanceof Int16Array)s=5122;else if(i instanceof Uint32Array)s=5125;else if(i instanceof Int32Array)s=5124;else if(i instanceof Int8Array)s=5120;else if(i instanceof Uint8Array)s=5121;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);s=5121}return{buffer:a,type:s,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}(t,i)):o.version<t.version&&(!function(t,r,i){const o=r.array,a=r.updateRange;e.bindBuffer(i,t),-1===a.count?e.bufferSubData(i,0,o):(n?e.bufferSubData(i,a.offset*o.BYTES_PER_ELEMENT,o,a.offset,a.count):e.bufferSubData(i,a.offset*o.BYTES_PER_ELEMENT,o.subarray(a.offset,a.offset+a.count)),a.count=-1)}(o.buffer,t,i),o.version=t.version)}}}class NE extends YA{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const i=e/2,o=t/2,a=Math.floor(n),s=Math.floor(r),l=a+1,c=s+1,u=e/a,d=t/s,f=[],h=[],p=[],m=[];for(let e=0;e<c;e++){const t=e*d-o;for(let n=0;n<l;n++){const r=n*u-i;h.push(r,-t,0),p.push(0,0,1),m.push(n/a),m.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<a;t++){const n=t+l*e,r=t+l*(e+1),i=t+1+l*(e+1),o=t+1+l*e;f.push(n,r,o),f.push(r,i,o)}this.setIndex(f),this.setAttribute("position",new FA(h,3)),this.setAttribute("normal",new FA(p,3)),this.setAttribute("uv",new FA(m,2))}static fromJSON(e){return new NE(e.width,e.height,e.widthSegments,e.heightSegments)}}const LE={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\n#ifdef USE_IRIDESCENCE\n\tvec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\t return vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat R21 = R12;\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = dFdy( surf_pos.xyz );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert\n#define Material_LightProbeLOD( material )\t(0)",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid 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 ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );\n\t#else\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if defined( USE_SHADOWMAP ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_COORDS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef texture2DLodEXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tgl_FragColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tgl_FragColor = vec4( mix( pow( gl_FragColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), gl_FragColor.rgb * 0.0773993808, vec3( lessThanEqual( gl_FragColor.rgb, vec3( 0.04045 ) ) ) ), gl_FragColor.w );\n\t#endif\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}"},DE={common:{diffuse:{value:new QM(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new LM},uv2Transform:{value:new LM},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new NM(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new QM(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new QM(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new LM}},sprite:{diffuse:{value:new QM(16777215)},opacity:{value:1},center:{value:new NM(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new LM}}},BE={basic:{uniforms:gE([DE.common,DE.specularmap,DE.envmap,DE.aomap,DE.lightmap,DE.fog]),vertexShader:LE.meshbasic_vert,fragmentShader:LE.meshbasic_frag},lambert:{uniforms:gE([DE.common,DE.specularmap,DE.envmap,DE.aomap,DE.lightmap,DE.emissivemap,DE.bumpmap,DE.normalmap,DE.displacementmap,DE.fog,DE.lights,{emissive:{value:new QM(0)}}]),vertexShader:LE.meshlambert_vert,fragmentShader:LE.meshlambert_frag},phong:{uniforms:gE([DE.common,DE.specularmap,DE.envmap,DE.aomap,DE.lightmap,DE.emissivemap,DE.bumpmap,DE.normalmap,DE.displacementmap,DE.fog,DE.lights,{emissive:{value:new QM(0)},specular:{value:new QM(1118481)},shininess:{value:30}}]),vertexShader:LE.meshphong_vert,fragmentShader:LE.meshphong_frag},standard:{uniforms:gE([DE.common,DE.envmap,DE.aomap,DE.lightmap,DE.emissivemap,DE.bumpmap,DE.normalmap,DE.displacementmap,DE.roughnessmap,DE.metalnessmap,DE.fog,DE.lights,{emissive:{value:new QM(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:LE.meshphysical_vert,fragmentShader:LE.meshphysical_frag},toon:{uniforms:gE([DE.common,DE.aomap,DE.lightmap,DE.emissivemap,DE.bumpmap,DE.normalmap,DE.displacementmap,DE.gradientmap,DE.fog,DE.lights,{emissive:{value:new QM(0)}}]),vertexShader:LE.meshtoon_vert,fragmentShader:LE.meshtoon_frag},matcap:{uniforms:gE([DE.common,DE.bumpmap,DE.normalmap,DE.displacementmap,DE.fog,{matcap:{value:null}}]),vertexShader:LE.meshmatcap_vert,fragmentShader:LE.meshmatcap_frag},points:{uniforms:gE([DE.points,DE.fog]),vertexShader:LE.points_vert,fragmentShader:LE.points_frag},dashed:{uniforms:gE([DE.common,DE.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:LE.linedashed_vert,fragmentShader:LE.linedashed_frag},depth:{uniforms:gE([DE.common,DE.displacementmap]),vertexShader:LE.depth_vert,fragmentShader:LE.depth_frag},normal:{uniforms:gE([DE.common,DE.bumpmap,DE.normalmap,DE.displacementmap,{opacity:{value:1}}]),vertexShader:LE.meshnormal_vert,fragmentShader:LE.meshnormal_frag},sprite:{uniforms:gE([DE.sprite,DE.fog]),vertexShader:LE.sprite_vert,fragmentShader:LE.sprite_frag},background:{uniforms:{uvTransform:{value:new LM},t2D:{value:null}},vertexShader:LE.background_vert,fragmentShader:LE.background_frag},cube:{uniforms:gE([DE.envmap,{opacity:{value:1}}]),vertexShader:LE.cube_vert,fragmentShader:LE.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:LE.equirect_vert,fragmentShader:LE.equirect_frag},distanceRGBA:{uniforms:gE([DE.common,DE.displacementmap,{referencePosition:{value:new d_},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:LE.distanceRGBA_vert,fragmentShader:LE.distanceRGBA_frag},shadow:{uniforms:gE([DE.lights,DE.fog,{color:{value:new QM(0)},opacity:{value:1}}]),vertexShader:LE.shadow_vert,fragmentShader:LE.shadow_frag}};function jE(e,t,n,r,i,o){const a=new QM(0);let s,l,c=!0===i?0:1,u=null,d=0,f=null;function h(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,o)}return{getClearColor:function(){return a},setClearColor:function(e,t=1){a.set(e),c=t,h(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,h(a,c)},render:function(n,i){let o=!1,p=!0===i.isScene?i.background:null;p&&p.isTexture&&(p=t.get(p));const m=e.xr,g=m.getSession&&m.getSession();g&&"additive"===g.environmentBlendMode&&(p=null),null===p?h(a,c):p&&p.isColor&&(h(p,1),o=!0),(e.autoClear||o)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),p&&(p.isCubeTexture||p.mapping===hx)?(void 0===l&&(l=new fE(new pE(1,1,1),new yE({name:"BackgroundCubeMaterial",uniforms:mE(BE.cube.uniforms),vertexShader:BE.cube.vertexShader,fragmentShader:BE.cube.fragmentShader,side:xw,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=p,l.material.uniforms.flipEnvMap.value=p.isCubeTexture&&!1===p.isRenderTargetTexture?-1:1,u===p&&d===p.version&&f===e.toneMapping||(l.material.needsUpdate=!0,u=p,d=p.version,f=e.toneMapping),l.layers.enableAll(),n.unshift(l,l.geometry,l.material,0,0,null)):p&&p.isTexture&&(void 0===s&&(s=new fE(new NE(2,2),new yE({name:"BackgroundMaterial",uniforms:mE(BE.background.uniforms),vertexShader:BE.background.vertexShader,fragmentShader:BE.background.fragmentShader,side:ww,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(s)),s.material.uniforms.t2D.value=p,!0===p.matrixAutoUpdate&&p.updateMatrix(),s.material.uniforms.uvTransform.value.copy(p.matrix),u===p&&d===p.version&&f===e.toneMapping||(s.material.needsUpdate=!0,u=p,d=p.version,f=e.toneMapping),s.layers.enableAll(),n.unshift(s,s.geometry,s.material,0,0,null))}}}function FE(e,t,n,r){const i=e.getParameter(34921),o=r.isWebGL2?null:t.get("OES_vertex_array_object"),a=r.isWebGL2||null!==o,s={},l=h(null);let c=l,u=!1;function d(t){return r.isWebGL2?e.bindVertexArray(t):o.bindVertexArrayOES(t)}function f(t){return r.isWebGL2?e.deleteVertexArray(t):o.deleteVertexArrayOES(t)}function h(e){const t=[],n=[],r=[];for(let e=0;e<i;e++)t[e]=0,n[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:r,object:e,attributes:{},index:null}}function p(){const e=c.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function m(e){g(e,0)}function g(n,i){const o=c.newAttributes,a=c.enabledAttributes,s=c.attributeDivisors;if(o[n]=1,0===a[n]&&(e.enableVertexAttribArray(n),a[n]=1),s[n]!==i){(r.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,i),s[n]=i}}function v(){const t=c.newAttributes,n=c.enabledAttributes;for(let r=0,i=n.length;r<i;r++)n[r]!==t[r]&&(e.disableVertexAttribArray(r),n[r]=0)}function y(t,n,i,o,a,s){!0!==r.isWebGL2||5124!==i&&5125!==i?e.vertexAttribPointer(t,n,i,o,a,s):e.vertexAttribIPointer(t,n,i,a,s)}function b(){w(),u=!0,c!==l&&(c=l,d(c.object))}function w(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(i,l,f,b,w){let x=!1;if(a){const t=function(t,n,i){const a=!0===i.wireframe;let l=s[t.id];void 0===l&&(l={},s[t.id]=l);let c=l[n.id];void 0===c&&(c={},l[n.id]=c);let u=c[a];void 0===u&&(u=h(r.isWebGL2?e.createVertexArray():o.createVertexArrayOES()),c[a]=u);return u}(b,f,l);c!==t&&(c=t,d(c.object)),x=function(e,t,n,r){const i=c.attributes,o=t.attributes;let a=0;const s=n.getAttributes();for(const t in s){if(s[t].location>=0){const n=i[t];let r=o[t];if(void 0===r&&("instanceMatrix"===t&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(r=e.instanceColor)),void 0===n)return!0;if(n.attribute!==r)return!0;if(r&&n.data!==r.data)return!0;a++}}return c.attributesNum!==a||c.index!==r}(i,b,f,w),x&&function(e,t,n,r){const i={},o=t.attributes;let a=0;const s=n.getAttributes();for(const t in s){if(s[t].location>=0){let n=o[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,a++}}c.attributes=i,c.attributesNum=a,c.index=r}(i,b,f,w)}else{const e=!0===l.wireframe;c.geometry===b.id&&c.program===f.id&&c.wireframe===e||(c.geometry=b.id,c.program=f.id,c.wireframe=e,x=!0)}null!==w&&n.update(w,34963),(x||u)&&(u=!1,function(i,o,a,s){if(!1===r.isWebGL2&&(i.isInstancedMesh||s.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;p();const l=s.attributes,c=a.getAttributes(),u=o.defaultAttributeValues;for(const t in c){const r=c[t];if(r.location>=0){let o=l[t];if(void 0===o&&("instanceMatrix"===t&&i.instanceMatrix&&(o=i.instanceMatrix),"instanceColor"===t&&i.instanceColor&&(o=i.instanceColor)),void 0!==o){const t=o.normalized,a=o.itemSize,l=n.get(o);if(void 0===l)continue;const c=l.buffer,u=l.type,d=l.bytesPerElement;if(o.isInterleavedBufferAttribute){const n=o.data,l=n.stride,f=o.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e<r.locationSize;e++)g(r.location+e,n.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let e=0;e<r.locationSize;e++)m(r.location+e);e.bindBuffer(34962,c);for(let e=0;e<r.locationSize;e++)y(r.location+e,a/r.locationSize,u,t,l*d,(f+a/r.locationSize*e)*d)}else{if(o.isInstancedBufferAttribute){for(let e=0;e<r.locationSize;e++)g(r.location+e,o.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let e=0;e<r.locationSize;e++)m(r.location+e);e.bindBuffer(34962,c);for(let e=0;e<r.locationSize;e++)y(r.location+e,a/r.locationSize,u,t,a*d,a/r.locationSize*e*d)}}else if(void 0!==u){const n=u[t];if(void 0!==n)switch(n.length){case 2:e.vertexAttrib2fv(r.location,n);break;case 3:e.vertexAttrib3fv(r.location,n);break;case 4:e.vertexAttrib4fv(r.location,n);break;default:e.vertexAttrib1fv(r.location,n)}}}}v()}(i,l,f,b),null!==w&&e.bindBuffer(34963,n.get(w).buffer))},reset:b,resetDefaultState:w,dispose:function(){b();for(const e in s){const t=s[e];for(const e in t){const n=t[e];for(const e in n)f(n[e].object),delete n[e];delete t[e]}delete s[e]}},releaseStatesOfGeometry:function(e){if(void 0===s[e.id])return;const t=s[e.id];for(const e in t){const n=t[e];for(const e in n)f(n[e].object),delete n[e];delete t[e]}delete s[e.id]},releaseStatesOfProgram:function(e){for(const t in s){const n=s[t];if(void 0===n[e.id])continue;const r=n[e.id];for(const e in r)f(r[e].object),delete r[e];delete n[e.id]}},initAttributes:p,enableAttribute:m,disableUnusedAttributes:v}}function UE(e,t,n,r){const i=r.isWebGL2;let o;this.setMode=function(e){o=e},this.render=function(t,r){e.drawArrays(o,t,r),n.update(r,o,1)},this.renderInstances=function(r,a,s){if(0===s)return;let l,c;if(i)l=e,c="drawArraysInstanced";else if(l=t.get("ANGLE_instanced_arrays"),c="drawArraysInstancedANGLE",null===l)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[c](o,r,a,s),n.update(a,o,s)}}function zE(e,t,n){let r;function i(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let a=void 0!==n.precision?n.precision:"highp";const s=i(a);s!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);const l=o||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,u=e.getParameter(34930),d=e.getParameter(35660),f=e.getParameter(3379),h=e.getParameter(34076),p=e.getParameter(34921),m=e.getParameter(36347),g=e.getParameter(36348),v=e.getParameter(36349),y=d>0,b=o||t.has("OES_texture_float");return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:i,precision:a,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:b,floatVertexTextures:y&&b,maxSamples:o?e.getParameter(36183):0}}function HE(e){const t=this;let n=null,r=0,i=!1,o=!1;const a=new kE,s=new LM,l={value:null,needsUpdate:!1};function c(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){const o=null!==e?e.length:0;let c=null;if(0!==o){if(c=l.value,!0!==i||null===c){const t=r+4*o,i=n.matrixWorldInverse;s.getNormalMatrix(i),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=r;t!==o;++t,n+=4)a.copy(e[t]).applyMatrix4(i,s),a.normal.toArray(c,n),c[n+3]=a.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=o,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,o){const a=0!==e.length||t||0!==r||i;return i=t,n=u(e,o,0),r=e.length,a},this.beginShadows=function(){o=!0,u(null)},this.endShadows=function(){o=!1,c()},this.setState=function(t,a,s){const d=t.clippingPlanes,f=t.clipIntersection,h=t.clipShadows,p=e.get(t);if(!i||null===d||0===d.length||o&&!h)o?u(null):c();else{const e=o?0:r,t=4*e;let i=p.clippingState||null;l.value=i,i=u(d,a,t,s);for(let e=0;e!==t;++e)i[e]=n[e];p.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}}}function VE(e){let t=new WeakMap;function n(e,t){return t===dx?e.mapping=cx:t===fx&&(e.mapping=ux),e}function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture&&!1===i.isRenderTargetTexture){const o=i.mapping;if(o===dx||o===fx){if(t.has(i)){return n(t.get(i).texture,i.mapping)}{const o=i.image;if(o&&o.height>0){const a=new _E(o.height/2);return a.fromEquirectangularTexture(e,i),t.set(i,a),i.addEventListener("dispose",r),n(a.texture,i.mapping)}return null}}}return i},dispose:function(){t=new WeakMap}}}BE.physical={uniforms:gE([BE.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new NM(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new QM(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new NM},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new QM(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new QM(1,1,1)},specularColorMap:{value:null}}]),vertexShader:LE.meshphysical_vert,fragmentShader:LE.meshphysical_frag};class WE extends bE{constructor(e=-1,t=1,n=1,r=-1,i=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,o){null===this.view&&(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=r,this.view.width=i,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(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,r=(this.top+this.bottom)/2;let i=n-e,o=n+e,a=r+t,s=r-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,o=i+e*this.view.width,a-=t*this.view.offsetY,s=a-t*this.view.height}this.projectionMatrix.makeOrthographic(i,o,a,s,this.near,this.far),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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}const GE=[.125,.215,.35,.446,.526,.582],qE=20,KE=new WE,YE=new QM;let JE=null;const QE=(1+Math.sqrt(5))/2,XE=1/QE,ZE=[new d_(1,1,1),new d_(-1,1,1),new d_(1,1,-1),new d_(-1,1,-1),new d_(0,QE,XE),new d_(0,QE,-XE),new d_(XE,0,QE),new d_(-XE,0,QE),new d_(QE,XE,0),new d_(-QE,XE,0)];class $E{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,r=100){JE=this._renderer.getRenderTarget(),this._setSize(256);const i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,n,r,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=rC(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=nC(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(JE),e.scissorTest=!1,tC(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===cx||e.mapping===ux?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),JE=this._renderer.getRenderTarget();const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Sx,minFilter:Sx,generateMipmaps:!1,type:Nx,format:Ux,encoding:DS,depthBuffer:!1},r=eC(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=eC(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(e){const t=[],n=[],r=[];let i=e;const o=e-4+1+GE.length;for(let a=0;a<o;a++){const o=Math.pow(2,i);n.push(o);let s=1/o;a>e-4?s=GE[a-e+4-1]:0===a&&(s=0),r.push(s);const l=1/(o-2),c=-l,u=1+l,d=[c,c,u,c,u,u,c,c,u,u,c,u],f=6,h=6,p=3,m=2,g=1,v=new Float32Array(p*h*f),y=new Float32Array(m*h*f),b=new Float32Array(g*h*f);for(let e=0;e<f;e++){const t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(r,p*h*e),y.set(d,m*h*e);const i=[e,e,e,e,e,e];b.set(i,g*h*e)}const w=new YA;w.setAttribute("position",new IA(v,p)),w.setAttribute("uv",new IA(y,m)),w.setAttribute("faceIndex",new IA(b,g)),t.push(w),i>4&&i--}return{lodPlanes:t,sizeLods:n,sigmas:r}}(r)),this._blurMaterial=function(e,t,n){const r=new Float32Array(qE),i=new d_(0,1,0),o=new yE({name:"SphericalGaussianBlur",defines:{n:qE,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:iC(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:Mw,depthTest:!1,depthWrite:!1});return o}(r,e,t)}return r}_compileMaterial(e){const t=new fE(this._lodPlanes[0],e);this._renderer.compile(t,KE)}_sceneToCubeUV(e,t,n,r){const i=new wE(90,1,t,n),o=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],s=this._renderer,l=s.autoClear,c=s.toneMapping;s.getClearColor(YE),s.toneMapping=nx,s.autoClear=!1;const u=new CA({name:"PMREM.Background",side:xw,depthWrite:!1,depthTest:!1}),d=new fE(new pE,u);let f=!1;const h=e.background;h?h.isColor&&(u.color.copy(h),e.background=null,f=!0):(u.color.copy(YE),f=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(i.up.set(0,o[t],0),i.lookAt(a[t],0,0)):1===n?(i.up.set(0,0,o[t]),i.lookAt(0,a[t],0)):(i.up.set(0,o[t],0),i.lookAt(0,0,a[t]));const l=this._cubeSize;tC(r,n*l,t>2?l:0,l,l),s.setRenderTarget(r),f&&s.render(d,i),s.render(e,i)}d.geometry.dispose(),d.material.dispose(),s.toneMapping=c,s.autoClear=l,e.background=h}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===cx||e.mapping===ux;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=rC()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=nC());const i=r?this._cubemapMaterial:this._equirectMaterial,o=new fE(this._lodPlanes[0],i);i.uniforms.envMap.value=e;const a=this._cubeSize;tC(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(o,KE)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t<this._lodPlanes.length;t++){const n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),r=ZE[(t-1)%ZE.length];this._blur(e,t-1,t,n,r)}t.autoClear=n}_blur(e,t,n,r,i){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,r,"latitudinal",i),this._halfBlur(o,e,n,n,r,"longitudinal",i)}_halfBlur(e,t,n,r,i,o,a){const s=this._renderer,l=this._blurMaterial;"latitudinal"!==o&&"longitudinal"!==o&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new fE(this._lodPlanes[r],l),u=l.uniforms,d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/39,h=i/f,p=isFinite(i)?1+Math.floor(3*h):qE;p>qE&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${p} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<qE;++e){const t=e/h,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e<p&&(g+=2*n)}for(let e=0;e<m.length;e++)m[e]=m[e]/g;u.envMap.value=e.texture,u.samples.value=p,u.weights.value=m,u.latitudinal.value="latitudinal"===o,a&&(u.poleAxis.value=a);const{_lodMax:v}=this;u.dTheta.value=f,u.mipInt.value=v-n;const y=this._sizeLods[r];tC(t,3*y*(r>v-4?r-v+4:0),4*(this._cubeSize-y),3*y,2*y),s.setRenderTarget(t),s.render(c,KE)}}function eC(e,t,n){const r=new i_(e,t,n);return r.texture.mapping=hx,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function tC(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function nC(){return new yE({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:iC(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:Mw,depthTest:!1,depthWrite:!1})}function rC(){return new yE({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:iC(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:Mw,depthTest:!1,depthWrite:!1})}function iC(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function oC(e){let t=new WeakMap,n=null;function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture){const o=i.mapping,a=o===dx||o===fx,s=o===cx||o===ux;if(a||s){if(i.isRenderTargetTexture&&!0===i.needsPMREMUpdate){i.needsPMREMUpdate=!1;let r=t.get(i);return null===n&&(n=new $E(e)),r=a?n.fromEquirectangular(i,r):n.fromCubemap(i,r),t.set(i,r),r.texture}if(t.has(i))return t.get(i).texture;{const o=i.image;if(a&&o&&o.height>0||s&&o&&function(e){let t=0;const n=6;for(let r=0;r<n;r++)void 0!==e[r]&&t++;return t===n}(o)){null===n&&(n=new $E(e));const o=a?n.fromEquirectangular(i):n.fromCubemap(i);return t.set(i,o),i.addEventListener("dispose",r),o.texture}return null}}}return i},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function aC(e){const t={};function n(n){if(void 0!==t[n])return t[n];let r;switch(n){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function sC(e,t,n,r){const i={},o=new WeakMap;function a(e){const s=e.target;null!==s.index&&t.remove(s.index);for(const e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener("dispose",a),delete i[s.id];const l=o.get(s);l&&(t.remove(l),o.delete(s)),r.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){const n=[],r=e.index,i=e.attributes.position;let a=0;if(null!==r){const e=r.array;a=r.version;for(let t=0,r=e.length;t<r;t+=3){const r=e[t+0],i=e[t+1],o=e[t+2];n.push(r,i,i,o,o,r)}}else{const e=i.array;a=i.version;for(let t=0,r=e.length/3-1;t<r;t+=3){const e=t+0,r=t+1,i=t+2;n.push(e,r,r,i,i,e)}}const s=new(DM(n)?BA:LA)(n,1);s.version=a;const l=o.get(e);l&&t.remove(l),o.set(e,s)}return{get:function(e,t){return!0===i[t.id]||(t.addEventListener("dispose",a),i[t.id]=!0,n.memory.geometries++),t},update:function(e){const n=e.attributes;for(const e in n)t.update(n[e],34962);const r=e.morphAttributes;for(const e in r){const n=r[e];for(let e=0,r=n.length;e<r;e++)t.update(n[e],34962)}},getWireframeAttribute:function(e){const t=o.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&s(e)}else s(e);return o.get(e)}}}function lC(e,t,n,r){const i=r.isWebGL2;let o,a,s;this.setMode=function(e){o=e},this.setIndex=function(e){a=e.type,s=e.bytesPerElement},this.render=function(t,r){e.drawElements(o,r,a,t*s),n.update(r,o,1)},this.renderInstances=function(r,l,c){if(0===c)return;let u,d;if(i)u=e,d="drawElementsInstanced";else if(u=t.get("ANGLE_instanced_arrays"),d="drawElementsInstancedANGLE",null===u)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");u[d](o,l,a,r*s,c),n.update(l,o,c)}}function cC(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(e,n,r){switch(t.calls++,n){case 4:t.triangles+=r*(e/3);break;case 1:t.lines+=r*(e/2);break;case 3:t.lines+=r*(e-1);break;case 2:t.lines+=r*e;break;case 0:t.points+=r*e;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function uC(e,t){return e[0]-t[0]}function dC(e,t){return Math.abs(t[1])-Math.abs(e[1])}function fC(e,t,n){const r={},i=new Float32Array(8),o=new WeakMap,a=new r_,s=[];for(let e=0;e<8;e++)s[e]=[e,0];return{update:function(l,c,u,d){const f=l.morphTargetInfluences;if(!0===t.isWebGL2){const r=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,i=void 0!==r?r.length:0;let s=o.get(c);if(void 0===s||s.count!==i){void 0!==s&&s.texture.dispose();const e=void 0!==c.morphAttributes.position,n=void 0!==c.morphAttributes.normal,r=void 0!==c.morphAttributes.color,l=c.morphAttributes.position||[],u=c.morphAttributes.normal||[],d=c.morphAttributes.color||[];let f=0;!0===e&&(f=1),!0===n&&(f=2),!0===r&&(f=3);let h=c.attributes.position.count*f,p=1;h>t.maxTextureSize&&(p=Math.ceil(h/t.maxTextureSize),h=t.maxTextureSize);const m=new Float32Array(h*p*4*i),g=new o_(m,h,p,i);g.type=Px,g.needsUpdate=!0;const v=4*f;for(let t=0;t<i;t++){const i=l[t],o=u[t],s=d[t],c=h*p*4*t;for(let t=0;t<i.count;t++){const l=t*v;!0===e&&(a.fromBufferAttribute(i,t),m[c+l+0]=a.x,m[c+l+1]=a.y,m[c+l+2]=a.z,m[c+l+3]=0),!0===n&&(a.fromBufferAttribute(o,t),m[c+l+4]=a.x,m[c+l+5]=a.y,m[c+l+6]=a.z,m[c+l+7]=0),!0===r&&(a.fromBufferAttribute(s,t),m[c+l+8]=a.x,m[c+l+9]=a.y,m[c+l+10]=a.z,m[c+l+11]=4===s.itemSize?a.w:1)}}s={count:i,texture:g,size:new NM(h,p)},o.set(c,s),c.addEventListener("dispose",(function e(){g.dispose(),o.delete(c),c.removeEventListener("dispose",e)}))}let l=0;for(let e=0;e<f.length;e++)l+=f[e];const u=c.morphTargetsRelative?1:1-l;d.getUniforms().setValue(e,"morphTargetBaseInfluence",u),d.getUniforms().setValue(e,"morphTargetInfluences",f),d.getUniforms().setValue(e,"morphTargetsTexture",s.texture,n),d.getUniforms().setValue(e,"morphTargetsTextureSize",s.size)}else{const t=void 0===f?0:f.length;let n=r[c.id];if(void 0===n||n.length!==t){n=[];for(let e=0;e<t;e++)n[e]=[e,0];r[c.id]=n}for(let e=0;e<t;e++){const t=n[e];t[0]=e,t[1]=f[e]}n.sort(dC);for(let e=0;e<8;e++)e<t&&n[e][1]?(s[e][0]=n[e][0],s[e][1]=n[e][1]):(s[e][0]=Number.MAX_SAFE_INTEGER,s[e][1]=0);s.sort(uC);const o=c.morphAttributes.position,a=c.morphAttributes.normal;let l=0;for(let e=0;e<8;e++){const t=s[e],n=t[0],r=t[1];n!==Number.MAX_SAFE_INTEGER&&r?(o&&c.getAttribute("morphTarget"+e)!==o[n]&&c.setAttribute("morphTarget"+e,o[n]),a&&c.getAttribute("morphNormal"+e)!==a[n]&&c.setAttribute("morphNormal"+e,a[n]),i[e]=r,l+=r):(o&&!0===c.hasAttribute("morphTarget"+e)&&c.deleteAttribute("morphTarget"+e),a&&!0===c.hasAttribute("morphNormal"+e)&&c.deleteAttribute("morphNormal"+e),i[e]=0)}const u=c.morphTargetsRelative?1:1-l;d.getUniforms().setValue(e,"morphTargetBaseInfluence",u),d.getUniforms().setValue(e,"morphTargetInfluences",i)}}}}function hC(e,t,n,r){let i=new WeakMap;function o(e){const t=e.target;t.removeEventListener("dispose",o),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(e){const a=r.render.frame,s=e.geometry,l=t.get(e,s);return i.get(l)!==a&&(t.update(l),i.set(l,a)),e.isInstancedMesh&&(!1===e.hasEventListener("dispose",o)&&e.addEventListener("dispose",o),n.update(e.instanceMatrix,34962),null!==e.instanceColor&&n.update(e.instanceColor,34962)),l},dispose:function(){i=new WeakMap}}}const pC=new n_,mC=new o_,gC=new s_,vC=new ME,yC=[],bC=[],wC=new Float32Array(16),xC=new Float32Array(9),SC=new Float32Array(4);function MC(e,t,n){const r=e[0];if(r<=0||r>0)return e;const i=t*n;let o=yC[i];if(void 0===o&&(o=new Float32Array(i),yC[i]=o),0!==t){r.toArray(o,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(o,i)}return o}function _C(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function AC(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n]}function EC(e,t){let n=bC[t];void 0===n&&(n=new Int32Array(t),bC[t]=n);for(let r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function CC(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function kC(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(_C(n,t))return;e.uniform2fv(this.addr,t),AC(n,t)}}function TC(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(_C(n,t))return;e.uniform3fv(this.addr,t),AC(n,t)}}function IC(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(_C(n,t))return;e.uniform4fv(this.addr,t),AC(n,t)}}function OC(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(_C(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),AC(n,t)}else{if(_C(n,r))return;SC.set(r),e.uniformMatrix2fv(this.addr,!1,SC),AC(n,r)}}function RC(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(_C(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),AC(n,t)}else{if(_C(n,r))return;xC.set(r),e.uniformMatrix3fv(this.addr,!1,xC),AC(n,r)}}function PC(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(_C(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),AC(n,t)}else{if(_C(n,r))return;wC.set(r),e.uniformMatrix4fv(this.addr,!1,wC),AC(n,r)}}function NC(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function LC(e,t){const n=this.cache;_C(n,t)||(e.uniform2iv(this.addr,t),AC(n,t))}function DC(e,t){const n=this.cache;_C(n,t)||(e.uniform3iv(this.addr,t),AC(n,t))}function BC(e,t){const n=this.cache;_C(n,t)||(e.uniform4iv(this.addr,t),AC(n,t))}function jC(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function FC(e,t){const n=this.cache;_C(n,t)||(e.uniform2uiv(this.addr,t),AC(n,t))}function UC(e,t){const n=this.cache;_C(n,t)||(e.uniform3uiv(this.addr,t),AC(n,t))}function zC(e,t){const n=this.cache;_C(n,t)||(e.uniform4uiv(this.addr,t),AC(n,t))}function HC(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2D(t||pC,i)}function VC(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||gC,i)}function WC(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(t||vC,i)}function GC(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||mC,i)}function qC(e,t){e.uniform1fv(this.addr,t)}function KC(e,t){const n=MC(t,this.size,2);e.uniform2fv(this.addr,n)}function YC(e,t){const n=MC(t,this.size,3);e.uniform3fv(this.addr,n)}function JC(e,t){const n=MC(t,this.size,4);e.uniform4fv(this.addr,n)}function QC(e,t){const n=MC(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function XC(e,t){const n=MC(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function ZC(e,t){const n=MC(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function $C(e,t){e.uniform1iv(this.addr,t)}function ek(e,t){e.uniform2iv(this.addr,t)}function tk(e,t){e.uniform3iv(this.addr,t)}function nk(e,t){e.uniform4iv(this.addr,t)}function rk(e,t){e.uniform1uiv(this.addr,t)}function ik(e,t){e.uniform2uiv(this.addr,t)}function ok(e,t){e.uniform3uiv(this.addr,t)}function ak(e,t){e.uniform4uiv(this.addr,t)}function sk(e,t,n){const r=t.length,i=EC(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTexture2D(t[e]||pC,i[e])}function lk(e,t,n){const r=t.length,i=EC(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTexture3D(t[e]||gC,i[e])}function ck(e,t,n){const r=t.length,i=EC(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTextureCube(t[e]||vC,i[e])}function uk(e,t,n){const r=t.length,i=EC(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTexture2DArray(t[e]||mC,i[e])}class dk{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=function(e){switch(e){case 5126:return CC;case 35664:return kC;case 35665:return TC;case 35666:return IC;case 35674:return OC;case 35675:return RC;case 35676:return PC;case 5124:case 35670:return NC;case 35667:case 35671:return LC;case 35668:case 35672:return DC;case 35669:case 35673:return BC;case 5125:return jC;case 36294:return FC;case 36295:return UC;case 36296:return zC;case 35678:case 36198:case 36298:case 36306:case 35682:return HC;case 35679:case 36299:case 36307:return VC;case 35680:case 36300:case 36308:case 36293:return WC;case 36289:case 36303:case 36311:case 36292:return GC}}(t.type)}}class fk{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=function(e){switch(e){case 5126:return qC;case 35664:return KC;case 35665:return YC;case 35666:return JC;case 35674:return QC;case 35675:return XC;case 35676:return ZC;case 5124:case 35670:return $C;case 35667:case 35671:return ek;case 35668:case 35672:return tk;case 35669:case 35673:return nk;case 5125:return rk;case 36294:return ik;case 36295:return ok;case 36296:return ak;case 35678:case 36198:case 36298:case 36306:case 35682:return sk;case 35679:case 36299:case 36307:return lk;case 35680:case 36300:case 36308:case 36293:return ck;case 36289:case 36303:case 36311:case 36292:return uk}}(t.type)}}class hk{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let i=0,o=r.length;i!==o;++i){const o=r[i];o.setValue(e,t[o.id],n)}}}const pk=/(\w+)(\])?(\[|\.)?/g;function mk(e,t){e.seq.push(t),e.map[t.id]=t}function gk(e,t,n){const r=e.name,i=r.length;for(pk.lastIndex=0;;){const o=pk.exec(r),a=pk.lastIndex;let s=o[1];const l="]"===o[2],c=o[3];if(l&&(s|=0),void 0===c||"["===c&&a+2===i){mk(n,void 0===c?new dk(s,e,t):new fk(s,e,t));break}{let e=n.map[s];void 0===e&&(e=new hk(s),mk(n,e)),n=e}}}class vk{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,35718);for(let r=0;r<n;++r){const n=e.getActiveUniform(t,r);gk(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,r){const i=this.map[t];void 0!==i&&i.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];void 0!==r&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,o=t.length;i!==o;++i){const o=t[i],a=n[o.id];!1!==a.needsUpdate&&o.setValue(e,a.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,i=e.length;r!==i;++r){const i=e[r];i.id in t&&n.push(i)}return n}}function yk(e,t,n){const r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}let bk=0;function wk(e,t,n){const r=e.getShaderParameter(t,35713),i=e.getShaderInfoLog(t).trim();if(r&&""===i)return"";const o=/ERROR: 0:(\d+)/.exec(i);if(o){const r=parseInt(o[1]);return n.toUpperCase()+"\n\n"+i+"\n\n"+function(e,t){const n=e.split("\n"),r=[],i=Math.max(t-6,0),o=Math.min(t+6,n.length);for(let e=i;e<o;e++){const i=e+1;r.push(`${i===t?">":" "} ${i}: ${n[e]}`)}return r.join("\n")}(e.getShaderSource(t),r)}return i}function xk(e,t){const n=function(e){switch(e){case DS:return["Linear","( value )"];case BS:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function Sk(e,t){let n;switch(t){case rx:n="Linear";break;case ix:n="Reinhard";break;case ox:n="OptimizedCineon";break;case ax:n="ACESFilmic";break;case sx:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Mk(e){return""!==e}function _k(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Ak(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Ek=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ck(e){return e.replace(Ek,kk)}function kk(e,t){const n=LE[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return Ck(n)}const Tk=/#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 Ik(e){return e.replace(Tk,Ok)}function Ok(e,t,n,r){let i="";for(let e=parseInt(t);e<parseInt(n);e++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return i}function Rk(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Pk(e,t,n,r){const i=e.getContext(),o=n.defines;let a=n.vertexShader,s=n.fragmentShader;const l=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===vw?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===yw?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===bw&&(t="SHADOWMAP_TYPE_VSM"),t}(n),c=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case cx:case ux:t="ENVMAP_TYPE_CUBE";break;case hx:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),u=function(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===ux&&(t="ENVMAP_MODE_REFRACTION");return t}(n),d=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case $w:t="ENVMAP_BLENDING_MULTIPLY";break;case ex:t="ENVMAP_BLENDING_MIX";break;case tx:t="ENVMAP_BLENDING_ADD"}return t}(n),f=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const n=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:r,maxMip:n}}(n),h=n.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Mk).join("\n")}(n),p=function(e){const t=[];for(const n in e){const r=e[n];!1!==r&&t.push("#define "+n+" "+r)}return t.join("\n")}(o),m=i.createProgram();let g,v,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(g=[p].filter(Mk).join("\n"),g.length>0&&(g+="\n"),v=[h,p].filter(Mk).join("\n"),v.length>0&&(v+="\n")):(g=[Rk(n),"#define SHADER_NAME "+n.shaderName,p,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Mk).join("\n"),v=[h,Rk(n),"#define SHADER_NAME "+n.shaderName,p,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==nx?"#define TONE_MAPPING":"",n.toneMapping!==nx?LE.tonemapping_pars_fragment:"",n.toneMapping!==nx?Sk("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",LE.encodings_pars_fragment,xk("linearToOutputTexel",n.outputEncoding),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Mk).join("\n")),a=Ck(a),a=_k(a,n),a=Ak(a,n),s=Ck(s),s=_k(s,n),s=Ak(s,n),a=Ik(a),s=Ik(s),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===vM?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===vM?"":"#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("\n")+"\n"+v);const b=y+v+s,w=yk(i,35633,y+g+a),x=yk(i,35632,b);if(i.attachShader(m,w),i.attachShader(m,x),void 0!==n.index0AttributeName?i.bindAttribLocation(m,0,n.index0AttributeName):!0===n.morphTargets&&i.bindAttribLocation(m,0,"position"),i.linkProgram(m),e.debug.checkShaderErrors){const e=i.getProgramInfoLog(m).trim(),t=i.getShaderInfoLog(w).trim(),n=i.getShaderInfoLog(x).trim();let r=!0,o=!0;if(!1===i.getProgramParameter(m,35714)){r=!1;const t=wk(i,w,"vertex"),n=wk(i,x,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(m,35715)+"\n\nProgram Info Log: "+e+"\n"+t+"\n"+n)}else""!==e?console.warn("THREE.WebGLProgram: Program Info Log:",e):""!==t&&""!==n||(o=!1);o&&(this.diagnostics={runnable:r,programLog:e,vertexShader:{log:t,prefix:g},fragmentShader:{log:n,prefix:v}})}let S,M;return i.deleteShader(w),i.deleteShader(x),this.getUniforms=function(){return void 0===S&&(S=new vk(i,m)),S},this.getAttributes=function(){return void 0===M&&(M=function(e,t){const n={},r=e.getProgramParameter(t,35721);for(let i=0;i<r;i++){const r=e.getActiveAttrib(t,i),o=r.name;let a=1;35674===r.type&&(a=2),35675===r.type&&(a=3),35676===r.type&&(a=4),n[o]={type:r.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}(i,m)),M},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.name=n.shaderName,this.id=bk++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=x,this}let Nk=0;class Lk{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return!1===o.has(r)&&(o.add(r),r.usedTimes++),!1===o.has(i)&&(o.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.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 void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return void 0===n&&(n=new Dk(e),t.set(e,n)),n}}class Dk{constructor(e){this.id=Nk++,this.code=e,this.usedTimes=0}}function Bk(e,t,n,r,i,o,a){const s=new $_,l=new Lk,c=[],u=i.isWebGL2,d=i.logarithmicDepthBuffer,f=i.vertexTextures;let h=i.precision;const p={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"};return{getParameters:function(o,s,c,m,g){const v=m.fog,y=g.geometry,b=o.isMeshStandardMaterial?m.environment:null,w=(o.isMeshStandardMaterial?n:t).get(o.envMap||b),x=w&&w.mapping===hx?w.image.height:null,S=p[o.type];null!==o.precision&&(h=i.getMaxPrecision(o.precision),h!==o.precision&&console.warn("THREE.WebGLProgram.getParameters:",o.precision,"not supported, using",h,"instead."));const M=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,_=void 0!==M?M.length:0;let A,E,C,k,T=0;if(void 0!==y.morphAttributes.position&&(T=1),void 0!==y.morphAttributes.normal&&(T=2),void 0!==y.morphAttributes.color&&(T=3),S){const e=BE[S];A=e.vertexShader,E=e.fragmentShader}else A=o.vertexShader,E=o.fragmentShader,l.update(o),C=l.getVertexShaderID(o),k=l.getFragmentShaderID(o);const I=e.getRenderTarget(),O=o.alphaTest>0,R=o.clearcoat>0,P=o.iridescence>0;return{isWebGL2:u,shaderID:S,shaderName:o.type,vertexShader:A,fragmentShader:E,defines:o.defines,customVertexShaderID:C,customFragmentShaderID:k,isRawShaderMaterial:!0===o.isRawShaderMaterial,glslVersion:o.glslVersion,precision:h,instancing:!0===g.isInstancedMesh,instancingColor:!0===g.isInstancedMesh&&null!==g.instanceColor,supportsVertexTextures:f,outputEncoding:null===I?e.outputEncoding:!0===I.isXRRenderTarget?I.texture.encoding:DS,map:!!o.map,matcap:!!o.matcap,envMap:!!w,envMapMode:w&&w.mapping,envMapCubeUVHeight:x,lightMap:!!o.lightMap,aoMap:!!o.aoMap,emissiveMap:!!o.emissiveMap,bumpMap:!!o.bumpMap,normalMap:!!o.normalMap,objectSpaceNormalMap:o.normalMapType===zS,tangentSpaceNormalMap:o.normalMapType===US,decodeVideoTexture:!!o.map&&!0===o.map.isVideoTexture&&o.map.encoding===BS,clearcoat:R,clearcoatMap:R&&!!o.clearcoatMap,clearcoatRoughnessMap:R&&!!o.clearcoatRoughnessMap,clearcoatNormalMap:R&&!!o.clearcoatNormalMap,iridescence:P,iridescenceMap:P&&!!o.iridescenceMap,iridescenceThicknessMap:P&&!!o.iridescenceThicknessMap,displacementMap:!!o.displacementMap,roughnessMap:!!o.roughnessMap,metalnessMap:!!o.metalnessMap,specularMap:!!o.specularMap,specularIntensityMap:!!o.specularIntensityMap,specularColorMap:!!o.specularColorMap,opaque:!1===o.transparent&&o.blending===_w,alphaMap:!!o.alphaMap,alphaTest:O,gradientMap:!!o.gradientMap,sheen:o.sheen>0,sheenColorMap:!!o.sheenColorMap,sheenRoughnessMap:!!o.sheenRoughnessMap,transmission:o.transmission>0,transmissionMap:!!o.transmissionMap,thicknessMap:!!o.thicknessMap,combine:o.combine,vertexTangents:!!o.normalMap&&!!y.attributes.tangent,vertexColors:o.vertexColors,vertexAlphas:!0===o.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,vertexUvs:!!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatMap||o.clearcoatRoughnessMap||o.clearcoatNormalMap||o.iridescenceMap||o.iridescenceThicknessMap||o.displacementMap||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularColorMap||o.sheenColorMap||o.sheenRoughnessMap),uvsVertexOnly:!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatNormalMap||o.iridescenceMap||o.iridescenceThicknessMap||o.transmission>0||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularColorMap||o.sheen>0||o.sheenColorMap||o.sheenRoughnessMap||!o.displacementMap),fog:!!v,useFog:!0===o.fog,fogExp2:v&&v.isFogExp2,flatShading:!!o.flatShading,sizeAttenuation:o.sizeAttenuation,logarithmicDepthBuffer:d,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:_,morphTextureStride:T,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:o.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:o.toneMapped?e.toneMapping:nx,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:o.premultipliedAlpha,doubleSided:o.side===Sw,flipSided:o.side===xw,useDepthPacking:!!o.depthPacking,depthPacking:o.depthPacking||0,index0AttributeName:o.index0AttributeName,extensionDerivatives:o.extensions&&o.extensions.derivatives,extensionFragDepth:o.extensions&&o.extensions.fragDepth,extensionDrawBuffers:o.extensions&&o.extensions.drawBuffers,extensionShaderTextureLOD:o.extensions&&o.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||r.has("EXT_shader_texture_lod"),customProgramCacheKey:o.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputEncoding),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.combine),e.push(t.vertexUvs),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){s.disableAll(),t.isWebGL2&&s.enable(0);t.supportsVertexTextures&&s.enable(1);t.instancing&&s.enable(2);t.instancingColor&&s.enable(3);t.map&&s.enable(4);t.matcap&&s.enable(5);t.envMap&&s.enable(6);t.lightMap&&s.enable(7);t.aoMap&&s.enable(8);t.emissiveMap&&s.enable(9);t.bumpMap&&s.enable(10);t.normalMap&&s.enable(11);t.objectSpaceNormalMap&&s.enable(12);t.tangentSpaceNormalMap&&s.enable(13);t.clearcoat&&s.enable(14);t.clearcoatMap&&s.enable(15);t.clearcoatRoughnessMap&&s.enable(16);t.clearcoatNormalMap&&s.enable(17);t.iridescence&&s.enable(18);t.iridescenceMap&&s.enable(19);t.iridescenceThicknessMap&&s.enable(20);t.displacementMap&&s.enable(21);t.specularMap&&s.enable(22);t.roughnessMap&&s.enable(23);t.metalnessMap&&s.enable(24);t.gradientMap&&s.enable(25);t.alphaMap&&s.enable(26);t.alphaTest&&s.enable(27);t.vertexColors&&s.enable(28);t.vertexAlphas&&s.enable(29);t.vertexUvs&&s.enable(30);t.vertexTangents&&s.enable(31);t.uvsVertexOnly&&s.enable(32);e.push(s.mask),s.disableAll(),t.fog&&s.enable(0);t.useFog&&s.enable(1);t.flatShading&&s.enable(2);t.logarithmicDepthBuffer&&s.enable(3);t.skinning&&s.enable(4);t.morphTargets&&s.enable(5);t.morphNormals&&s.enable(6);t.morphColors&&s.enable(7);t.premultipliedAlpha&&s.enable(8);t.shadowMapEnabled&&s.enable(9);t.physicallyCorrectLights&&s.enable(10);t.doubleSided&&s.enable(11);t.flipSided&&s.enable(12);t.useDepthPacking&&s.enable(13);t.dithering&&s.enable(14);t.specularIntensityMap&&s.enable(15);t.specularColorMap&&s.enable(16);t.transmission&&s.enable(17);t.transmissionMap&&s.enable(18);t.thicknessMap&&s.enable(19);t.sheen&&s.enable(20);t.sheenColorMap&&s.enable(21);t.sheenRoughnessMap&&s.enable(22);t.decodeVideoTexture&&s.enable(23);t.opaque&&s.enable(24);e.push(s.mask)}(n,t),n.push(e.outputEncoding)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=p[e.type];let n;if(t){const e=BE[t];n=vE.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let r;for(let e=0,t=c.length;e<t;e++){const t=c[e];if(t.cacheKey===n){r=t,++r.usedTimes;break}}return void 0===r&&(r=new Pk(e,n,t,o),c.push(r)),r},releaseProgram:function(e){if(0==--e.usedTimes){const t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:c,dispose:function(){l.dispose()}}}function jk(){let e=new WeakMap;return{get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,r){e.get(t)[n]=r},dispose:function(){e=new WeakMap}}}function Fk(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Uk(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function zk(){const e=[];let t=0;const n=[],r=[],i=[];function o(n,r,i,o,a,s){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:r,material:i,groupOrder:o,renderOrder:n.renderOrder,z:a,group:s},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.groupOrder=o,l.renderOrder=n.renderOrder,l.z=a,l.group=s),t++,l}return{opaque:n,transmissive:r,transparent:i,init:function(){t=0,n.length=0,r.length=0,i.length=0},push:function(e,t,a,s,l,c){const u=o(e,t,a,s,l,c);a.transmission>0?r.push(u):!0===a.transparent?i.push(u):n.push(u)},unshift:function(e,t,a,s,l,c){const u=o(e,t,a,s,l,c);a.transmission>0?r.unshift(u):!0===a.transparent?i.unshift(u):n.unshift(u)},finish:function(){for(let n=t,r=e.length;n<r;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||Fk),r.length>1&&r.sort(t||Uk),i.length>1&&i.sort(t||Uk)}}}function Hk(){let e=new WeakMap;return{get:function(t,n){const r=e.get(t);let i;return void 0===r?(i=new zk,e.set(t,[i])):n>=r.length?(i=new zk,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function Vk(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new d_,color:new QM};break;case"SpotLight":n={position:new d_,direction:new d_,color:new QM,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new d_,color:new QM,distance:0,decay:0};break;case"HemisphereLight":n={direction:new d_,skyColor:new QM,groundColor:new QM};break;case"RectAreaLight":n={color:new QM,position:new d_,halfWidth:new d_,halfHeight:new d_}}return e[t.id]=n,n}}}let Wk=0;function Gk(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function qk(e,t){const n=new Vk,r=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new NM};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new NM,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let e=0;e<9;e++)i.probe.push(new d_);const o=new d_,a=new H_,s=new H_;return{setup:function(o,a){let s=0,l=0,c=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let u=0,d=0,f=0,h=0,p=0,m=0,g=0,v=0,y=0,b=0;o.sort(Gk);const w=!0!==a?Math.PI:1;for(let e=0,t=o.length;e<t;e++){const t=o[e],a=t.color,x=t.intensity,S=t.distance,M=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)s+=a.r*x*w,l+=a.g*x*w,c+=a.b*x*w;else if(t.isLightProbe)for(let e=0;e<9;e++)i.probe[e].addScaledVector(t.sh.coefficients[e],x);else if(t.isDirectionalLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*w),t.castShadow){const e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,i.directionalShadow[u]=n,i.directionalShadowMap[u]=M,i.directionalShadowMatrix[u]=t.shadow.matrix,m++}i.directional[u]=e,u++}else if(t.isSpotLight){const e=n.get(t);e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(a).multiplyScalar(x*w),e.distance=S,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,i.spot[f]=e;const o=t.shadow;if(t.map&&(i.spotLightMap[y]=t.map,y++,o.updateMatrices(t),t.castShadow&&b++),i.spotLightMatrix[f]=o.matrix,t.castShadow){const e=r.get(t);e.shadowBias=o.bias,e.shadowNormalBias=o.normalBias,e.shadowRadius=o.radius,e.shadowMapSize=o.mapSize,i.spotShadow[f]=e,i.spotShadowMap[f]=M,v++}f++}else if(t.isRectAreaLight){const e=n.get(t);e.color.copy(a).multiplyScalar(x),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),i.rectArea[h]=e,h++}else if(t.isPointLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*w),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,n.shadowCameraNear=e.camera.near,n.shadowCameraFar=e.camera.far,i.pointShadow[d]=n,i.pointShadowMap[d]=M,i.pointShadowMatrix[d]=t.shadow.matrix,g++}i.point[d]=e,d++}else if(t.isHemisphereLight){const e=n.get(t);e.skyColor.copy(t.color).multiplyScalar(x*w),e.groundColor.copy(t.groundColor).multiplyScalar(x*w),i.hemi[p]=e,p++}}h>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=DE.LTC_FLOAT_1,i.rectAreaLTC2=DE.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(i.rectAreaLTC1=DE.LTC_HALF_1,i.rectAreaLTC2=DE.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=s,i.ambient[1]=l,i.ambient[2]=c;const x=i.hash;x.directionalLength===u&&x.pointLength===d&&x.spotLength===f&&x.rectAreaLength===h&&x.hemiLength===p&&x.numDirectionalShadows===m&&x.numPointShadows===g&&x.numSpotShadows===v&&x.numSpotMaps===y||(i.directional.length=u,i.spot.length=f,i.rectArea.length=h,i.point.length=d,i.hemi.length=p,i.directionalShadow.length=m,i.directionalShadowMap.length=m,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=v,i.spotShadowMap.length=v,i.directionalShadowMatrix.length=m,i.pointShadowMatrix.length=g,i.spotLightMatrix.length=v+y-b,i.spotLightMap.length=y,i.numSpotLightShadowsWithMaps=b,x.directionalLength=u,x.pointLength=d,x.spotLength=f,x.rectAreaLength=h,x.hemiLength=p,x.numDirectionalShadows=m,x.numPointShadows=g,x.numSpotShadows=v,x.numSpotMaps=y,i.version=Wk++)},setupView:function(e,t){let n=0,r=0,l=0,c=0,u=0;const d=t.matrixWorldInverse;for(let t=0,f=e.length;t<f;t++){const f=e[t];if(f.isDirectionalLight){const e=i.directional[n];e.direction.setFromMatrixPosition(f.matrixWorld),o.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(d),n++}else if(f.isSpotLight){const e=i.spot[l];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),e.direction.setFromMatrixPosition(f.matrixWorld),o.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(d),l++}else if(f.isRectAreaLight){const e=i.rectArea[c];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),s.identity(),a.copy(f.matrixWorld),a.premultiply(d),s.extractRotation(a),e.halfWidth.set(.5*f.width,0,0),e.halfHeight.set(0,.5*f.height,0),e.halfWidth.applyMatrix4(s),e.halfHeight.applyMatrix4(s),c++}else if(f.isPointLight){const e=i.point[r];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),r++}else if(f.isHemisphereLight){const e=i.hemi[u];e.direction.setFromMatrixPosition(f.matrixWorld),e.direction.transformDirection(d),u++}}},state:i}}function Kk(e,t){const n=new qk(e,t),r=[],i=[];return{init:function(){r.length=0,i.length=0},state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:function(e){n.setup(r,e)},setupLightsView:function(e){n.setupView(r,e)},pushLight:function(e){r.push(e)},pushShadow:function(e){i.push(e)}}}function Yk(e,t){let n=new WeakMap;return{get:function(r,i=0){const o=n.get(r);let a;return void 0===o?(a=new Kk(e,t),n.set(r,[a])):i>=o.length?(a=new Kk(e,t),o.push(a)):a=o[i],a},dispose:function(){n=new WeakMap}}}class Jk extends EA{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=jS,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 Qk extends EA{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new d_,this.nearDistance=1,this.farDistance=1e3,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.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Xk(e,t,n){let r=new OE;const i=new NM,o=new NM,a=new r_,s=new Jk({depthPacking:FS}),l=new Qk,c={},u=n.maxTextureSize,d={0:xw,1:ww,2:Sw},f=new yE({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new NM},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),h=f.clone();h.defines.HORIZONTAL_PASS=1;const p=new YA;p.setAttribute("position",new IA(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new fE(p,f),g=this;function v(n,r){const o=t.update(m);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,h.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,h.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new i_(i.x,i.y)),f.uniforms.shadow_pass.value=n.map.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,o,f,m,null),h.uniforms.shadow_pass.value=n.mapPass.texture,h.uniforms.resolution.value=n.mapSize,h.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,o,h,m,null)}function y(t,n,r,i,o,a){let u=null;const f=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(u=void 0!==f?f:!0===r.isPointLight?l:s,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0){const e=u.uuid,t=n.uuid;let r=c[e];void 0===r&&(r={},c[e]=r);let i=r[t];void 0===i&&(i=u.clone(),r[t]=i),u=i}return u.visible=n.visible,u.wireframe=n.wireframe,u.side=a===bw?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:d[n.side],u.alphaMap=n.alphaMap,u.alphaTest=n.alphaTest,u.clipShadows=n.clipShadows,u.clippingPlanes=n.clippingPlanes,u.clipIntersection=n.clipIntersection,u.displacementMap=n.displacementMap,u.displacementScale=n.displacementScale,u.displacementBias=n.displacementBias,u.wireframeLinewidth=n.wireframeLinewidth,u.linewidth=n.linewidth,!0===r.isPointLight&&!0===u.isMeshDistanceMaterial&&(u.referencePosition.setFromMatrixPosition(r.matrixWorld),u.nearDistance=i,u.farDistance=o),u}function b(n,i,o,a,s){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===bw)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n.matrixWorld);const r=t.update(n),i=n.material;if(Array.isArray(i)){const t=r.groups;for(let l=0,c=t.length;l<c;l++){const c=t[l],u=i[c.materialIndex];if(u&&u.visible){const t=y(n,u,a,o.near,o.far,s);e.renderBufferDirect(o,null,r,t,n,c)}}}else if(i.visible){const t=y(n,i,a,o.near,o.far,s);e.renderBufferDirect(o,null,r,t,n,null)}}const l=n.children;for(let e=0,t=l.length;e<t;e++)b(l[e],i,o,a,s)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=vw,this.render=function(t,n,s){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===t.length)return;const l=e.getRenderTarget(),c=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(Mw),f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);for(let l=0,c=t.length;l<c;l++){const c=t[l],d=c.shadow;if(void 0===d){console.warn("THREE.WebGLShadowMap:",c,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;i.copy(d.mapSize);const h=d.getFrameExtents();if(i.multiply(h),o.copy(d.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(o.x=Math.floor(u/h.x),i.x=o.x*h.x,d.mapSize.x=o.x),i.y>u&&(o.y=Math.floor(u/h.y),i.y=o.y*h.y,d.mapSize.y=o.y)),null===d.map){const e=this.type!==bw?{minFilter:vx,magFilter:vx}:{};d.map=new i_(i.x,i.y,e),d.map.texture.name=c.name+".shadowMap",d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();const p=d.getViewportCount();for(let e=0;e<p;e++){const t=d.getViewport(e);a.set(o.x*t.x,o.y*t.y,o.x*t.z,o.y*t.w),f.viewport(a),d.updateMatrices(c,e),r=d.getFrustum(),b(n,s,d.camera,c,this.type)}!0!==d.isPointLightShadow&&this.type===bw&&v(d,s),d.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(l,c,d)}}function Zk(e,t,n){const r=n.isWebGL2;const i=new function(){let t=!1;const n=new r_;let r=null;const i=new r_(0,0,0,0);return{setMask:function(n){r===n||t||(e.colorMask(n,n,n,n),r=n)},setLocked:function(e){t=e},setClear:function(t,r,o,a,s){!0===s&&(t*=a,r*=a,o*=a),n.set(t,r,o,a),!1===i.equals(n)&&(e.clearColor(t,r,o,a),i.copy(n))},reset:function(){t=!1,r=null,i.set(-1,0,0,0)}}},o=new function(){let t=!1,n=null,r=null,i=null;return{setTest:function(e){e?U(2929):z(2929)},setMask:function(r){n===r||t||(e.depthMask(r),n=r)},setFunc:function(t){if(r!==t){if(t)switch(t){case Gw:e.depthFunc(512);break;case qw:e.depthFunc(519);break;case Kw:e.depthFunc(513);break;case Yw:e.depthFunc(515);break;case Jw:e.depthFunc(514);break;case Qw:e.depthFunc(518);break;case Xw:e.depthFunc(516);break;case Zw:e.depthFunc(517);break;default:e.depthFunc(515)}else e.depthFunc(515);r=t}},setLocked:function(e){t=e},setClear:function(t){i!==t&&(e.clearDepth(t),i=t)},reset:function(){t=!1,n=null,r=null,i=null}}},a=new function(){let t=!1,n=null,r=null,i=null,o=null,a=null,s=null,l=null,c=null;return{setTest:function(e){t||(e?U(2960):z(2960))},setMask:function(r){n===r||t||(e.stencilMask(r),n=r)},setFunc:function(t,n,a){r===t&&i===n&&o===a||(e.stencilFunc(t,n,a),r=t,i=n,o=a)},setOp:function(t,n,r){a===t&&s===n&&l===r||(e.stencilOp(t,n,r),a=t,s=n,l=r)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,r=null,i=null,o=null,a=null,s=null,l=null,c=null}}},s=new WeakMap,l=new WeakMap;let c={},u={},d=new WeakMap,f=[],h=null,p=!1,m=null,g=null,v=null,y=null,b=null,w=null,x=null,S=!1,M=null,_=null,A=null,E=null,C=null;const k=e.getParameter(35661);let T=!1,I=0;const O=e.getParameter(7938);-1!==O.indexOf("WebGL")?(I=parseFloat(/^WebGL (\d)/.exec(O)[1]),T=I>=1):-1!==O.indexOf("OpenGL ES")&&(I=parseFloat(/^OpenGL ES (\d)/.exec(O)[1]),T=I>=2);let R=null,P={};const N=e.getParameter(3088),L=e.getParameter(2978),D=(new r_).fromArray(N),B=(new r_).fromArray(L);function j(t,n,r){const i=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;t<r;t++)e.texImage2D(n+t,0,6408,1,1,0,6408,5121,i);return o}const F={};function U(t){!0!==c[t]&&(e.enable(t),c[t]=!0)}function z(t){!1!==c[t]&&(e.disable(t),c[t]=!1)}F[3553]=j(3553,3553,1),F[34067]=j(34067,34069,6),i.setClear(0,0,0,1),o.setClear(1),a.setClear(0),U(2929),o.setFunc(Yw),G(!1),q(hw),U(2884),W(Mw);const H={[Tw]:32774,[Iw]:32778,[Ow]:32779};if(r)H[Rw]=32775,H[Pw]=32776;else{const e=t.get("EXT_blend_minmax");null!==e&&(H[Rw]=e.MIN_EXT,H[Pw]=e.MAX_EXT)}const V={[Nw]:0,[Lw]:1,[Dw]:768,[jw]:770,[Ww]:776,[Hw]:774,[Uw]:772,[Bw]:769,[Fw]:771,[Vw]:775,[zw]:773};function W(t,n,r,i,o,a,s,l){if(t!==Mw){if(!1===p&&(U(3042),p=!0),t===kw)o=o||n,a=a||r,s=s||i,n===g&&o===b||(e.blendEquationSeparate(H[n],H[o]),g=n,b=o),r===v&&i===y&&a===w&&s===x||(e.blendFuncSeparate(V[r],V[i],V[a],V[s]),v=r,y=i,w=a,x=s),m=t,S=null;else if(t!==m||l!==S){if(g===Tw&&b===Tw||(e.blendEquation(32774),g=Tw,b=Tw),l)switch(t){case _w:e.blendFuncSeparate(1,771,1,771);break;case Aw:e.blendFunc(1,1);break;case Ew:e.blendFuncSeparate(0,769,0,1);break;case Cw:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case _w:e.blendFuncSeparate(770,771,1,771);break;case Aw:e.blendFunc(770,1);break;case Ew:e.blendFuncSeparate(0,769,0,1);break;case Cw:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}v=null,y=null,w=null,x=null,m=t,S=l}}else!0===p&&(z(3042),p=!1)}function G(t){M!==t&&(t?e.frontFace(2304):e.frontFace(2305),M=t)}function q(t){t!==fw?(U(2884),t!==_&&(t===hw?e.cullFace(1029):t===pw?e.cullFace(1028):e.cullFace(1032))):z(2884),_=t}function K(t,n,r){t?(U(32823),E===n&&C===r||(e.polygonOffset(n,r),E=n,C=r)):z(32823)}function Y(t){void 0===t&&(t=33984+k-1),R!==t&&(e.activeTexture(t),R=t)}return{buffers:{color:i,depth:o,stencil:a},enable:U,disable:z,bindFramebuffer:function(t,n){return u[t]!==n&&(e.bindFramebuffer(t,n),u[t]=n,r&&(36009===t&&(u[36160]=n),36160===t&&(u[36009]=n)),!0)},drawBuffers:function(r,i){let o=f,a=!1;if(r)if(o=d.get(i),void 0===o&&(o=[],d.set(i,o)),r.isWebGLMultipleRenderTargets){const e=r.texture;if(o.length!==e.length||36064!==o[0]){for(let t=0,n=e.length;t<n;t++)o[t]=36064+t;o.length=e.length,a=!0}}else 36064!==o[0]&&(o[0]=36064,a=!0);else 1029!==o[0]&&(o[0]=1029,a=!0);a&&(n.isWebGL2?e.drawBuffers(o):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(o))},useProgram:function(t){return h!==t&&(e.useProgram(t),h=t,!0)},setBlending:W,setMaterial:function(e,t){e.side===Sw?z(2884):U(2884);let n=e.side===xw;t&&(n=!n),G(n),e.blending===_w&&!1===e.transparent?W(Mw):W(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),o.setFunc(e.depthFunc),o.setTest(e.depthTest),o.setMask(e.depthWrite),i.setMask(e.colorWrite);const r=e.stencilWrite;a.setTest(r),r&&(a.setMask(e.stencilWriteMask),a.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),a.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),K(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?U(32926):z(32926)},setFlipSided:G,setCullFace:q,setLineWidth:function(t){t!==A&&(T&&e.lineWidth(t),A=t)},setPolygonOffset:K,setScissorTest:function(e){e?U(3089):z(3089)},activeTexture:Y,bindTexture:function(t,n){null===R&&Y();let r=P[R];void 0===r&&(r={type:void 0,texture:void 0},P[R]=r),r.type===t&&r.texture===n||(e.bindTexture(t,n||F[t]),r.type=t,r.texture=n)},unbindTexture:function(){const t=P[R];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},updateUBOMapping:function(t,n){let r=l.get(n);void 0===r&&(r=new WeakMap,l.set(n,r));let i=r.get(t);void 0===i&&(i=e.getUniformBlockIndex(n,t.name),r.set(t,i))},uniformBlockBinding:function(t,n){const r=l.get(n).get(t);s.get(t)!==r&&(e.uniformBlockBinding(n,r,t.__bindingPointIndex),s.set(t,r))},texStorage2D:function(){try{e.texStorage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===D.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),D.copy(t))},viewport:function(t){!1===B.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),B.copy(t))},reset:function(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),!0===r&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),c={},R=null,P={},u={},d=new WeakMap,f=[],h=null,p=!1,m=null,g=null,v=null,y=null,b=null,w=null,x=null,S=!1,M=null,_=null,A=null,E=null,C=null,D.set(0,0,e.canvas.width,e.canvas.height),B.set(0,0,e.canvas.width,e.canvas.height),i.reset(),o.reset(),a.reset()}}}function $k(e,t,n,r,i,o,a){const s=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,u=i.maxTextureSize,d=i.maxSamples,f=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,h=/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap;let m;const g=new WeakMap;let v=!1;try{v="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function y(e,t){return v?new OffscreenCanvas(e,t):FM("canvas")}function b(e,t,n,r){let i=1;if((e.width>r||e.height>r)&&(i=r/Math.max(e.width,e.height)),i<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const r=t?IM:Math.floor,o=r(i*e.width),a=r(i*e.height);void 0===m&&(m=y(o,a));const s=n?y(o,a):m;s.width=o,s.height=a;return s.getContext("2d").drawImage(e,0,0,o,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+a+")."),s}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function w(e){return kM(e.width)&&kM(e.height)}function x(e,t){return e.generateMipmaps&&t&&e.minFilter!==vx&&e.minFilter!==Sx}function S(t){e.generateMipmap(t)}function M(n,r,i,o,a=!1){if(!1===s)return r;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=r;return 6403===r&&(5126===i&&(l=33326),5131===i&&(l=33325),5121===i&&(l=33321)),33319===r&&(5126===i&&(l=33328),5131===i&&(l=33327),5121===i&&(l=33323)),6408===r&&(5126===i&&(l=34836),5131===i&&(l=34842),5121===i&&(l=o===BS&&!1===a?35907:32856),32819===i&&(l=32854),32820===i&&(l=32855)),33325!==l&&33326!==l&&33327!==l&&33328!==l&&34842!==l&&34836!==l||t.get("EXT_color_buffer_float"),l}function _(e,t,n){return!0===x(e,n)||e.isFramebufferTexture&&e.minFilter!==vx&&e.minFilter!==Sx?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function A(e){return e===vx||e===yx||e===wx?9728:9729}function E(e){const t=e.target;t.removeEventListener("dispose",E),function(e){const t=r.get(e);if(void 0===t.__webglInit)return;const n=e.source,i=g.get(n);if(i){const r=i[t.__cacheKey];r.usedTimes--,0===r.usedTimes&&k(e),0===Object.keys(i).length&&g.delete(n)}r.remove(e)}(t),t.isVideoTexture&&p.delete(t)}function C(t){const n=t.target;n.removeEventListener("dispose",C),function(t){const n=t.texture,i=r.get(t),o=r.get(n);void 0!==o.__webglTexture&&(e.deleteTexture(o.__webglTexture),a.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(i.__webglFramebuffer[t]),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer[t]);else{if(e.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&e.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let t=0;t<i.__webglColorRenderbuffer.length;t++)i.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(i.__webglColorRenderbuffer[t]);i.__webglDepthRenderbuffer&&e.deleteRenderbuffer(i.__webglDepthRenderbuffer)}if(t.isWebGLMultipleRenderTargets)for(let t=0,i=n.length;t<i;t++){const i=r.get(n[t]);i.__webglTexture&&(e.deleteTexture(i.__webglTexture),a.memory.textures--),r.remove(n[t])}r.remove(n),r.remove(t)}(n)}function k(t){const n=r.get(t);e.deleteTexture(n.__webglTexture);const i=t.source;delete g.get(i)[n.__cacheKey],a.memory.textures--}let T=0;function I(e,t){const i=r.get(e);if(e.isVideoTexture&&function(e){const t=a.render.frame;p.get(e)!==t&&(p.set(e,t),e.update())}(e),!1===e.isRenderTargetTexture&&e.version>0&&i.__version!==e.version){const n=e.image;if(null===n)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==n.complete)return void L(i,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+t),n.bindTexture(3553,i.__webglTexture)}const O={[px]:10497,[mx]:33071,[gx]:33648},R={[vx]:9728,[yx]:9984,[wx]:9986,[Sx]:9729,[Mx]:9985,[Ax]:9987};function P(n,o,a){if(a?(e.texParameteri(n,10242,O[o.wrapS]),e.texParameteri(n,10243,O[o.wrapT]),32879!==n&&35866!==n||e.texParameteri(n,32882,O[o.wrapR]),e.texParameteri(n,10240,R[o.magFilter]),e.texParameteri(n,10241,R[o.minFilter])):(e.texParameteri(n,10242,33071),e.texParameteri(n,10243,33071),32879!==n&&35866!==n||e.texParameteri(n,32882,33071),o.wrapS===mx&&o.wrapT===mx||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,10240,A(o.magFilter)),e.texParameteri(n,10241,A(o.minFilter)),o.minFilter!==vx&&o.minFilter!==Sx&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===t.has("EXT_texture_filter_anisotropic")){const a=t.get("EXT_texture_filter_anisotropic");if(o.type===Px&&!1===t.has("OES_texture_float_linear"))return;if(!1===s&&o.type===Nx&&!1===t.has("OES_texture_half_float_linear"))return;(o.anisotropy>1||r.get(o).__currentAnisotropy)&&(e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,i.getMaxAnisotropy())),r.get(o).__currentAnisotropy=o.anisotropy)}}function N(t,n){let r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",E));const i=n.source;let o=g.get(i);void 0===o&&(o={},g.set(i,o));const s=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.encoding),t.join()}(n);if(s!==t.__cacheKey){void 0===o[s]&&(o[s]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,r=!0),o[s].usedTimes++;const i=o[t.__cacheKey];void 0!==i&&(o[t.__cacheKey].usedTimes--,0===i.usedTimes&&k(n)),t.__cacheKey=s,t.__webglTexture=o[s].texture}return r}function L(t,r,i){let a=3553;r.isDataArrayTexture&&(a=35866),r.isData3DTexture&&(a=32879);const l=N(t,r),c=r.source;if(n.activeTexture(33984+i),n.bindTexture(a,t.__webglTexture),c.version!==c.__currentVersion||!0===l){e.pixelStorei(37440,r.flipY),e.pixelStorei(37441,r.premultiplyAlpha),e.pixelStorei(3317,r.unpackAlignment),e.pixelStorei(37443,0);const t=function(e){return!s&&(e.wrapS!==mx||e.wrapT!==mx||e.minFilter!==vx&&e.minFilter!==Sx)}(r)&&!1===w(r.image);let i=b(r.image,t,!1,u);i=z(r,i);const d=w(i)||s,f=o.convert(r.format,r.encoding);let h,p=o.convert(r.type),m=M(r.internalFormat,f,p,r.encoding,r.isVideoTexture);P(a,r,d);const g=r.mipmaps,v=s&&!0!==r.isVideoTexture,y=void 0===c.__currentVersion||!0===l,A=_(r,i,d);if(r.isDepthTexture)m=6402,s?m=r.type===Px?36012:r.type===Rx?33190:r.type===Bx?35056:33189:r.type===Px&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===Vx&&6402===m&&r.type!==Ix&&r.type!==Rx&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Rx,p=o.convert(r.type)),r.format===Wx&&6402===m&&(m=34041,r.type!==Bx&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Bx,p=o.convert(r.type))),y&&(v?n.texStorage2D(3553,1,m,i.width,i.height):n.texImage2D(3553,0,m,i.width,i.height,0,f,p,null));else if(r.isDataTexture)if(g.length>0&&d){v&&y&&n.texStorage2D(3553,A,m,g[0].width,g[0].height);for(let e=0,t=g.length;e<t;e++)h=g[e],v?n.texSubImage2D(3553,e,0,0,h.width,h.height,f,p,h.data):n.texImage2D(3553,e,m,h.width,h.height,0,f,p,h.data);r.generateMipmaps=!1}else v?(y&&n.texStorage2D(3553,A,m,i.width,i.height),n.texSubImage2D(3553,0,0,0,i.width,i.height,f,p,i.data)):n.texImage2D(3553,0,m,i.width,i.height,0,f,p,i.data);else if(r.isCompressedTexture){v&&y&&n.texStorage2D(3553,A,m,g[0].width,g[0].height);for(let e=0,t=g.length;e<t;e++)h=g[e],r.format!==Ux?null!==f?v?n.compressedTexSubImage2D(3553,e,0,0,h.width,h.height,f,h.data):n.compressedTexImage2D(3553,e,m,h.width,h.height,0,h.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):v?n.texSubImage2D(3553,e,0,0,h.width,h.height,f,p,h.data):n.texImage2D(3553,e,m,h.width,h.height,0,f,p,h.data)}else if(r.isDataArrayTexture)v?(y&&n.texStorage3D(35866,A,m,i.width,i.height,i.depth),n.texSubImage3D(35866,0,0,0,0,i.width,i.height,i.depth,f,p,i.data)):n.texImage3D(35866,0,m,i.width,i.height,i.depth,0,f,p,i.data);else if(r.isData3DTexture)v?(y&&n.texStorage3D(32879,A,m,i.width,i.height,i.depth),n.texSubImage3D(32879,0,0,0,0,i.width,i.height,i.depth,f,p,i.data)):n.texImage3D(32879,0,m,i.width,i.height,i.depth,0,f,p,i.data);else if(r.isFramebufferTexture){if(y)if(v)n.texStorage2D(3553,A,m,i.width,i.height);else{let e=i.width,t=i.height;for(let r=0;r<A;r++)n.texImage2D(3553,r,m,e,t,0,f,p,null),e>>=1,t>>=1}}else if(g.length>0&&d){v&&y&&n.texStorage2D(3553,A,m,g[0].width,g[0].height);for(let e=0,t=g.length;e<t;e++)h=g[e],v?n.texSubImage2D(3553,e,0,0,f,p,h):n.texImage2D(3553,e,m,f,p,h);r.generateMipmaps=!1}else v?(y&&n.texStorage2D(3553,A,m,i.width,i.height),n.texSubImage2D(3553,0,0,0,f,p,i)):n.texImage2D(3553,0,m,f,p,i);x(r,d)&&S(a),c.__currentVersion=c.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}function D(t,i,a,s,l){const c=o.convert(a.format,a.encoding),u=o.convert(a.type),d=M(a.internalFormat,c,u,a.encoding);r.get(i).__hasExternalTextures||(32879===l||35866===l?n.texImage3D(l,0,d,i.width,i.height,i.depth,0,c,u,null):n.texImage2D(l,0,d,i.width,i.height,0,c,u,null)),n.bindFramebuffer(36160,t),U(i)?f.framebufferTexture2DMultisampleEXT(36160,s,l,r.get(a).__webglTexture,0,F(i)):e.framebufferTexture2D(36160,s,l,r.get(a).__webglTexture,0),n.bindFramebuffer(36160,null)}function B(t,n,r){if(e.bindRenderbuffer(36161,t),n.depthBuffer&&!n.stencilBuffer){let i=33189;if(r||U(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===Px?i=36012:t.type===Rx&&(i=33190));const r=F(n);U(n)?f.renderbufferStorageMultisampleEXT(36161,r,i,n.width,n.height):e.renderbufferStorageMultisample(36161,r,i,n.width,n.height)}else e.renderbufferStorage(36161,i,n.width,n.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(n.depthBuffer&&n.stencilBuffer){const i=F(n);r&&!1===U(n)?e.renderbufferStorageMultisample(36161,i,35056,n.width,n.height):U(n)?f.renderbufferStorageMultisampleEXT(36161,i,35056,n.width,n.height):e.renderbufferStorage(36161,34041,n.width,n.height),e.framebufferRenderbuffer(36160,33306,36161,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let i=0;i<t.length;i++){const a=t[i],s=o.convert(a.format,a.encoding),l=o.convert(a.type),c=M(a.internalFormat,s,l,a.encoding),u=F(n);r&&!1===U(n)?e.renderbufferStorageMultisample(36161,u,c,n.width,n.height):U(n)?f.renderbufferStorageMultisampleEXT(36161,u,c,n.width,n.height):e.renderbufferStorage(36161,c,n.width,n.height)}}e.bindRenderbuffer(36161,null)}function j(t){const i=r.get(t),o=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(o)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,i){if(i&&i.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(36160,t),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(i.depthTexture).__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),I(i.depthTexture,0);const o=r.get(i.depthTexture).__webglTexture,a=F(i);if(i.depthTexture.format===Vx)U(i)?f.framebufferTexture2DMultisampleEXT(36160,36096,3553,o,0,a):e.framebufferTexture2D(36160,36096,3553,o,0);else{if(i.depthTexture.format!==Wx)throw new Error("Unknown depthTexture format");U(i)?f.framebufferTexture2DMultisampleEXT(36160,33306,3553,o,0,a):e.framebufferTexture2D(36160,33306,3553,o,0)}}(i.__webglFramebuffer,t)}else if(o){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)n.bindFramebuffer(36160,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]=e.createRenderbuffer(),B(i.__webglDepthbuffer[r],t,!1)}else n.bindFramebuffer(36160,i.__webglFramebuffer),i.__webglDepthbuffer=e.createRenderbuffer(),B(i.__webglDepthbuffer,t,!1);n.bindFramebuffer(36160,null)}function F(e){return Math.min(d,e.samples)}function U(e){const n=r.get(e);return s&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function z(e,n){const r=e.encoding,i=e.format,o=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===yM||r!==DS&&(r===BS?!1===s?!0===t.has("EXT_sRGB")&&i===Ux?(e.format=yM,e.minFilter=Sx,e.generateMipmaps=!1):n=ZM.sRGBToLinear(n):i===Ux&&o===Cx||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",r)),n}this.allocateTextureUnit=function(){const e=T;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),T+=1,e},this.resetTextureUnits=function(){T=0},this.setTexture2D=I,this.setTexture2DArray=function(e,t){const i=r.get(e);e.version>0&&i.__version!==e.version?L(i,e,t):(n.activeTexture(33984+t),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(e,t){const i=r.get(e);e.version>0&&i.__version!==e.version?L(i,e,t):(n.activeTexture(33984+t),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=function(t,i){const a=r.get(t);t.version>0&&a.__version!==t.version?function(t,r,i){if(6!==r.image.length)return;const a=N(t,r),l=r.source;if(n.activeTexture(33984+i),n.bindTexture(34067,t.__webglTexture),l.version!==l.__currentVersion||!0===a){e.pixelStorei(37440,r.flipY),e.pixelStorei(37441,r.premultiplyAlpha),e.pixelStorei(3317,r.unpackAlignment),e.pixelStorei(37443,0);const t=r.isCompressedTexture||r.image[0].isCompressedTexture,i=r.image[0]&&r.image[0].isDataTexture,u=[];for(let e=0;e<6;e++)u[e]=t||i?i?r.image[e].image:r.image[e]:b(r.image[e],!1,!0,c),u[e]=z(r,u[e]);const d=u[0],f=w(d)||s,h=o.convert(r.format,r.encoding),p=o.convert(r.type),m=M(r.internalFormat,h,p,r.encoding),g=s&&!0!==r.isVideoTexture,v=void 0===l.__currentVersion||!0===a;let y,A=_(r,d,f);if(P(34067,r,f),t){g&&v&&n.texStorage2D(34067,A,m,d.width,d.height);for(let e=0;e<6;e++){y=u[e].mipmaps;for(let t=0;t<y.length;t++){const i=y[t];r.format!==Ux?null!==h?g?n.compressedTexSubImage2D(34069+e,t,0,0,i.width,i.height,h,i.data):n.compressedTexImage2D(34069+e,t,m,i.width,i.height,0,i.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):g?n.texSubImage2D(34069+e,t,0,0,i.width,i.height,h,p,i.data):n.texImage2D(34069+e,t,m,i.width,i.height,0,h,p,i.data)}}}else{y=r.mipmaps,g&&v&&(y.length>0&&A++,n.texStorage2D(34067,A,m,u[0].width,u[0].height));for(let e=0;e<6;e++)if(i){g?n.texSubImage2D(34069+e,0,0,0,u[e].width,u[e].height,h,p,u[e].data):n.texImage2D(34069+e,0,m,u[e].width,u[e].height,0,h,p,u[e].data);for(let t=0;t<y.length;t++){const r=y[t].image[e].image;g?n.texSubImage2D(34069+e,t+1,0,0,r.width,r.height,h,p,r.data):n.texImage2D(34069+e,t+1,m,r.width,r.height,0,h,p,r.data)}}else{g?n.texSubImage2D(34069+e,0,0,0,h,p,u[e]):n.texImage2D(34069+e,0,m,h,p,u[e]);for(let t=0;t<y.length;t++){const r=y[t];g?n.texSubImage2D(34069+e,t+1,0,0,h,p,r.image[e]):n.texImage2D(34069+e,t+1,m,h,p,r.image[e])}}}x(r,f)&&S(34067),l.__currentVersion=l.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}(a,t,i):(n.activeTexture(33984+i),n.bindTexture(34067,a.__webglTexture))},this.rebindTextures=function(e,t,n){const i=r.get(e);void 0!==t&&D(i.__webglFramebuffer,e,e.texture,36064,3553),void 0!==n&&j(e)},this.setupRenderTarget=function(t){const l=t.texture,c=r.get(t),u=r.get(l);t.addEventListener("dispose",C),!0!==t.isWebGLMultipleRenderTargets&&(void 0===u.__webglTexture&&(u.__webglTexture=e.createTexture()),u.__version=l.version,a.memory.textures++);const d=!0===t.isWebGLCubeRenderTarget,f=!0===t.isWebGLMultipleRenderTargets,h=w(t)||s;if(d){c.__webglFramebuffer=[];for(let t=0;t<6;t++)c.__webglFramebuffer[t]=e.createFramebuffer()}else{if(c.__webglFramebuffer=e.createFramebuffer(),f)if(i.drawBuffers){const n=t.texture;for(let t=0,i=n.length;t<i;t++){const i=r.get(n[t]);void 0===i.__webglTexture&&(i.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(s&&t.samples>0&&!1===U(t)){const r=f?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(36160,c.__webglMultisampledFramebuffer);for(let n=0;n<r.length;n++){const i=r[n];c.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(36161,c.__webglColorRenderbuffer[n]);const a=o.convert(i.format,i.encoding),s=o.convert(i.type),l=M(i.internalFormat,a,s,i.encoding),u=F(t);e.renderbufferStorageMultisample(36161,u,l,t.width,t.height),e.framebufferRenderbuffer(36160,36064+n,36161,c.__webglColorRenderbuffer[n])}e.bindRenderbuffer(36161,null),t.depthBuffer&&(c.__webglDepthRenderbuffer=e.createRenderbuffer(),B(c.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(36160,null)}}if(d){n.bindTexture(34067,u.__webglTexture),P(34067,l,h);for(let e=0;e<6;e++)D(c.__webglFramebuffer[e],t,l,36064,34069+e);x(l,h)&&S(34067),n.unbindTexture()}else if(f){const e=t.texture;for(let i=0,o=e.length;i<o;i++){const o=e[i],a=r.get(o);n.bindTexture(3553,a.__webglTexture),P(3553,o,h),D(c.__webglFramebuffer,t,o,36064+i,3553),x(o,h)&&S(3553)}n.unbindTexture()}else{let e=3553;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(s?e=t.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(e,u.__webglTexture),P(e,l,h),D(c.__webglFramebuffer,t,l,36064,e),x(l,h)&&S(e),n.unbindTexture()}t.depthBuffer&&j(t)},this.updateRenderTargetMipmap=function(e){const t=w(e)||s,i=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let o=0,a=i.length;o<a;o++){const a=i[o];if(x(a,t)){const t=e.isWebGLCubeRenderTarget?34067:3553,i=r.get(a).__webglTexture;n.bindTexture(t,i),S(t),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(s&&t.samples>0&&!1===U(t)){const i=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],o=t.width,a=t.height;let s=16384;const l=[],c=t.stencilBuffer?33306:36096,u=r.get(t),d=!0===t.isWebGLMultipleRenderTargets;if(d)for(let t=0;t<i.length;t++)n.bindFramebuffer(36160,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+t,36161,null),n.bindFramebuffer(36160,u.__webglFramebuffer),e.framebufferTexture2D(36009,36064+t,3553,null,0);n.bindFramebuffer(36008,u.__webglMultisampledFramebuffer),n.bindFramebuffer(36009,u.__webglFramebuffer);for(let n=0;n<i.length;n++){l.push(36064+n),t.depthBuffer&&l.push(c);const f=void 0!==u.__ignoreDepthValues&&u.__ignoreDepthValues;if(!1===f&&(t.depthBuffer&&(s|=256),t.stencilBuffer&&(s|=1024)),d&&e.framebufferRenderbuffer(36008,36064,36161,u.__webglColorRenderbuffer[n]),!0===f&&(e.invalidateFramebuffer(36008,[c]),e.invalidateFramebuffer(36009,[c])),d){const t=r.get(i[n]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,t,0)}e.blitFramebuffer(0,0,o,a,0,0,o,a,s,9728),h&&e.invalidateFramebuffer(36008,l)}if(n.bindFramebuffer(36008,null),n.bindFramebuffer(36009,null),d)for(let t=0;t<i.length;t++){n.bindFramebuffer(36160,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+t,36161,u.__webglColorRenderbuffer[t]);const o=r.get(i[t]).__webglTexture;n.bindFramebuffer(36160,u.__webglFramebuffer),e.framebufferTexture2D(36009,36064+t,3553,o,0)}n.bindFramebuffer(36009,u.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=j,this.setupFrameBufferTexture=D,this.useMultisampledRTT=U}function eT(e,t,n){const r=n.isWebGL2;return{convert:function(n,i=null){let o;if(n===Cx)return 5121;if(n===Lx)return 32819;if(n===Dx)return 32820;if(n===kx)return 5120;if(n===Tx)return 5122;if(n===Ix)return 5123;if(n===Ox)return 5124;if(n===Rx)return 5125;if(n===Px)return 5126;if(n===Nx)return r?5131:(o=t.get("OES_texture_half_float"),null!==o?o.HALF_FLOAT_OES:null);if(n===jx)return 6406;if(n===Ux)return 6408;if(n===zx)return 6409;if(n===Hx)return 6410;if(n===Vx)return 6402;if(n===Wx)return 34041;if(n===Gx)return 6403;if(n===Fx)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(n===yM)return o=t.get("EXT_sRGB"),null!==o?o.SRGB_ALPHA_EXT:null;if(n===qx)return 36244;if(n===Kx)return 33319;if(n===Yx)return 33320;if(n===Jx)return 36249;if(n===Qx||n===Xx||n===Zx||n===$x)if(i===BS){if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===o)return null;if(n===Qx)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Xx)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Zx)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===$x)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(o=t.get("WEBGL_compressed_texture_s3tc"),null===o)return null;if(n===Qx)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Xx)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Zx)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===$x)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===eS||n===tS||n===nS||n===rS){if(o=t.get("WEBGL_compressed_texture_pvrtc"),null===o)return null;if(n===eS)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===tS)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===nS)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===rS)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===iS)return o=t.get("WEBGL_compressed_texture_etc1"),null!==o?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===oS||n===aS){if(o=t.get("WEBGL_compressed_texture_etc"),null===o)return null;if(n===oS)return i===BS?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===aS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}if(n===sS||n===lS||n===cS||n===uS||n===dS||n===fS||n===hS||n===pS||n===mS||n===gS||n===vS||n===yS||n===bS||n===wS){if(o=t.get("WEBGL_compressed_texture_astc"),null===o)return null;if(n===sS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===lS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===cS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===uS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===dS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===fS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===hS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===pS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===mS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===gS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===vS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===yS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===bS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===wS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===xS){if(o=t.get("EXT_texture_compression_bptc"),null===o)return null;if(n===xS)return i===BS?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}return n===Bx?r?34042:(o=t.get("WEBGL_depth_texture"),null!==o?o.UNSIGNED_INT_24_8_WEBGL:null):void 0!==e[n]?e[n]:null}}}class tT extends wE{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class nT extends hA{constructor(){super(),this.isGroup=!0,this.type="Group"}}const rT={type:"move"};class iT{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new nT,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new nT,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new d_,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new d_),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new nT,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new d_,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new d_),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,o=null;const a=this._targetRay,s=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){o=!0;for(const r of e.hand.values()){const e=t.getJointPose(r,n);if(void 0===l.joints[r.jointName]){const e=new nT;e.matrixAutoUpdate=!1,e.visible=!1,l.joints[r.jointName]=e,l.add(e)}const i=l.joints[r.jointName];null!==e&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.jointRadius=e.radius),i.visible=null!==e}const r=l.joints["index-finger-tip"],i=l.joints["thumb-tip"],a=r.position.distanceTo(i.position),s=.02,c=.005;l.inputState.pinching&&a>s+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=s-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));null!==a&&(r=t.getPose(e.targetRaySpace,n),null===r&&null!==i&&(r=i),null!==r&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(rT)))}return null!==a&&(a.visible=null!==r),null!==s&&(s.visible=null!==i),null!==l&&(l.visible=null!==o),this}}class oT extends n_{constructor(e,t,n,r,i,o,a,s,l,c){if((c=void 0!==c?c:Vx)!==Vx&&c!==Wx)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===Vx&&(n=Rx),void 0===n&&c===Wx&&(n=Bx),super(null,r,i,o,a,s,c,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==a?a:vx,this.minFilter=void 0!==s?s:vx,this.flipY=!1,this.generateMipmaps=!1}}class aT extends bM{constructor(e,t){super();const n=this;let r=null,i=1,o=null,a="local-floor",s=null,l=null,c=null,u=null,d=null,f=null;const h=t.getContextAttributes();let p=null,m=null;const g=[],v=[],y=new wE;y.layers.enable(1),y.viewport=new r_;const b=new wE;b.layers.enable(2),b.viewport=new r_;const w=[y,b],x=new tT;x.layers.enable(1),x.layers.enable(2);let S=null,M=null;function _(e){const t=v.indexOf(e.inputSource);if(-1===t)return;const n=g[t];void 0!==n&&n.dispatchEvent({type:e.type,data:e.inputSource})}function A(){r.removeEventListener("select",_),r.removeEventListener("selectstart",_),r.removeEventListener("selectend",_),r.removeEventListener("squeeze",_),r.removeEventListener("squeezestart",_),r.removeEventListener("squeezeend",_),r.removeEventListener("end",A),r.removeEventListener("inputsourceschange",E);for(let e=0;e<g.length;e++){const t=v[e];null!==t&&(v[e]=null,g[e].disconnect(t))}S=null,M=null,e.setRenderTarget(p),d=null,u=null,c=null,r=null,m=null,O.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function E(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],r=v.indexOf(n);r>=0&&(v[r]=null,g[r].dispatchEvent({type:"disconnected",data:n}))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let r=v.indexOf(n);if(-1===r){for(let e=0;e<g.length;e++){if(e>=v.length){v.push(n),r=e;break}if(null===v[e]){v[e]=n,r=e;break}}if(-1===r)break}const i=g[r];i&&i.dispatchEvent({type:"connected",data:n})}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=g[e];return void 0===t&&(t=new iT,g[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=g[e];return void 0===t&&(t=new iT,g[e]=t),t.getGripSpace()},this.getHand=function(e){let t=g[e];return void 0===t&&(t=new iT,g[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){i=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s||o},this.setReferenceSpace=function(e){s=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return f},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,null!==r){if(p=e.getRenderTarget(),r.addEventListener("select",_),r.addEventListener("selectstart",_),r.addEventListener("selectend",_),r.addEventListener("squeeze",_),r.addEventListener("squeezestart",_),r.addEventListener("squeezeend",_),r.addEventListener("end",A),r.addEventListener("inputsourceschange",E),!0!==h.xrCompatible&&await t.makeXRCompatible(),void 0===r.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==r.renderState.layers||h.antialias,alpha:h.alpha,depth:h.depth,stencil:h.stencil,framebufferScaleFactor:i};d=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:d}),m=new i_(d.framebufferWidth,d.framebufferHeight,{format:Ux,type:Cx,encoding:e.outputEncoding,stencilBuffer:h.stencil})}else{let n=null,o=null,a=null;h.depth&&(a=h.stencil?35056:33190,n=h.stencil?Wx:Vx,o=h.stencil?Bx:Rx);const s={colorFormat:32856,depthFormat:a,scaleFactor:i};c=new XRWebGLBinding(r,t),u=c.createProjectionLayer(s),r.updateRenderState({layers:[u]}),m=new i_(u.textureWidth,u.textureHeight,{format:Ux,type:Cx,depthTexture:new oT(u.textureWidth,u.textureHeight,o,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:h.stencil,encoding:e.outputEncoding,samples:h.antialias?4:0});e.properties.get(m).__ignoreDepthValues=u.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(1),s=null,o=await r.requestReferenceSpace(a),O.setContext(r),O.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};const C=new d_,k=new d_;function T(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===r)return;x.near=b.near=y.near=e.near,x.far=b.far=y.far=e.far,S===x.near&&M===x.far||(r.updateRenderState({depthNear:x.near,depthFar:x.far}),S=x.near,M=x.far);const t=e.parent,n=x.cameras;T(x,t);for(let e=0;e<n.length;e++)T(n[e],t);x.matrixWorld.decompose(x.position,x.quaternion,x.scale),e.matrix.copy(x.matrix),e.matrix.decompose(e.position,e.quaternion,e.scale);const i=e.children;for(let e=0,t=i.length;e<t;e++)i[e].updateMatrixWorld(!0);2===n.length?function(e,t,n){C.setFromMatrixPosition(t.matrixWorld),k.setFromMatrixPosition(n.matrixWorld);const r=C.distanceTo(k),i=t.projectionMatrix.elements,o=n.projectionMatrix.elements,a=i[14]/(i[10]-1),s=i[14]/(i[10]+1),l=(i[9]+1)/i[5],c=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(o[8]+1)/o[0],f=a*u,h=a*d,p=r/(-u+d),m=p*-u;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(p),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const g=a+p,v=s+p,y=f-m,b=h+(r-m),w=l*s/v*g,x=c*s/v*g;e.projectionMatrix.makePerspective(y,b,w,x,g,v)}(x,y,b):x.projectionMatrix.copy(y.projectionMatrix)},this.getCamera=function(){return x},this.getFoveation=function(){return null!==u?u.fixedFoveation:null!==d?d.fixedFoveation:void 0},this.setFoveation=function(e){null!==u&&(u.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)};let I=null;const O=new RE;O.setAnimationLoop((function(t,n){if(l=n.getViewerPose(s||o),f=n,null!==l){const t=l.views;null!==d&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let n=!1;t.length!==x.cameras.length&&(x.cameras.length=0,n=!0);for(let r=0;r<t.length;r++){const i=t[r];let o=null;if(null!==d)o=d.getViewport(i);else{const t=c.getViewSubImage(u,i);o=t.viewport,0===r&&(e.setRenderTargetTextures(m,t.colorTexture,u.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(m))}let a=w[r];void 0===a&&(a=new wE,a.layers.enable(r),a.viewport=new r_,w[r]=a),a.matrix.fromArray(i.transform.matrix),a.projectionMatrix.fromArray(i.projectionMatrix),a.viewport.set(o.x,o.y,o.width,o.height),0===r&&x.matrix.copy(a.matrix),!0===n&&x.cameras.push(a)}}for(let e=0;e<g.length;e++){const t=v[e],r=g[e];null!==t&&void 0!==r&&r.update(t,n,s||o)}I&&I(t,n),f=null})),this.setAnimationLoop=function(e){I=e},this.dispose=function(){}}}function sT(e,t){function n(n,r){n.opacity.value=r.opacity,r.color&&n.diffuse.value.copy(r.color),r.emissive&&n.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(n.map.value=r.map),r.alphaMap&&(n.alphaMap.value=r.alphaMap),r.bumpMap&&(n.bumpMap.value=r.bumpMap,n.bumpScale.value=r.bumpScale,r.side===xw&&(n.bumpScale.value*=-1)),r.displacementMap&&(n.displacementMap.value=r.displacementMap,n.displacementScale.value=r.displacementScale,n.displacementBias.value=r.displacementBias),r.emissiveMap&&(n.emissiveMap.value=r.emissiveMap),r.normalMap&&(n.normalMap.value=r.normalMap,n.normalScale.value.copy(r.normalScale),r.side===xw&&n.normalScale.value.negate()),r.specularMap&&(n.specularMap.value=r.specularMap),r.alphaTest>0&&(n.alphaTest.value=r.alphaTest);const i=t.get(r).envMap;if(i&&(n.envMap.value=i,n.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,n.reflectivity.value=r.reflectivity,n.ior.value=r.ior,n.refractionRatio.value=r.refractionRatio),r.lightMap){n.lightMap.value=r.lightMap;const t=!0!==e.physicallyCorrectLights?Math.PI:1;n.lightMapIntensity.value=r.lightMapIntensity*t}let o,a;r.aoMap&&(n.aoMap.value=r.aoMap,n.aoMapIntensity.value=r.aoMapIntensity),r.map?o=r.map:r.specularMap?o=r.specularMap:r.displacementMap?o=r.displacementMap:r.normalMap?o=r.normalMap:r.bumpMap?o=r.bumpMap:r.roughnessMap?o=r.roughnessMap:r.metalnessMap?o=r.metalnessMap:r.alphaMap?o=r.alphaMap:r.emissiveMap?o=r.emissiveMap:r.clearcoatMap?o=r.clearcoatMap:r.clearcoatNormalMap?o=r.clearcoatNormalMap:r.clearcoatRoughnessMap?o=r.clearcoatRoughnessMap:r.iridescenceMap?o=r.iridescenceMap:r.iridescenceThicknessMap?o=r.iridescenceThicknessMap:r.specularIntensityMap?o=r.specularIntensityMap:r.specularColorMap?o=r.specularColorMap:r.transmissionMap?o=r.transmissionMap:r.thicknessMap?o=r.thicknessMap:r.sheenColorMap?o=r.sheenColorMap:r.sheenRoughnessMap&&(o=r.sheenRoughnessMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),n.uvTransform.value.copy(o.matrix)),r.aoMap?a=r.aoMap:r.lightMap&&(a=r.lightMap),void 0!==a&&(a.isWebGLRenderTarget&&(a=a.texture),!0===a.matrixAutoUpdate&&a.updateMatrix(),n.uv2Transform.value.copy(a.matrix))}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function(e,r,i,o,a){r.isMeshBasicMaterial||r.isMeshLambertMaterial?n(e,r):r.isMeshToonMaterial?(n(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(n(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(n(e,r),function(e,n){e.roughness.value=n.roughness,e.metalness.value=n.metalness,n.roughnessMap&&(e.roughnessMap.value=n.roughnessMap);n.metalnessMap&&(e.metalnessMap.value=n.metalnessMap);const r=t.get(n).envMap;r&&(e.envMapIntensity.value=n.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,n){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap),t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,t.side===xw&&e.clearcoatNormalScale.value.negate()));t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=n.texture,e.transmissionSamplerSize.value.set(n.width,n.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap);t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap)}(e,r,a)):r.isMeshMatcapMaterial?(n(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?n(e,r):r.isMeshDistanceMaterial?(n(e,r),function(e,t){e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(e,r)):r.isMeshNormalMaterial?n(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,n,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=.5*r,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let i;t.map?i=t.map:t.alphaMap&&(i=t.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix))}(e,r,i,o):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let n;t.map?n=t.map:t.alphaMap&&(n=t.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function lT(e,t,n,r){let i={},o={},a=[];const s=n.isWebGL2?e.getParameter(35375):0;function l(e,t,n){const r=e.value;if(void 0===n[t])return n[t]="number"==typeof r?r:r.clone(),!0;if("number"==typeof r){if(n[t]!==r)return n[t]=r,!0}else{const e=n[t];if(!1===e.equals(r))return e.copy(r),!0}return!1}function c(e){const t=e.value,n={boundary:0,storage:0};return"number"==typeof t?(n.boundary=4,n.storage=4):t.isVector2?(n.boundary=8,n.storage=8):t.isVector3||t.isColor?(n.boundary=16,n.storage=12):t.isVector4?(n.boundary=16,n.storage=16):t.isMatrix3?(n.boundary=48,n.storage=48):t.isMatrix4?(n.boundary=64,n.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),n}function u(t){const n=t.target;n.removeEventListener("dispose",u);const r=a.indexOf(n.__bindingPointIndex);a.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete o[n.id]}return{bind:function(e,t){const n=t.program;r.uniformBlockBinding(e,n)},update:function(n,d){let f=i[n.id];void 0===f&&(!function(e){const t=e.uniforms;let n=0;const r=16;let i=0;for(let e=0,o=t.length;e<o;e++){const o=t[e],a=c(o);if(o.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),o.__offset=n,e>0){i=n%r;0!==i&&r-i-a.boundary<0&&(n+=r-i,o.__offset=n)}n+=a.storage}i=n%r,i>0&&(n+=r-i);e.__size=n,e.__cache={}}(n),f=function(t){const n=function(){for(let e=0;e<s;e++)if(-1===a.indexOf(e))return a.push(e),e;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const r=e.createBuffer(),i=t.__size,o=t.usage;return e.bindBuffer(35345,r),e.bufferData(35345,i,o),e.bindBuffer(35345,null),e.bindBufferBase(35345,n,r),r}(n),i[n.id]=f,n.addEventListener("dispose",u));const h=d.program;r.updateUBOMapping(n,h);const p=t.render.frame;o[n.id]!==p&&(!function(t){const n=i[t.id],r=t.uniforms,o=t.__cache;e.bindBuffer(35345,n);for(let t=0,n=r.length;t<n;t++){const n=r[t];if(!0===l(n,t,o)){const t=n.value,r=n.__offset;"number"==typeof t?(n.__data[0]=t,e.bufferSubData(35345,r,n.__data)):(n.value.isMatrix3?(n.__data[0]=n.value.elements[0],n.__data[1]=n.value.elements[1],n.__data[2]=n.value.elements[2],n.__data[3]=n.value.elements[0],n.__data[4]=n.value.elements[3],n.__data[5]=n.value.elements[4],n.__data[6]=n.value.elements[5],n.__data[7]=n.value.elements[0],n.__data[8]=n.value.elements[6],n.__data[9]=n.value.elements[7],n.__data[10]=n.value.elements[8],n.__data[11]=n.value.elements[0]):t.toArray(n.__data),e.bufferSubData(35345,r,n.__data))}}e.bindBuffer(35345,null)}(n),o[n.id]=p)},dispose:function(){for(const t in i)e.deleteBuffer(i[t]);a=[],i={},o={}}}}function cT(e={}){this.isWebGLRenderer=!0;const t=void 0!==e.canvas?e.canvas:function(){const e=FM("canvas");return e.style.display="block",e}(),n=void 0!==e.context?e.context:null,r=void 0===e.depth||e.depth,i=void 0===e.stencil||e.stencil,o=void 0!==e.antialias&&e.antialias,a=void 0===e.premultipliedAlpha||e.premultipliedAlpha,s=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,l=void 0!==e.powerPreference?e.powerPreference:"default",c=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let u;u=null!==n?n.getContextAttributes().alpha:void 0!==e.alpha&&e.alpha;let d=null,f=null;const h=[],p=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=DS,this.physicallyCorrectLights=!1,this.toneMapping=nx,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});const m=this;let g=!1,v=0,y=0,b=null,w=-1,x=null;const S=new r_,M=new r_;let _=null,A=t.width,E=t.height,C=1,k=null,T=null;const I=new r_(0,0,A,E),O=new r_(0,0,A,E);let R=!1;const P=new OE;let N=!1,L=!1,D=null;const B=new H_,j=new NM,F=new d_,U={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function z(){return null===b?C:1}let H,V,W,G,q,K,Y,J,Q,X,Z,$,ee,te,ne,re,ie,oe,ae,se,le,ce,ue,de,fe=n;function he(e,n){for(let r=0;r<e.length;r++){const i=e[r],o=t.getContext(i,n);if(null!==o)return o}return null}try{const e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:s,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${cw}`),t.addEventListener("webglcontextlost",ge,!1),t.addEventListener("webglcontextrestored",ve,!1),t.addEventListener("webglcontextcreationerror",ye,!1),null===fe){const t=["webgl2","webgl","experimental-webgl"];if(!0===m.isWebGL1Renderer&&t.shift(),fe=he(t,e),null===fe)throw he(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===fe.getShaderPrecisionFormat&&(fe.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function pe(){H=new aC(fe),V=new zE(fe,H,e),H.init(V),ce=new eT(fe,H,V),W=new Zk(fe,H,V),G=new cC,q=new jk,K=new $k(fe,H,W,q,V,ce,G),Y=new VE(m),J=new oC(m),Q=new PE(fe,V),ue=new FE(fe,H,Q,V),X=new sC(fe,Q,G,ue),Z=new hC(fe,X,Q,G),ae=new fC(fe,V,K),re=new HE(q),$=new Bk(m,Y,J,H,V,ue,re),ee=new sT(m,q),te=new Hk,ne=new Yk(H,V),oe=new jE(m,Y,W,Z,u,a),ie=new Xk(m,Z,V),de=new lT(fe,G,V,W),se=new UE(fe,H,G,V),le=new lC(fe,H,G,V),G.programs=$.programs,m.capabilities=V,m.extensions=H,m.properties=q,m.renderLists=te,m.shadowMap=ie,m.state=W,m.info=G}pe();const me=new aT(m,fe);function ge(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function ve(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;const e=G.autoReset,t=ie.enabled,n=ie.autoUpdate,r=ie.needsUpdate,i=ie.type;pe(),G.autoReset=e,ie.enabled=t,ie.autoUpdate=n,ie.needsUpdate=r,ie.type=i}function ye(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function be(e){const t=e.target;t.removeEventListener("dispose",be),function(e){(function(e){const t=q.get(e).programs;void 0!==t&&(t.forEach((function(e){$.releaseProgram(e)})),e.isShaderMaterial&&$.releaseShaderCache(e))})(e),q.remove(e)}(t)}this.xr=me,this.getContext=function(){return fe},this.getContextAttributes=function(){return fe.getContextAttributes()},this.forceContextLoss=function(){const e=H.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=H.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(e){void 0!==e&&(C=e,this.setSize(A,E,!1))},this.getSize=function(e){return e.set(A,E)},this.setSize=function(e,n,r){me.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(A=e,E=n,t.width=Math.floor(e*C),t.height=Math.floor(n*C),!1!==r&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(A*C,E*C).floor()},this.setDrawingBufferSize=function(e,n,r){A=e,E=n,C=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(S)},this.getViewport=function(e){return e.copy(I)},this.setViewport=function(e,t,n,r){e.isVector4?I.set(e.x,e.y,e.z,e.w):I.set(e,t,n,r),W.viewport(S.copy(I).multiplyScalar(C).floor())},this.getScissor=function(e){return e.copy(O)},this.setScissor=function(e,t,n,r){e.isVector4?O.set(e.x,e.y,e.z,e.w):O.set(e,t,n,r),W.scissor(M.copy(O).multiplyScalar(C).floor())},this.getScissorTest=function(){return R},this.setScissorTest=function(e){W.setScissorTest(R=e)},this.setOpaqueSort=function(e){k=e},this.setTransparentSort=function(e){T=e},this.getClearColor=function(e){return e.copy(oe.getClearColor())},this.setClearColor=function(){oe.setClearColor.apply(oe,arguments)},this.getClearAlpha=function(){return oe.getClearAlpha()},this.setClearAlpha=function(){oe.setClearAlpha.apply(oe,arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;e&&(r|=16384),t&&(r|=256),n&&(r|=1024),fe.clear(r)},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",ge,!1),t.removeEventListener("webglcontextrestored",ve,!1),t.removeEventListener("webglcontextcreationerror",ye,!1),te.dispose(),ne.dispose(),q.dispose(),Y.dispose(),J.dispose(),Z.dispose(),ue.dispose(),de.dispose(),$.dispose(),me.dispose(),me.removeEventListener("sessionstart",xe),me.removeEventListener("sessionend",Se),D&&(D.dispose(),D=null),Me.stop()},this.renderBufferDirect=function(e,t,n,r,i,o){null===t&&(t=U);const a=i.isMesh&&i.matrixWorld.determinant()<0,s=function(e,t,n,r,i){!0!==t.isScene&&(t=U);K.resetTextureUnits();const o=t.fog,a=r.isMeshStandardMaterial?t.environment:null,s=null===b?m.outputEncoding:!0===b.isXRRenderTarget?b.texture.encoding:DS,l=(r.isMeshStandardMaterial?J:Y).get(r.envMap||a),c=!0===r.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!r.normalMap&&!!n.attributes.tangent,d=!!n.morphAttributes.position,h=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,g=r.toneMapped?m.toneMapping:nx,v=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,y=void 0!==v?v.length:0,S=q.get(r),M=f.state.lights;if(!0===N&&(!0===L||e!==x)){const t=e===x&&r.id===w;re.setState(r,e,t)}let _=!1;r.version===S.__version?S.needsLights&&S.lightsStateVersion!==M.state.version||S.outputEncoding!==s||i.isInstancedMesh&&!1===S.instancing?_=!0:i.isInstancedMesh||!0!==S.instancing?i.isSkinnedMesh&&!1===S.skinning?_=!0:i.isSkinnedMesh||!0!==S.skinning?S.envMap!==l||!0===r.fog&&S.fog!==o?_=!0:void 0===S.numClippingPlanes||S.numClippingPlanes===re.numPlanes&&S.numIntersection===re.numIntersection?(S.vertexAlphas!==c||S.vertexTangents!==u||S.morphTargets!==d||S.morphNormals!==h||S.morphColors!==p||S.toneMapping!==g||!0===V.isWebGL2&&S.morphTargetsCount!==y)&&(_=!0):_=!0:_=!0:_=!0:(_=!0,S.__version=r.version);let A=S.currentProgram;!0===_&&(A=ke(r,t,i));let k=!1,T=!1,I=!1;const O=A.getUniforms(),R=S.uniforms;W.useProgram(A.program)&&(k=!0,T=!0,I=!0);r.id!==w&&(w=r.id,T=!0);if(k||x!==e){if(O.setValue(fe,"projectionMatrix",e.projectionMatrix),V.logarithmicDepthBuffer&&O.setValue(fe,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),x!==e&&(x=e,T=!0,I=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshStandardMaterial||r.envMap){const t=O.map.cameraPosition;void 0!==t&&t.setValue(fe,F.setFromMatrixPosition(e.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(fe,"isOrthographic",!0===e.isOrthographicCamera),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.isShadowMaterial||i.isSkinnedMesh)&&O.setValue(fe,"viewMatrix",e.matrixWorldInverse)}if(i.isSkinnedMesh){O.setOptional(fe,i,"bindMatrix"),O.setOptional(fe,i,"bindMatrixInverse");const e=i.skeleton;e&&(V.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),O.setValue(fe,"boneTexture",e.boneTexture,K),O.setValue(fe,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const P=n.morphAttributes;(void 0!==P.position||void 0!==P.normal||void 0!==P.color&&!0===V.isWebGL2)&&ae.update(i,n,r,A);(T||S.receiveShadow!==i.receiveShadow)&&(S.receiveShadow=i.receiveShadow,O.setValue(fe,"receiveShadow",i.receiveShadow));r.isMeshGouraudMaterial&&null!==r.envMap&&(R.envMap.value=l,R.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);T&&(O.setValue(fe,"toneMappingExposure",m.toneMappingExposure),S.needsLights&&(j=I,(B=R).ambientLightColor.needsUpdate=j,B.lightProbe.needsUpdate=j,B.directionalLights.needsUpdate=j,B.directionalLightShadows.needsUpdate=j,B.pointLights.needsUpdate=j,B.pointLightShadows.needsUpdate=j,B.spotLights.needsUpdate=j,B.spotLightShadows.needsUpdate=j,B.rectAreaLights.needsUpdate=j,B.hemisphereLights.needsUpdate=j),o&&!0===r.fog&&ee.refreshFogUniforms(R,o),ee.refreshMaterialUniforms(R,r,C,E,D),vk.upload(fe,S.uniformsList,R,K));var B,j;r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(vk.upload(fe,S.uniformsList,R,K),r.uniformsNeedUpdate=!1);r.isSpriteMaterial&&O.setValue(fe,"center",i.center);if(O.setValue(fe,"modelViewMatrix",i.modelViewMatrix),O.setValue(fe,"normalMatrix",i.normalMatrix),O.setValue(fe,"modelMatrix",i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){const e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++)if(V.isWebGL2){const n=e[t];de.update(n,A),de.bind(n,A)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return A}(e,t,n,r,i);W.setMaterial(r,a);let l=n.index;const c=n.attributes.position;if(null===l){if(void 0===c||0===c.count)return}else if(0===l.count)return;let u,d=1;!0===r.wireframe&&(l=X.getWireframeAttribute(n),d=2),ue.setup(i,r,s,n,l);let h=se;null!==l&&(u=Q.get(l),h=le,h.setIndex(u));const p=null!==l?l.count:c.count,g=n.drawRange.start*d,v=n.drawRange.count*d,y=null!==o?o.start*d:0,S=null!==o?o.count*d:1/0,M=Math.max(g,y),_=Math.min(p,g+v,y+S)-1,A=Math.max(0,_-M+1);if(0!==A){if(i.isMesh)!0===r.wireframe?(W.setLineWidth(r.wireframeLinewidth*z()),h.setMode(1)):h.setMode(4);else if(i.isLine){let e=r.linewidth;void 0===e&&(e=1),W.setLineWidth(e*z()),i.isLineSegments?h.setMode(1):i.isLineLoop?h.setMode(2):h.setMode(3)}else i.isPoints?h.setMode(0):i.isSprite&&h.setMode(4);if(i.isInstancedMesh)h.renderInstances(M,A,i.count);else if(n.isInstancedBufferGeometry){const e=Math.min(n.instanceCount,n._maxInstanceCount);h.renderInstances(M,A,e)}else h.render(M,A)}},this.compile=function(e,t){function n(e,t,n){!0===e.transparent&&e.side===Sw?(e.side=xw,e.needsUpdate=!0,ke(e,t,n),e.side=ww,e.needsUpdate=!0,ke(e,t,n),e.side=Sw):ke(e,t,n)}f=ne.get(e),f.init(),p.push(f),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(f.pushLight(e),e.castShadow&&f.pushShadow(e))})),f.setupLights(m.physicallyCorrectLights),e.traverse((function(t){const r=t.material;if(r)if(Array.isArray(r))for(let i=0;i<r.length;i++){n(r[i],e,t)}else n(r,e,t)})),p.pop(),f=null};let we=null;function xe(){Me.stop()}function Se(){Me.start()}const Me=new RE;function _e(e,t,n,r){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)f.pushLight(e),e.castShadow&&f.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||P.intersectsSprite(e)){r&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(B);const t=Z.update(e),i=e.material;i.visible&&d.push(e,t,i,n,F.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.frame!==G.render.frame&&(e.skeleton.update(),e.skeleton.frame=G.render.frame),!e.frustumCulled||P.intersectsObject(e))){r&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(B);const t=Z.update(e),i=e.material;if(Array.isArray(i)){const r=t.groups;for(let o=0,a=r.length;o<a;o++){const a=r[o],s=i[a.materialIndex];s&&s.visible&&d.push(e,t,s,n,F.z,a)}}else i.visible&&d.push(e,t,i,n,F.z,null)}const i=e.children;for(let e=0,o=i.length;e<o;e++)_e(i[e],t,n,r)}function Ae(e,t,n,r){const i=e.opaque,a=e.transmissive,s=e.transparent;f.setupLightsView(n),a.length>0&&function(e,t,n){const r=V.isWebGL2;null===D&&(D=new i_(1,1,{generateMipmaps:!0,type:H.has("EXT_color_buffer_half_float")?Nx:Cx,minFilter:Ax,samples:r&&!0===o?4:0}));m.getDrawingBufferSize(j),r?D.setSize(j.x,j.y):D.setSize(IM(j.x),IM(j.y));const i=m.getRenderTarget();m.setRenderTarget(D),m.clear();const a=m.toneMapping;m.toneMapping=nx,Ee(e,t,n),m.toneMapping=a,K.updateMultisampleRenderTarget(D),K.updateRenderTargetMipmap(D),m.setRenderTarget(i)}(i,t,n),r&&W.viewport(S.copy(r)),i.length>0&&Ee(i,t,n),a.length>0&&Ee(a,t,n),s.length>0&&Ee(s,t,n),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function Ee(e,t,n){const r=!0===t.isScene?t.overrideMaterial:null;for(let i=0,o=e.length;i<o;i++){const o=e[i],a=o.object,s=o.geometry,l=null===r?o.material:r,c=o.group;a.layers.test(n.layers)&&Ce(a,t,n,s,l,c)}}function Ce(e,t,n,r,i,o){e.onBeforeRender(m,t,n,r,i,o),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(m,t,n,r,e,o),!0===i.transparent&&i.side===Sw?(i.side=xw,i.needsUpdate=!0,m.renderBufferDirect(n,t,r,i,e,o),i.side=ww,i.needsUpdate=!0,m.renderBufferDirect(n,t,r,i,e,o),i.side=Sw):m.renderBufferDirect(n,t,r,i,e,o),e.onAfterRender(m,t,n,r,i,o)}function ke(e,t,n){!0!==t.isScene&&(t=U);const r=q.get(e),i=f.state.lights,o=f.state.shadowsArray,a=i.state.version,s=$.getParameters(e,i.state,o,t,n),l=$.getProgramCacheKey(s);let c=r.programs;r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=(e.isMeshStandardMaterial?J:Y).get(e.envMap||r.environment),void 0===c&&(e.addEventListener("dispose",be),c=new Map,r.programs=c);let u=c.get(l);if(void 0!==u){if(r.currentProgram===u&&r.lightsStateVersion===a)return Te(e,s),u}else s.uniforms=$.getUniforms(e),e.onBuild(n,s,m),e.onBeforeCompile(s,m),u=$.acquireProgram(s,l),c.set(l,u),r.uniforms=s.uniforms;const d=r.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(d.clippingPlanes=re.uniform),Te(e,s),r.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),r.lightsStateVersion=a,r.needsLights&&(d.ambientLightColor.value=i.state.ambient,d.lightProbe.value=i.state.probe,d.directionalLights.value=i.state.directional,d.directionalLightShadows.value=i.state.directionalShadow,d.spotLights.value=i.state.spot,d.spotLightShadows.value=i.state.spotShadow,d.rectAreaLights.value=i.state.rectArea,d.ltc_1.value=i.state.rectAreaLTC1,d.ltc_2.value=i.state.rectAreaLTC2,d.pointLights.value=i.state.point,d.pointLightShadows.value=i.state.pointShadow,d.hemisphereLights.value=i.state.hemi,d.directionalShadowMap.value=i.state.directionalShadowMap,d.directionalShadowMatrix.value=i.state.directionalShadowMatrix,d.spotShadowMap.value=i.state.spotShadowMap,d.spotLightMatrix.value=i.state.spotLightMatrix,d.spotLightMap.value=i.state.spotLightMap,d.pointShadowMap.value=i.state.pointShadowMap,d.pointShadowMatrix.value=i.state.pointShadowMatrix);const h=u.getUniforms(),p=vk.seqWithValue(h.seq,d);return r.currentProgram=u,r.uniformsList=p,u}function Te(e,t){const n=q.get(e);n.outputEncoding=t.outputEncoding,n.instancing=t.instancing,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}Me.setAnimationLoop((function(e){we&&we(e)})),"undefined"!=typeof self&&Me.setContext(self),this.setAnimationLoop=function(e){we=e,me.setAnimationLoop(e),null===e?Me.stop():Me.start()},me.addEventListener("sessionstart",xe),me.addEventListener("sessionend",Se),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===g)return;!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===me.enabled&&!0===me.isPresenting&&(!0===me.cameraAutoUpdate&&me.updateCamera(t),t=me.getCamera()),!0===e.isScene&&e.onBeforeRender(m,e,t,b),f=ne.get(e,p.length),f.init(),p.push(f),B.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),P.setFromProjectionMatrix(B),L=this.localClippingEnabled,N=re.init(this.clippingPlanes,L,t),d=te.get(e,h.length),d.init(),h.push(d),_e(e,t,0,m.sortObjects),d.finish(),!0===m.sortObjects&&d.sort(k,T),!0===N&&re.beginShadows();const n=f.state.shadowsArray;if(ie.render(n,e,t),!0===N&&re.endShadows(),!0===this.info.autoReset&&this.info.reset(),oe.render(d,e),f.setupLights(m.physicallyCorrectLights),t.isArrayCamera){const n=t.cameras;for(let t=0,r=n.length;t<r;t++){const r=n[t];Ae(d,e,r,r.viewport)}}else Ae(d,e,t);null!==b&&(K.updateMultisampleRenderTarget(b),K.updateRenderTargetMipmap(b)),!0===e.isScene&&e.onAfterRender(m,e,t),ue.resetDefaultState(),w=-1,x=null,p.pop(),f=p.length>0?p[p.length-1]:null,h.pop(),d=h.length>0?h[h.length-1]:null},this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(e,t,n){q.get(e.texture).__webglTexture=t,q.get(e.depthTexture).__webglTexture=n;const r=q.get(e);r.__hasExternalTextures=!0,r.__hasExternalTextures&&(r.__autoAllocateDepthBuffer=void 0===n,r.__autoAllocateDepthBuffer||!0===H.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),r.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const n=q.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){b=e,v=t,y=n;let r=!0;if(e){const t=q.get(e);void 0!==t.__useDefaultFramebuffer?(W.bindFramebuffer(36160,null),r=!1):void 0===t.__webglFramebuffer?K.setupRenderTarget(e):t.__hasExternalTextures&&K.rebindTextures(e,q.get(e.texture).__webglTexture,q.get(e.depthTexture).__webglTexture)}let i=null,o=!1,a=!1;if(e){const n=e.texture;(n.isData3DTexture||n.isDataArrayTexture)&&(a=!0);const r=q.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=r[t],o=!0):i=V.isWebGL2&&e.samples>0&&!1===K.useMultisampledRTT(e)?q.get(e).__webglMultisampledFramebuffer:r,S.copy(e.viewport),M.copy(e.scissor),_=e.scissorTest}else S.copy(I).multiplyScalar(C).floor(),M.copy(O).multiplyScalar(C).floor(),_=R;if(W.bindFramebuffer(36160,i)&&V.drawBuffers&&r&&W.drawBuffers(e,i),W.viewport(S),W.scissor(M),W.setScissorTest(_),o){const r=q.get(e.texture);fe.framebufferTexture2D(36160,36064,34069+t,r.__webglTexture,n)}else if(a){const r=q.get(e.texture),i=t||0;fe.framebufferTextureLayer(36160,36064,r.__webglTexture,n||0,i)}w=-1},this.readRenderTargetPixels=function(e,t,n,r,i,o,a){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let s=q.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(s=s[a]),s){W.bindFramebuffer(36160,s);try{const a=e.texture,s=a.format,l=a.type;if(s!==Ux&&ce.convert(s)!==fe.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===Nx&&(H.has("EXT_color_buffer_half_float")||V.isWebGL2&&H.has("EXT_color_buffer_float"));if(!(l===Cx||ce.convert(l)===fe.getParameter(35738)||l===Px&&(V.isWebGL2||H.has("OES_texture_float")||H.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&fe.readPixels(t,n,r,i,ce.convert(s),ce.convert(l),o)}finally{const e=null!==b?q.get(b).__webglFramebuffer:null;W.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const r=Math.pow(2,-n),i=Math.floor(t.image.width*r),o=Math.floor(t.image.height*r);K.setTexture2D(t,0),fe.copyTexSubImage2D(3553,n,0,0,e.x,e.y,i,o),W.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r=0){const i=t.image.width,o=t.image.height,a=ce.convert(n.format),s=ce.convert(n.type);K.setTexture2D(n,0),fe.pixelStorei(37440,n.flipY),fe.pixelStorei(37441,n.premultiplyAlpha),fe.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?fe.texSubImage2D(3553,r,e.x,e.y,i,o,a,s,t.image.data):t.isCompressedTexture?fe.compressedTexSubImage2D(3553,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):fe.texSubImage2D(3553,r,e.x,e.y,a,s,t.image),0===r&&n.generateMipmaps&&fe.generateMipmap(3553),W.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,r,i=0){if(m.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const o=e.max.x-e.min.x+1,a=e.max.y-e.min.y+1,s=e.max.z-e.min.z+1,l=ce.convert(r.format),c=ce.convert(r.type);let u;if(r.isData3DTexture)K.setTexture3D(r,0),u=32879;else{if(!r.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");K.setTexture2DArray(r,0),u=35866}fe.pixelStorei(37440,r.flipY),fe.pixelStorei(37441,r.premultiplyAlpha),fe.pixelStorei(3317,r.unpackAlignment);const d=fe.getParameter(3314),f=fe.getParameter(32878),h=fe.getParameter(3316),p=fe.getParameter(3315),g=fe.getParameter(32877),v=n.isCompressedTexture?n.mipmaps[0]:n.image;fe.pixelStorei(3314,v.width),fe.pixelStorei(32878,v.height),fe.pixelStorei(3316,e.min.x),fe.pixelStorei(3315,e.min.y),fe.pixelStorei(32877,e.min.z),n.isDataTexture||n.isData3DTexture?fe.texSubImage3D(u,i,t.x,t.y,t.z,o,a,s,l,c,v.data):n.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),fe.compressedTexSubImage3D(u,i,t.x,t.y,t.z,o,a,s,l,v.data)):fe.texSubImage3D(u,i,t.x,t.y,t.z,o,a,s,l,c,v),fe.pixelStorei(3314,d),fe.pixelStorei(32878,f),fe.pixelStorei(3316,h),fe.pixelStorei(3315,p),fe.pixelStorei(32877,g),0===i&&r.generateMipmaps&&fe.generateMipmap(u),W.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?K.setTextureCube(e,0):e.isData3DTexture?K.setTexture3D(e,0):e.isDataArrayTexture?K.setTexture2DArray(e,0):K.setTexture2D(e,0),W.unbindTexture()},this.resetState=function(){v=0,y=0,b=null,W.reset(),ue.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class uT extends cT{}uT.prototype.isWebGL1Renderer=!0;class dT{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new QM(e),this.density=t}clone(){return new dT(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class fT{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new QM(e),this.near=t,this.far=n}clone(){return new fT(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class hT extends hA{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}}class pT{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=sM,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=_M()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=_M()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(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 void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=_M()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(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 mT=new d_;class gT{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=!0===r}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++)mT.fromBufferAttribute(this,t),mT.applyMatrix4(e),this.setXYZ(t,mT.x,mT.y,mT.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)mT.fromBufferAttribute(this,t),mT.applyNormalMatrix(e),this.setXYZ(t,mT.x,mT.y,mT.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)mT.fromBufferAttribute(this,t),mT.transformDirection(e),this.setXYZ(t,mT.x,mT.y,mT.z);return this}setX(e,t){return this.normalized&&(t=RM(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=RM(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=RM(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=RM(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=OM(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=OM(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=OM(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=OM(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=RM(t,this.array),n=RM(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=RM(t,this.array),n=RM(n,this.array),r=RM(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=RM(t,this.array),n=RM(n,this.array),r=RM(r,this.array),i=RM(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new IA(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new gT(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class vT extends EA{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new QM(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let yT;const bT=new d_,wT=new d_,xT=new d_,ST=new NM,MT=new NM,_T=new H_,AT=new d_,ET=new d_,CT=new d_,kT=new NM,TT=new NM,IT=new NM;class OT extends hA{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",void 0===yT){yT=new YA;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new pT(e,5);yT.setIndex([0,1,2,0,2,3]),yT.setAttribute("position",new gT(t,3,0,!1)),yT.setAttribute("uv",new gT(t,2,3,!1))}this.geometry=yT,this.material=void 0!==e?e:new vT,this.center=new NM(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),wT.setFromMatrixScale(this.matrixWorld),_T.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),xT.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&wT.multiplyScalar(-xT.z);const n=this.material.rotation;let r,i;0!==n&&(i=Math.cos(n),r=Math.sin(n));const o=this.center;RT(AT.set(-.5,-.5,0),xT,o,wT,r,i),RT(ET.set(.5,-.5,0),xT,o,wT,r,i),RT(CT.set(.5,.5,0),xT,o,wT,r,i),kT.set(0,0),TT.set(1,0),IT.set(1,1);let a=e.ray.intersectTriangle(AT,ET,CT,!1,bT);if(null===a&&(RT(ET.set(-.5,.5,0),xT,o,wT,r,i),TT.set(0,1),a=e.ray.intersectTriangle(AT,CT,ET,!1,bT),null===a))return;const s=e.ray.origin.distanceTo(bT);s<e.near||s>e.far||t.push({distance:s,point:bT.clone(),uv:_A.getUV(bT,AT,ET,CT,kT,TT,IT,new NM),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function RT(e,t,n,r,i,o){ST.subVectors(e,n).addScalar(.5).multiply(r),void 0!==i?(MT.x=o*ST.x-i*ST.y,MT.y=i*ST.x+o*ST.y):MT.copy(ST),e.copy(t),e.x+=MT.x,e.y+=MT.y,e.applyMatrix4(_T)}const PT=new d_,NT=new d_;class LT extends hA{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,n=t.length;e<n;e++){const n=t[e];this.addLevel(n.object.clone(),n.distance)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0){t=Math.abs(t);const n=this.levels;let r;for(r=0;r<n.length&&!(t<n[r].distance);r++);return n.splice(r,0,{distance:t,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r&&!(e<t[n].distance);n++);return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){PT.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(PT);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){PT.setFromMatrixPosition(e.matrixWorld),NT.setFromMatrixPosition(this.matrixWorld);const n=PT.distanceTo(NT)/e.zoom;let r,i;for(t[0].object.visible=!0,r=1,i=t.length;r<i&&n>=t[r].distance;r++)t[r-1].object.visible=!1,t[r].object.visible=!0;for(this._currentLevel=r-1;r<i;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let e=0,r=n.length;e<r;e++){const r=n[e];t.object.levels.push({object:r.object.uuid,distance:r.distance})}return t}}const DT=new d_,BT=new r_,jT=new r_,FT=new d_,UT=new H_;class zT extends fE{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new H_,this.bindMatrixInverse=new H_}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,this}bind(e,t){this.skeleton=e,void 0===t&&(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 r_,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;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),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,t){const n=this.skeleton,r=this.geometry;BT.fromBufferAttribute(r.attributes.skinIndex,e),jT.fromBufferAttribute(r.attributes.skinWeight,e),DT.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const r=jT.getComponent(e);if(0!==r){const i=BT.getComponent(e);UT.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(FT.copy(DT).applyMatrix4(UT),r)}}return t.applyMatrix4(this.bindMatrixInverse)}}class HT extends hA{constructor(){super(),this.isBone=!0,this.type="Bone"}}class VT extends n_{constructor(e=null,t=1,n=1,r,i,o,a,s,l=vx,c=vx,u,d){super(null,o,a,s,l,c,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const WT=new H_,GT=new H_;class qT{constructor(e=[],t=[]){this.uuid=_M(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)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 e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new H_)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new H_;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=e.length;r<i;r++){const i=e[r]?e[r].matrixWorld:GT;WT.multiplyMatrices(i,t[r]),WT.toArray(n,16*r)}null!==r&&(r.needsUpdate=!0)}clone(){return new qT(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=TM(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new VT(t,e,e,Ux,Px);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const r=e.bones[n];let i=t[r];void 0===i&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),i=new HT),this.bones.push(i),this.boneInverses.push((new H_).fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){const i=t[r];e.bones.push(i.uuid);const o=n[r];e.boneInverses.push(o.toArray())}return e}}class KT extends IA{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}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 YT=new H_,JT=new H_,QT=[],XT=new fE;class ZT extends fE{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new KT(new Float32Array(16*n),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){const n=this.matrixWorld,r=this.count;if(XT.geometry=this.geometry,XT.material=this.material,void 0!==XT.material)for(let i=0;i<r;i++){this.getMatrixAt(i,YT),JT.multiplyMatrices(n,YT),XT.matrixWorld=JT,XT.raycast(e,QT);for(let e=0,n=QT.length;e<n;e++){const n=QT[e];n.instanceId=i,n.object=this,t.push(n)}QT.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new KT(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class $T extends EA{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new QM(16777215),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.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const eI=new d_,tI=new d_,nI=new H_,rI=new z_,iI=new P_;class oI extends hA{constructor(e=new YA,t=new $T){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)eI.fromBufferAttribute(t,e-1),tI.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=eI.distanceTo(tI);e.setAttribute("lineDistance",new FA(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,o=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),iI.copy(n.boundingSphere),iI.applyMatrix4(r),iI.radius+=i,!1===e.ray.intersectsSphere(iI))return;nI.copy(r).invert(),rI.copy(e.ray).applyMatrix4(nI);const a=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=a*a,l=new d_,c=new d_,u=new d_,d=new d_,f=this.isLineSegments?2:1,h=n.index,p=n.attributes.position;if(null!==h){for(let n=Math.max(0,o.start),r=Math.min(h.count,o.start+o.count)-1;n<r;n+=f){const r=h.getX(n),i=h.getX(n+1);l.fromBufferAttribute(p,r),c.fromBufferAttribute(p,i);if(rI.distanceSqToSegment(l,c,d,u)>s)continue;d.applyMatrix4(this.matrixWorld);const o=e.ray.origin.distanceTo(d);o<e.near||o>e.far||t.push({distance:o,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else{for(let n=Math.max(0,o.start),r=Math.min(p.count,o.start+o.count)-1;n<r;n+=f){l.fromBufferAttribute(p,n),c.fromBufferAttribute(p,n+1);if(rI.distanceSqToSegment(l,c,d,u)>s)continue;d.applyMatrix4(this.matrixWorld);const r=e.ray.origin.distanceTo(d);r<e.near||r>e.far||t.push({distance:r,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}const aI=new d_,sI=new d_;class lI extends oI{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)aI.fromBufferAttribute(t,e),sI.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+aI.distanceTo(sI);e.setAttribute("lineDistance",new FA(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class cI extends oI{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class uI extends EA{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new QM(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 dI=new H_,fI=new z_,hI=new P_,pI=new d_;class mI extends hA{constructor(e=new YA,t=new uI){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,o=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),hI.copy(n.boundingSphere),hI.applyMatrix4(r),hI.radius+=i,!1===e.ray.intersectsSphere(hI))return;dI.copy(r).invert(),fI.copy(e.ray).applyMatrix4(dI);const a=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=a*a,l=n.index,c=n.attributes.position;if(null!==l){for(let n=Math.max(0,o.start),i=Math.min(l.count,o.start+o.count);n<i;n++){const i=l.getX(n);pI.fromBufferAttribute(c,i),gI(pI,i,s,r,e,t,this)}}else{for(let n=Math.max(0,o.start),i=Math.min(c.count,o.start+o.count);n<i;n++)pI.fromBufferAttribute(c,n),gI(pI,n,s,r,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function gI(e,t,n,r,i,o,a){const s=fI.distanceSqToPoint(e);if(s<n){const n=new d_;fI.closestPointToPoint(e,n),n.applyMatrix4(r);const l=i.ray.origin.distanceTo(n);if(l<i.near||l>i.far)return;o.push({distance:l,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:a})}}class vI extends n_{constructor(e,t,n,r,i,o,a,s,l){super(e,t,n,r,i,o,a,s,l),this.isVideoTexture=!0,this.minFilter=void 0!==o?o:Sx,this.magFilter=void 0!==i?i:Sx,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class yI extends n_{constructor(e,t,n){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=n,this.magFilter=vx,this.minFilter=vx,this.generateMipmaps=!1,this.needsUpdate=!0}}class bI extends n_{constructor(e,t,n,r,i,o,a,s,l,c,u,d){super(null,o,a,s,l,c,r,i,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class wI extends n_{constructor(e,t,n,r,i,o,a,s,l){super(e,t,n,r,i,o,a,s,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class xI{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),i=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const i=n.length;let o;o=t||e*n[i-1];let a,s=0,l=i-1;for(;s<=l;)if(r=Math.floor(s+(l-s)/2),a=n[r]-o,a<0)s=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(r=l,n[r]===o)return r/(i-1);const c=n[r];return(r+(o-c)/(n[r+1]-c))/(i-1)}getTangent(e,t){const n=1e-4;let r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);const o=this.getPoint(r),a=this.getPoint(i),s=t||(o.isVector2?new NM:new d_);return s.copy(a).sub(o).normalize(),s}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new d_,r=[],i=[],o=[],a=new d_,s=new H_;for(let t=0;t<=e;t++){const n=t/e;r[t]=this.getTangentAt(n,new d_)}i[0]=new d_,o[0]=new d_;let l=Number.MAX_VALUE;const c=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);c<=l&&(l=c,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),d<=l&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],a),o[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),o[t]=o[t-1].clone(),a.crossVectors(r[t-1],r[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(AM(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(a,e))}o[t].crossVectors(r[t],i[t])}if(!0===t){let t=Math.acos(AM(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(a.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),o[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:o}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class SI extends xI{constructor(e=0,t=0,n=1,r=1,i=0,o=2*Math.PI,a=!1,s=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s}getPoint(e,t){const n=t||new NM,r=2*Math.PI;let i=this.aEndAngle-this.aStartAngle;const o=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=r;for(;i>r;)i-=r;i<Number.EPSILON&&(i=o?0:r),!0!==this.aClockwise||o||(i===r?i=-r:i-=r);const a=this.aStartAngle+e*i;let s=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=l-this.aY;s=n*e-r*t+this.aX,l=n*t+r*e+this.aY}return n.set(s,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class MI extends SI{constructor(e,t,n,r,i,o){super(e,t,n,n,r,i,o),this.isArcCurve=!0,this.type="ArcCurve"}}function _I(){let e=0,t=0,n=0,r=0;function i(i,o,a,s){e=i,t=a,n=-3*i+3*o-2*a-s,r=2*i-2*o+a+s}return{initCatmullRom:function(e,t,n,r,o){i(t,n,o*(n-e),o*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,o,a,s){let l=(t-e)/o-(n-e)/(o+a)+(n-t)/a,c=(n-t)/a-(r-t)/(a+s)+(r-n)/s;l*=a,c*=a,i(t,n,l,c)},calc:function(i){const o=i*i;return e+t*i+n*o+r*(o*i)}}}const AI=new d_,EI=new _I,CI=new _I,kI=new _I;class TI extends xI{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new d_){const n=t,r=this.points,i=r.length,o=(i-(this.closed?0:1))*e;let a,s,l=Math.floor(o),c=o-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/i)+1)*i:0===c&&l===i-1&&(l=i-2,c=1),this.closed||l>0?a=r[(l-1)%i]:(AI.subVectors(r[0],r[1]).add(r[0]),a=AI);const u=r[l%i],d=r[(l+1)%i];if(this.closed||l+2<i?s=r[(l+2)%i]:(AI.subVectors(r[i-1],r[i-2]).add(r[i-1]),s=AI),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(a.distanceToSquared(u),e),n=Math.pow(u.distanceToSquared(d),e),r=Math.pow(d.distanceToSquared(s),e);n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),EI.initNonuniformCatmullRom(a.x,u.x,d.x,s.x,t,n,r),CI.initNonuniformCatmullRom(a.y,u.y,d.y,s.y,t,n,r),kI.initNonuniformCatmullRom(a.z,u.z,d.z,s.z,t,n,r)}else"catmullrom"===this.curveType&&(EI.initCatmullRom(a.x,u.x,d.x,s.x,this.tension),CI.initCatmullRom(a.y,u.y,d.y,s.y,this.tension),kI.initCatmullRom(a.z,u.z,d.z,s.z,this.tension));return n.set(EI.calc(c),CI.calc(c),kI.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new d_).fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function II(e,t,n,r,i){const o=.5*(r-t),a=.5*(i-n),s=e*e;return(2*n-2*r+o+a)*(e*s)+(-3*n+3*r-2*o-a)*s+o*e+n}function OI(e,t,n,r){return function(e,t){const n=1-e;return n*n*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,n)+function(e,t){return e*e*t}(e,r)}function RI(e,t,n,r,i){return function(e,t){const n=1-e;return n*n*n*t}(e,t)+function(e,t){const n=1-e;return 3*n*n*e*t}(e,n)+function(e,t){return 3*(1-e)*e*e*t}(e,r)+function(e,t){return e*e*e*t}(e,i)}class PI extends xI{constructor(e=new NM,t=new NM,n=new NM,r=new NM){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new NM){const n=t,r=this.v0,i=this.v1,o=this.v2,a=this.v3;return n.set(RI(e,r.x,i.x,o.x,a.x),RI(e,r.y,i.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class NI extends xI{constructor(e=new d_,t=new d_,n=new d_,r=new d_){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new d_){const n=t,r=this.v0,i=this.v1,o=this.v2,a=this.v3;return n.set(RI(e,r.x,i.x,o.x,a.x),RI(e,r.y,i.y,o.y,a.y),RI(e,r.z,i.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class LI extends xI{constructor(e=new NM,t=new NM){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new NM){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){const n=t||new NM;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class DI extends xI{constructor(e=new d_,t=new d_){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new d_){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class BI extends xI{constructor(e=new NM,t=new NM,n=new NM){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new NM){const n=t,r=this.v0,i=this.v1,o=this.v2;return n.set(OI(e,r.x,i.x,o.x),OI(e,r.y,i.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class jI extends xI{constructor(e=new d_,t=new d_,n=new d_){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new d_){const n=t,r=this.v0,i=this.v1,o=this.v2;return n.set(OI(e,r.x,i.x,o.x),OI(e,r.y,i.y,o.y),OI(e,r.z,i.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class FI extends xI{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new NM){const n=t,r=this.points,i=(r.length-1)*e,o=Math.floor(i),a=i-o,s=r[0===o?o:o-1],l=r[o],c=r[o>r.length-2?r.length-1:o+1],u=r[o>r.length-3?r.length-1:o+2];return n.set(II(a,s.x,l.x,c.x,u.x),II(a,s.y,l.y,c.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new NM).fromArray(n))}return this}}var UI=Object.freeze({__proto__:null,ArcCurve:MI,CatmullRomCurve3:TI,CubicBezierCurve:PI,CubicBezierCurve3:NI,EllipseCurve:SI,LineCurve:LI,LineCurve3:DI,QuadraticBezierCurve:BI,QuadraticBezierCurve3:jI,SplineCurve:FI});class zI extends xI{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new LI(t,e))}getPoint(e,t){const n=e*this.getLength(),r=this.getCurveLengths();let i=0;for(;i<r.length;){if(r[i]>=n){const e=r[i]-n,o=this.curves[i],a=o.getLength(),s=0===a?0:1-e/a;return o.getPointAt(s,t)}i++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let r=0,i=this.curves;r<i.length;r++){const o=i[r],a=o.isEllipseCurve?2*e:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,s=o.getPoints(a);for(let e=0;e<s.length;e++){const r=s[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push((new UI[n.type]).fromJSON(n))}return this}}class HI extends zI{constructor(e){super(),this.type="Path",this.currentPoint=new NM,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new LI(this.currentPoint.clone(),new NM(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const i=new BI(this.currentPoint.clone(),new NM(e,t),new NM(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,o){const a=new PI(this.currentPoint.clone(),new NM(e,t),new NM(n,r),new NM(i,o));return this.curves.push(a),this.currentPoint.set(i,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new FI(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,o){const a=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+a,t+s,n,r,i,o),this}absarc(e,t,n,r,i,o){return this.absellipse(e,t,n,n,r,i,o),this}ellipse(e,t,n,r,i,o,a,s){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+l,t+c,n,r,i,o,a,s),this}absellipse(e,t,n,r,i,o,a,s){const l=new SI(e,t,n,r,i,o,a,s);if(this.curves.length>0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class VI extends YA{constructor(e=[new NM(0,-.5),new NM(.5,0),new NM(0,.5)],t=12,n=0,r=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=AM(r,0,2*Math.PI);const i=[],o=[],a=[],s=[],l=[],c=1/t,u=new d_,d=new NM,f=new d_,h=new d_,p=new d_;let m=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=1*g,f.y=-m,f.z=0*g,p.copy(f),f.normalize(),s.push(f.x,f.y,f.z);break;case e.length-1:s.push(p.x,p.y,p.z);break;default:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=1*g,f.y=-m,f.z=0*g,h.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),s.push(f.x,f.y,f.z),p.copy(h)}for(let i=0;i<=t;i++){const f=n+i*c*r,h=Math.sin(f),p=Math.cos(f);for(let n=0;n<=e.length-1;n++){u.x=e[n].x*h,u.y=e[n].y,u.z=e[n].x*p,o.push(u.x,u.y,u.z),d.x=i/t,d.y=n/(e.length-1),a.push(d.x,d.y);const r=s[3*n+0]*h,c=s[3*n+1],f=s[3*n+0]*p;l.push(r,c,f)}}for(let n=0;n<t;n++)for(let t=0;t<e.length-1;t++){const r=t+n*e.length,o=r,a=r+e.length,s=r+e.length+1,l=r+1;i.push(o,a,l),i.push(s,l,a)}this.setIndex(i),this.setAttribute("position",new FA(o,3)),this.setAttribute("uv",new FA(a,2)),this.setAttribute("normal",new FA(l,3))}static fromJSON(e){return new VI(e.points,e.segments,e.phiStart,e.phiLength)}}class WI extends VI{constructor(e=1,t=1,n=4,r=8){const i=new HI;i.absarc(0,-t/2,e,1.5*Math.PI,0),i.absarc(0,t/2,e,0,.5*Math.PI),super(i.getPoints(n),r),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:r}}static fromJSON(e){return new WI(e.radius,e.length,e.capSegments,e.radialSegments)}}class GI extends YA{constructor(e=1,t=8,n=0,r=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const i=[],o=[],a=[],s=[],l=new d_,c=new NM;o.push(0,0,0),a.push(0,0,1),s.push(.5,.5);for(let i=0,u=3;i<=t;i++,u+=3){const d=n+i/t*r;l.x=e*Math.cos(d),l.y=e*Math.sin(d),o.push(l.x,l.y,l.z),a.push(0,0,1),c.x=(o[u]/e+1)/2,c.y=(o[u+1]/e+1)/2,s.push(c.x,c.y)}for(let e=1;e<=t;e++)i.push(e,e+1,0);this.setIndex(i),this.setAttribute("position",new FA(o,3)),this.setAttribute("normal",new FA(a,3)),this.setAttribute("uv",new FA(s,2))}static fromJSON(e){return new GI(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class qI extends YA{constructor(e=1,t=1,n=1,r=8,i=1,o=!1,a=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:o,thetaStart:a,thetaLength:s};const l=this;r=Math.floor(r),i=Math.floor(i);const c=[],u=[],d=[],f=[];let h=0;const p=[],m=n/2;let g=0;function v(n){const i=h,o=new NM,p=new d_;let v=0;const y=!0===n?e:t,b=!0===n?1:-1;for(let e=1;e<=r;e++)u.push(0,m*b,0),d.push(0,b,0),f.push(.5,.5),h++;const w=h;for(let e=0;e<=r;e++){const t=e/r*s+a,n=Math.cos(t),i=Math.sin(t);p.x=y*i,p.y=m*b,p.z=y*n,u.push(p.x,p.y,p.z),d.push(0,b,0),o.x=.5*n+.5,o.y=.5*i*b+.5,f.push(o.x,o.y),h++}for(let e=0;e<r;e++){const t=i+e,r=w+e;!0===n?c.push(r,r+1,t):c.push(r+1,r,t),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}!function(){const o=new d_,v=new d_;let y=0;const b=(t-e)/n;for(let l=0;l<=i;l++){const c=[],g=l/i,y=g*(t-e)+e;for(let e=0;e<=r;e++){const t=e/r,i=t*s+a,l=Math.sin(i),p=Math.cos(i);v.x=y*l,v.y=-g*n+m,v.z=y*p,u.push(v.x,v.y,v.z),o.set(l,b,p).normalize(),d.push(o.x,o.y,o.z),f.push(t,1-g),c.push(h++)}p.push(c)}for(let e=0;e<r;e++)for(let t=0;t<i;t++){const n=p[t][e],r=p[t+1][e],i=p[t+1][e+1],o=p[t][e+1];c.push(n,r,o),c.push(r,i,o),y+=6}l.addGroup(g,y,0),g+=y}(),!1===o&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new FA(u,3)),this.setAttribute("normal",new FA(d,3)),this.setAttribute("uv",new FA(f,2))}static fromJSON(e){return new qI(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class KI extends qI{constructor(e=1,t=1,n=8,r=1,i=!1,o=0,a=2*Math.PI){super(0,e,t,n,r,i,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:o,thetaLength:a}}static fromJSON(e){return new KI(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class YI extends YA{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};const i=[],o=[];function a(e,t,n,r){const i=r+1,o=[];for(let r=0;r<=i;r++){o[r]=[];const a=e.clone().lerp(n,r/i),s=t.clone().lerp(n,r/i),l=i-r;for(let e=0;e<=l;e++)o[r][e]=0===e&&r===i?a:a.clone().lerp(s,e/l)}for(let e=0;e<i;e++)for(let t=0;t<2*(i-e)-1;t++){const n=Math.floor(t/2);t%2==0?(s(o[e][n+1]),s(o[e+1][n]),s(o[e][n])):(s(o[e][n+1]),s(o[e+1][n+1]),s(o[e+1][n]))}}function s(e){i.push(e.x,e.y,e.z)}function l(t,n){const r=3*t;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function c(e,t,n,r){r<0&&1===e.x&&(o[t]=e.x-1),0===n.x&&0===n.z&&(o[t]=r/2/Math.PI+.5)}function u(e){return Math.atan2(e.z,-e.x)}!function(e){const n=new d_,r=new d_,i=new d_;for(let o=0;o<t.length;o+=3)l(t[o+0],n),l(t[o+1],r),l(t[o+2],i),a(n,r,i,e)}(r),function(e){const t=new d_;for(let n=0;n<i.length;n+=3)t.x=i[n+0],t.y=i[n+1],t.z=i[n+2],t.normalize().multiplyScalar(e),i[n+0]=t.x,i[n+1]=t.y,i[n+2]=t.z}(n),function(){const e=new d_;for(let n=0;n<i.length;n+=3){e.x=i[n+0],e.y=i[n+1],e.z=i[n+2];const r=u(e)/2/Math.PI+.5,a=(t=e,Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))/Math.PI+.5);o.push(r,1-a)}var t;(function(){const e=new d_,t=new d_,n=new d_,r=new d_,a=new NM,s=new NM,l=new NM;for(let d=0,f=0;d<i.length;d+=9,f+=6){e.set(i[d+0],i[d+1],i[d+2]),t.set(i[d+3],i[d+4],i[d+5]),n.set(i[d+6],i[d+7],i[d+8]),a.set(o[f+0],o[f+1]),s.set(o[f+2],o[f+3]),l.set(o[f+4],o[f+5]),r.copy(e).add(t).add(n).divideScalar(3);const h=u(r);c(a,f+0,e,h),c(s,f+2,t,h),c(l,f+4,n,h)}})(),function(){for(let e=0;e<o.length;e+=6){const t=o[e+0],n=o[e+2],r=o[e+4],i=Math.max(t,n,r),a=Math.min(t,n,r);i>.9&&a<.1&&(t<.2&&(o[e+0]+=1),n<.2&&(o[e+2]+=1),r<.2&&(o[e+4]+=1))}}()}(),this.setAttribute("position",new FA(i,3)),this.setAttribute("normal",new FA(i.slice(),3)),this.setAttribute("uv",new FA(o,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(e){return new YI(e.vertices,e.indices,e.radius,e.details)}}class JI extends YI{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new JI(e.radius,e.detail)}}const QI=new d_,XI=new d_,ZI=new d_,$I=new _A;class eO extends YA{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=4,r=Math.pow(10,n),i=Math.cos(SM*t),o=e.getIndex(),a=e.getAttribute("position"),s=o?o.count:a.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),d={},f=[];for(let e=0;e<s;e+=3){o?(l[0]=o.getX(e),l[1]=o.getX(e+1),l[2]=o.getX(e+2)):(l[0]=e,l[1]=e+1,l[2]=e+2);const{a:t,b:n,c:s}=$I;if(t.fromBufferAttribute(a,l[0]),n.fromBufferAttribute(a,l[1]),s.fromBufferAttribute(a,l[2]),$I.getNormal(ZI),u[0]=`${Math.round(t.x*r)},${Math.round(t.y*r)},${Math.round(t.z*r)}`,u[1]=`${Math.round(n.x*r)},${Math.round(n.y*r)},${Math.round(n.z*r)}`,u[2]=`${Math.round(s.x*r)},${Math.round(s.y*r)},${Math.round(s.z*r)}`,u[0]!==u[1]&&u[1]!==u[2]&&u[2]!==u[0])for(let e=0;e<3;e++){const t=(e+1)%3,n=u[e],r=u[t],o=$I[c[e]],a=$I[c[t]],s=`${n}_${r}`,h=`${r}_${n}`;h in d&&d[h]?(ZI.dot(d[h].normal)<=i&&(f.push(o.x,o.y,o.z),f.push(a.x,a.y,a.z)),d[h]=null):s in d||(d[s]={index0:l[e],index1:l[t],normal:ZI.clone()})}}for(const e in d)if(d[e]){const{index0:t,index1:n}=d[e];QI.fromBufferAttribute(a,t),XI.fromBufferAttribute(a,n),f.push(QI.x,QI.y,QI.z),f.push(XI.x,XI.y,XI.z)}this.setAttribute("position",new FA(f,3))}}}class tO extends HI{constructor(e){super(e),this.uuid=_M(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push((new HI).fromJSON(n))}return this}}const nO=function(e,t,n=2){const r=t&&t.length,i=r?t[0]*n:e.length;let o=rO(e,0,i,n,!0);const a=[];if(!o||o.next===o.prev)return a;let s,l,c,u,d,f,h;if(r&&(o=function(e,t,n,r){const i=[];let o,a,s,l,c;for(o=0,a=t.length;o<a;o++)s=t[o]*r,l=o<a-1?t[o+1]*r:e.length,c=rO(e,s,l,r,!1),c===c.next&&(c.steiner=!0),i.push(pO(c));for(i.sort(uO),o=0;o<i.length;o++)dO(i[o],n),n=iO(n,n.next);return n}(e,t,o,n)),e.length>80*n){s=c=e[0],l=u=e[1];for(let t=n;t<i;t+=n)d=e[t],f=e[t+1],d<s&&(s=d),f<l&&(l=f),d>c&&(c=d),f>u&&(u=f);h=Math.max(c-s,u-l),h=0!==h?1/h:0}return oO(o,a,n,s,l,h),a};function rO(e,t,n,r,i){let o,a;if(i===function(e,t,n,r){let i=0;for(let o=t,a=n-r;o<n;o+=r)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}(e,t,n,r)>0)for(o=t;o<n;o+=r)a=_O(o,e[o],e[o+1],a);else for(o=n-r;o>=t;o-=r)a=_O(o,e[o],e[o+1],a);return a&&yO(a,a.next)&&(AO(a),a=a.next),a}function iO(e,t){if(!e)return e;t||(t=e);let n,r=e;do{if(n=!1,r.steiner||!yO(r,r.next)&&0!==vO(r.prev,r,r.next))r=r.next;else{if(AO(r),r=t=r.prev,r===r.next)break;n=!0}}while(n||r!==t);return t}function oO(e,t,n,r,i,o,a){if(!e)return;!a&&o&&function(e,t,n,r){let i=e;do{null===i.z&&(i.z=hO(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,n,r,i,o,a,s,l,c=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,r=n,s=0,t=0;t<c&&(s++,r=r.nextZ,r);t++);for(l=c;s>0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,c*=2}while(a>1)}(i)}(e,r,i,o);let s,l,c=e;for(;e.prev!==e.next;)if(s=e.prev,l=e.next,o?sO(e,r,i,o):aO(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),AO(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?oO(e=lO(iO(e),t,n),t,n,r,i,o,2):2===a&&cO(e,t,n,r,i,o):oO(iO(e),t,n,r,i,o,1);break}}function aO(e){const t=e.prev,n=e,r=e.next;if(vO(t,n,r)>=0)return!1;let i=e.next.next;for(;i!==e.prev;){if(mO(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&vO(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function sO(e,t,n,r){const i=e.prev,o=e,a=e.next;if(vO(i,o,a)>=0)return!1;const s=i.x<o.x?i.x<a.x?i.x:a.x:o.x<a.x?o.x:a.x,l=i.y<o.y?i.y<a.y?i.y:a.y:o.y<a.y?o.y:a.y,c=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,u=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,d=hO(s,l,t,n,r),f=hO(c,u,t,n,r);let h=e.prevZ,p=e.nextZ;for(;h&&h.z>=d&&p&&p.z<=f;){if(h!==e.prev&&h!==e.next&&mO(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&vO(h.prev,h,h.next)>=0)return!1;if(h=h.prevZ,p!==e.prev&&p!==e.next&&mO(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&vO(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;h&&h.z>=d;){if(h!==e.prev&&h!==e.next&&mO(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&vO(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;p&&p.z<=f;){if(p!==e.prev&&p!==e.next&&mO(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&vO(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function lO(e,t,n){let r=e;do{const i=r.prev,o=r.next.next;!yO(i,o)&&bO(i,r,r.next,o)&&SO(i,o)&&SO(o,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(o.i/n),AO(r),AO(r.next),r=e=o),r=r.next}while(r!==e);return iO(r)}function cO(e,t,n,r,i,o){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&gO(a,e)){let s=MO(a,e);return a=iO(a,a.next),s=iO(s,s.next),oO(a,t,n,r,i,o),void oO(s,t,n,r,i,o)}e=e.next}a=a.next}while(a!==e)}function uO(e,t){return e.x-t.x}function dO(e,t){if(t=function(e,t){let n=t;const r=e.x,i=e.y;let o,a=-1/0;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){const e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a){if(a=e,e===r){if(i===n.y)return n;if(i===n.next.y)return n.next}o=n.x<n.next.x?n:n.next}}n=n.next}while(n!==t);if(!o)return null;if(r===a)return o;const s=o,l=o.x,c=o.y;let u,d=1/0;n=o;do{r>=n.x&&n.x>=l&&r!==n.x&&mO(i<c?r:a,i,l,c,i<c?a:r,i,n.x,n.y)&&(u=Math.abs(i-n.y)/(r-n.x),SO(n,e)&&(u<d||u===d&&(n.x>o.x||n.x===o.x&&fO(o,n)))&&(o=n,d=u)),n=n.next}while(n!==s);return o}(e,t),t){const n=MO(t,e);iO(t,t.next),iO(n,n.next)}}function fO(e,t){return vO(e.prev,e,t.prev)<0&&vO(t.next,e,e.next)<0}function hO(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function pO(e){let t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function mO(e,t,n,r,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(r-s)-(n-a)*(t-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function gO(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&bO(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(SO(e,t)&&SO(t,e)&&function(e,t){let n=e,r=!1;const i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(vO(e.prev,e,t.prev)||vO(e,t.prev,t))||yO(e,t)&&vO(e.prev,e,e.next)>0&&vO(t.prev,t,t.next)>0)}function vO(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function yO(e,t){return e.x===t.x&&e.y===t.y}function bO(e,t,n,r){const i=xO(vO(e,t,n)),o=xO(vO(e,t,r)),a=xO(vO(n,r,e)),s=xO(vO(n,r,t));return i!==o&&a!==s||(!(0!==i||!wO(e,n,t))||(!(0!==o||!wO(e,r,t))||(!(0!==a||!wO(n,e,r))||!(0!==s||!wO(n,t,r)))))}function wO(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function xO(e){return e>0?1:e<0?-1:0}function SO(e,t){return vO(e.prev,e,e.next)<0?vO(e,t,e.next)>=0&&vO(e,e.prev,t)>=0:vO(e,t,e.prev)<0||vO(e,e.next,t)<0}function MO(e,t){const n=new EO(e.i,e.x,e.y),r=new EO(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function _O(e,t,n,r){const i=new EO(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function AO(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function EO(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class CO{static area(e){const t=e.length;let n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return.5*n}static isClockWise(e){return CO.area(e)<0}static triangulateShape(e,t){const n=[],r=[],i=[];kO(e),TO(n,e);let o=e.length;t.forEach(kO);for(let e=0;e<t.length;e++)r.push(o),o+=t[e].length,TO(n,t[e]);const a=nO(n,r);for(let e=0;e<a.length;e+=3)i.push(a.slice(e,e+3));return i}}function kO(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function TO(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}class IO extends YA{constructor(e=new tO([new NM(.5,.5),new NM(-.5,.5),new NM(-.5,-.5),new NM(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,r=[],i=[];for(let t=0,n=e.length;t<n;t++){o(e[t])}function o(e){const o=[],a=void 0!==t.curveSegments?t.curveSegments:12,s=void 0!==t.steps?t.steps:1,l=void 0!==t.depth?t.depth:1;let c=void 0===t.bevelEnabled||t.bevelEnabled,u=void 0!==t.bevelThickness?t.bevelThickness:.2,d=void 0!==t.bevelSize?t.bevelSize:u-.1,f=void 0!==t.bevelOffset?t.bevelOffset:0,h=void 0!==t.bevelSegments?t.bevelSegments:3;const p=t.extrudePath,m=void 0!==t.UVGenerator?t.UVGenerator:OO;let g,v,y,b,w,x=!1;p&&(g=p.getSpacedPoints(s),x=!0,c=!1,v=p.computeFrenetFrames(s,!1),y=new d_,b=new d_,w=new d_),c||(h=0,u=0,d=0,f=0);const S=e.extractPoints(a);let M=S.shape;const _=S.holes;if(!CO.isClockWise(M)){M=M.reverse();for(let e=0,t=_.length;e<t;e++){const t=_[e];CO.isClockWise(t)&&(_[e]=t.reverse())}}const A=CO.triangulateShape(M,_),E=M;for(let e=0,t=_.length;e<t;e++){const t=_[e];M=M.concat(t)}function C(e,t,n){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(n).add(e)}const k=M.length,T=A.length;function I(e,t,n){let r,i,o;const a=e.x-t.x,s=e.y-t.y,l=n.x-e.x,c=n.y-e.y,u=a*a+s*s,d=a*c-s*l;if(Math.abs(d)>Number.EPSILON){const d=Math.sqrt(u),f=Math.sqrt(l*l+c*c),h=t.x-s/d,p=t.y+a/d,m=((n.x-c/f-h)*c-(n.y+l/f-p)*l)/(a*c-s*l);r=h+a*m-e.x,i=p+s*m-e.y;const g=r*r+i*i;if(g<=2)return new NM(r,i);o=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(s)===Math.sign(c)&&(e=!0),e?(r=-s,i=a,o=Math.sqrt(u)):(r=a,i=s,o=Math.sqrt(u/2))}return new NM(r/o,i/o)}const O=[];for(let e=0,t=E.length,n=t-1,r=e+1;e<t;e++,n++,r++)n===t&&(n=0),r===t&&(r=0),O[e]=I(E[e],E[n],E[r]);const R=[];let P,N=O.concat();for(let e=0,t=_.length;e<t;e++){const t=_[e];P=[];for(let e=0,n=t.length,r=n-1,i=e+1;e<n;e++,r++,i++)r===n&&(r=0),i===n&&(i=0),P[e]=I(t[e],t[r],t[i]);R.push(P),N=N.concat(P)}for(let e=0;e<h;e++){const t=e/h,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=E.length;e<t;e++){const t=C(E[e],O[e],r);B(t.x,t.y,-n)}for(let e=0,t=_.length;e<t;e++){const t=_[e];P=R[e];for(let e=0,i=t.length;e<i;e++){const i=C(t[e],P[e],r);B(i.x,i.y,-n)}}}const L=d+f;for(let e=0;e<k;e++){const t=c?C(M[e],N[e],L):M[e];x?(b.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),w.copy(g[0]).add(b).add(y),B(w.x,w.y,w.z)):B(t.x,t.y,0)}for(let e=1;e<=s;e++)for(let t=0;t<k;t++){const n=c?C(M[t],N[t],L):M[t];x?(b.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),w.copy(g[e]).add(b).add(y),B(w.x,w.y,w.z)):B(n.x,n.y,l/s*e)}for(let e=h-1;e>=0;e--){const t=e/h,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=E.length;e<t;e++){const t=C(E[e],O[e],r);B(t.x,t.y,l+n)}for(let e=0,t=_.length;e<t;e++){const t=_[e];P=R[e];for(let e=0,i=t.length;e<i;e++){const i=C(t[e],P[e],r);x?B(i.x,i.y+g[s-1].y,g[s-1].x+n):B(i.x,i.y,l+n)}}}function D(e,t){let n=e.length;for(;--n>=0;){const r=n;let i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+2*h;e<n;e++){const n=k*e,o=k*(e+1);F(t+r+n,t+i+n,t+i+o,t+r+o)}}}function B(e,t,n){o.push(e),o.push(t),o.push(n)}function j(e,t,i){U(e),U(t),U(i);const o=r.length/3,a=m.generateTopUV(n,r,o-3,o-2,o-1);z(a[0]),z(a[1]),z(a[2])}function F(e,t,i,o){U(e),U(t),U(o),U(t),U(i),U(o);const a=r.length/3,s=m.generateSideWallUV(n,r,a-6,a-3,a-2,a-1);z(s[0]),z(s[1]),z(s[3]),z(s[1]),z(s[2]),z(s[3])}function U(e){r.push(o[3*e+0]),r.push(o[3*e+1]),r.push(o[3*e+2])}function z(e){i.push(e.x),i.push(e.y)}!function(){const e=r.length/3;if(c){let e=0,t=k*e;for(let e=0;e<T;e++){const n=A[e];j(n[2]+t,n[1]+t,n[0]+t)}e=s+2*h,t=k*e;for(let e=0;e<T;e++){const n=A[e];j(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<T;e++){const t=A[e];j(t[2],t[1],t[0])}for(let e=0;e<T;e++){const t=A[e];j(t[0]+k*s,t[1]+k*s,t[2]+k*s)}}n.addGroup(e,r.length/3-e,0)}(),function(){const e=r.length/3;let t=0;D(E,t),t+=E.length;for(let e=0,n=_.length;e<n;e++){const n=_[e];D(n,t),t+=n.length}n.addGroup(e,r.length/3-e,1)}()}this.setAttribute("position",new FA(r,3)),this.setAttribute("uv",new FA(i,2)),this.computeVertexNormals()}toJSON(){const e=super.toJSON();return function(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,r=e.length;t<r;t++){const r=e[t];n.shapes.push(r.uuid)}else n.shapes.push(e.uuid);n.options=Object.assign({},t),void 0!==t.extrudePath&&(n.options.extrudePath=t.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){const n=[];for(let r=0,i=e.shapes.length;r<i;r++){const i=t[e.shapes[r]];n.push(i)}const r=e.options.extrudePath;return void 0!==r&&(e.options.extrudePath=(new UI[r.type]).fromJSON(r)),new IO(n,e.options)}}const OO={generateTopUV:function(e,t,n,r,i){const o=t[3*n],a=t[3*n+1],s=t[3*r],l=t[3*r+1],c=t[3*i],u=t[3*i+1];return[new NM(o,a),new NM(s,l),new NM(c,u)]},generateSideWallUV:function(e,t,n,r,i,o){const a=t[3*n],s=t[3*n+1],l=t[3*n+2],c=t[3*r],u=t[3*r+1],d=t[3*r+2],f=t[3*i],h=t[3*i+1],p=t[3*i+2],m=t[3*o],g=t[3*o+1],v=t[3*o+2];return Math.abs(s-u)<Math.abs(a-c)?[new NM(a,1-l),new NM(c,1-d),new NM(f,1-p),new NM(m,1-v)]:[new NM(s,1-l),new NM(u,1-d),new NM(h,1-p),new NM(g,1-v)]}};class RO extends YI{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new RO(e.radius,e.detail)}}class PO extends YI{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new PO(e.radius,e.detail)}}class NO extends YA{constructor(e=.5,t=1,n=8,r=1,i=0,o=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:o},n=Math.max(3,n);const a=[],s=[],l=[],c=[];let u=e;const d=(t-e)/(r=Math.max(1,r)),f=new d_,h=new NM;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){const r=i+e/n*o;f.x=u*Math.cos(r),f.y=u*Math.sin(r),s.push(f.x,f.y,f.z),l.push(0,0,1),h.x=(f.x/t+1)/2,h.y=(f.y/t+1)/2,c.push(h.x,h.y)}u+=d}for(let e=0;e<r;e++){const t=e*(n+1);for(let e=0;e<n;e++){const r=e+t,i=r,o=r+n+1,s=r+n+2,l=r+1;a.push(i,o,l),a.push(o,s,l)}}this.setIndex(a),this.setAttribute("position",new FA(s,3)),this.setAttribute("normal",new FA(l,3)),this.setAttribute("uv",new FA(c,2))}static fromJSON(e){return new NO(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class LO extends YA{constructor(e=new tO([new NM(0,.5),new NM(-.5,-.5),new NM(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],r=[],i=[],o=[];let a=0,s=0;if(!1===Array.isArray(e))l(e);else for(let t=0;t<e.length;t++)l(e[t]),this.addGroup(a,s,t),a+=s,s=0;function l(e){const a=r.length/3,l=e.extractPoints(t);let c=l.shape;const u=l.holes;!1===CO.isClockWise(c)&&(c=c.reverse());for(let e=0,t=u.length;e<t;e++){const t=u[e];!0===CO.isClockWise(t)&&(u[e]=t.reverse())}const d=CO.triangulateShape(c,u);for(let e=0,t=u.length;e<t;e++){const t=u[e];c=c.concat(t)}for(let e=0,t=c.length;e<t;e++){const t=c[e];r.push(t.x,t.y,0),i.push(0,0,1),o.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){const t=d[e],r=t[0]+a,i=t[1]+a,o=t[2]+a;n.push(r,i,o),s+=3}}this.setIndex(n),this.setAttribute("position",new FA(r,3)),this.setAttribute("normal",new FA(i,3)),this.setAttribute("uv",new FA(o,2))}toJSON(){const e=super.toJSON();return function(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){const r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}(this.parameters.shapes,e)}static fromJSON(e,t){const n=[];for(let r=0,i=e.shapes.length;r<i;r++){const i=t[e.shapes[r]];n.push(i)}return new LO(n,e.curveSegments)}}class DO extends YA{constructor(e=1,t=32,n=16,r=0,i=2*Math.PI,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const s=Math.min(o+a,Math.PI);let l=0;const c=[],u=new d_,d=new d_,f=[],h=[],p=[],m=[];for(let f=0;f<=n;f++){const g=[],v=f/n;let y=0;0==f&&0==o?y=.5/t:f==n&&s==Math.PI&&(y=-.5/t);for(let n=0;n<=t;n++){const s=n/t;u.x=-e*Math.cos(r+s*i)*Math.sin(o+v*a),u.y=e*Math.cos(o+v*a),u.z=e*Math.sin(r+s*i)*Math.sin(o+v*a),h.push(u.x,u.y,u.z),d.copy(u).normalize(),p.push(d.x,d.y,d.z),m.push(s+y,1-v),g.push(l++)}c.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){const t=c[e][r+1],i=c[e][r],a=c[e+1][r],l=c[e+1][r+1];(0!==e||o>0)&&f.push(t,i,l),(e!==n-1||s<Math.PI)&&f.push(i,a,l)}this.setIndex(f),this.setAttribute("position",new FA(h,3)),this.setAttribute("normal",new FA(p,3)),this.setAttribute("uv",new FA(m,2))}static fromJSON(e){return new DO(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class BO extends YI{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new BO(e.radius,e.detail)}}class jO extends YA{constructor(e=1,t=.4,n=8,r=6,i=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:i},n=Math.floor(n),r=Math.floor(r);const o=[],a=[],s=[],l=[],c=new d_,u=new d_,d=new d_;for(let o=0;o<=n;o++)for(let f=0;f<=r;f++){const h=f/r*i,p=o/n*Math.PI*2;u.x=(e+t*Math.cos(p))*Math.cos(h),u.y=(e+t*Math.cos(p))*Math.sin(h),u.z=t*Math.sin(p),a.push(u.x,u.y,u.z),c.x=e*Math.cos(h),c.y=e*Math.sin(h),d.subVectors(u,c).normalize(),s.push(d.x,d.y,d.z),l.push(f/r),l.push(o/n)}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){const n=(r+1)*e+t-1,i=(r+1)*(e-1)+t-1,a=(r+1)*(e-1)+t,s=(r+1)*e+t;o.push(n,i,s),o.push(i,a,s)}this.setIndex(o),this.setAttribute("position",new FA(a,3)),this.setAttribute("normal",new FA(s,3)),this.setAttribute("uv",new FA(l,2))}static fromJSON(e){return new jO(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class FO extends YA{constructor(e=1,t=.4,n=64,r=8,i=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:i,q:o},n=Math.floor(n),r=Math.floor(r);const a=[],s=[],l=[],c=[],u=new d_,d=new d_,f=new d_,h=new d_,p=new d_,m=new d_,g=new d_;for(let a=0;a<=n;++a){const y=a/n*i*Math.PI*2;v(y,i,o,e,f),v(y+.01,i,o,e,h),m.subVectors(h,f),g.addVectors(h,f),p.crossVectors(m,g),g.crossVectors(p,m),p.normalize(),g.normalize();for(let e=0;e<=r;++e){const i=e/r*Math.PI*2,o=-t*Math.cos(i),h=t*Math.sin(i);u.x=f.x+(o*g.x+h*p.x),u.y=f.y+(o*g.y+h*p.y),u.z=f.z+(o*g.z+h*p.z),s.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),l.push(d.x,d.y,d.z),c.push(a/n),c.push(e/r)}}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){const n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),o=(r+1)*e+t,s=(r+1)*(e-1)+t;a.push(n,i,s),a.push(i,o,s)}function v(e,t,n,r,i){const o=Math.cos(e),a=Math.sin(e),s=n/t*e,l=Math.cos(s);i.x=r*(2+l)*.5*o,i.y=r*(2+l)*a*.5,i.z=r*Math.sin(s)*.5}this.setIndex(a),this.setAttribute("position",new FA(s,3)),this.setAttribute("normal",new FA(l,3)),this.setAttribute("uv",new FA(c,2))}static fromJSON(e){return new FO(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class UO extends YA{constructor(e=new jI(new d_(-1,-1,0),new d_(-1,1,0),new d_(1,1,0)),t=64,n=1,r=8,i=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:i};const o=e.computeFrenetFrames(t,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new d_,s=new d_,l=new NM;let c=new d_;const u=[],d=[],f=[],h=[];function p(i){c=e.getPointAt(i/t,c);const l=o.normals[i],f=o.binormals[i];for(let e=0;e<=r;e++){const t=e/r*Math.PI*2,i=Math.sin(t),o=-Math.cos(t);s.x=o*l.x+i*f.x,s.y=o*l.y+i*f.y,s.z=o*l.z+i*f.z,s.normalize(),d.push(s.x,s.y,s.z),a.x=c.x+n*s.x,a.y=c.y+n*s.y,a.z=c.z+n*s.z,u.push(a.x,a.y,a.z)}}!function(){for(let e=0;e<t;e++)p(e);p(!1===i?t:0),function(){for(let e=0;e<=t;e++)for(let n=0;n<=r;n++)l.x=e/t,l.y=n/r,f.push(l.x,l.y)}(),function(){for(let e=1;e<=t;e++)for(let t=1;t<=r;t++){const n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),o=(r+1)*e+t,a=(r+1)*(e-1)+t;h.push(n,i,a),h.push(i,o,a)}}()}(),this.setIndex(h),this.setAttribute("position",new FA(u,3)),this.setAttribute("normal",new FA(d,3)),this.setAttribute("uv",new FA(f,2))}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new UO((new UI[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class zO extends YA{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){const t=[],n=new Set,r=new d_,i=new d_;if(null!==e.index){const o=e.attributes.position,a=e.index;let s=e.groups;0===s.length&&(s=[{start:0,count:a.count,materialIndex:0}]);for(let e=0,l=s.length;e<l;++e){const l=s[e],c=l.start;for(let e=c,s=c+l.count;e<s;e+=3)for(let s=0;s<3;s++){const l=a.getX(e+s),c=a.getX(e+(s+1)%3);r.fromBufferAttribute(o,l),i.fromBufferAttribute(o,c),!0===HO(r,i,n)&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}}else{const o=e.attributes.position;for(let e=0,a=o.count/3;e<a;e++)for(let a=0;a<3;a++){const s=3*e+a,l=3*e+(a+1)%3;r.fromBufferAttribute(o,s),i.fromBufferAttribute(o,l),!0===HO(r,i,n)&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}this.setAttribute("position",new FA(t,3))}}}function HO(e,t,n){const r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return!0!==n.has(r)&&!0!==n.has(i)&&(n.add(r),n.add(i),!0)}var VO=Object.freeze({__proto__:null,BoxGeometry:pE,CapsuleGeometry:WI,CircleGeometry:GI,ConeGeometry:KI,CylinderGeometry:qI,DodecahedronGeometry:JI,EdgesGeometry:eO,ExtrudeGeometry:IO,IcosahedronGeometry:RO,LatheGeometry:VI,OctahedronGeometry:PO,PlaneGeometry:NE,PolyhedronGeometry:YI,RingGeometry:NO,ShapeGeometry:LO,SphereGeometry:DO,TetrahedronGeometry:BO,TorusGeometry:jO,TorusKnotGeometry:FO,TubeGeometry:UO,WireframeGeometry:zO});class WO extends EA{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new QM(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class GO extends yE{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class qO extends EA{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new QM(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 QM(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=US,this.normalScale=new NM(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class KO extends qO{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new NM(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return AM(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new QM(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new QM(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new QM(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._iridescence=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=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 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.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class YO extends EA{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new QM(16777215),this.specular=new QM(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new QM(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=US,this.normalScale=new NM(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$w,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class JO extends EA{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new QM(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new QM(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=US,this.normalScale=new NM(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class QO extends EA{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=US,this.normalScale=new NM(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class XO extends EA{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new QM(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new QM(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=US,this.normalScale=new NM(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$w,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class ZO extends EA{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new QM(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=US,this.normalScale=new NM(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class $O extends $T{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function eR(e,t,n){return nR(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function tR(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function nR(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function rR(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n}function iR(e,t,n){const r=e.length,i=new e.constructor(r);for(let o=0,a=0;a!==r;++o){const r=n[o]*t;for(let n=0;n!==t;++n)i[a++]=e[r+n]}return i}function oR(e,t,n,r){let i=1,o=e[0];for(;void 0!==o&&void 0===o[r];)o=e[i++];if(void 0===o)return;let a=o[r];if(void 0!==a)if(Array.isArray(a))do{a=o[r],void 0!==a&&(t.push(o.time),n.push.apply(n,a)),o=e[i++]}while(void 0!==o);else if(void 0!==a.toArray)do{a=o[r],void 0!==a&&(t.push(o.time),a.toArray(n,n.length)),o=e[i++]}while(void 0!==o);else do{a=o[r],void 0!==a&&(t.push(o.time),n.push(a)),o=e[i++]}while(void 0!==o)}var aR=Object.freeze({__proto__:null,arraySlice:eR,convertArray:tR,isTypedArray:nR,getKeyframeOrder:rR,sortedArray:iR,flattenJSON:oR,subclip:function(e,t,n,r,i=30){const o=e.clone();o.name=t;const a=[];for(let e=0;e<o.tracks.length;++e){const t=o.tracks[e],s=t.getValueSize(),l=[],c=[];for(let e=0;e<t.times.length;++e){const o=t.times[e]*i;if(!(o<n||o>=r)){l.push(t.times[e]);for(let n=0;n<s;++n)c.push(t.values[e*s+n])}}0!==l.length&&(t.times=tR(l,t.times.constructor),t.values=tR(c,t.values.constructor),a.push(t))}o.tracks=a;let s=1/0;for(let e=0;e<o.tracks.length;++e)s>o.tracks[e].times[0]&&(s=o.tracks[e].times[0]);for(let e=0;e<o.tracks.length;++e)o.tracks[e].shift(-1*s);return o.resetDuration(),o},makeClipAdditive:function(e,t=0,n=e,r=30){r<=0&&(r=30);const i=n.tracks.length,o=t/r;for(let t=0;t<i;++t){const r=n.tracks[t],i=r.ValueTypeName;if("bool"===i||"string"===i)continue;const a=e.tracks.find((function(e){return e.name===r.name&&e.ValueTypeName===i}));if(void 0===a)continue;let s=0;const l=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=l/3);let c=0;const u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=u/3);const d=r.times.length-1;let f;if(o<=r.times[0]){const e=s,t=l-s;f=eR(r.values,e,t)}else if(o>=r.times[d]){const e=d*l+s,t=e+l-s;f=eR(r.values,e,t)}else{const e=r.createInterpolant(),t=s,n=l-s;e.evaluate(o),f=eR(e.resultBuffer,t,n)}if("quaternion"===i){(new u_).fromArray(f).normalize().conjugate().toArray(f)}const h=a.times.length;for(let e=0;e<h;++e){const t=e*u+c;if("quaternion"===i)u_.multiplyQuaternionsFlat(a.values,t,f,0,a.values,t);else{const e=u-2*c;for(let n=0;n<e;++n)a.values[t+n]-=f[n]}}}return e.blendMode=RS,e}});class sR{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r: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,r=t[n],i=t[n-1];e:{t:{let o;n:{r:if(!(e<r)){for(let o=n+2;;){if(void 0===r){if(e<i)break r;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(i=r,r=t[++n],e<r)break t}o=t.length;break n}if(e>=i)break e;{const a=t[1];e<a&&(n=2,i=a);for(let o=n-2;;){if(void 0===i)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(r=i,i=t[--n-1],e>=i)break t}o=n,n=0}}for(;n<o;){const r=n+o>>>1;e<t[r]?o=r:n=r+1}if(r=t[n],i=t[n-1],void 0===i)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===r)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class lR extends sR{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:kS,endingEnd:kS}}intervalChanged_(e,t,n){const r=this.parameterPositions;let i=e-2,o=e+1,a=r[i],s=r[o];if(void 0===a)switch(this.getSettings_().endingStart){case TS:i=e,a=2*t-n;break;case IS:i=r.length-2,a=t+r[i]-r[i+1];break;default:i=e,a=n}if(void 0===s)switch(this.getSettings_().endingEnd){case TS:o=e,s=2*n-t;break;case IS:o=1,s=n+r[1]-r[0];break;default:o=e-1,s=t}const l=.5*(n-t),c=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(s-n),this._offsetPrev=i*c,this._offsetNext=o*c}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=e*a,l=s-a,c=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,h=(n-t)/(r-t),p=h*h,m=p*h,g=-d*m+2*d*p-d*h,v=(1+d)*m+(-1.5-2*d)*p+(-.5+d)*h+1,y=(-1-f)*m+(1.5+f)*p+.5*h,b=f*m-f*p;for(let e=0;e!==a;++e)i[e]=g*o[c+e]+v*o[l+e]+y*o[s+e]+b*o[u+e];return i}}class cR extends sR{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=e*a,l=s-a,c=(n-t)/(r-t),u=1-c;for(let e=0;e!==a;++e)i[e]=o[l+e]*u+o[s+e]*c;return i}}class uR extends sR{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class dR{constructor(e,t,n,r){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=tR(t,this.TimeBufferType),this.values=tR(n,this.ValueBufferType),this.setInterpolation(r||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:tR(e.times,Array),values:tR(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new uR(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new cR(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new lR(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case AS:t=this.InterpolantFactoryMethodDiscrete;break;case ES:t=this.InterpolantFactoryMethodLinear;break;case CS:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return AS;case this.InterpolantFactoryMethodLinear:return ES;case this.InterpolantFactoryMethodSmooth:return CS}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let i=0,o=r-1;for(;i!==r&&n[i]<e;)++i;for(;-1!==o&&n[o]>t;)--o;if(++o,0!==i||o!==r){i>=o&&(o=Math.max(o,1),i=o-1);const e=this.getValueSize();this.times=eR(n,i,o),this.values=eR(this.values,i*e,o*e)}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,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let t=0;t!==i;t++){const r=n[t];if("number"==typeof r&&isNaN(r)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,r),e=!1;break}if(null!==o&&o>r){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,r,o),e=!1;break}o=r}if(void 0!==r&&nR(r))for(let t=0,n=r.length;t!==n;++t){const n=r[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=eR(this.times),t=eR(this.values),n=this.getValueSize(),r=this.getInterpolation()===CS,i=e.length-1;let o=1;for(let a=1;a<i;++a){let i=!1;const s=e[a];if(s!==e[a+1]&&(1!==a||s!==e[0]))if(r)i=!0;else{const e=a*n,r=e-n,o=e+n;for(let a=0;a!==n;++a){const n=t[e+a];if(n!==t[r+a]||n!==t[o+a]){i=!0;break}}}if(i){if(a!==o){e[o]=e[a];const r=a*n,i=o*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++o}}if(i>0){e[o]=e[i];for(let e=i*n,r=o*n,a=0;a!==n;++a)t[r+a]=t[e+a];++o}return o!==e.length?(this.times=eR(e,0,o),this.values=eR(t,0,o*n)):(this.times=e,this.values=t),this}clone(){const e=eR(this.times,0),t=eR(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}dR.prototype.TimeBufferType=Float32Array,dR.prototype.ValueBufferType=Float32Array,dR.prototype.DefaultInterpolation=ES;class fR extends dR{}fR.prototype.ValueTypeName="bool",fR.prototype.ValueBufferType=Array,fR.prototype.DefaultInterpolation=AS,fR.prototype.InterpolantFactoryMethodLinear=void 0,fR.prototype.InterpolantFactoryMethodSmooth=void 0;class hR extends dR{}hR.prototype.ValueTypeName="color";class pR extends dR{}pR.prototype.ValueTypeName="number";class mR extends sR{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=(n-t)/(r-t);let l=e*a;for(let e=l+a;l!==e;l+=4)u_.slerpFlat(i,0,o,l-a,o,l,s);return i}}class gR extends dR{InterpolantFactoryMethodLinear(e){return new mR(this.times,this.values,this.getValueSize(),e)}}gR.prototype.ValueTypeName="quaternion",gR.prototype.DefaultInterpolation=ES,gR.prototype.InterpolantFactoryMethodSmooth=void 0;class vR extends dR{}vR.prototype.ValueTypeName="string",vR.prototype.ValueBufferType=Array,vR.prototype.DefaultInterpolation=AS,vR.prototype.InterpolantFactoryMethodLinear=void 0,vR.prototype.InterpolantFactoryMethodSmooth=void 0;class yR extends dR{}yR.prototype.ValueTypeName="vector";class bR{constructor(e,t=-1,n,r=OS){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=_M(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push(wR(n[e]).scale(r));const i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,r=n.length;e!==r;++e)t.push(dR.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const i=t.length,o=[];for(let e=0;e<i;e++){let a=[],s=[];a.push((e+i-1)%i,e,(e+1)%i),s.push(0,1,0);const l=rR(a);a=iR(a,1,l),s=iR(s,1,l),r||0!==a[0]||(a.push(i),s.push(s[0])),o.push(new pR(".morphTargetInfluences["+t[e].name+"]",a,s).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},i=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){const n=e[t],o=n.name.match(i);if(o&&o.length>1){const e=o[1];let t=r[e];t||(r[e]=t=[]),t.push(n)}}const o=[];for(const e in r)o.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,r,i){if(0!==n.length){const o=[],a=[];oR(n,o,a,r),0!==o.length&&i.push(new e(t,o,a))}},r=[],i=e.name||"default",o=e.fps||30,a=e.blendMode;let s=e.length||-1;const l=e.hierarchy||[];for(let e=0;e<l.length;e++){const i=l[e].keys;if(i&&0!==i.length)if(i[0].morphTargets){const e={};let t;for(t=0;t<i.length;t++)if(i[t].morphTargets)for(let n=0;n<i[t].morphTargets.length;n++)e[i[t].morphTargets[n]]=-1;for(const n in e){const e=[],o=[];for(let r=0;r!==i[t].morphTargets.length;++r){const r=i[t];e.push(r.time),o.push(r.morphTarget===n?1:0)}r.push(new pR(".morphTargetInfluence["+n+"]",e,o))}s=e.length*o}else{const o=".bones["+t[e].name+"]";n(yR,o+".position",i,"pos",r),n(gR,o+".quaternion",i,"rot",r),n(yR,o+".scale",i,"scl",r)}}if(0===r.length)return null;return new this(i,s,r,a)}resetDuration(){let e=0;for(let t=0,n=this.tracks.length;t!==n;++t){const n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,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 wR(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return pR;case"vector":case"vector2":case"vector3":case"vector4":return yR;case"color":return hR;case"quaternion":return gR;case"bool":case"boolean":return fR;case"string":return vR}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],n=[];oR(e.keys,t,n,"value"),e.times=t,e.values=n}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const xR={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class SR{constructor(e,t,n){const r=this;let i,o=!1,a=0,s=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){s++,!1===o&&void 0!==r.onStart&&r.onStart(e,a,s),o=!0},this.itemEnd=function(e){a++,void 0!==r.onProgress&&r.onProgress(e,a,s),a===s&&(o=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return i?i(e):e},this.setURLModifier=function(e){return i=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){const t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=l.length;t<n;t+=2){const n=l[t],r=l[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}}const MR=new SR;class _R{constructor(e){this.manager=void 0!==e?e:MR,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise((function(r,i){n.load(e,r,t,i)}))}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}}const AR={};class ER extends Error{constructor(e,t){super(e),this.response=t}}class CR extends _R{constructor(e){super(e)}load(e,t,n,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=xR.get(e);if(void 0!==i)return this.manager.itemStart(e),setTimeout((()=>{t&&t(i),this.manager.itemEnd(e)}),0),i;if(void 0!==AR[e])return void AR[e].push({onLoad:t,onProgress:n,onError:r});AR[e]=[],AR[e].push({onLoad:t,onProgress:n,onError:r});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,s=this.responseType;fetch(o).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=AR[e],r=t.body.getReader(),i=t.headers.get("Content-Length"),o=i?parseInt(i):0,a=0!==o;let s=0;const l=new ReadableStream({start(e){!function t(){r.read().then((({done:r,value:i})=>{if(r)e.close();else{s+=i.byteLength;const r=new ProgressEvent("progress",{lengthComputable:a,loaded:s,total:o});for(let e=0,t=n.length;e<t;e++){const t=n[e];t.onProgress&&t.onProgress(r)}e.enqueue(i),t()}}))}()}});return new Response(l)}throw new ER(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(s){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,a)));case"json":return e.json();default:if(void 0===a)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(a),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then((e=>r.decode(e)))}}})).then((t=>{xR.add(e,t);const n=AR[e];delete AR[e];for(let e=0,r=n.length;e<r;e++){const r=n[e];r.onLoad&&r.onLoad(t)}})).catch((t=>{const n=AR[e];if(void 0===n)throw this.manager.itemError(e),t;delete AR[e];for(let e=0,r=n.length;e<r;e++){const r=n[e];r.onError&&r.onError(t)}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 kR extends _R{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new CR(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e){const t=[];for(let n=0;n<e.length;n++){const r=bR.parse(e[n]);t.push(r)}return t}}class TR extends _R{constructor(e){super(e)}load(e,t,n,r){const i=this,o=[],a=new bI,s=new CR(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(i.withCredentials);let l=0;function c(c){s.load(e[c],(function(e){const n=i.parse(e,!0);o[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(a.minFilter=Sx),a.image=o,a.format=n.format,a.needsUpdate=!0,t&&t(a))}),n,r)}if(Array.isArray(e))for(let t=0,n=e.length;t<n;++t)c(t);else s.load(e,(function(e){const n=i.parse(e,!0);if(n.isCubemap){const e=n.mipmaps.length/n.mipmapCount;for(let t=0;t<e;t++){o[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)o[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),o[t].format=n.format,o[t].width=n.width,o[t].height=n.height}a.image=o}else a.image.width=n.width,a.image.height=n.height,a.mipmaps=n.mipmaps;1===n.mipmapCount&&(a.minFilter=Sx),a.format=n.format,a.needsUpdate=!0,t&&t(a)}),n,r);return a}}class IR extends _R{constructor(e){super(e)}load(e,t,n,r){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,o=xR.get(e);if(void 0!==o)return i.manager.itemStart(e),setTimeout((function(){t&&t(o),i.manager.itemEnd(e)}),0),o;const a=FM("img");function s(){c(),xR.add(e,this),t&&t(this),i.manager.itemEnd(e)}function l(t){c(),r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)}function c(){a.removeEventListener("load",s,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",s,!1),a.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),i.manager.itemStart(e),a.src=e,a}}class OR extends _R{constructor(e){super(e)}load(e,t,n,r){const i=new ME,o=new IR(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function s(n){o.load(e[n],(function(e){i.images[n]=e,a++,6===a&&(i.needsUpdate=!0,t&&t(i))}),void 0,r)}for(let t=0;t<e.length;++t)s(t);return i}}class RR extends _R{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new VT,a=new CR(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(i.withCredentials),a.load(e,(function(e){const n=i.parse(e);n&&(void 0!==n.image?o.image=n.image:void 0!==n.data&&(o.image.width=n.width,o.image.height=n.height,o.image.data=n.data),o.wrapS=void 0!==n.wrapS?n.wrapS:mx,o.wrapT=void 0!==n.wrapT?n.wrapT:mx,o.magFilter=void 0!==n.magFilter?n.magFilter:Sx,o.minFilter=void 0!==n.minFilter?n.minFilter:Sx,o.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.encoding&&(o.encoding=n.encoding),void 0!==n.flipY&&(o.flipY=n.flipY),void 0!==n.format&&(o.format=n.format),void 0!==n.type&&(o.type=n.type),void 0!==n.mipmaps&&(o.mipmaps=n.mipmaps,o.minFilter=Ax),1===n.mipmapCount&&(o.minFilter=Sx),void 0!==n.generateMipmaps&&(o.generateMipmaps=n.generateMipmaps),o.needsUpdate=!0,t&&t(o,n))}),n,r),o}}class PR extends _R{constructor(e){super(e)}load(e,t,n,r){const i=new n_,o=new IR(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,(function(e){i.image=e,i.needsUpdate=!0,void 0!==t&&t(i)}),n,r),i}}class NR extends hA{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new QM(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,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}class LR extends NR{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(hA.DefaultUp),this.updateMatrix(),this.groundColor=new QM(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const DR=new H_,BR=new d_,jR=new d_;class FR{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new NM(512,512),this.map=null,this.mapPass=null,this.matrix=new H_,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new OE,this._frameExtents=new NM(1,1),this._viewportCount=1,this._viewports=[new r_(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;BR.setFromMatrixPosition(e.matrixWorld),t.position.copy(BR),jR.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(jR),t.updateMatrixWorld(),DR.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(DR),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class UR extends FR{constructor(){super(new wE(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=2*MM*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,i=e.distance||t.far;n===t.fov&&r===t.aspect&&i===t.far||(t.fov=n,t.aspect=r,t.far=i,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class zR extends NR{constructor(e,t,n=0,r=Math.PI/3,i=0,o=1){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(hA.DefaultUp),this.updateMatrix(),this.target=new hA,this.distance=n,this.angle=r,this.penumbra=i,this.decay=o,this.map=null,this.shadow=new UR}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 HR=new H_,VR=new d_,WR=new d_;class GR extends FR{constructor(){super(new wE(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new NM(4,2),this._viewportCount=6,this._viewports=[new r_(2,1,1,1),new r_(0,1,1,1),new r_(3,1,1,1),new r_(1,1,1,1),new r_(3,0,1,1),new r_(1,0,1,1)],this._cubeDirections=[new d_(1,0,0),new d_(-1,0,0),new d_(0,0,1),new d_(0,0,-1),new d_(0,1,0),new d_(0,-1,0)],this._cubeUps=[new d_(0,1,0),new d_(0,1,0),new d_(0,1,0),new d_(0,1,0),new d_(0,0,1),new d_(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,i=e.distance||n.far;i!==n.far&&(n.far=i,n.updateProjectionMatrix()),VR.setFromMatrixPosition(e.matrixWorld),n.position.copy(VR),WR.copy(n.position),WR.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(WR),n.updateMatrixWorld(),r.makeTranslation(-VR.x,-VR.y,-VR.z),HR.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(HR)}}class qR extends NR{constructor(e,t,n=0,r=1){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new GR}get power(){return 4*this.intensity*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 KR extends FR{constructor(){super(new WE(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class YR extends NR{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(hA.DefaultUp),this.updateMatrix(),this.target=new hA,this.shadow=new KR}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class JR extends NR{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class QR extends NR{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class XR{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new d_)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,r=e.y,i=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*i),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],n*r*1.092548),t.addScaledVector(o[5],r*i*1.092548),t.addScaledVector(o[6],.315392*(3*i*i-1)),t.addScaledVector(o[7],n*i*1.092548),t.addScaledVector(o[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){const n=e.x,r=e.y,i=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],1.023328*r),t.addScaledVector(o[2],1.023328*i),t.addScaledVector(o[3],1.023328*n),t.addScaledVector(o[4],.858086*n*r),t.addScaledVector(o[5],.858086*r*i),t.addScaledVector(o[6],.743125*i*i-.247708),t.addScaledVector(o[7],.858086*n*i),t.addScaledVector(o[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+3*r);return this}toArray(e=[],t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+3*r);return e}static getBasisAt(e,t){const n=e.x,r=e.y,i=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*i,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*i,t[6]=.315392*(3*i*i-1),t[7]=1.092548*n*i,t[8]=.546274*(n*n-r*r)}}class ZR extends NR{constructor(e=new XR,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class $R extends _R{constructor(e){super(e),this.textures={}}load(e,t,n,r){const i=this,o=new CR(i.manager);o.setPath(i.path),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,(function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e){const t=this.textures;function n(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}const r=$R.createMaterialFromType(e.type);if(void 0!==e.uuid&&(r.uuid=e.uuid),void 0!==e.name&&(r.name=e.name),void 0!==e.color&&void 0!==r.color&&r.color.setHex(e.color),void 0!==e.roughness&&(r.roughness=e.roughness),void 0!==e.metalness&&(r.metalness=e.metalness),void 0!==e.sheen&&(r.sheen=e.sheen),void 0!==e.sheenColor&&(r.sheenColor=(new QM).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(r.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==r.emissive&&r.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==r.specular&&r.specular.setHex(e.specular),void 0!==e.specularIntensity&&(r.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==r.specularColor&&r.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(r.shininess=e.shininess),void 0!==e.clearcoat&&(r.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(r.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.iridescence&&(r.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(r.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(r.transmission=e.transmission),void 0!==e.thickness&&(r.thickness=e.thickness),void 0!==e.attenuationDistance&&(r.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==r.attenuationColor&&r.attenuationColor.setHex(e.attenuationColor),void 0!==e.fog&&(r.fog=e.fog),void 0!==e.flatShading&&(r.flatShading=e.flatShading),void 0!==e.blending&&(r.blending=e.blending),void 0!==e.combine&&(r.combine=e.combine),void 0!==e.side&&(r.side=e.side),void 0!==e.shadowSide&&(r.shadowSide=e.shadowSide),void 0!==e.opacity&&(r.opacity=e.opacity),void 0!==e.transparent&&(r.transparent=e.transparent),void 0!==e.alphaTest&&(r.alphaTest=e.alphaTest),void 0!==e.depthTest&&(r.depthTest=e.depthTest),void 0!==e.depthWrite&&(r.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(r.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(r.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(r.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(r.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(r.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(r.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(r.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(r.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(r.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(r.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(r.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(r.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(r.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(r.rotation=e.rotation),1!==e.linewidth&&(r.linewidth=e.linewidth),void 0!==e.dashSize&&(r.dashSize=e.dashSize),void 0!==e.gapSize&&(r.gapSize=e.gapSize),void 0!==e.scale&&(r.scale=e.scale),void 0!==e.polygonOffset&&(r.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(r.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(r.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(r.dithering=e.dithering),void 0!==e.alphaToCoverage&&(r.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(r.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.visible&&(r.visible=e.visible),void 0!==e.toneMapped&&(r.toneMapped=e.toneMapped),void 0!==e.userData&&(r.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const i=e.uniforms[t];switch(r.uniforms[t]={},i.type){case"t":r.uniforms[t].value=n(i.value);break;case"c":r.uniforms[t].value=(new QM).setHex(i.value);break;case"v2":r.uniforms[t].value=(new NM).fromArray(i.value);break;case"v3":r.uniforms[t].value=(new d_).fromArray(i.value);break;case"v4":r.uniforms[t].value=(new r_).fromArray(i.value);break;case"m3":r.uniforms[t].value=(new LM).fromArray(i.value);break;case"m4":r.uniforms[t].value=(new H_).fromArray(i.value);break;default:r.uniforms[t].value=i.value}}if(void 0!==e.defines&&(r.defines=e.defines),void 0!==e.vertexShader&&(r.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(r.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(r.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)r.extensions[t]=e.extensions[t];if(void 0!==e.size&&(r.size=e.size),void 0!==e.sizeAttenuation&&(r.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(r.map=n(e.map)),void 0!==e.matcap&&(r.matcap=n(e.matcap)),void 0!==e.alphaMap&&(r.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(r.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(r.bumpScale=e.bumpScale),void 0!==e.normalMap&&(r.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(r.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),r.normalScale=(new NM).fromArray(t)}return void 0!==e.displacementMap&&(r.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(r.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(r.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(r.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(r.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(r.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(r.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(r.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(r.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(r.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(r.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(r.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(r.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(r.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(r.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(r.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(r.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(r.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(r.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(r.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(r.clearcoatNormalScale=(new NM).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(r.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(r.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(r.thicknessMap=n(e.thicknessMap)),void 0!==e.sheenColorMap&&(r.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:WO,SpriteMaterial:vT,RawShaderMaterial:GO,ShaderMaterial:yE,PointsMaterial:uI,MeshPhysicalMaterial:KO,MeshStandardMaterial:qO,MeshPhongMaterial:YO,MeshToonMaterial:JO,MeshNormalMaterial:QO,MeshLambertMaterial:XO,MeshDepthMaterial:Jk,MeshDistanceMaterial:Qk,MeshBasicMaterial:CA,MeshMatcapMaterial:ZO,LineDashedMaterial:$O,LineBasicMaterial:$T,Material:EA}[e]}}class eP{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch(e){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===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 tP extends YA{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return(new this.constructor).copy(this)}toJSON(){const e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class nP extends _R{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new CR(i.manager);o.setPath(i.path),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,(function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e){const t={},n={};function r(e,r){if(void 0!==t[r])return t[r];const i=e.interleavedBuffers[r],o=function(e,t){if(void 0!==n[t])return n[t];const r=e.arrayBuffers,i=r[t],o=new Uint32Array(i).buffer;return n[t]=o,o}(e,i.buffer),a=jM(i.type,o),s=new pT(a,i.stride);return s.uuid=i.uuid,t[r]=s,s}const i=e.isInstancedBufferGeometry?new tP:new YA,o=e.data.index;if(void 0!==o){const e=jM(o.type,o.array);i.setIndex(new IA(e,1))}const a=e.data.attributes;for(const t in a){const n=a[t];let o;if(n.isInterleavedBufferAttribute){const t=r(e.data,n.data);o=new gT(t,n.itemSize,n.offset,n.normalized)}else{const e=jM(n.type,n.array);o=new(n.isInstancedBufferAttribute?KT:IA)(e,n.itemSize,n.normalized)}void 0!==n.name&&(o.name=n.name),void 0!==n.usage&&o.setUsage(n.usage),void 0!==n.updateRange&&(o.updateRange.offset=n.updateRange.offset,o.updateRange.count=n.updateRange.count),i.setAttribute(t,o)}const s=e.data.morphAttributes;if(s)for(const t in s){const n=s[t],o=[];for(let t=0,i=n.length;t<i;t++){const i=n[t];let a;if(i.isInterleavedBufferAttribute){const t=r(e.data,i.data);a=new gT(t,i.itemSize,i.offset,i.normalized)}else{const e=jM(i.type,i.array);a=new IA(e,i.itemSize,i.normalized)}void 0!==i.name&&(a.name=i.name),o.push(a)}i.morphAttributes[t]=o}e.data.morphTargetsRelative&&(i.morphTargetsRelative=!0);const l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(let e=0,t=l.length;e!==t;++e){const t=l[e];i.addGroup(t.start,t.count,t.materialIndex)}const c=e.data.boundingSphere;if(void 0!==c){const e=new d_;void 0!==c.center&&e.fromArray(c.center),i.boundingSphere=new P_(e,c.radius)}return e.name&&(i.name=e.name),e.userData&&(i.userData=e.userData),i}}class rP extends _R{constructor(e){super(e)}load(e,t,n,r){const i=this,o=""===this.path?eP.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const a=new CR(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){let o=null;try{o=JSON.parse(n)}catch(t){return void 0!==r&&r(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}const a=o.metadata;void 0!==a&&void 0!==a.type&&"geometry"!==a.type.toLowerCase()?i.parse(o,t):console.error("THREE.ObjectLoader: Can't load "+e)}),n,r)}async loadAsync(e,t){const n=""===this.path?eP.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;const r=new CR(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);const i=await r.loadAsync(e,t),o=JSON.parse(i),a=o.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+e);return await this.parseAsync(o)}parse(e,t){const n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,(function(){void 0!==t&&t(l)})),a=this.parseTextures(e.textures,o),s=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,i,s,a,n),c=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,c),void 0!==t){let e=!1;for(const t in o)if(o[t].data instanceof HTMLImageElement){e=!0;break}!1===e&&t(l)}return l}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),i=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,i),a=this.parseMaterials(e.materials,o),s=this.parseObject(e.object,r,a,o,t),l=this.parseSkeletons(e.skeletons,s);return this.bindSkeletons(s,l),s}parseShapes(e){const t={};if(void 0!==e)for(let n=0,r=e.length;n<r;n++){const r=(new tO).fromJSON(e[n]);t[r.uuid]=r}return t}parseSkeletons(e,t){const n={},r={};if(t.traverse((function(e){e.isBone&&(r[e.uuid]=e)})),void 0!==e)for(let t=0,i=e.length;t<i;t++){const i=(new qT).fromJSON(e[t],r);n[i.uuid]=i}return n}parseGeometries(e,t){const n={};if(void 0!==e){const r=new nP;for(let i=0,o=e.length;i<o;i++){let o;const a=e[i];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(a);break;default:a.type in VO?o=VO[a.type].fromJSON(a,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}o.uuid=a.uuid,void 0!==a.name&&(o.name=a.name),!0===o.isBufferGeometry&&void 0!==a.userData&&(o.userData=a.userData),n[a.uuid]=o}}return n}parseMaterials(e,t){const n={},r={};if(void 0!==e){const i=new $R;i.setTextures(t);for(let t=0,o=e.length;t<o;t++){const o=e[t];void 0===n[o.uuid]&&(n[o.uuid]=i.parse(o)),r[o.uuid]=n[o.uuid]}}return r}parseAnimations(e){const t={};if(void 0!==e)for(let n=0;n<e.length;n++){const r=e[n],i=bR.parse(r);t[i.uuid]=i}return t}parseImages(e,t){const n=this,r={};let i;function o(e){if("string"==typeof e){const t=e;return function(e){return n.manager.itemStart(e),i.load(e,(function(){n.manager.itemEnd(e)}),void 0,(function(){n.manager.itemError(e),n.manager.itemEnd(e)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t)?t:n.resourcePath+t)}return e.data?{data:jM(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){const n=new SR(t);i=new IR(n),i.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){const n=e[t],i=n.url;if(Array.isArray(i)){const e=[];for(let t=0,n=i.length;t<n;t++){const n=o(i[t]);null!==n&&(n instanceof HTMLImageElement?e.push(n):e.push(new VT(n.data,n.width,n.height)))}r[n.uuid]=new $M(e)}else{const e=o(n.url);r[n.uuid]=new $M(e)}}}return r}async parseImagesAsync(e){const t=this,n={};let r;async function i(e){if("string"==typeof e){const n=e,i=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:t.resourcePath+n;return await r.loadAsync(i)}return e.data?{data:jM(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){r=new IR(this.manager),r.setCrossOrigin(this.crossOrigin);for(let t=0,r=e.length;t<r;t++){const r=e[t],o=r.url;if(Array.isArray(o)){const e=[];for(let t=0,n=o.length;t<n;t++){const n=o[t],r=await i(n);null!==r&&(r instanceof HTMLImageElement?e.push(r):e.push(new VT(r.data,r.width,r.height)))}n[r.uuid]=new $M(e)}else{const e=await i(r.url);n[r.uuid]=new $M(e)}}}return n}parseTextures(e,t){function n(e,t){return"number"==typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}const r={};if(void 0!==e)for(let i=0,o=e.length;i<o;i++){const o=e[i];void 0===o.image&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),void 0===t[o.image]&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const a=t[o.image],s=a.data;let l;Array.isArray(s)?(l=new ME,6===s.length&&(l.needsUpdate=!0)):(l=s&&s.data?new VT:new n_,s&&(l.needsUpdate=!0)),l.source=a,l.uuid=o.uuid,void 0!==o.name&&(l.name=o.name),void 0!==o.mapping&&(l.mapping=n(o.mapping,iP)),void 0!==o.offset&&l.offset.fromArray(o.offset),void 0!==o.repeat&&l.repeat.fromArray(o.repeat),void 0!==o.center&&l.center.fromArray(o.center),void 0!==o.rotation&&(l.rotation=o.rotation),void 0!==o.wrap&&(l.wrapS=n(o.wrap[0],oP),l.wrapT=n(o.wrap[1],oP)),void 0!==o.format&&(l.format=o.format),void 0!==o.type&&(l.type=o.type),void 0!==o.encoding&&(l.encoding=o.encoding),void 0!==o.minFilter&&(l.minFilter=n(o.minFilter,aP)),void 0!==o.magFilter&&(l.magFilter=n(o.magFilter,aP)),void 0!==o.anisotropy&&(l.anisotropy=o.anisotropy),void 0!==o.flipY&&(l.flipY=o.flipY),void 0!==o.premultiplyAlpha&&(l.premultiplyAlpha=o.premultiplyAlpha),void 0!==o.unpackAlignment&&(l.unpackAlignment=o.unpackAlignment),void 0!==o.userData&&(l.userData=o.userData),r[o.uuid]=l}return r}parseObject(e,t,n,r,i){let o,a,s;function l(e){return void 0===t[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),t[e]}function c(e){if(void 0!==e){if(Array.isArray(e)){const t=[];for(let r=0,i=e.length;r<i;r++){const i=e[r];void 0===n[i]&&console.warn("THREE.ObjectLoader: Undefined material",i),t.push(n[i])}return t}return void 0===n[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),n[e]}}function u(e){return void 0===r[e]&&console.warn("THREE.ObjectLoader: Undefined texture",e),r[e]}switch(e.type){case"Scene":o=new hT,void 0!==e.background&&(Number.isInteger(e.background)?o.background=new QM(e.background):o.background=u(e.background)),void 0!==e.environment&&(o.environment=u(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?o.fog=new fT(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(o.fog=new dT(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":o=new wE(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(o.focus=e.focus),void 0!==e.zoom&&(o.zoom=e.zoom),void 0!==e.filmGauge&&(o.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(o.filmOffset=e.filmOffset),void 0!==e.view&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new WE(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(o.zoom=e.zoom),void 0!==e.view&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new JR(e.color,e.intensity);break;case"DirectionalLight":o=new YR(e.color,e.intensity);break;case"PointLight":o=new qR(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new QR(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new zR(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new LR(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=(new ZR).fromJSON(e);break;case"SkinnedMesh":a=l(e.geometry),s=c(e.material),o=new zT(a,s),void 0!==e.bindMode&&(o.bindMode=e.bindMode),void 0!==e.bindMatrix&&o.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(o.skeleton=e.skeleton);break;case"Mesh":a=l(e.geometry),s=c(e.material),o=new fE(a,s);break;case"InstancedMesh":a=l(e.geometry),s=c(e.material);const t=e.count,n=e.instanceMatrix,r=e.instanceColor;o=new ZT(a,s,t),o.instanceMatrix=new KT(new Float32Array(n.array),16),void 0!==r&&(o.instanceColor=new KT(new Float32Array(r.array),r.itemSize));break;case"LOD":o=new LT;break;case"Line":o=new oI(l(e.geometry),c(e.material));break;case"LineLoop":o=new cI(l(e.geometry),c(e.material));break;case"LineSegments":o=new lI(l(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new mI(l(e.geometry),c(e.material));break;case"Sprite":o=new OT(c(e.material));break;case"Group":o=new nT;break;case"Bone":o=new HT;break;default:o=new hA}if(o.uuid=e.uuid,void 0!==e.name&&(o.name=e.name),void 0!==e.matrix?(o.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(void 0!==e.position&&o.position.fromArray(e.position),void 0!==e.rotation&&o.rotation.fromArray(e.rotation),void 0!==e.quaternion&&o.quaternion.fromArray(e.quaternion),void 0!==e.scale&&o.scale.fromArray(e.scale)),void 0!==e.castShadow&&(o.castShadow=e.castShadow),void 0!==e.receiveShadow&&(o.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(o.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(o.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(o.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&o.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(o.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(o.visible=e.visible),void 0!==e.frustumCulled&&(o.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(o.renderOrder=e.renderOrder),void 0!==e.userData&&(o.userData=e.userData),void 0!==e.layers&&(o.layers.mask=e.layers),void 0!==e.children){const a=e.children;for(let e=0;e<a.length;e++)o.add(this.parseObject(a[e],t,n,r,i))}if(void 0!==e.animations){const t=e.animations;for(let e=0;e<t.length;e++){const n=t[e];o.animations.push(i[n])}}if("LOD"===e.type){void 0!==e.autoUpdate&&(o.autoUpdate=e.autoUpdate);const t=e.levels;for(let e=0;e<t.length;e++){const n=t[e],r=o.getObjectByProperty("uuid",n.object);void 0!==r&&o.addLevel(r,n.distance)}}return o}bindSkeletons(e,t){0!==Object.keys(t).length&&e.traverse((function(e){if(!0===e.isSkinnedMesh&&void 0!==e.skeleton){const n=t[e.skeleton];void 0===n?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(n,e.bindMatrix)}}))}}const iP={UVMapping:lx,CubeReflectionMapping:cx,CubeRefractionMapping:ux,EquirectangularReflectionMapping:dx,EquirectangularRefractionMapping:fx,CubeUVReflectionMapping:hx},oP={RepeatWrapping:px,ClampToEdgeWrapping:mx,MirroredRepeatWrapping:gx},aP={NearestFilter:vx,NearestMipmapNearestFilter:yx,NearestMipmapLinearFilter:wx,LinearFilter:Sx,LinearMipmapNearestFilter:Mx,LinearMipmapLinearFilter:Ax};class sP extends _R{constructor(e){super(e),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,o=xR.get(e);if(void 0!==o)return i.manager.itemStart(e),setTimeout((function(){t&&t(o),i.manager.itemEnd(e)}),0),o;const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(i.options,{colorSpaceConversion:"none"}))})).then((function(n){xR.add(e,n),t&&t(n),i.manager.itemEnd(e)})).catch((function(t){r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)})),i.manager.itemStart(e)}}let lP;const cP={getContext:function(){return void 0===lP&&(lP=new(window.AudioContext||window.webkitAudioContext)),lP},setContext:function(e){lP=e}};class uP extends _R{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new CR(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{const e=n.slice(0);cP.getContext().decodeAudioData(e,(function(e){t(e)}))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}}class dP extends ZR{constructor(e,t,n=1){super(void 0,n),this.isHemisphereLightProbe=!0;const r=(new QM).set(e),i=(new QM).set(t),o=new d_(r.r,r.g,r.b),a=new d_(i.r,i.g,i.b),s=Math.sqrt(Math.PI),l=s*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(a).multiplyScalar(s),this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(l)}}class fP extends ZR{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const n=(new QM).set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const hP=new H_,pP=new H_,mP=new H_;class gP{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new wE,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new wE,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,mP.copy(e.projectionMatrix);const n=t.eyeSep/2,r=n*t.near/t.focus,i=t.near*Math.tan(SM*t.fov*.5)/t.zoom;let o,a;pP.elements[12]=-n,hP.elements[12]=n,o=-i*t.aspect+r,a=i*t.aspect+r,mP.elements[0]=2*t.near/(a-o),mP.elements[8]=(a+o)/(a-o),this.cameraL.projectionMatrix.copy(mP),o=-i*t.aspect-r,a=i*t.aspect-r,mP.elements[0]=2*t.near/(a-o),mP.elements[8]=(a+o)/(a-o),this.cameraR.projectionMatrix.copy(mP)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(pP),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(hP)}}class vP{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=yP(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=yP();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function yP(){return("undefined"==typeof performance?Date:performance).now()}const bP=new d_,wP=new u_,xP=new d_,SP=new d_;class MP extends hA{constructor(){super(),this.type="AudioListener",this.context=cP.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new vP}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(bP,wP,xP),SP.set(0,0,-1).applyQuaternion(wP),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(bP.x,e),t.positionY.linearRampToValueAtTime(bP.y,e),t.positionZ.linearRampToValueAtTime(bP.z,e),t.forwardX.linearRampToValueAtTime(SP.x,e),t.forwardY.linearRampToValueAtTime(SP.y,e),t.forwardZ.linearRampToValueAtTime(SP.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(bP.x,bP.y,bP.z),t.setOrientation(SP.x,SP.y,SP.z,n.x,n.y,n.z)}}class _P extends hA{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const AP=new d_,EP=new u_,CP=new d_,kP=new d_;class TP extends _P{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(AP,EP,CP),kP.set(0,0,1).applyQuaternion(EP);const t=this.panner;if(t.positionX){const e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(AP.x,e),t.positionY.linearRampToValueAtTime(AP.y,e),t.positionZ.linearRampToValueAtTime(AP.z,e),t.orientationX.linearRampToValueAtTime(kP.x,e),t.orientationY.linearRampToValueAtTime(kP.y,e),t.orientationZ.linearRampToValueAtTime(kP.z,e)}else t.setPosition(AP.x,AP.y,AP.z),t.setOrientation(kP.x,kP.y,kP.z)}}class IP{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class OP{constructor(e,t,n){let r,i,o;switch(this.binding=e,this.valueSize=n,t){case"quaternion":r=this._slerp,i=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":r=this._select,i=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:r=this._lerp,i=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=i,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,r=this.valueSize,i=e*r+r;let o=this.cumulativeWeight;if(0===o){for(let e=0;e!==r;++e)n[i+e]=n[e];o=t}else{o+=t;const e=t/o;this._mixBufferRegion(n,i,0,e,r)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,r=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,r=e*t+t,i=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,i<1){const e=t*this._origIndex;this._mixBufferRegion(n,r,e,1-i,t)}o>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let e=t,i=t+t;e!==i;++e)if(n[e]!==n[e+t]){a.setValue(n,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let e=n,i=r;e!==i;++e)t[e]=t[r+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;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,r,i){if(r>=.5)for(let r=0;r!==i;++r)e[t+r]=e[n+r]}_slerp(e,t,n,r){u_.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,i){const o=this._workIndex*i;u_.multiplyQuaternionsFlat(e,o,e,t,e,n),u_.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,n,r,i){const o=1-r;for(let a=0;a!==i;++a){const i=t+a;e[i]=e[i]*o+e[n+a]*r}}_lerpAdditive(e,t,n,r,i){for(let o=0;o!==i;++o){const i=t+o;e[i]=e[i]+e[n+o]*r}}}const RP="\\[\\]\\.:\\/",PP=new RegExp("["+RP+"]","g"),NP="[^"+RP+"]",LP="[^"+RP.replace("\\.","")+"]",DP=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",NP)+/(WCOD+)?/.source.replace("WCOD",LP)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",NP)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",NP)+"$"),BP=["material","materials","bones","map"];class jP{constructor(e,t,n){this.path=t,this.parsedPath=n||jP.parseTrackName(t),this.node=jP.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new jP.Composite(e,t,n):new jP(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(PP,"")}static parseTrackName(e){const t=DP.exec(e);if(null===t)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]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){const e=n.nodeName.substring(r+1);-1!==BP.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let r=0;r<e.length;r++){const i=e[r];if(i.name===t||i.uuid===t)return i;const o=n(i.children);if(o)return o}return null},r=n(e.children);if(r)return r}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 r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_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 r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=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,r=t.propertyName;let i=t.propertyIndex;if(e||(e=jP.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(n){let r=t.objectIndex;switch(n){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===r){r=t;break}break;case"map":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;default:if(void 0===e[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[n]}if(void 0!==r){if(void 0===e[r])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[r]}}const o=e[r];if(void 0===o){const n=t.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+n+"."+r+" but it wasn't found.",e)}let a=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let s=this.BindingType.Direct;if(void 0!==i){if("morphTargetInfluences"===r){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[i]&&(i=e.morphTargetDictionary[i])}s=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=i}else void 0!==o.fromArray&&void 0!==o.toArray?(s=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(s=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[s],this.setValue=this.SetterByBindingTypeAndVersioning[s][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}jP.Composite=class{constructor(e,t,n){const r=n||jP.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];void 0!==r&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].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()}},jP.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},jP.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},jP.prototype.GetterByBindingType=[jP.prototype._getValue_direct,jP.prototype._getValue_array,jP.prototype._getValue_arrayElement,jP.prototype._getValue_toArray],jP.prototype.SetterByBindingTypeAndVersioning=[[jP.prototype._setValue_direct,jP.prototype._setValue_direct_setNeedsUpdate,jP.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[jP.prototype._setValue_array,jP.prototype._setValue_array_setNeedsUpdate,jP.prototype._setValue_array_setMatrixWorldNeedsUpdate],[jP.prototype._setValue_arrayElement,jP.prototype._setValue_arrayElement_setNeedsUpdate,jP.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[jP.prototype._setValue_fromArray,jP.prototype._setValue_fromArray_setNeedsUpdate,jP.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class FP{constructor(){this.isAnimationObjectGroup=!0,this.uuid=_M(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let t=0,n=arguments.length;t!==n;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,r=this._parsedPaths,i=this._bindings,o=i.length;let a,s=e.length,l=this.nCachedObjects_;for(let c=0,u=arguments.length;c!==u;++c){const u=arguments[c],d=u.uuid;let f=t[d];if(void 0===f){f=s++,t[d]=f,e.push(u);for(let e=0,t=o;e!==t;++e)i[e].push(new jP(u,n[e],r[e]))}else if(f<l){a=e[f];const s=--l,c=e[s];t[c.uuid]=f,e[f]=c,t[d]=s,e[s]=u;for(let e=0,t=o;e!==t;++e){const t=i[e],o=t[s];let a=t[f];t[f]=o,void 0===a&&(a=new jP(u,n[e],r[e])),t[s]=a}}else e[f]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let i=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const a=arguments[o],s=a.uuid,l=t[s];if(void 0!==l&&l>=i){const o=i++,c=e[o];t[c.uuid]=l,e[l]=c,t[s]=o,e[o]=a;for(let e=0,t=r;e!==t;++e){const t=n[e],r=t[o],i=t[l];t[l]=r,t[o]=i}}}this.nCachedObjects_=i}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let i=this.nCachedObjects_,o=e.length;for(let a=0,s=arguments.length;a!==s;++a){const s=arguments[a].uuid,l=t[s];if(void 0!==l)if(delete t[s],l<i){const a=--i,s=e[a],c=--o,u=e[c];t[s.uuid]=l,e[l]=s,t[u.uuid]=a,e[a]=u,e.pop();for(let e=0,t=r;e!==t;++e){const t=n[e],r=t[a],i=t[c];t[l]=r,t[a]=i,t.pop()}}else{const i=--o,a=e[i];i>0&&(t[a.uuid]=l),e[l]=a,e.pop();for(let e=0,t=r;e!==t;++e){const t=n[e];t[l]=t[i],t.pop()}}}this.nCachedObjects_=i}subscribe_(e,t){const n=this._bindingsIndicesByPath;let r=n[e];const i=this._bindings;if(void 0!==r)return i[r];const o=this._paths,a=this._parsedPaths,s=this._objects,l=s.length,c=this.nCachedObjects_,u=new Array(l);r=i.length,n[e]=r,o.push(e),a.push(t),i.push(u);for(let n=c,r=s.length;n!==r;++n){const r=s[n];u[n]=new jP(r,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const r=this._paths,i=this._parsedPaths,o=this._bindings,a=o.length-1,s=o[a];t[e[a]]=n,o[n]=s,o.pop(),i[n]=i[a],i.pop(),r[n]=r[a],r.pop()}}}class UP{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const i=t.tracks,o=i.length,a=new Array(o),s={endingStart:kS,endingEnd:kS};for(let e=0;e!==o;++e){const t=i[e].createInterpolant(null);a[e]=t,t.settings=s}this._interpolantSettings=s,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=MS,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&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const n=this._clip.duration,r=e._clip.duration,i=r/n,o=n/r;e.warp(1,i,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return null!==e&&(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 r=this._mixer,i=r.time,o=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const s=a.parameterPositions,l=a.sampleValues;return s[0]=i,s[1]=i+n,l[0]=e/o,l[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(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,r){if(!this.enabled)return void this._updateWeight(e);const i=this._startTime;if(null!==i){const r=(e-i)*n;r<0||0===n?t=0:(this._startTime=null,t=n*r)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===RS)for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(o),t[n].accumulateAdditive(a);else for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(o),t[n].accumulate(r,a)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let r=this.time+e,i=this._loopCount;const o=n===_S;if(0===e)return-1===i?r:o&&1==(1&i)?t-r:r;if(n===SS){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else{if(!(r<0)){this.time=r;break e}r=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===i&&(e>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),r>=t||r<0){const n=Math.floor(r/t);r-=t*n,i+=Math.abs(n);const a=this.repetitions-i;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===a){const t=e<0;this._setEndings(t,!t,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(o&&1==(1&i))return t-r}return r}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=TS,r.endingEnd=TS):(r.endingStart=e?this.zeroSlopeAtStart?TS:kS:IS,r.endingEnd=t?this.zeroSlopeAtEnd?TS:kS:IS)}_scheduleFading(e,t,n){const r=this._mixer,i=r.time;let o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=t,a[1]=i+e,s[1]=n,this}}const zP=new Float32Array(1);class HP extends bM{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,r=e._clip.tracks,i=r.length,o=e._propertyBindings,a=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName;let c=l[s];void 0===c&&(c={},l[s]=c);for(let e=0;e!==i;++e){const i=r[e],l=i.name;let u=c[l];if(void 0!==u)++u.referenceCount,o[e]=u;else{if(u=o[e],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,s,l));continue}const r=t&&t._propertyBindings[e].binding.parsedPath;u=new OP(jP.create(n,l,r),i.ValueTypeName,i.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,l),o[e]=u}a[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}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 null!==t&&t<this._nActiveActions}_addInactiveAction(e,t,n){const r=this._actions,i=this._actionsByClip;let o=i[t];if(void 0===o)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,i[t]=o;else{const t=o.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;const i=e._clip.uuid,o=this._actionsByClip,a=o[i],s=a.knownActions,l=s[s.length-1],c=e._byClipCacheIndex;l._byClipCacheIndex=c,s[c]=l,s.pop(),e._byClipCacheIndex=null;delete a.actionByRoot[(e._localRoot||this._root).uuid],0===s.length&&delete o[i],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.referenceCount&&this._removeInactiveBinding(n)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_addInactiveBinding(e,t,n){const r=this._bindingsByRootAndName,i=this._bindings;let o=r[t];void 0===o&&(o={},r[t]=o),o[n]=e,e._cacheIndex=i.length,i.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,r=n.rootNode.uuid,i=n.path,o=this._bindingsByRootAndName,a=o[r],s=t[t.length-1],l=e._cacheIndex;s._cacheIndex=l,t[l]=s,t.pop(),delete a[i],0===Object.keys(a).length&&delete o[r]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return void 0===n&&(n=new cR(new Float32Array(2),new Float32Array(2),1,zP),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,i=t[r];e.__cacheIndex=r,t[r]=e,i.__cacheIndex=n,t[n]=i}clipAction(e,t,n){const r=t||this._root,i=r.uuid;let o="string"==typeof e?bR.findByName(r,e):e;const a=null!==o?o.uuid:e,s=this._actionsByClip[a];let l=null;if(void 0===n&&(n=null!==o?o.blendMode:OS),void 0!==s){const e=s.actionByRoot[i];if(void 0!==e&&e.blendMode===n)return e;l=s.knownActions[0],null===o&&(o=l._clip)}if(null===o)return null;const c=new UP(this,o,t,n);return this._bindAction(c,l),this._addInactiveAction(c,a,i),c}existingAction(e,t){const n=t||this._root,r=n.uuid,i="string"==typeof e?bR.findByName(n,e):e,o=i?i.uuid:e,a=this._actionsByClip[o];return void 0!==a&&a.actionByRoot[r]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,r=this.time+=e,i=Math.sign(e),o=this._accuIndex^=1;for(let a=0;a!==n;++a){t[a]._update(r,e,i,o)}const a=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)a[e].apply(o);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,r=this._actionsByClip,i=r[n];if(void 0!==i){const e=i.knownActions;for(let n=0,r=e.length;n!==r;++n){const r=e[n];this._deactivateAction(r);const i=r._cacheIndex,o=t[t.length-1];r._cacheIndex=null,r._byClipCacheIndex=null,o._cacheIndex=i,t[i]=o,t.pop(),this._removeInactiveBindingsForAction(r)}delete r[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const e in n){const r=n[e].actionByRoot[t];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}const r=this._bindingsByRootAndName[t];if(void 0!==r)for(const e in r){const t=r[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){const n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class VP{constructor(e){this.value=e}clone(){return new VP(void 0===this.value.clone?this.value:this.value.clone())}}let WP=0;class GP extends bM{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:WP++}),this.name="",this.usage=sM,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let e=0,n=t.length;e<n;e++)this.uniforms.push(t[e].clone());return this}clone(){return(new this.constructor).copy(this)}}class qP extends pT{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class KP{constructor(e,t,n,r,i){this.isGLBufferAttribute=!0,this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=i,this.version=0}set needsUpdate(e){!0===e&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}class YP{constructor(e,t,n=0,r=1/0){this.ray=new z_(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new $_,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return QP(e,this,n,t),n.sort(JP),n}intersectObjects(e,t=!0,n=[]){for(let r=0,i=e.length;r<i;r++)QP(e[r],this,n,t);return n.sort(JP),n}}function JP(e,t){return e.distance-t.distance}function QP(e,t,n,r){if(e.layers.test(t.layers)&&e.raycast(t,n),!0===r){const r=e.children;for(let e=0,i=r.length;e<i;e++)QP(r[e],t,n,!0)}}class XP{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(AM(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class ZP{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return(new this.constructor).copy(this)}}const $P=new NM;class eN{constructor(e=new NM(1/0,1/0),t=new NM(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=$P.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return $P.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const tN=new d_,nN=new d_;class rN{constructor(e=new d_,t=new d_){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){tN.subVectors(e,this.start),nN.subVectors(this.end,this.start);const n=nN.dot(nN);let r=nN.dot(tN)/n;return t&&(r=AM(r,0,1)),r}closestPointToPoint(e,t,n){const r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const iN=new d_;class oN extends hA{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;const n=new YA,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1,n=32;e<n;e++,t++){const i=e/n*Math.PI*2,o=t/n*Math.PI*2;r.push(Math.cos(i),Math.sin(i),1,Math.cos(o),Math.sin(o),1)}n.setAttribute("position",new FA(r,3));const i=new $T({fog:!1,toneMapped:!1});this.cone=new lI(n,i),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),iN.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(iN),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const aN=new d_,sN=new H_,lN=new H_;class cN extends lI{constructor(e){const t=uN(e),n=new YA,r=[],i=[],o=new QM(0,0,1),a=new QM(0,1,0);for(let e=0;e<t.length;e++){const n=t[e];n.parent&&n.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),i.push(o.r,o.g,o.b),i.push(a.r,a.g,a.b))}n.setAttribute("position",new FA(r,3)),n.setAttribute("color",new FA(i,3));super(n,new $T({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),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,r=n.getAttribute("position");lN.copy(this.root.matrixWorld).invert();for(let e=0,n=0;e<t.length;e++){const i=t[e];i.parent&&i.parent.isBone&&(sN.multiplyMatrices(lN,i.matrixWorld),aN.setFromMatrixPosition(sN),r.setXYZ(n,aN.x,aN.y,aN.z),sN.multiplyMatrices(lN,i.parent.matrixWorld),aN.setFromMatrixPosition(sN),r.setXYZ(n+1,aN.x,aN.y,aN.z),n+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}function uN(e){const t=[];!0===e.isBone&&t.push(e);for(let n=0;n<e.children.length;n++)t.push.apply(t,uN(e.children[n]));return t}class dN extends fE{constructor(e,t,n){super(new DO(t,4,2),new CA({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.light.updateMatrixWorld(),this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const fN=new d_,hN=new QM,pN=new QM;class mN extends hA{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;const r=new PO(t);r.rotateY(.5*Math.PI),this.material=new CA({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const i=r.getAttribute("position"),o=new Float32Array(3*i.count);r.setAttribute("color",new IA(o,3)),this.add(new fE(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");hN.copy(this.light.color),pN.copy(this.light.groundColor);for(let e=0,n=t.count;e<n;e++){const r=e<n/2?hN:pN;t.setXYZ(e,r.r,r.g,r.b)}t.needsUpdate=!0}e.lookAt(fN.setFromMatrixPosition(this.light.matrixWorld).negate())}}class gN extends lI{constructor(e=10,t=10,n=4473924,r=8947848){n=new QM(n),r=new QM(r);const i=t/2,o=e/t,a=e/2,s=[],l=[];for(let e=0,c=0,u=-a;e<=t;e++,u+=o){s.push(-a,0,u,a,0,u),s.push(u,0,-a,u,0,a);const t=e===i?n:r;t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3}const c=new YA;c.setAttribute("position",new FA(s,3)),c.setAttribute("color",new FA(l,3));super(c,new $T({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}class vN extends lI{constructor(e=10,t=16,n=8,r=64,i=4473924,o=8947848){i=new QM(i),o=new QM(o);const a=[],s=[];if(t>1)for(let n=0;n<t;n++){const r=n/t*(2*Math.PI),l=Math.sin(r)*e,c=Math.cos(r)*e;a.push(0,0,0),a.push(l,0,c);const u=1&n?i:o;s.push(u.r,u.g,u.b),s.push(u.r,u.g,u.b)}for(let t=0;t<n;t++){const l=1&t?i:o,c=e-e/n*t;for(let e=0;e<r;e++){let t=e/r*(2*Math.PI),n=Math.sin(t)*c,i=Math.cos(t)*c;a.push(n,0,i),s.push(l.r,l.g,l.b),t=(e+1)/r*(2*Math.PI),n=Math.sin(t)*c,i=Math.cos(t)*c,a.push(n,0,i),s.push(l.r,l.g,l.b)}}const l=new YA;l.setAttribute("position",new FA(a,3)),l.setAttribute("color",new FA(s,3));super(l,new $T({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}}const yN=new d_,bN=new d_,wN=new d_;class xN extends hA{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,void 0===t&&(t=1);let r=new YA;r.setAttribute("position",new FA([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const i=new $T({fog:!1,toneMapped:!1});this.lightPlane=new oI(r,i),this.add(this.lightPlane),r=new YA,r.setAttribute("position",new FA([0,0,0,0,0,1],3)),this.targetLine=new oI(r,i),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){yN.setFromMatrixPosition(this.light.matrixWorld),bN.setFromMatrixPosition(this.light.target.matrixWorld),wN.subVectors(bN,yN),this.lightPlane.lookAt(bN),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(bN),this.targetLine.scale.z=wN.length()}}const SN=new d_,MN=new bE;class _N extends lI{constructor(e){const t=new YA,n=new $T({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],i=[],o={};function a(e,t){s(e),s(t)}function s(e){r.push(0,0,0),i.push(0,0,0),void 0===o[e]&&(o[e]=[]),o[e].push(r.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),t.setAttribute("position",new FA(r,3)),t.setAttribute("color",new FA(i,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const l=new QM(16755200),c=new QM(16711680),u=new QM(43775),d=new QM(16777215),f=new QM(3355443);this.setColors(l,c,u,d,f)}setColors(e,t,n,r,i){const o=this.geometry.getAttribute("color");o.setXYZ(0,e.r,e.g,e.b),o.setXYZ(1,e.r,e.g,e.b),o.setXYZ(2,e.r,e.g,e.b),o.setXYZ(3,e.r,e.g,e.b),o.setXYZ(4,e.r,e.g,e.b),o.setXYZ(5,e.r,e.g,e.b),o.setXYZ(6,e.r,e.g,e.b),o.setXYZ(7,e.r,e.g,e.b),o.setXYZ(8,e.r,e.g,e.b),o.setXYZ(9,e.r,e.g,e.b),o.setXYZ(10,e.r,e.g,e.b),o.setXYZ(11,e.r,e.g,e.b),o.setXYZ(12,e.r,e.g,e.b),o.setXYZ(13,e.r,e.g,e.b),o.setXYZ(14,e.r,e.g,e.b),o.setXYZ(15,e.r,e.g,e.b),o.setXYZ(16,e.r,e.g,e.b),o.setXYZ(17,e.r,e.g,e.b),o.setXYZ(18,e.r,e.g,e.b),o.setXYZ(19,e.r,e.g,e.b),o.setXYZ(20,e.r,e.g,e.b),o.setXYZ(21,e.r,e.g,e.b),o.setXYZ(22,e.r,e.g,e.b),o.setXYZ(23,e.r,e.g,e.b),o.setXYZ(24,t.r,t.g,t.b),o.setXYZ(25,t.r,t.g,t.b),o.setXYZ(26,t.r,t.g,t.b),o.setXYZ(27,t.r,t.g,t.b),o.setXYZ(28,t.r,t.g,t.b),o.setXYZ(29,t.r,t.g,t.b),o.setXYZ(30,t.r,t.g,t.b),o.setXYZ(31,t.r,t.g,t.b),o.setXYZ(32,n.r,n.g,n.b),o.setXYZ(33,n.r,n.g,n.b),o.setXYZ(34,n.r,n.g,n.b),o.setXYZ(35,n.r,n.g,n.b),o.setXYZ(36,n.r,n.g,n.b),o.setXYZ(37,n.r,n.g,n.b),o.setXYZ(38,r.r,r.g,r.b),o.setXYZ(39,r.r,r.g,r.b),o.setXYZ(40,i.r,i.g,i.b),o.setXYZ(41,i.r,i.g,i.b),o.setXYZ(42,i.r,i.g,i.b),o.setXYZ(43,i.r,i.g,i.b),o.setXYZ(44,i.r,i.g,i.b),o.setXYZ(45,i.r,i.g,i.b),o.setXYZ(46,i.r,i.g,i.b),o.setXYZ(47,i.r,i.g,i.b),o.setXYZ(48,i.r,i.g,i.b),o.setXYZ(49,i.r,i.g,i.b),o.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap;MN.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),AN("c",t,e,MN,0,0,-1),AN("t",t,e,MN,0,0,1),AN("n1",t,e,MN,-1,-1,-1),AN("n2",t,e,MN,1,-1,-1),AN("n3",t,e,MN,-1,1,-1),AN("n4",t,e,MN,1,1,-1),AN("f1",t,e,MN,-1,-1,1),AN("f2",t,e,MN,1,-1,1),AN("f3",t,e,MN,-1,1,1),AN("f4",t,e,MN,1,1,1),AN("u1",t,e,MN,.7,1.1,-1),AN("u2",t,e,MN,-.7,1.1,-1),AN("u3",t,e,MN,0,2,-1),AN("cf1",t,e,MN,-1,0,1),AN("cf2",t,e,MN,1,0,1),AN("cf3",t,e,MN,0,-1,1),AN("cf4",t,e,MN,0,1,1),AN("cn1",t,e,MN,-1,0,-1),AN("cn2",t,e,MN,1,0,-1),AN("cn3",t,e,MN,0,-1,-1),AN("cn4",t,e,MN,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function AN(e,t,n,r,i,o,a){SN.set(i,o,a).unproject(r);const s=t[e];if(void 0!==s){const e=n.getAttribute("position");for(let t=0,n=s.length;t<n;t++)e.setXYZ(s[t],SN.x,SN.y,SN.z)}}const EN=new p_;class CN extends lI{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),i=new YA;i.setIndex(new IA(n,1)),i.setAttribute("position",new IA(r,3)),super(i,new $T({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&EN.setFromObject(this.object),EN.isEmpty())return;const t=EN.min,n=EN.max,r=this.geometry.attributes.position,i=r.array;i[0]=n.x,i[1]=n.y,i[2]=n.z,i[3]=t.x,i[4]=n.y,i[5]=n.z,i[6]=t.x,i[7]=t.y,i[8]=n.z,i[9]=n.x,i[10]=t.y,i[11]=n.z,i[12]=n.x,i[13]=n.y,i[14]=t.z,i[15]=t.x,i[16]=n.y,i[17]=t.z,i[18]=t.x,i[19]=t.y,i[20]=t.z,i[21]=n.x,i[22]=t.y,i[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}}class kN extends lI{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new YA;r.setIndex(new IA(n,1)),r.setAttribute("position",new FA([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(r,new $T({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}}class TN extends oI{constructor(e,t=1,n=16776960){const r=n,i=new YA;i.setAttribute("position",new FA([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),i.computeBoundingSphere(),super(i,new $T({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=new YA;o.setAttribute("position",new FA([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),o.computeBoundingSphere(),this.add(new fE(o,new CA({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}}const IN=new d_;let ON,RN;class PN extends hA{constructor(e=new d_(0,0,1),t=new d_(0,0,0),n=1,r=16776960,i=.2*n,o=.2*i){super(),this.type="ArrowHelper",void 0===ON&&(ON=new YA,ON.setAttribute("position",new FA([0,0,0,0,1,0],3)),RN=new qI(0,.5,1,5,1),RN.translate(0,-.5,0)),this.position.copy(t),this.line=new oI(ON,new $T({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new fE(RN,new CA({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,i,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{IN.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(IN,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}}class NN extends lI{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new YA;n.setAttribute("position",new FA(t,3)),n.setAttribute("color",new FA([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(n,new $T({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){const r=new QM,i=this.geometry.attributes.color.array;return r.set(e),r.toArray(i,0),r.toArray(i,3),r.set(t),r.toArray(i,6),r.toArray(i,9),r.set(n),r.toArray(i,12),r.toArray(i,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class LN{constructor(){this.type="ShapePath",this.color=new QM,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new HI,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,i,o){return this.currentPath.bezierCurveTo(e,t,n,r,i,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const n=t.length;let r=!1;for(let i=n-1,o=0;o<n;i=o++){let n=t[i],a=t[o],s=a.x-n.x,l=a.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=t[o],s=-s,a=t[i],l=-l),e.y<n.y||e.y>a.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-s*(e.y-n.y);if(0===t)return!0;if(t<0)continue;r=!r}}else{if(e.y!==n.y)continue;if(a.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=a.x)return!0}}return r}const n=CO.isClockWise,r=this.subPaths;if(0===r.length)return[];let i,o,a;const s=[];if(1===r.length)return o=r[0],a=new tO,a.curves=o.curves,s.push(a),s;let l=!n(r[0].getPoints());l=e?!l:l;const c=[],u=[];let d,f,h=[],p=0;u[p]=void 0,h[p]=[];for(let t=0,a=r.length;t<a;t++)o=r[t],d=o.getPoints(),i=n(d),i=e?!i:i,i?(!l&&u[p]&&p++,u[p]={s:new tO,p:d},u[p].s.curves=o.curves,l&&p++,h[p]=[]):h[p].push({h:o,p:d[0]});if(!u[0])return function(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n],i=new tO;i.curves=r.curves,t.push(i)}return t}(r);if(u.length>1){let e=!1,n=0;for(let e=0,t=u.length;e<t;e++)c[e]=[];for(let r=0,i=u.length;r<i;r++){const i=h[r];for(let o=0;o<i.length;o++){const a=i[o];let s=!0;for(let i=0;i<u.length;i++)t(a.p,u[i].p)&&(r!==i&&n++,s?(s=!1,c[i].push(a)):e=!0);s&&c[r].push(a)}}n>0&&!1===e&&(h=c)}for(let e=0,t=u.length;e<t;e++){a=u[e].s,s.push(a),f=h[e];for(let e=0,t=f.length;e<t;e++)a.holes.push(f[e].h)}return s}}const DN=BN();function BN(){const e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(r[e]=0,r[256|e]=32768,i[e]=24,i[256|e]=24):t<-14?(r[e]=1024>>-t-14,r[256|e]=1024>>-t-14|32768,i[e]=-t-1,i[256|e]=-t-1):t<=15?(r[e]=t+15<<10,r[256|e]=t+15<<10|32768,i[e]=13,i[256|e]=13):t<128?(r[e]=31744,r[256|e]=64512,i[e]=24,i[256|e]=24):(r[e]=31744,r[256|e]=64512,i[e]=13,i[256|e]=13)}const o=new Uint32Array(2048),a=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;0==(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,o[e]=t|n}for(let e=1024;e<2048;++e)o[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)a[e]=e<<23;a[31]=1199570944,a[32]=2147483648;for(let e=33;e<63;++e)a[e]=2147483648+(e-32<<23);a[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:o,exponentTable:a,offsetTable:s}}var jN=Object.freeze({__proto__:null,toHalfFloat:function(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=AM(e,-65504,65504),DN.floatView[0]=e;const t=DN.uint32View[0],n=t>>23&511;return DN.baseTable[n]+((8388607&t)>>DN.shiftTable[n])},fromHalfFloat:function(e){const t=e>>10;return DN.uint32View[0]=DN.mantissaTable[DN.offsetTable[t]+(1023&e)]+DN.exponentTable[t],DN.floatView[0]}});function FN(){console.error("THREE.ImmediateRenderObject has been removed.")}class UN extends i_{constructor(e,t,n){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,n),this.samples=4}}class zN extends o_{constructor(e,t,n,r){console.warn("THREE.DataTexture2DArray has been renamed to DataArrayTexture."),super(e,t,n,r)}}class HN extends s_{constructor(e,t,n,r){console.warn("THREE.DataTexture3D has been renamed to Data3DTexture."),super(e,t,n,r)}}class VN extends pE{constructor(e,t,n,r,i,o){console.warn("THREE.BoxBufferGeometry has been renamed to THREE.BoxGeometry."),super(e,t,n,r,i,o)}}class WN extends WI{constructor(e,t,n,r){console.warn("THREE.CapsuleBufferGeometry has been renamed to THREE.CapsuleGeometry."),super(e,t,n,r)}}class GN extends GI{constructor(e,t,n,r){console.warn("THREE.CircleBufferGeometry has been renamed to THREE.CircleGeometry."),super(e,t,n,r)}}class qN extends KI{constructor(e,t,n,r,i,o,a){console.warn("THREE.ConeBufferGeometry has been renamed to THREE.ConeGeometry."),super(e,t,n,r,i,o,a)}}class KN extends qI{constructor(e,t,n,r,i,o,a,s){console.warn("THREE.CylinderBufferGeometry has been renamed to THREE.CylinderGeometry."),super(e,t,n,r,i,o,a,s)}}class YN extends JI{constructor(e,t){console.warn("THREE.DodecahedronBufferGeometry has been renamed to THREE.DodecahedronGeometry."),super(e,t)}}class JN extends IO{constructor(e,t){console.warn("THREE.ExtrudeBufferGeometry has been renamed to THREE.ExtrudeGeometry."),super(e,t)}}class QN extends RO{constructor(e,t){console.warn("THREE.IcosahedronBufferGeometry has been renamed to THREE.IcosahedronGeometry."),super(e,t)}}class XN extends VI{constructor(e,t,n,r){console.warn("THREE.LatheBufferGeometry has been renamed to THREE.LatheGeometry."),super(e,t,n,r)}}class ZN extends PO{constructor(e,t){console.warn("THREE.OctahedronBufferGeometry has been renamed to THREE.OctahedronGeometry."),super(e,t)}}class $N extends NE{constructor(e,t,n,r){console.warn("THREE.PlaneBufferGeometry has been renamed to THREE.PlaneGeometry."),super(e,t,n,r)}}class eL extends YI{constructor(e,t,n,r){console.warn("THREE.PolyhedronBufferGeometry has been renamed to THREE.PolyhedronGeometry."),super(e,t,n,r)}}class tL extends NO{constructor(e,t,n,r,i,o){console.warn("THREE.RingBufferGeometry has been renamed to THREE.RingGeometry."),super(e,t,n,r,i,o)}}class nL extends LO{constructor(e,t){console.warn("THREE.ShapeBufferGeometry has been renamed to THREE.ShapeGeometry."),super(e,t)}}class rL extends DO{constructor(e,t,n,r,i,o,a){console.warn("THREE.SphereBufferGeometry has been renamed to THREE.SphereGeometry."),super(e,t,n,r,i,o,a)}}class iL extends BO{constructor(e,t){console.warn("THREE.TetrahedronBufferGeometry has been renamed to THREE.TetrahedronGeometry."),super(e,t)}}class oL extends jO{constructor(e,t,n,r,i){console.warn("THREE.TorusBufferGeometry has been renamed to THREE.TorusGeometry."),super(e,t,n,r,i)}}class aL extends FO{constructor(e,t,n,r,i,o){console.warn("THREE.TorusKnotBufferGeometry has been renamed to THREE.TorusKnotGeometry."),super(e,t,n,r,i,o)}}class sL extends UO{constructor(e,t,n,r,i){console.warn("THREE.TubeBufferGeometry has been renamed to THREE.TubeGeometry."),super(e,t,n,r,i)}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:cw}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=cw);const lL=new WeakMap;class cL extends _R{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,r){const i=new CR(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(e=>{const n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,n).then(t).catch(r)}),n,r)}decodeDracoFile(e,t,n,r){const i={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,i).then(t)}decodeGeometry(e,t){for(const e in t.attributeTypes){const n=t.attributeTypes[e];void 0!==n.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=n.name)}const n=JSON.stringify(t);if(lL.has(e)){const t=lL.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const i=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(i,o).then((n=>(r=n,new Promise(((n,o)=>{r._callbacks[i]={resolve:n,reject:o},r.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return a.catch((()=>!0)).then((()=>{r&&i&&this._releaseTask(r,i)})),lL.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new YA;e.index&&t.setIndex(new IA(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n],i=r.name,o=r.array,a=r.itemSize;t.setAttribute(i,new IA(o,a))}return t}_loadLibrary(e,t){const n=new CR(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,r)=>{n.load(e,t,void 0,r)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,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((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const r=uL.toString(),i=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._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}}function uL(){let e,t;function n(e,t,n,r,i,o){const a=o.num_components(),s=n.num_points()*a,l=s*i.BYTES_PER_ELEMENT,c=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,i),u=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,o,c,l,u);const d=new i(e.HEAPF32.buffer,u,s).slice();return e._free(u),{name:r,array:d,itemSize:a}}onmessage=function(r){const i=r.data;switch(i.type){case"init":e=i.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=i.buffer,o=i.taskConfig;t.then((e=>{const t=e.draco,a=new t.Decoder,s=new t.DecoderBuffer;s.Init(new Int8Array(r),r.byteLength);try{const e=function(e,t,r,i){const o=i.attributeIDs,a=i.attributeTypes;let s,l;const c=t.GetEncodedGeometryType(r);if(c===e.TRIANGULAR_MESH)s=new e.Mesh,l=t.DecodeBufferToMesh(r,s);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");s=new e.PointCloud,l=t.DecodeBufferToPointCloud(r,s)}if(!l.ok()||0===s.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const u={index:null,attributes:[]};for(const r in o){const l=self[a[r]];let c,d;if(i.useUniqueIDs)d=o[r],c=t.GetAttributeByUniqueId(s,d);else{if(d=t.GetAttributeId(s,e[o[r]]),-1===d)continue;c=t.GetAttribute(s,d)}u.attributes.push(n(e,t,s,r,l,c))}c===e.TRIANGULAR_MESH&&(u.index=function(e,t,n){const r=n.num_faces(),i=3*r,o=4*i,a=e._malloc(o);t.GetTrianglesUInt32Array(n,o,a);const s=new Uint32Array(e.HEAPF32.buffer,a,i).slice();return e._free(a),{array:s,itemSize:1}}(e,t,s));return e.destroy(s),u}(t,a,s,o),r=e.attributes.map((e=>e.array.buffer));e.index&&r.push(e.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:e},r)}catch(e){console.error(e),self.postMessage({type:"error",id:i.id,error:e.message})}finally{t.destroy(s),t.destroy(a)}}))}}}class dL extends _R{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new vL(e)})),this.register((function(e){return new _L(e)})),this.register((function(e){return new AL(e)})),this.register((function(e){return new bL(e)})),this.register((function(e){return new wL(e)})),this.register((function(e){return new xL(e)})),this.register((function(e){return new SL(e)})),this.register((function(e){return new gL(e)})),this.register((function(e){return new ML(e)})),this.register((function(e){return new yL(e)})),this.register((function(e){return new pL(e)})),this.register((function(e){return new EL(e)}))}load(e,t,n,r){const i=this;let o;o=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:eP.extractUrlBase(e),this.manager.itemStart(e);const a=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new CR(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(n){try{i.parse(n,o,(function(n){t(n),i.manager.itemEnd(e)}),a)}catch(e){a(e)}}),n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i;const o={},a={};if("string"==typeof e)i=e;else{if(eP.decodeText(new Uint8Array(e,0,4))===CL){try{o[hL.KHR_BINARY_GLTF]=new IL(e)}catch(e){return void(r&&r(e))}i=o[hL.KHR_BINARY_GLTF].content}else i=eP.decodeText(new Uint8Array(e))}const s=JSON.parse(i);if(void 0===s.asset||s.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new lD(s,{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 e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);a[t.name]=t,o[t.name]=!0}if(s.extensionsUsed)for(let e=0;e<s.extensionsUsed.length;++e){const t=s.extensionsUsed[e],n=s.extensionsRequired||[];switch(t){case hL.KHR_MATERIALS_UNLIT:o[t]=new mL;break;case hL.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:o[t]=new NL;break;case hL.KHR_DRACO_MESH_COMPRESSION:o[t]=new OL(s,this.dracoLoader);break;case hL.KHR_TEXTURE_TRANSFORM:o[t]=new RL;break;case hL.KHR_MESH_QUANTIZATION:o[t]=new LL;break;default:n.indexOf(t)>=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,r)}parseAsync(e,t){const n=this;return new Promise((function(r,i){n.parse(e,t,r,i)}))}}function fL(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const hL={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_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",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_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_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class pL{constructor(e){this.parser=e,this.name=hL.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const i=t.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let a;const s=new QM(16777215);void 0!==o.color&&s.fromArray(o.color);const l=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new YR(s),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new qR(s),a.distance=l;break;case"spot":a=new zR(s),a.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),a.decay=2,void 0!==o.intensity&&(a.intensity=o.intensity),a.name=t.createUniqueName(o.name||"light_"+e),r=Promise.resolve(a),t.cache.add(n,r),r}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(e){return n._getNodeRef(t.cache,i,e)}))}}class mL{constructor(){this.name=hL.KHR_MATERIALS_UNLIT}getMaterialType(){return CA}extendParams(e,t,n){const r=[];e.color=new QM(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(e,"map",i.baseColorTexture,BS))}return Promise.all(r)}}class gL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name].emissiveStrength;return void 0!==r&&(t.emissiveIntensity=r),Promise.resolve()}}class vL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];if(void 0!==o.clearcoatFactor&&(t.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&i.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(i.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const e=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new NM(e,e)}return Promise.all(i)}}class yL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];return void 0!==o.iridescenceFactor&&(t.iridescence=o.iridescenceFactor),void 0!==o.iridescenceTexture&&i.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),void 0!==o.iridescenceIor&&(t.iridescenceIOR=o.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==o.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),void 0!==o.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),void 0!==o.iridescenceThicknessTexture&&i.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class bL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new QM(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=r.extensions[this.name];return void 0!==o.sheenColorFactor&&t.sheenColor.fromArray(o.sheenColorFactor),void 0!==o.sheenRoughnessFactor&&(t.sheenRoughness=o.sheenRoughnessFactor),void 0!==o.sheenColorTexture&&i.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,BS)),void 0!==o.sheenRoughnessTexture&&i.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class wL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];return void 0!==o.transmissionFactor&&(t.transmission=o.transmissionFactor),void 0!==o.transmissionTexture&&i.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class xL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];t.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&i.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new QM(a[0],a[1],a[2]),Promise.all(i)}}class SL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class ML{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];t.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&i.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new QM(a[0],a[1],a[2]),void 0!==o.specularColorTexture&&i.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,BS)),Promise.all(i)}}class _L{constructor(e){this.parser=e,this.name=hL.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const i=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){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,i.source,o)}}class AL{constructor(e){this.parser=e,this.name=hL.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],a=r.images[o.source];let s=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(s=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,o.source,s);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class EL{constructor(e){this.name=hL.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 e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.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(t){const n=e.byteOffset||0,r=e.byteLength||0,o=e.count,a=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(o,a,s,e.mode,e.filter).then((function(e){return e.buffer})):i.ready.then((function(){const t=new ArrayBuffer(o*a);return i.decodeGltfBuffer(new Uint8Array(t),o,a,s,e.mode,e.filter),t}))}))}return null}}const CL="glTF",kL=1313821514,TL=5130562;class IL{constructor(e){this.name=hL.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:eP.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==CL)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(e,12);let i=0;for(;i<n;){const t=r.getUint32(i,!0);i+=4;const n=r.getUint32(i,!0);if(i+=4,n===kL){const n=new Uint8Array(e,12+i,t);this.content=eP.decodeText(n)}else if(n===TL){const n=12+i;this.body=e.slice(n,n+t)}i+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class OL{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=hL.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},s={},l={};for(const e in o){const t=QL[e]||e.toLowerCase();a[t]=o[e]}for(const t in e.attributes){const r=QL[t]||t.toLowerCase();if(void 0!==o[t]){const i=n.accessors[e.attributes[t]],o=qL[i.componentType];l[r]=o.name,s[r]=!0===i.normalized}}return t.getDependency("bufferView",i).then((function(e){return new Promise((function(t){r.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],r=s[t];void 0!==r&&(n.normalized=r)}t(e)}),a,l)}))}))}}class RL{constructor(){this.name=hL.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class PL extends qO{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const t=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),n=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),r=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),i=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),o=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),a={specular:{value:(new QM).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(e){for(const t in a)e.uniforms[t]=a[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",r).replace("#include <metalnessmap_fragment>",i).replace("#include <lights_physical_fragment>",o)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(e){a.specular.value=e}},specularMap:{get:function(){return a.specularMap.value},set:function(e){a.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(e){a.glossiness.value=e}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(e){a.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class NL{constructor(){this.name=hL.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return PL}extendParams(e,t,n){const r=t.extensions[this.name];e.color=new QM(1,1,1),e.opacity=1;const i=[];if(Array.isArray(r.diffuseFactor)){const t=r.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==r.diffuseTexture&&i.push(n.assignTexture(e,"map",r.diffuseTexture,BS)),e.emissive=new QM(0,0,0),e.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,e.specular=new QM(1,1,1),Array.isArray(r.specularFactor)&&e.specular.fromArray(r.specularFactor),void 0!==r.specularGlossinessTexture){const t=r.specularGlossinessTexture;i.push(n.assignTexture(e,"glossinessMap",t)),i.push(n.assignTexture(e,"specularMap",t,BS))}return Promise.all(i)}createMaterial(e){const t=new PL(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=void 0===e.emissiveIntensity?1:e.emissiveIntensity,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=US,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}}class LL{constructor(){this.name=hL.KHR_MESH_QUANTIZATION}}class DL extends sR{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=2*a,l=3*a,c=r-t,u=(n-t)/c,d=u*u,f=d*u,h=e*l,p=h-l,m=-2*f+3*d,g=f-d,v=1-m,y=g-d+u;for(let e=0;e!==a;e++){const t=o[p+e+a],n=o[p+e+s]*c,r=o[h+e+a],l=o[h+e]*c;i[e]=v*t+y*n+m*r+g*l}return i}}const BL=new u_;class jL extends DL{interpolate_(e,t,n,r){const i=super.interpolate_(e,t,n,r);return BL.fromArray(i).normalize().toArray(i),i}}const FL=0,UL=1,zL=2,HL=3,VL=4,WL=5,GL=6,qL={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},KL={9728:vx,9729:Sx,9984:yx,9985:Mx,9986:wx,9987:Ax},YL={33071:mx,33648:gx,10497:px},JL={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},QL={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},XL={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ZL={CUBICSPLINE:void 0,LINEAR:ES,STEP:AS},$L="OPAQUE",eD="MASK",tD="BLEND";function nD(e,t,n){for(const r in n.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function rD(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function iD(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function oD(e){const t=e.extensions&&e.extensions[hL.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+aD(t.attributes):e.indices+":"+aD(e.attributes)+":"+e.mode,n}function aD(e){let t="";const n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+":"+e[n[r]]+";";return t}function sD(e){switch(e){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.")}}class lD{constructor(e={},t={}){var n,r;this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new fL,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};const i="undefined"!=typeof navigator&&!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),o="undefined"!=typeof navigator&&(null===(n=navigator.userAgent)||void 0===n?void 0:n.indexOf("Firefox"))>-1,a="undefined"!=typeof navigator&&o?null===(r=navigator.userAgent)||void 0===r?void 0:r.match(/Firefox\/([0-9]+)\./)[1]:-1;"undefined"==typeof createImageBitmap||i||o&&a<98?this.textureLoader=new PR(this.options.manager):this.textureLoader=new sP(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new CR(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const o={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};nD(i,o,r),rD(o,r),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(o)}))).then((function(){e(o)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){const r=e[t];void 0!==r.mesh&&(this._addNodeRef(this.meshCache,r.mesh),void 0!==r.skin&&(n[r.mesh].isSkinnedMesh=!0)),void 0!==r.camera&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),i=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this.loadNode(t);break;case"mesh":r=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":r=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":r=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map((function(t,r){return n.getDependency(e,r)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[hL.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(e,i){n.load(eP.resolveURL(t.uri,r.path),e,void 0,(function(){i(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(e){const n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)}))}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse)return Promise.resolve(null);const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then((function(e){const i=e[0],o=JL[r.type],a=qL[r.componentType],s=a.BYTES_PER_ELEMENT,l=s*o,c=r.byteOffset||0,u=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,d=!0===r.normalized;let f,h;if(u&&u!==l){const e=Math.floor(c/u),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let l=t.cache.get(n);l||(f=new a(i,e*u,r.count*u/s),l=new pT(f,u/s),t.cache.add(n,l)),h=new gT(l,o,c%u/s,d)}else f=null===i?new a(r.count*o):new a(i,c,r.count*o),h=new IA(f,o,d);if(void 0!==r.sparse){const t=JL.SCALAR,n=qL[r.sparse.indices.componentType],s=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,c=new n(e[1],s,r.sparse.count*t),u=new a(e[2],l,r.sparse.count*o);null!==i&&(h=new IA(h.array.slice(),h.itemSize,h.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(h.setX(t,u[e*o]),o>=2&&h.setY(t,u[e*o+1]),o>=3&&h.setZ(t,u[e*o+2]),o>=4&&h.setW(t,u[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return h}))}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r];let o=this.textureLoader;if(i.uri){const e=n.manager.getHandler(i.uri);null!==e&&(o=e)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){const r=this,i=this.json,o=i.textures[e],a=i.images[t],s=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[s])return this.textureCache[s];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,o.name&&(t.name=o.name);const n=(i.samplers||{})[o.sampler]||{};return t.magFilter=KL[n.magFilter]||Sx,t.minFilter=KL[n.minFilter]||Ax,t.wrapS=YL[n.wrapS]||px,t.wrapT=YL[n.wrapT]||px,r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[s]=l,l}loadImageSource(e,t){const n=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const i=n.images[e],o=self.URL||self.webkitURL;let a=i.uri||"",s=!1;if(void 0!==i.bufferView)a=this.getDependency("bufferView",i.bufferView).then((function(e){s=!0;const t=new Blob([e],{type:i.mimeType});return a=o.createObjectURL(t),a}));else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(a).then((function(e){return new Promise((function(n,i){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){const t=new n_(e);t.needsUpdate=!0,n(t)}),t.load(eP.resolveURL(e,r.path),o,void 0,i)}))})).then((function(e){var t;return!0===s&&o.revokeObjectURL(a),e.userData.mimeType=i.mimeType||((t=i.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){const i=this;return this.getDependency("texture",n.index).then((function(o){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),i.extensions[hL.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[hL.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(o);o=i.extensions[hL.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),i.associations.set(o,t)}}return void 0!==r&&(o.encoding=r),e[t]=o,o}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new uI,EA.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new $T,EA.prototype.copy.call(t,n),t.color.copy(n.color),this.cache.add(e,t)),n=t}if(r||i||o){let e="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return qO}loadMaterial(e){const t=this,n=this.json,r=this.extensions,i=n.materials[e];let o;const a={},s=i.extensions||{},l=[];if(s[hL.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=r[hL.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];o=e.getMaterialType(),l.push(e.extendParams(a,i,t))}else if(s[hL.KHR_MATERIALS_UNLIT]){const e=r[hL.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),l.push(e.extendParams(a,i,t))}else{const n=i.pbrMetallicRoughness||{};if(a.color=new QM(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.fromArray(e),a.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(a,"map",n.baseColorTexture,BS)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),o=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===i.doubleSided&&(a.side=Sw);const c=i.alphaMode||$L;if(c===tD?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===eD&&(a.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&o!==CA&&(l.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new NM(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==i.occlusionTexture&&o!==CA&&(l.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(a.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&o!==CA&&(a.emissive=(new QM).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&o!==CA&&l.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,BS)),Promise.all(l).then((function(){let n;return n=o===PL?r[hL.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new o(a),i.name&&(n.name=i.name),rD(n,i),t.associations.set(n,{materials:e}),i.extensions&&nD(r,n,i),n}))}createUniqueName(e){const t=jP.sanitizeNodeName(e||"");let n=t;for(let e=1;this.nodeNamesUsed[n];++e)n=t+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[hL.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return uD(n,e,t)}))}const o=[];for(let n=0,a=e.length;n<a;n++){const a=e[n],s=oD(a),l=r[s];if(l)o.push(l.promise);else{let e;e=a.extensions&&a.extensions[hL.KHR_DRACO_MESH_COMPRESSION]?i(a):uD(new YA,a,t),r[s]={primitive:a,promise:e},o.push(e)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,r=this.extensions,i=n.meshes[e],o=i.primitives,a=[];for(let e=0,t=o.length;e<t;e++){const t=void 0===o[e].material?(void 0===(s=this.cache).DefaultMaterial&&(s.DefaultMaterial=new qO({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ww})),s.DefaultMaterial):this.getDependency("material",o[e].material);a.push(t)}var s;return a.push(t.loadGeometries(o)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),s=n[n.length-1],l=[];for(let n=0,c=s.length;n<c;n++){const c=s[n],u=o[n];let d;const f=a[n];if(u.mode===VL||u.mode===WL||u.mode===GL||void 0===u.mode)d=!0===i.isSkinnedMesh?new zT(c,f):new fE(c,f),!0!==d.isSkinnedMesh||d.geometry.attributes.skinWeight.normalized||d.normalizeSkinWeights(),u.mode===WL?d.geometry=dD(d.geometry,NS):u.mode===GL&&(d.geometry=dD(d.geometry,LS));else if(u.mode===UL)d=new lI(c,f);else if(u.mode===HL)d=new oI(c,f);else if(u.mode===zL)d=new cI(c,f);else{if(u.mode!==FL)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);d=new mI(c,f)}Object.keys(d.geometry.morphAttributes).length>0&&iD(d,i),d.name=t.createUniqueName(i.name||"mesh_"+e),rD(d,i),u.extensions&&nD(r,d,u),t.assignFinalMaterial(d),l.push(d)}for(let n=0,r=l.length;n<r;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return l[0];const c=new nT;t.associations.set(c,{meshes:e});for(let e=0,t=l.length;e<t;e++)c.add(l[e]);return c}))}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(r)return"perspective"===n.type?t=new wE(PM.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(t=new WE(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),rD(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(n):this.getDependency("accessor",t.inverseBindMatrices).then((function(e){return n.inverseBindMatrices=e,n}))}loadAnimation(e){const t=this.json.animations[e],n=[],r=[],i=[],o=[],a=[];for(let e=0,s=t.channels.length;e<s;e++){const s=t.channels[e],l=t.samplers[s.sampler],c=s.target,u=c.node,d=void 0!==t.parameters?t.parameters[l.input]:l.input,f=void 0!==t.parameters?t.parameters[l.output]:l.output;n.push(this.getDependency("node",u)),r.push(this.getDependency("accessor",d)),i.push(this.getDependency("accessor",f)),o.push(l),a.push(c)}return Promise.all([Promise.all(n),Promise.all(r),Promise.all(i),Promise.all(o),Promise.all(a)]).then((function(n){const r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=[];for(let e=0,t=r.length;e<t;e++){const t=r[e],n=i[e],c=o[e],u=a[e],d=s[e];if(void 0===t)continue;let f;switch(t.updateMatrix(),XL[d.path]){case XL.weights:f=pR;break;case XL.rotation:f=gR;break;default:f=yR}const h=t.name?t.name:t.uuid,p=void 0!==u.interpolation?ZL[u.interpolation]:ES,m=[];XL[d.path]===XL.weights?t.traverse((function(e){e.morphTargetInfluences&&m.push(e.name?e.name:e.uuid)})):m.push(h);let g=c.array;if(c.normalized){const e=sD(g.constructor),t=new Float32Array(g.length);for(let n=0,r=g.length;n<r;n++)t[n]=g[n]*e;g=t}for(let e=0,t=m.length;e<t;e++){const t=new f(m[e]+"."+XL[d.path],n.array,g,p);"CUBICSPLINE"===u.interpolation&&(t.createInterpolant=function(e){return new(this instanceof gR?jL:DL)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(t)}}const c=t.name?t.name:"animation_"+e;return new bR(c,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]})),t}))}loadNode(e){const t=this.json,n=this.extensions,r=this,i=t.nodes[e],o=i.name?r.createUniqueName(i.name):"";return function(){const t=[],n=r._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return n&&t.push(n),void 0!==i.camera&&t.push(r.getDependency("camera",i.camera).then((function(e){return r._getNodeRef(r.cameraCache,i.camera,e)}))),r._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let a;if(a=!0===i.isBone?new HT:t.length>1?new nT:1===t.length?t[0]:new hA,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(i.name&&(a.userData.name=i.name,a.name=o),rD(a,i),i.extensions&&nD(n,a,i),void 0!==i.matrix){const e=new H_;e.fromArray(i.matrix),a.applyMatrix4(e)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);return r.associations.has(a)||r.associations.set(a,{}),r.associations.get(a).nodes=e,a}))}loadScene(e){const t=this.json,n=this.extensions,r=this.json.scenes[e],i=this,o=new nT;r.name&&(o.name=i.createUniqueName(r.name)),rD(o,r),r.extensions&&nD(n,o,r);const a=r.nodes||[],s=[];for(let e=0,n=a.length;e<n;e++)s.push(cD(a[e],o,t,i));return Promise.all(s).then((function(){return i.associations=(e=>{const t=new Map;for(const[e,n]of i.associations)(e instanceof EA||e instanceof n_)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(o),o}))}}function cD(e,t,n,r){const i=n.nodes[e];return r.getDependency("node",e).then((function(e){if(void 0===i.skin)return e;let t;return r.getDependency("skin",i.skin).then((function(e){t=e;const n=[];for(let e=0,i=t.joints.length;e<i;e++)n.push(r.getDependency("node",t.joints[e]));return Promise.all(n)})).then((function(n){return e.traverse((function(e){if(!e.isMesh)return;const r=[],i=[];for(let e=0,o=n.length;e<o;e++){const o=n[e];if(o){r.push(o);const n=new H_;void 0!==t.inverseBindMatrices&&n.fromArray(t.inverseBindMatrices.array,16*e),i.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}e.bind(new qT(r,i),e.matrixWorld)})),e}))})).then((function(e){t.add(e);const o=[];if(i.children){const t=i.children;for(let i=0,a=t.length;i<a;i++){const a=t[i];o.push(cD(a,e,n,r))}}return Promise.all(o)}))}function uD(e,t,n){const r=t.attributes,i=[];function o(t,r){return n.getDependency("accessor",t).then((function(t){e.setAttribute(r,t)}))}for(const t in r){const n=QL[t]||t.toLowerCase();n in e.attributes||i.push(o(r[t],n))}if(void 0!==t.indices&&!e.index){const r=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));i.push(r)}return rD(e,t),function(e,t,n){const r=t.attributes,i=new p_;if(void 0===r.POSITION)return;{const e=n.json.accessors[r.POSITION],t=e.min,o=e.max;if(void 0===t||void 0===o)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new d_(t[0],t[1],t[2]),new d_(o[0],o[1],o[2])),e.normalized){const t=sD(qL[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}const o=t.targets;if(void 0!==o){const e=new d_,t=new d_;for(let r=0,i=o.length;r<i;r++){const i=o[r];if(void 0!==i.POSITION){const r=n.json.accessors[i.POSITION],o=r.min,a=r.max;if(void 0!==o&&void 0!==a){if(t.setX(Math.max(Math.abs(o[0]),Math.abs(a[0]))),t.setY(Math.max(Math.abs(o[1]),Math.abs(a[1]))),t.setZ(Math.max(Math.abs(o[2]),Math.abs(a[2]))),r.normalized){const e=sD(qL[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(e)}e.boundingBox=i;const a=new P_;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=a}(e,t,n),Promise.all(i).then((function(){return void 0!==t.targets?function(e,t,n){let r=!1,i=!1,o=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(r=!0),void 0!==n.NORMAL&&(i=!0),void 0!==n.COLOR_0&&(o=!0),r&&i&&o)break}if(!r&&!i&&!o)return Promise.resolve(e);const a=[],s=[],l=[];for(let c=0,u=t.length;c<u;c++){const u=t[c];if(r){const t=void 0!==u.POSITION?n.getDependency("accessor",u.POSITION):e.attributes.position;a.push(t)}if(i){const t=void 0!==u.NORMAL?n.getDependency("accessor",u.NORMAL):e.attributes.normal;s.push(t)}if(o){const t=void 0!==u.COLOR_0?n.getDependency("accessor",u.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(a),Promise.all(s),Promise.all(l)]).then((function(t){const n=t[0],a=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=a),o&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}function dD(e,t){let n=e.getIndex();if(null===n){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const r=n.count-2,i=[];if(t===LS)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=e.clone();return o.setIndex(i),o}let fD;const hD=()=>{if(fD)return fD;const e=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]),t=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]);if("object"!=typeof WebAssembly)return{supported:!1};let n,r="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB";WebAssembly.validate(e)&&(r="B9h9z9tFBBBFiI9gBB9gLaaaaaFa9gEaaaB9gFaFaEMcBBFBFFGGGEILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBOn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBNI9z9iqlBVc+N9IcIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMk8lLbaE97F9+FaL978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAeDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAeDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBReCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBH8ZCFD9tA8ZAPD9OD9hD9RH8ZDQBTFtGmEYIPLdKeOnHpAIAQJDBIBHyCFD9tAyAPD9OD9hD9RHyAIASJDBIBH8cCFD9tA8cAPD9OD9hD9RH8cDQBTFtGmEYIPLdKeOnH8dDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAeD9uHeDyBjGBAEAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeApA8dDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNiV8ZcpMyS8cQ8df8eb8fHdAyA8cDQNiV8ZcpMyS8cQ8df8eb8fH8ZDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/dLEK97FaF97GXGXAGCI9HQBAF9FQFCBRGEXABABDBBBHECiD+rFCiD+sFD/6FHIAECND+rFCiD+sFD/6FAID/gFAECTD+rFCiD+sFD/6FHLD/gFD/kFD/lFHKCBDtD+2FHOAICUUUU94DtHND9OD9RD/kFHI9DBB/+hDYAIAID/mFAKAKD/mFALAOALAND9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHLD/mF9DBBX9LDYHOD/kFCgFDtD9OAECUUU94DtD9OD9QAIALD/mFAOD/kFCND+rFCU/+EDtD9OD9QAKALD/mFAOD/kFCTD+rFCUU/8ODtD9OD9QDMBBABCTJRBAGCIJHGAF9JQBSGMMAF9FQBCBRGEXABCTJHVAVDBBBHECBDtHOCUU98D8cFCUU98D8cEHND9OABDBBBHKAEDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAKAEDQBFGENVcMTtmYi8ZpyHECTD+sFD/6FHID/gFAECTD+rFCTD+sFD/6FHLD/gFD/kFD/lFHE9DB/+g6DYALAEAOD+2FHOALCUUUU94DtHcD9OD9RD/kFHLALD/mFAEAED/mFAIAOAIAcD9OD9RD/kFHEAED/mFD/kFD/kFD/jFD/nFHID/mF9DBBX9LDYHOD/kFCTD+rFALAID/mFAOD/kFCggEDtD9OD9QHLAEAID/mFAOD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHEDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAKAND9OALAEDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM/hEIGaF97FaL978jUUUUBCTlREGXAF9FQBCBRIEXAEABDBBBHLABCTJHKDBBBHODQILKOSQfbPden8c8d8e8fHNCTD+sFHVCID+rFDMIBAB9DBBU8/DY9D/zI818/DYAVCEDtD9QD/6FD/nFHVALAODQBFGENVcMTtmYi8ZpyHLCTD+rFCTD+sFD/6FD/mFHOAOD/mFAVALCTD+sFD/6FD/mFHcAcD/mFAVANCTD+rFCTD+sFD/6FD/mFHNAND/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHVD/mF9DBBX9LDYHLD/kFCggEDtHMD9OAcAVD/mFALD/kFCTD+rFD9QHcANAVD/mFALD/kFCTD+rFAOAVD/mFALD/kFAMD9OD9QHVDQBFTtGEmYILPdKOenHLD8dBAEDBIBDyB+t+J83EBABCNJALD8dFAEDBIBDyF+t+J83EBAKAcAVDQNVi8ZcMpySQ8c8dfb8e8fHVD8dBAEDBIBDyG+t+J83EBABCiJAVD8dFAEDBIBDyE+t+J83EBABCAJRBAICIJHIAF9JQBMMM9jFF97GXAGCGrAF9sHG9FQBCBRFEXABABDBBBHECND+rFCND+sFD/6FAECiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBABCTJRBAFCIJHFAG9JQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB");const i=WebAssembly.instantiate(function(e){const n=new Uint8Array(e.length);for(let t=0;t<e.length;++t){const r=e.charCodeAt(t);n[t]=r>96?r-71:r>64?r-65:r>47?r+4:r>46?63:62}let r=0;for(let i=0;i<e.length;++i)n[r++]=n[i]<60?t[n[i]]:64*(n[i]-60)+n[++i];return n.buffer.slice(0,r)}(r),{}).then((e=>{n=e.instance,n.exports.__wasm_call_ctors()}));function o(e,t,r,i,o,a){const s=n.exports.sbrk,l=r+3&-4,c=s(l*i),u=s(o.length),d=new Uint8Array(n.exports.memory.buffer);d.set(o,u);const f=e(c,r,i,u,o.length);if(0===f&&a&&a(c,l,i),t.set(d.subarray(c,c+r*i)),s(c-s(0)),0!==f)throw new Error(`Malformed buffer data: ${f}`)}const a={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},s={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return fD={ready:i,supported:!0,decodeVertexBuffer(e,t,r,i,s){o(n.exports.meshopt_decodeVertexBuffer,e,t,r,i,n.exports[a[s]])},decodeIndexBuffer(e,t,r,i){o(n.exports.meshopt_decodeIndexBuffer,e,t,r,i)},decodeIndexSequence(e,t,r,i){o(n.exports.meshopt_decodeIndexSequence,e,t,r,i)},decodeGltfBuffer(e,t,r,i,l,c){o(n.exports[s[l]],e,t,r,i,n.exports[a[c]])}},fD};u=a("85Hg2");var pD={};Object.defineProperty(pD,"__esModule",{value:!0});u=a("85Hg2");function mD(e){var t,n=new Set,r=function(e,r){var i="function"==typeof e?e(t):e;if(i!==t){var o=t;t=r?i:Object.assign({},t,i),n.forEach((function(e){return e(t,o)}))}},i=function(){return t},o={setState:r,getState:i,subscribe:function(e,r,o){return r||o?function(e,r,o){void 0===r&&(r=i),void 0===o&&(o=Object.is),console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");var a=r(t);function s(){var n=r(t);if(!o(a,n)){var i=a;e(a=n,i)}}return n.add(s),function(){return n.delete(s)}}(e,r,o):(n.add(e),function(){return n.delete(e)})},destroy:function(){return n.clear()}};return t=e(r,i,o),o}var gD="undefined"==typeof window||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent)?u.useEffect:u.useLayoutEffect;pD.default=function(e){var t="function"==typeof e?mD(e):e,n=function(e,n){void 0===e&&(e=t.getState),void 0===n&&(n=Object.is);var r,i=u.useReducer((function(e){return e+1}),0)[1],o=t.getState(),a=u.useRef(o),s=u.useRef(e),l=u.useRef(n),c=u.useRef(!1),d=u.useRef();void 0===d.current&&(d.current=e(o));var f=!1;(a.current!==o||s.current!==e||l.current!==n||c.current)&&(r=e(o),f=!n(d.current,r)),gD((function(){f&&(d.current=r),a.current=o,s.current=e,l.current=n,c.current=!1}));var h=u.useRef(o);gD((function(){var e=function(){try{var e=t.getState(),n=s.current(e);l.current(d.current,n)||(a.current=e,d.current=n,i())}catch(e){c.current=!0,i()}},n=t.subscribe(e);return t.getState()!==h.current&&e(),n}),[]);var p=f?r:d.current;return u.useDebugValue(p),p};return Object.assign(n,t),n[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");var e=[n,t];return{next:function(){var t=e.length<=0;return{value:e.shift(),done:t}}}},n};var vD;vD=a("YtP34");var yD,bD=a("kMsGZ");yD=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(i=r;0!=i--;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(i=r;0!=i--;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;0!=i--;){var a=o[i];if(!e(t[a],n[a]))return!1}return!0}return t!=t&&n!=n};const wD=[];function xD(e,t,n,i=0,o=!1){for(const e of t)if(r(yD)(n,e.args)){if(o)return;if(e.error)throw e.error;if(e.response)return e.response;throw e.promise}const a={args:n,promise:e(...n).then((e=>a.response=null==e||e)).catch((e=>a.error=null!=e?e:"unknown error")).then((()=>{i>0&&setTimeout((()=>{const e=t.indexOf(a);-1!==e&&t.splice(e,1)}),i)}))};if(t.push(a),!o)throw a.promise}function SD(e,...t){if(void 0===t||0===t.length)e.splice(0,e.length);else{const n=e.find((e=>r(yD)(t,e.args)));if(n){const t=e.indexOf(n);-1!==t&&e.splice(t,1)}}}function MD(e,...t){return xD(e,wD,t,MD.lifespan)}MD.lifespan=0,MD.clear=(...e)=>SD(wD,...e),MD.preload=(e,...t)=>{xD(e,wD,t,MD.lifespan,!0)},MD.peek=(...e)=>{var t;return null==(t=wD.find((t=>r(yD)(e,t.args))))?void 0:t.response};var _D;u=a("85Hg2");function AD(e,t,n){var r,i,o,a,s;function l(){var c=Date.now()-a;c<t&&c>=0?r=setTimeout(l,t-c):(r=null,n||(s=e.apply(o,i),o=i=null))}null==t&&(t=100);var c=function(){o=this,i=arguments,a=Date.now();var c=n&&!r;return r||(r=setTimeout(l,t)),c&&(s=e.apply(o,i),o=i=null),s};return c.clear=function(){r&&(clearTimeout(r),r=null)},c.flush=function(){r&&(s=e.apply(o,i),o=i=null,clearTimeout(r),r=null)},c}function ED(e){let{debounce:t,scroll:n,polyfill:i,offsetSize:o}=void 0===e?{debounce:0,scroll:!1,offsetSize:!1}:e;const a=i||("undefined"==typeof window?class{}:window.ResizeObserver);if(!a)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,l]=(0,u.useState)({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),c=(0,u.useRef)({element:null,scrollContainers:null,resizeObserver:null,lastBounds:s}),d=t?"number"==typeof t?t:t.scroll:null,f=t?"number"==typeof t?t:t.resize:null,h=(0,u.useRef)(!1);(0,u.useEffect)((()=>(h.current=!0,()=>{h.current=!1})));const[p,m,g]=(0,u.useMemo)((()=>{const e=()=>{if(!c.current.element)return;const{left:e,top:t,width:n,height:r,bottom:i,right:a,x:s,y:u}=c.current.element.getBoundingClientRect(),d={left:e,top:t,width:n,height:r,bottom:i,right:a,x:s,y:u};c.current.element instanceof HTMLElement&&o&&(d.height=c.current.element.offsetHeight,d.width=c.current.element.offsetWidth),Object.freeze(d),h.current&&!TD(c.current.lastBounds,d)&&l(c.current.lastBounds=d)};return[e,f?r(_D)(e,f):e,d?r(_D)(e,d):e]}),[l,o,d,f]);function v(){c.current.scrollContainers&&(c.current.scrollContainers.forEach((e=>e.removeEventListener("scroll",g,!0))),c.current.scrollContainers=null),c.current.resizeObserver&&(c.current.resizeObserver.disconnect(),c.current.resizeObserver=null)}function y(){c.current.element&&(c.current.resizeObserver=new a(g),c.current.resizeObserver.observe(c.current.element),n&&c.current.scrollContainers&&c.current.scrollContainers.forEach((e=>e.addEventListener("scroll",g,{capture:!0,passive:!0}))))}var b,w,x;return b=g,w=Boolean(n),(0,u.useEffect)((()=>{if(w){const e=b;return window.addEventListener("scroll",e,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",e,!0)}}}),[b,w]),x=m,(0,u.useEffect)((()=>{const e=x;return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[x]),(0,u.useEffect)((()=>{v(),y()}),[n,g,m]),(0,u.useEffect)((()=>v),[]),[e=>{e&&e!==c.current.element&&(v(),c.current.element=e,c.current.scrollContainers=CD(e),y())},s,p]}function CD(e){const t=[];if(!e||e===document.body)return t;const{overflow:n,overflowX:r,overflowY:i}=window.getComputedStyle(e);return[n,r,i].some((e=>"auto"===e||"scroll"===e))&&t.push(e),[...t,...CD(e.parentElement)]}AD.debounce=AD,_D=AD;const kD=["x","y","top","bottom","left","right","width","height"],TD=(e,t)=>kD.every((n=>e[n]===t[n]));const ID={obj:e=>e===Object(e)&&!ID.arr(e)&&"function"!=typeof e,fun:e=>"function"==typeof e,str:e=>"string"==typeof e,num:e=>"number"==typeof e,und:e=>void 0===e,arr:e=>Array.isArray(e),equ(e,t){if(typeof e!=typeof t||!!e!=!!t)return!1;if(ID.str(e)||ID.num(e)||ID.obj(e))return e===t;if(ID.arr(e)&&e==t)return!0;let n;for(n in e)if(!(n in t))return!1;for(n in t)if(e[n]!==t[n])return!1;return!ID.und(n)||e===t}};function OD(e){return(e.eventObject||e.object).uuid+"/"+e.index+e.instanceId}function RD(e,t,n,r){const i=n.get(t);i&&(n.delete(t),0===n.size&&(e.delete(r),i.target.releasePointerCapture(r)))}function PD(e){const t=new lw.Vector3;function n(e){return e.filter((e=>["Move","Over","Enter","Out","Leave"].some((t=>{var n;return null==(n=e.__r3f)?void 0:n.handlers["onPointer"+t]}))))}function r(t){const{internal:n}=e.getState();Array.from(n.hovered.values()).forEach((e=>{if(!t.length||!t.find((t=>t.object===e.object&&t.index===e.index&&t.instanceId===e.instanceId))){const r=e.eventObject.__r3f,i=null==r?void 0:r.handlers;if(n.hovered.delete(OD(e)),null!=r&&r.eventCount){const n={...e,intersections:t||[]};null==i.onPointerOut||i.onPointerOut(n),null==i.onPointerLeave||i.onPointerLeave(n)}}}))}function i(e,t){t.forEach((t=>{var n;return null==(n=t.__r3f)||null==n.handlers.onPointerMissed?void 0:n.handlers.onPointerMissed(e)}))}return{handlePointer:o=>{switch(o){case"onPointerLeave":case"onPointerCancel":return()=>r([]);case"onLostPointerCapture":return t=>{const{internal:n}=e.getState();"pointerId"in t&&!n.capturedMap.has(t.pointerId)&&(n.capturedMap.delete(t.pointerId),r([]))}}return a=>{const{onPointerMissed:s,internal:l}=e.getState();!function(t){var n;const r=e.getState(),{raycaster:i,mouse:o,camera:a,size:s}=r,{offsetX:l,offsetY:c}=null!=(n=null==i.computeOffsets?void 0:i.computeOffsets(t,r))?n:t,{width:u,height:d}=s;o.set(l/u*2-1,-c/d*2+1),i.setFromCamera(o,a)}(a),l.lastEvent.current=a;const c="onPointerMove"===o,u="onClick"===o||"onContextMenu"===o||"onDoubleClick"===o,d=function(t,n){const{internal:r}=e.getState();if("pointerId"in n&&r.capturedMap.has(n.pointerId))for(let e of r.capturedMap.get(n.pointerId).values())t.push(e.intersection);return t}(function(t){const n=e.getState(),{raycaster:r,internal:i}=n;if(!r.enabled)return[];const o=new Set,a=[],s=t?t(i.interaction):i.interaction;let l=r.intersectObjects(s,!0).filter((e=>{const t=OD(e);return!o.has(t)&&(o.add(t),!0)}));r.filter&&(l=r.filter(l,n));for(const e of l){let t=e.object;for(;t;){var c;null!=(c=t.__r3f)&&c.eventCount&&a.push({...e,eventObject:t}),t=t.parent}}return a}(c?n:void 0),a),f=u?function(t){const{internal:n}=e.getState(),r=t.offsetX-n.initialClick[0],i=t.offsetY-n.initialClick[1];return Math.round(Math.sqrt(r*r+i*i))}(a):0;"onPointerDown"===o&&(l.initialClick=[a.offsetX,a.offsetY],l.initialHits=d.map((e=>e.eventObject))),u&&!d.length&&f<=2&&(i(a,l.interaction),s&&s(a)),c&&r(d),function(n,i,o,a){const{raycaster:s,mouse:l,camera:c,internal:u}=e.getState();if(n.length){const e=t.set(l.x,l.y,0).unproject(c),d={stopped:!1};for(const t of n){const f=e=>{var n,r;return null!=(n=null==(r=u.capturedMap.get(e))?void 0:r.has(t.eventObject))&&n},h=e=>{const n={intersection:t,target:i.target};u.capturedMap.has(e)?u.capturedMap.get(e).set(t.eventObject,n):u.capturedMap.set(e,new Map([[t.eventObject,n]])),i.target.setPointerCapture(e)},p=e=>{const n=u.capturedMap.get(e);n&&RD(u.capturedMap,t.eventObject,n,e)};let m={};for(let e in i){let t=i[e];"function"!=typeof t&&(m[e]=t)}let g={...t,...m,spaceX:l.x,spaceY:l.y,intersections:n,stopped:d.stopped,delta:o,unprojectedPoint:e,ray:s.ray,camera:c,stopPropagation:()=>{const e="pointerId"in i&&u.capturedMap.get(i.pointerId);(!e||e.has(t.eventObject))&&(g.stopped=d.stopped=!0,u.hovered.size&&Array.from(u.hovered.values()).find((e=>e.eventObject===t.eventObject)))&&r([...n.slice(0,n.indexOf(t)),t])},target:{hasPointerCapture:f,setPointerCapture:h,releasePointerCapture:p},currentTarget:{hasPointerCapture:f,setPointerCapture:h,releasePointerCapture:p},sourceEvent:i,nativeEvent:i};if(a(g),!0===d.stopped)break}}}(d,a,f,(e=>{const t=e.eventObject,n=t.__r3f,r=null==n?void 0:n.handlers;if(null!=n&&n.eventCount)if(c){if(r.onPointerOver||r.onPointerEnter||r.onPointerOut||r.onPointerLeave){const t=OD(e),n=l.hovered.get(t);n?n.stopped&&e.stopPropagation():(l.hovered.set(t,e),null==r.onPointerOver||r.onPointerOver(e),null==r.onPointerEnter||r.onPointerEnter(e))}null==r.onPointerMove||r.onPointerMove(e)}else{const n=r[o];n?u&&!l.initialHits.includes(t)||(i(a,l.interaction.filter((e=>!l.initialHits.includes(e)))),n(e)):u&&l.initialHits.includes(t)&&i(a,l.interaction.filter((e=>!l.initialHits.includes(e))))}}))}}}}const ND=e=>e&&!!e.getState,LD=(e,t)=>{var n,r;return{root:ND(e)?e:null!=(n=null==(r=e.__r3f)?void 0:r.root)?n:t.__r3f.root,container:ND(e)?e.getState().scene:e}},DD="__default",BD={};let jD={};function FD(e,t){const n=e;return(null!=t&&t.primitive||!n.__r3f)&&(n.__r3f={root:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...t}),e}const UD=e=>e&&e.isOrthographicCamera;function zD(e){return Array.isArray(e)?Math.min(Math.max(e[0],window.devicePixelRatio),e[1]):e}const HD=u.createContext(null);let VD,WD=[],GD=[],qD=[];function KD(e,t){for(VD=0;VD<e.length;VD++)e[VD](t)}function YD(e,t){let n=t.clock.getDelta();for("never"===t.frameloop&&"number"==typeof e&&(n=e-t.clock.elapsedTime,t.clock.oldTime=t.clock.elapsedTime,t.clock.elapsedTime=e),VD=0;VD<t.internal.subscribers.length;VD++)t.internal.subscribers[VD].ref.current(t,n);return!t.internal.priority&&t.gl.render&&t.gl.render(t.scene,t.camera),t.internal.frames=Math.max(0,t.internal.frames-1),"always"===t.frameloop?1:t.internal.frames}function JD(e){const{handlePointer:t}=PD(e),n={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};return{connected:!1,handlers:Object.keys(n).reduce(((e,n)=>({...e,[n]:t(n)})),{}),connect:t=>{var r;const{set:i,events:o}=e.getState();null==o.disconnect||o.disconnect(),i((e=>({events:{...e.events,connected:t}}))),Object.entries(null!=(r=null==o?void 0:o.handlers)?r:[]).forEach((([e,r])=>{const[i,o]=n[e];t.addEventListener(i,r,{passive:o})}))},disconnect:()=>{const{set:t,events:r}=e.getState();var i;r.connected&&(Object.entries(null!=(i=r.handlers)?i:[]).forEach((([e,t])=>{if(r&&r.connected instanceof HTMLElement){const[i]=n[e];r.connected.removeEventListener(i,t)}})),t((e=>({events:{...e.events,connected:!1}}))))}}}const QD="undefined"!=typeof window?u.useLayoutEffect:u.useEffect;function XD({set:e}){return QD((()=>(e(new Promise((()=>null))),()=>e(!1))),[]),null}class ZD extends u.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}ZD.getDerivedStateFromError=()=>({error:!0});const $D=u.forwardRef((function({children:e,fallback:t,tabIndex:n,resize:i,id:o,style:a,className:s,events:l,...c},d){const[f,{width:h,height:p}]=ED({scroll:!0,debounce:{scroll:50,resize:0},...i}),m=u.useRef(null),[g,v]=u.useState(!1),[y,b]=u.useState(!1);if(g)throw g;if(y)throw y;return QD((()=>{h>0&&p>0&&function(e,t,{gl:n,size:i,mode:o=lB[1],events:a,onCreated:s,...l}={}){var c,d,f,h,p;i||(i={width:null!=(d=null==(f=t.parentElement)?void 0:f.clientWidth)?d:0,height:null!=(h=null==(p=t.parentElement)?void 0:p.clientHeight)?h:0});let m=sB.get(t),g=null==m?void 0:m.fiber,v=null==m?void 0:m.store,y=null==(c=v)?void 0:c.getState();if(g&&y){void 0===l.dpr||ID.equ(y.viewport.dpr,zD(l.dpr))||y.setDpr(l.dpr),y.size.width===i.width&&y.size.height===i.height||y.setSize(i.width,i.height),y.frameloop!==l.frameloop&&y.setFrameloop(l.frameloop);l.linear!==y.internal.lastProps.linear&&(pB(t),g=void 0)}if(!g){const e=((e,t)=>{const n="function"==typeof e?e(t):e;if(r=n,null!=r&&r.render)return n;var r;const i=new lw.WebGLRenderer({powerPreference:"high-performance",canvas:t,antialias:!0,alpha:!0,...e});i.outputEncoding=lw.sRGBEncoding,i.toneMapping=lw.ACESFilmicToneMapping,e&&fB(i,e);return i})(n,t);l.vr&&(e.xr.enabled=!0,e.setAnimationLoop((e=>uB(e,!0)))),v=((e,t,n,i)=>{const{gl:o,size:a,shadows:s=!1,linear:l=!1,flat:c=!1,vr:d=!1,orthographic:f=!1,frameloop:h="always",dpr:p=1,performance:m,clock:g=new lw.Clock,raycaster:v,camera:y,onPointerMissed:b}=i;s&&(o.shadowMap.enabled=!0,"object"==typeof s?Object.assign(o.shadowMap,s):o.shadowMap.type=lw.PCFSoftShadowMap),l&&(o.outputEncoding=lw.LinearEncoding),c&&(o.toneMapping=lw.NoToneMapping),"never"===h&&(g.stop(),g.elapsedTime=0);const w=r(pD)(((r,a)=>{const s=new lw.Raycaster,{params:w,...x}=v||{};e(s,{enabled:!0,...x,params:{...s.params,...w}});const S=y instanceof lw.Camera,M=S?y:f?new lw.OrthographicCamera(0,0,0,0,.1,1e3):new lw.PerspectiveCamera(75,0,.1,1e3);S||(M.position.z=5,y&&e(M,y),null!=y&&y.rotation||M.lookAt(0,0,0));const _=zD(p),A=new lw.Vector3,E=new lw.Vector3,C=new lw.Vector3;function k(e=a().camera,t=E,n=a().size){const{width:r,height:i}=n,o=r/i;t instanceof lw.Vector3?C.copy(t):C.set(...t);const s=e.getWorldPosition(A).distanceTo(C);if(UD(e))return{width:r/e.zoom,height:i/e.zoom,factor:1,distance:s,aspect:o};{const t=e.fov*Math.PI/180,n=2*Math.tan(t/2)*s,a=n*(r/i);return{width:a,height:n,factor:r/a,distance:s,aspect:o}}}let T;const I=e=>r((t=>({performance:{...t.performance,current:e}})));return{gl:o,set:r,get:a,invalidate:()=>t(a()),advance:(e,t)=>n(e,t,a()),linear:l,flat:c,scene:FD(new lw.Scene),camera:M,controls:null,raycaster:s,clock:g,mouse:new lw.Vector2,vr:d,frameloop:h,onPointerMissed:b,performance:{current:1,min:.5,max:1,debounce:200,...m,regress:()=>{const e=a();T&&clearTimeout(T),e.performance.current!==e.performance.min&&I(e.performance.min),T=setTimeout((()=>I(a().performance.max)),e.performance.debounce)}},size:{width:0,height:0},viewport:{initialDpr:_,dpr:_,width:0,height:0,aspect:0,distance:0,factor:0,getCurrentViewport:k},setSize:(e,t)=>{const n={width:e,height:t};r((e=>({size:n,viewport:{...e.viewport,...k(M,E,n)}})))},setDpr:e=>r((t=>({viewport:{...t.viewport,dpr:zD(e)}}))),setFrameloop:(e="always")=>r((()=>({frameloop:e}))),events:{connected:!1},internal:{active:!1,priority:0,frames:0,lastProps:i,lastEvent:u.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(e,t=0)=>(r((({internal:n})=>({internal:{...n,priority:n.priority+(t>0?1:0),subscribers:[...n.subscribers,{ref:e,priority:t}].sort(((e,t)=>e.priority-t.priority))}}))),()=>{r((({internal:n})=>({internal:{...n,priority:n.priority-(t>0?1:0),subscribers:n.subscribers.filter((t=>t.ref!==e))}})))})}}})),x=w.getState();let S=x.size,M=x.viewport.dpr;return w.subscribe((()=>{const{camera:e,size:t,viewport:n,internal:r}=w.getState();t===S&&n.dpr===M||(e.manual||r.lastProps.camera instanceof lw.Camera||(UD(e)?(e.left=t.width/-2,e.right=t.width/2,e.top=t.height/2,e.bottom=t.height/-2):e.aspect=t.width/t.height,e.updateProjectionMatrix(),e.updateMatrixWorld()),o.setPixelRatio(n.dpr),o.setSize(t.width,t.height),S=t,M=n.dpr)})),a&&x.setSize(a.width,a.height),w.subscribe((e=>t(e))),w})(fB,cB,uB,{gl:e,size:i,...l});const s=v.getState();g=dB.createContainer(v,lB.indexOf(o),!1,null),sB.set(t,{fiber:g,store:v}),a&&s.set({events:a(v)})}if(v&&g)return dB.updateContainer(u.createElement(hB,{store:v,element:e,onCreated:s,target:t}),g,null,(()=>{})),v;throw"Error creating root!"}(u.createElement(ZD,{set:b},u.createElement(u.Suspense,{fallback:u.createElement(XD,{set:v})},e)),m.current,{...c,size:{width:h,height:p},events:l||JD})}),[h,p,e]),QD((()=>{const e=m.current;return()=>pB(e)}),[]),u.createElement("div",{ref:f,id:o,className:s,tabIndex:n,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",...a}},u.createElement("canvas",{ref:(w=[m,d],function(e){w.forEach((function(t){"function"==typeof t?t(e):null!=t&&(t.current=e)}))}),style:{display:"block"}},t));var w}));function eB(){const e=u.useContext(HD);if(!e)throw"R3F hooks can only be used within the Canvas component!";return e}function tB(e=(e=>e),t){return eB()(e,t)}function nB(e,t=0){const n=eB().getState().internal.subscribe,r=u.useRef(e);return u.useLayoutEffect((()=>{r.current=e}),[e]),u.useLayoutEffect((()=>n(r,t)),[t,n]),null}function rB(e){const t={nodes:{},materials:{}};return e&&e.traverse((e=>{e.name&&(t.nodes[e.name]=e),e.material&&!t.materials[e.material.name]&&(t.materials[e.material.name]=e.material)})),t}function iB(e){return u.useMemo((()=>rB(e)),[e])}function oB(e,t){return function(n,...r){const i=new n;return e&&e(i),Promise.all(r.map((e=>new Promise(((n,r)=>i.load(e,(e=>{e.scene&&Object.assign(e,rB(e.scene)),n(e)}),t,(t=>r(`Could not load ${e}: ${t.message}`))))))))}}function aB(e,t,n,r){const i=Array.isArray(t)?t:[t],o=MD(oB(n,r),e,...i);return Array.isArray(t)?o:o[0]}aB.preload=function(e,t,n){const r=Array.isArray(t)?t:[t];return MD.preload(oB(n),e,...r)},aB.clear=function(e,t){const n=Array.isArray(t)?t:[t];return MD.clear(e,...n)};const sB=new Map,lB=["legacy","blocking","concurrent"],{invalidate:cB,advance:uB}=function(e){let t,n=!1;function r(i){if(n=!0,t=0,KD(WD,i),e.forEach((e=>{const n=e.store.getState();n.internal.active&&("always"===n.frameloop||n.internal.frames>0)&&(t+=YD(i,n))})),KD(GD,i),t>0)return requestAnimationFrame(r);KD(qD,i),n=!1}return{loop:r,invalidate:function t(i){if(!i)return e.forEach((e=>t(e.store.getState())));!i.vr&&i.internal.active&&"never"!==i.frameloop&&(i.internal.frames=Math.min(60,i.internal.frames+1),n||(n=!0,requestAnimationFrame(r)))},advance:function(t,n=!0,r){n&&KD(WD,t),r?YD(t,r):e.forEach((e=>YD(t,e.store.getState()))),n&&KD(GD,t)}}}(sB),{reconciler:dB,applyProps:fB}=function(e){function t(e,{children:t,key:n,ref:r,...i},{children:o,key:a,ref:s,...l}={},c=!1){var u;const d=null!=(u=null==e?void 0:e.__r3f)?u:{},f=Object.entries(i),h=[];if(c){const e=Object.keys(l);for(let t=0;t<e.length;t++)i.hasOwnProperty(e[t])||f.unshift([e[t],DD+"remove"])}f.forEach((([t,n])=>{var r;if(null!=(r=e.__r3f)&&r.primitive&&"object"===t)return;if(function(e,t){return!(!ID.arr(e)||!ID.equ(e,t))||e===t}(n,l[t]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(t))return h.push([t,n,!0,[]]);let i=[];t.includes("-")&&(i=t.split("-")),h.push([t,n,!1,i])}));const p={...i};return d.memoizedProps&&d.memoizedProps.args&&(p.args=d.memoizedProps.args),d.memoizedProps&&d.memoizedProps.attach&&(p.attach=d.memoizedProps.attach),{accumulative:c,memoized:p,changes:h}}function n(e,n){var r,a,s;const l=null!=(r=null==e?void 0:e.__r3f)?r:{},c=l.root,u=null!=(a=null==c||null==c.getState?void 0:c.getState())?a:{},{memoized:d,changes:f}=(h=n)&&h.memoized&&h.changes?n:t(e,n);var h;const p=l.eventCount;if(e.__r3f&&(e.__r3f.memoizedProps=d),f.forEach((([t,n,r,o])=>{var a;let s=e,c=s[t];if(o.length&&(c=o.reduce(((e,t)=>e[t]),e),!c||!c.set)){const[n,...r]=o.reverse();s=r.reverse().reduce(((e,t)=>e[t]),e),t=n}if(n===DD+"remove")if(c&&c.constructor)n=new c.constructor(d.args);else if(s.constructor){const e=new s.constructor(s.__r3f.memoizedProps.args);n=e[c],e.dispose&&e.dispose()}else n=0;const f=(null==u||null==(a=u.gl)?void 0:a.outputEncoding)===lw.LinearEncoding;if(r)n?l.handlers[t]=n:delete l.handlers[t],l.eventCount=Object.keys(l.handlers).length;else if(c&&c.set&&(c.copy||c instanceof lw.Layers)){if(Array.isArray(n))c.fromArray?c.fromArray(n):c.set(...n);else if(c.copy&&n&&n.constructor&&c.constructor.name===n.constructor.name)c.copy(n);else if(void 0!==n){const e=c instanceof lw.Color;!e&&c.setScalar?c.setScalar(n):c instanceof lw.Layers&&n instanceof lw.Layers?c.mask=n.mask:c.set(n),!f&&e&&c.convertSRGBToLinear()}}else s[t]=n,!f&&s[t]instanceof lw.Texture&&(s[t].encoding=lw.sRGBEncoding);i(e)})),l.parent&&u.internal&&e.raycast&&p!==l.eventCount){const t=u.internal.interaction.indexOf(e);t>-1&&u.internal.interaction.splice(t,1),l.eventCount&&u.internal.interaction.push(e)}return f.length&&null!=(s=e.__r3f)&&s.parent&&o(e),e}function i(e){var t,n;const r=null==(t=e.__r3f)||null==(n=t.root)||null==n.getState?void 0:n.getState();r&&0===r.internal.frames&&r.invalidate()}function o(e){null==e.onUpdate||e.onUpdate(e)}function a(e,{args:t=[],...r},i,o,a){let s,l=`${e[0].toUpperCase()}${e.slice(1)}`;if(!ND(i)&&a){const e=t=>t.return?e(t.return):t.stateNode&&t.stateNode.containerInfo;i=e(a)}if(!i||!ND(i))throw`No valid root for ${l}!`;if("primitive"===e){if(void 0===r.object)throw"Primitives without 'object' are invalid!";s=FD(r.object,{root:i,primitive:!0})}else{const e=jD[l]||lw[l];if(!e)throw`${l} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`;if(!Array.isArray(t))throw"The args prop must be an array!";s=FD(new e(...t),{root:i,memoizedProps:{args:0===t.length?null:t}})}return"attachFns"in r||(l.endsWith("Geometry")?r={attach:"geometry",...r}:l.endsWith("Material")&&(r={attach:"material",...r})),n(s,r),s}function s(e,t){let n=!1;if(t){if(t.attachArray)ID.arr(e[t.attachArray])||(e[t.attachArray]=[]),e[t.attachArray].push(t);else if(t.attachObject)ID.obj(e[t.attachObject[0]])||(e[t.attachObject[0]]={}),e[t.attachObject[0]][t.attachObject[1]]=t;else if(t.attach&&!ID.fun(t.attach))e[t.attach]=t;else if(ID.arr(t.attachFns)){const[n]=t.attachFns;ID.str(n)&&ID.fun(e[n])?e[n](t):ID.fun(n)&&n(t,e)}else t.isObject3D&&e.isObject3D&&(e.add(t),n=!0);n||e.__r3f.objects.push(t),t.__r3f||FD(t,{}),t.__r3f.parent=e,o(t),i(t)}}function l(e,t,n){let r=!1;if(t){if(t.attachArray){const r=e[t.attachArray];ID.arr(r)||(e[t.attachArray]=[]),r.splice(r.indexOf(n),0,t)}else{if(t.attachObject||t.attach&&!ID.fun(t.attach))return s(e,t);if(t.isObject3D&&e.isObject3D){t.parent=e,t.dispatchEvent({type:"added"});const i=e.children.filter((e=>e!==t)),o=i.indexOf(n);e.children=[...i.slice(0,o),t,...i.slice(o)],r=!0}}r||e.__r3f.objects.push(t),t.__r3f||FD(t,{}),t.__r3f.parent=e,o(t),i(t)}}function c(e,t,n=!1){e&&[...e].forEach((e=>u(t,e,n)))}function u(e,t,n){if(t){var r,o;if(t.__r3f&&(t.__r3f.parent=null),null!=(r=e.__r3f)&&r.objects&&(e.__r3f.objects=e.__r3f.objects.filter((e=>e!==t))),t.attachArray)e[t.attachArray]=e[t.attachArray].filter((e=>e!==t));else if(t.attachObject)delete e[t.attachObject[0]][t.attachObject[1]];else if(t.attach&&!ID.fun(t.attach)&&e[t.attach]===t)e[t.attach]=null;else if(ID.arr(t.attachFns)){const[,n]=t.attachFns;ID.str(n)&&ID.fun(e[n])?e[n](t):ID.fun(n)&&n(t,e)}else if(t.isObject3D&&e.isObject3D){var a;e.remove(t),null!=(a=t.__r3f)&&a.root&&function(e,t){const{internal:n}=e.getState();n.interaction=n.interaction.filter((e=>e!==t)),n.initialHits=n.initialHits.filter((e=>e!==t)),n.hovered.forEach(((e,r)=>{e.eventObject!==t&&e.object!==t||n.hovered.delete(r)})),n.capturedMap.forEach(((e,r)=>{RD(n.capturedMap,t,e,r)}))}(t.__r3f.root,t)}const l=null==(o=t.__r3f)?void 0:o.primitive,u=void 0===n?null!==t.dispose&&!l:n;var s;if(!l)c(null==(s=t.__r3f)?void 0:s.objects,t,u),c(t.children,t,u);t.__r3f&&(delete t.__r3f.root,delete t.__r3f.objects,delete t.__r3f.handlers,delete t.__r3f.memoizedProps,l||delete t.__r3f),u&&t.dispose&&"Scene"!==t.type&&(0,bD.unstable_runWithPriority)(bD.unstable_IdlePriority,(()=>{try{t.dispose()}catch(e){}})),i(e)}}const d=r(vD)({now:bD.unstable_now,createInstance:a,removeChild:u,appendChild:s,appendInitialChild:s,insertBefore:l,warnsIfNotActing:!0,supportsMutation:!0,isPrimaryRenderer:!1,scheduleTimeout:ID.fun(setTimeout)?setTimeout:void 0,cancelTimeout:ID.fun(clearTimeout)?clearTimeout:void 0,setTimeout:ID.fun(setTimeout)?setTimeout:void 0,clearTimeout:ID.fun(clearTimeout)?clearTimeout:void 0,noTimeout:-1,appendChildToContainer:(e,t)=>{const{container:n,root:r}=LD(e,t);n.__r3f.root=r,s(n,t)},removeChildFromContainer:(e,t)=>u(LD(e,t).container,t),insertInContainerBefore:(e,t,n)=>l(LD(e,t).container,t,n),prepareUpdate(e,n,r,i){if(e.__r3f.primitive&&i.object&&i.object!==e)return[!0];{const{args:n=[],children:o,...a}=i,{args:l=[],children:c,...u}=r;if(!Array.isArray(n))throw"The args prop must be an array!";if(n.some(((e,t)=>e!==l[t])))return[!0];const d=t(e,a,u,!0);if(d.changes.length)return[!1,d];if(e.attach&&"function"!=typeof e.attach){const t=e.__r3f.parent;t&&t[e.attach]!==e&&s(t,e)}return null}},commitUpdate(e,[t,r],i,o,l,c){t?function(e,t,n,r){var i;const o=null==(i=e.__r3f)?void 0:i.parent;if(!o)return;const l=a(t,n,e.__r3f.root);"primitive"!==t&&e.children&&(e.children.forEach((e=>s(l,e))),e.children=[]),e.__r3f.objects.forEach((e=>s(l,e))),e.__r3f.objects=[],u(o,e),s(o,l),l.raycast&&l.__r3f.eventCount&&l.__r3f.root.getState().internal.interaction.push(l);[r,r.alternate].forEach((e=>{null!==e&&(e.stateNode=l,e.ref&&("function"==typeof e.ref?e.ref(l):e.ref.current=l))}))}(e,i,l,c):n(e,r)},hideInstance(e){e.isObject3D&&(e.visible=!1,i(e))},unhideInstance(e,t){(e.isObject3D&&null==t.visible||t.visible)&&(e.visible=!0,i(e))},hideTextInstance(){throw new Error("Text is not allowed in the R3F tree.")},getPublicInstance:e=>e,getRootHostContext:e=>BD,getChildHostContext:e=>e,createTextInstance(){},finalizeInitialChildren(e){var t;return!!(null!=(t=null==e?void 0:e.__r3f)?t:{}).handlers},commitMount(e){var t;const n=null!=(t=null==e?void 0:e.__r3f)?t:{};e.raycast&&n.handlers&&n.eventCount&&e.__r3f.root.getState().internal.interaction.push(e)},shouldDeprioritizeSubtree:()=>!1,prepareForCommit:()=>null,preparePortalMount(e){FD(e)},resetAfterCommit(){},shouldSetTextContent:()=>!1,clearContainer:()=>!1});return{reconciler:d,applyProps:n}}();function hB({store:e,element:t,onCreated:n,target:r}){return u.useEffect((()=>{const t=e.getState();t.set((e=>({internal:{...e.internal,active:!0}}))),null==t.events.connect||t.events.connect(r),n&&n(t)}),[]),u.createElement(HD.Provider,{value:e},t)}function pB(e,t){const n=sB.get(e),r=null==n?void 0:n.fiber;if(r){const i=null==n?void 0:n.store.getState();i&&(i.internal.active=!1),dB.updateContainer(null,r,null,(()=>{i&&setTimeout((()=>{var n,r,o;null==i.events.disconnect||i.events.disconnect(),null==(n=i.gl)||null==(r=n.renderLists)||null==r.dispose||r.dispose(),null==(o=i.gl)||null==o.forceContextLoss||o.forceContextLoss(),mB(i),sB.delete(e),t&&t(e)}),500)}))}}function mB(e){e.dispose&&"Scene"!==e.type&&e.dispose();for(const r in e){var t,n;null==(t=(n=r).dispose)||t.call(n),delete e[r]}}dB.act;function gB(e,t){return dB.createPortal(e,t,null,null)}dB.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:"17.0.2"});let vB=null;function yB(e,t,n){return r=>{n&&n(r),e&&(vB||(vB=new cL),vB.setDecoderPath("string"==typeof e?e:"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),r.setDRACOLoader(vB)),t&&r.setMeshoptDecoder(hD())}}function bB(e,t=!0,n=!0,r){return aB(dL,e,yB(t,n,r))}bB.preload=(e,t=!0,n=!0,r)=>aB.preload(dL,e,yB(t,n,r)),bB.clear=e=>aB.clear(dL,e);u=a("85Hg2");let wB,xB,SB=999,MB=0;const _B=()=>{SB=0,wB=setTimeout(_B,5e3*Math.random()+2e3)};function AB(e,t){(0,u.useEffect)((()=>{if(e)return xB=t.Wolf3D_Head||t.Wolf3D_Avatar,(null==xB?void 0:xB.morphTargetDictionary)&&(null==xB?void 0:xB.morphTargetInfluences)&&(MB=xB.morphTargetDictionary.eyesClosed),wB=setTimeout(_B,3e3),()=>{clearTimeout(wB)}}),[t,e]),nB(((t,n)=>{if(e)if(SB<2&&(null==xB?void 0:xB.morphTargetInfluences)){let e=Math.abs(Math.sin(SB*Math.PI/2));SB+=10*n,xB.morphTargetInfluences[MB]=e}else(null==xB?void 0:xB.morphTargetInfluences)&&(xB.morphTargetInfluences[MB]=0)}))}u=a("85Hg2");const EB=(e,t,n=.05)=>e*(1-n)+t*n,CB=(e,t,n,r,i)=>((e=((e,t,n)=>Math.min(Math.max(e,t),n))(e,t,n))-t)*(i-r)/(n-t)+r,kB=e=>{e.Wolf3D_Hands&&(e.Wolf3D_Hands.visible=!1),e.RightHand&&e.LeftHand&&(e.RightHand.position.set(0,-2,0),e.LeftHand.position.set(0,-2,0))},TB=e=>{Object.values(e).forEach((e=>{e.map&&(e.map.minFilter=Sx),e&&(e.depthWrite=!0)}))},IB=e=>"SkinnedMesh"===e.type,OB=Math.PI/180;let RB,PB=!1;const NB=new NM(0,0),LB=new NM(0,0),DB=()=>{RB=setTimeout((()=>{PB=!0}),1e3)},BB=()=>{clearTimeout(RB),PB=!1};function jB(e,t){const{gl:n}=tB();(0,u.useEffect)((()=>{if(e)return n.domElement.addEventListener("mouseleave",DB),n.domElement.addEventListener("mouseenter",BB),()=>{n.domElement.removeEventListener("mouseleave",DB),n.domElement.removeEventListener("mouseenter",BB)}}),[n.domElement,e]),nB((n=>{if(!e||!(null==t?void 0:t.Neck)||!(null==t?void 0:t.Head))return;const r=Math.abs(n.camera.rotation.z);!PB&&r<.2?(NB.x=CB(n.mouse.y,-1,1,5*OB,-5*OB),NB.y=CB(n.mouse.x,-1,1,-10*OB,10*OB)):NB.set(0,0),LB.x=EB(LB.x,NB.x),LB.y=EB(LB.y,NB.y),t.Neck.rotation.x=LB.x+.1,t.Neck.rotation.y=LB.y,t.Head.rotation.x=2*LB.x,t.Head.rotation.y=2*LB.y}))}u=a("85Hg2");let FB,UB,zB=999,HB=0,VB=0,WB=0,GB=0;const qB=()=>{zB=0,FB=setTimeout(qB,500*Math.random())};function KB(e,t){(0,u.useEffect)((()=>{if(e)return UB=t.Wolf3D_Head||t.Wolf3D_Avatar||t.Wolf3D_Avatar001,(null==UB?void 0:UB.morphTargetDictionary)&&(null==UB?void 0:UB.morphTargetInfluences)&&(HB=UB.morphTargetDictionary.mouthOpen,VB=UB.morphTargetDictionary.mouthSmile,WB=UB.morphTargetDictionary.mouthFunner,GB=UB.morphTargetDictionary.mouthPucker),FB=setTimeout(qB,200),()=>{clearTimeout(FB)}}),[t,e]),nB(((t,n)=>{if(e)if(zB<2&&(null==UB?void 0:UB.morphTargetInfluences)){let e=Math.abs(Math.sin(zB*Math.PI/2));zB+=10*n,UB.morphTargetInfluences[HB]=e/3,UB.morphTargetInfluences[VB]=e/10,UB.morphTargetInfluences[WB]=e/7,UB.morphTargetInfluences[GB]=e/5}else(null==UB?void 0:UB.morphTargetInfluences)&&(UB.morphTargetInfluences[HB]=0,UB.morphTargetInfluences[VB]=0,UB.morphTargetInfluences[WB]=0,UB.morphTargetInfluences[GB]=0);else(null==UB?void 0:UB.morphTargetInfluences)&&(UB.morphTargetInfluences[HB]=0,UB.morphTargetInfluences[VB]=0,UB.morphTargetInfluences[WB]=0,UB.morphTargetInfluences[GB]=0)}))}const YB=new d_(0,-.6,0);function JB({url:e,eyeBlink:t,headMovement:n,speaking:r,onLoaded:i}){const{scene:o}=bB(e),{nodes:a,materials:l}=iB(o);return AB(t,a),jB(n,a),KB(!!r,a),(0,u.useEffect)((()=>(kB(a),TB(l),i&&i(),()=>{Object.values(l).forEach(mB),Object.values(a).filter(IB).forEach(mB)})),[l,a,e,i]),(0,s.jsxs)("group",{position:YB,children:[(0,s.jsx)("primitive",{object:a.Hips},"armature"),Object.values(a).filter(IB).map((e=>(0,s.jsx)("primitive",{object:e,receiveShadow:!0,castShadow:!0},e.name)))]})}u=a("85Hg2"),u=a("85Hg2");function QB(e,t){const n=u.useRef(),[r]=u.useState((()=>t?t instanceof hA?{current:t}:t:n)),[i]=u.useState((()=>new HP(void 0))),o=u.useRef({}),[a]=u.useState((()=>{const t={};return e.forEach((e=>Object.defineProperty(t,e.name,{enumerable:!0,get(){if(r.current)return o.current[e.name]||(o.current[e.name]=i.clipAction(e,r.current))}}))),{ref:r,clips:e,actions:t,names:e.map((e=>e.name)),mixer:i}}));return nB(((e,t)=>i.update(t))),u.useEffect((()=>{const e=r.current;return()=>{o.current={},Object.values(a.actions).forEach((t=>{e&&i.uncacheAction(t,e)}))}}),[e]),a}u=a("85Hg2");let XB,ZB=0,$B=0;function ej(e,t){(0,u.useEffect)((()=>{e&&(XB=t.Wolf3D_Head||t.Wolf3D_Avatar||t.Wolf3D_Avatar001,(null==XB?void 0:XB.morphTargetDictionary)&&(null==XB?void 0:XB.morphTargetInfluences)&&(ZB=XB.morphTargetDictionary.mouthOpen,$B=XB.morphTargetDictionary.viseme_U))}),[t,e]),nB((()=>{e?(null==XB?void 0:XB.morphTargetInfluences)&&(XB.morphTargetInfluences[ZB]=.56,XB.morphTargetInfluences[$B]=.67):(null==XB?void 0:XB.morphTargetInfluences)&&(XB.morphTargetInfluences[ZB]=0,XB.morphTargetInfluences[$B]=0)}))}u=a("85Hg2");let tj,nj=0;function rj(e,t){(0,u.useEffect)((()=>{e&&(tj=t.Wolf3D_Head||t.Wolf3D_Avatar||t.Wolf3D_Avatar001,(null==tj?void 0:tj.morphTargetDictionary)&&(null==tj?void 0:tj.morphTargetInfluences)&&(nj=tj.morphTargetDictionary.mouthSmile))}),[t,e]),nB((()=>{e?(null==tj?void 0:tj.morphTargetInfluences)&&(tj.morphTargetInfluences[nj]=1/3):(null==tj?void 0:tj.morphTargetInfluences)&&(tj.morphTargetInfluences[nj]=0)}))}const ij=new d_(0,-1,0),oj=new Z_(.175,0,0);function aj({url:e,sex:t,eyeBlink:n,speaking:r,onLoaded:i,animation:o}){var a,l;const{scene:c}=bB(e),{animations:d}=bB("MALE"===t?"https://assets.memori.ai/api/v2/asset/b11eef07-c45b-4959-9d43-be8105365c1f.glb":"https://assets.memori.ai/api/v2/asset/24dc2bd7-d6b5-4492-ab29-791928b0a669.glb"),{animations:f}=bB("MALE"===t?"https://assets.memori.ai/api/v2/asset/2150d3d3-b77d-4489-8455-e6239334e8a7.glb":"https://assets.memori.ai/api/v2/asset/0a04e5b2-1a02-4964-9534-75c2a7574660.glb"),{nodes:h,materials:p}=iB(c),m=QB(d,c),g=QB(f.filter((e=>"Loading"===e.name)),c);AB(n,h),KB(!!r,h),ej("Loading"===o,h),rj("Sad"!==o&&"Loading"!==o,h),(0,u.useEffect)((()=>(TB(p),i&&i(),()=>{Object.values(p).forEach(mB),Object.values(h).filter(IB).forEach(mB)})),[p,h,e,i]);try{o&&o in m.actions?(Object.keys(m.actions).forEach((e=>{let t=m.actions[e];t&&(e===o&&"Loading"!==o?t.fadeIn(.3).play():t.fadeOut(.3).stop())})),"Loading"===o?null===(a=g.actions.Loading)||void 0===a||a.fadeIn(.3).play():null===(l=g.actions.Loading)||void 0===l||l.fadeOut(.3).stop()):Object.values(m.actions).forEach((e=>{e&&(null==e||e.fadeOut(.2).reset().stop())}))}catch(e){console.log(e)}return(0,s.jsx)("group",{position:ij,rotation:oj,children:(0,s.jsx)("primitive",{object:c})})}let sj=0;const lj=r(pD)((e=>(MR.onStart=(t,n,r)=>{e({active:!0,item:t,loaded:n,total:r,progress:(n-sj)/(r-sj)*100})},MR.onLoad=()=>{e({active:!1})},MR.onError=t=>e((e=>({errors:[...e.errors,t]}))),MR.onProgress=(t,n,r)=>{n===r&&(sj=r),e({active:!0,item:t,loaded:n,total:r,progress:(n-sj)/(r-sj)*100||100})},{errors:[],active:!1,progress:0,item:"",loaded:0,total:0})));function cj(){return cj=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},cj.apply(this,arguments)}u=a("85Hg2"),c=a("2BCLI");const uj=new d_,dj=new d_,fj=new d_;function hj(e,t,n){const r=uj.setFromMatrixPosition(e.matrixWorld);r.project(t);const i=n.width/2,o=n.height/2;return[r.x*i+i,-r.y*o+o]}const pj=e=>Math.abs(e)<1e-10?0:e;function mj(e,t,n=""){let r="matrix3d(";for(let n=0;16!==n;n++)r+=pj(t[n]*e.elements[n])+(15!==n?",":")");return n+r}const gj=(vj=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>mj(e,vj));var vj;const yj=(e,t)=>{return mj(e,[1/(n=t),1/n,1/n,1,-1/n,-1/n,-1/n,-1,1/n,1/n,1/n,1,1,1,1,1],"translate(-50%,-50%)");var n},bj=u.forwardRef((({children:e,eps:t=.001,style:n,className:r,prepend:i,center:o,fullscreen:a,portal:s,distanceFactor:l,sprite:d=!1,transform:f=!1,occlude:h,onOcclude:p,zIndexRange:m=[16777271,0],calculatePosition:g=hj,as:v="div",wrapperClass:y,pointerEvents:b="auto",...w},x)=>{var S;const M=tB((({gl:e})=>e)),_=tB((({camera:e})=>e)),A=tB((({scene:e})=>e)),E=tB((({size:e})=>e)),C=tB((({raycaster:e})=>e)),[k]=u.useState((()=>document.createElement(v))),T=u.useRef(null),I=u.useRef(0),O=u.useRef([0,0]),R=u.useRef(null),P=u.useRef(null),N=null!==(S=null==s?void 0:s.current)&&void 0!==S?S:M.domElement.parentNode;u.useEffect((()=>{if(T.current){if(A.updateMatrixWorld(),f)k.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const e=g(T.current,_,E);k.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return N&&(i?N.prepend(k):N.appendChild(k)),()=>{N&&N.removeChild(k),c.unmountComponentAtNode(k)}}}),[N,f]),u.useLayoutEffect((()=>{y&&(k.className=y)}),[y]);const L=u.useMemo((()=>f?{position:"absolute",top:0,left:0,width:E.width,height:E.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:o?"translate3d(-50%,-50%,0)":"none",...a&&{top:-E.height/2,left:-E.width/2,width:E.width,height:E.height},...n}),[n,o,a,E,f]),D=u.useMemo((()=>({position:"absolute",pointerEvents:b})),[b]);u.useLayoutEffect((()=>{f?c.render(u.createElement("div",{ref:R,style:L},u.createElement("div",{ref:P,style:D},u.createElement("div",{ref:x,className:r,style:n,children:e}))),k):c.render(u.createElement("div",{ref:x,style:L,className:r,children:e}),k)}));const B=u.useRef(!0);return nB((()=>{if(T.current){_.updateMatrixWorld(),T.current.updateWorldMatrix(!0,!1);const e=f?O.current:g(T.current,_,E);if(f||Math.abs(I.current-_.zoom)>t||Math.abs(O.current[0]-e[0])>t||Math.abs(O.current[1]-e[1])>t){const t=function(e,t){const n=uj.setFromMatrixPosition(e.matrixWorld),r=dj.setFromMatrixPosition(t.matrixWorld),i=n.sub(r),o=t.getWorldDirection(fj);return i.angleTo(o)>Math.PI/2}(T.current,_);let n=!1;"boolean"==typeof h?!0===h&&(n=[A]):Array.isArray(h)&&(n=h.map((e=>e.current)));const r=B.current;if(n){const e=function(e,t,n,r){const i=uj.setFromMatrixPosition(e.matrixWorld),o=i.clone();o.project(t),n.setFromCamera(o,t);const a=n.intersectObjects(r,!0);if(a.length){const e=a[0].distance;return i.distanceTo(n.ray.origin)<e}return!0}(T.current,_,C,n);B.current=e&&!t}else B.current=!t;if(r!==B.current&&(p?p(!B.current):k.style.display=B.current?"block":"none"),k.style.zIndex=`${function(e,t,n){if(t instanceof wE||t instanceof WE){const r=uj.setFromMatrixPosition(e.matrixWorld),i=dj.setFromMatrixPosition(t.matrixWorld),o=r.distanceTo(i),a=(n[1]-n[0])/(t.far-t.near),s=n[1]-a*t.far;return Math.round(a*o+s)}}(T.current,_,m)}`,f){const[e,t]=[E.width/2,E.height/2],n=_.projectionMatrix.elements[5]*t,{isOrthographicCamera:r,top:i,left:o,bottom:a,right:s}=_,c=gj(_.matrixWorldInverse),u=r?`scale(${n})translate(${pj(-(s+o)/2)}px,${pj((i+a)/2)}px)`:`translateZ(${n}px)`;let f=T.current.matrixWorld;d&&(f=_.matrixWorldInverse.clone().transpose().copyPosition(f).scale(T.current.scale),f.elements[3]=f.elements[7]=f.elements[11]=0,f.elements[15]=1),k.style.width=E.width+"px",k.style.height=E.height+"px",k.style.perspective=r?"":`${n}px`,R.current&&P.current&&(R.current.style.transform=`${u}${c}translate(${e}px,${t}px)`,P.current.style.transform=yj(f,1/((l||10)/400)))}else{const t=void 0===l?1:function(e,t){if(t instanceof WE)return t.zoom;if(t instanceof wE){const n=uj.setFromMatrixPosition(e.matrixWorld),r=dj.setFromMatrixPosition(t.matrixWorld),i=t.fov*Math.PI/180,o=n.distanceTo(r);return 1/(2*Math.tan(i/2)*o)}return 1}(T.current,_)*l;k.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}O.current=e,I.current=_.zoom}}})),u.createElement("group",cj({},w,{ref:T}))}));var wj=({fallbackImg:e})=>{const{progress:t}=lj();return(0,s.jsx)(bj,{center:!0,className:"avatar-loader",children:(0,s.jsx)(dp,{spinning:!0,children:e?(0,s.jsxs)("figure",{children:[(0,s.jsx)("img",{src:e,alt:`${Math.round(t)}% loaded`,title:`${Math.round(t)}% loaded`}),(0,s.jsx)("figcaption",{children:`${Math.round(t)}%`})]}):(0,s.jsxs)(s.Fragment,{children:[Math.round(t)," % loaded"]})})})};u=a("85Hg2");class xj extends yE{constructor(){super({uniforms:{depth:{value:null},opacity:{value:1},attenuation:{value:2.5},anglePower:{value:12},spotPosition:{value:new d_(0,0,0)},lightColor:{value:new QM("white")},cameraNear:{value:0},cameraFar:{value:1},resolution:{value:new NM(0,0)}},transparent:!0,depthWrite:!1,vertexShader:"\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n varying float vViewZ;\n varying float vIntensity;\n uniform vec3 spotPosition;\n uniform float attenuation; \n\n void main() {\n // compute intensity\n vNormal = normalize( normalMatrix * normal );\n vec4 worldPosition\t= modelMatrix * vec4( position, 1.0 );\n vWorldPosition = worldPosition.xyz;\n vec4 viewPosition = viewMatrix * worldPosition;\n vViewZ = viewPosition.z;\n float intensity\t= distance(worldPosition.xyz, spotPosition) / attenuation;\n intensity\t= 1.0 - clamp(intensity, 0.0, 1.0);\n vIntensity = intensity; \n // set gl_Position\n gl_Position\t= projectionMatrix * viewPosition;\n\n }",fragmentShader:"\n #include <packing>\n\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n uniform vec3 lightColor;\n uniform vec3 spotPosition;\n uniform float attenuation;\n uniform float anglePower;\n uniform sampler2D depth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n varying float vViewZ;\n varying float vIntensity;\n uniform float opacity;\n\n float readDepth( sampler2D depthSampler, vec2 coord ) {\n float fragCoordZ = texture2D( depthSampler, coord ).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZ;\n }\n\n void main() {\n float d = 1.0;\n bool isSoft = resolution[0] > 0.0 && resolution[1] > 0.0;\n if (isSoft) {\n vec2 sUv = gl_FragCoord.xy / resolution;\n d = readDepth(depth, sUv);\n }\n float intensity = vIntensity;\n vec3 normal\t= vec3(vNormal.x, vNormal.y, abs(vNormal.z));\n float angleIntensity\t= pow( dot(normal, vec3(0.0, 0.0, 1.0)), anglePower );\n intensity\t*= angleIntensity;\n // fades when z is close to sampled depth, meaning the cone is intersecting existing geometry\n if (isSoft) {\n intensity\t*= smoothstep(0., 1., vViewZ - d);\n }\n gl_FragColor = vec4(lightColor, intensity * opacity);\n\n #include <tonemapping_fragment>\n\t #include <encodings_fragment>\n }"})}}const Sj=new d_,Mj=u.forwardRef((({opacity:e=1,radiusTop:t,radiusBottom:n,depthBuffer:r,color:i="white",distance:o=5,angle:a=.15,attenuation:s=5,anglePower:l=5,...c},d)=>{const f=u.useRef(null),h=tB((e=>e.size)),p=tB((e=>e.camera)),m=tB((e=>e.viewport.dpr)),[g]=u.useState((()=>new xj));t=void 0===t?.1:t,n=void 0===n?7*a:n,nB((()=>{g.uniforms.spotPosition.value.copy(f.current.getWorldPosition(Sj)),f.current.lookAt(f.current.parent.target.getWorldPosition(Sj))}));const v=u.useMemo((()=>{const e=new qI(t,n,o,128,64,!0);return e.applyMatrix4((new H_).makeTranslation(0,-o/2,0)),e.applyMatrix4((new H_).makeRotationX(-Math.PI/2)),e}),[a,o,t,n]);return u.createElement("spotLight",cj({ref:d,angle:a,color:i,distance:o},c),u.createElement("mesh",{ref:f,geometry:v,raycast:()=>null},u.createElement("primitive",{object:g,attach:"material","uniforms-opacity-value":e,"uniforms-lightColor-value":i,"uniforms-attenuation-value":s,"uniforms-anglePower-value":l,"uniforms-depth-value":r,"uniforms-cameraNear-value":p.near,"uniforms-cameraFar-value":p.far,"uniforms-resolution-value":r?[h.width*m,h.height*m]:[0,0]})))}));u=a("85Hg2");class _j extends RR{constructor(e){super(e),this.type=Nx}parse(e){const t=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},n=function(e,t,n){t=t||1024;let r=e.pos,i=-1,o=0,a="",s=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));for(;0>(i=s.indexOf("\n"))&&o<t&&r<e.byteLength;)a+=s,o+=s.length,r+=128,s+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));return-1<i&&(!1!==n&&(e.pos+=o+i+1),a+s.slice(0,i))},r=function(e,t,n,r){const i=e[t+3],o=Math.pow(2,i-128)/255;n[r+0]=e[t+0]*o,n[r+1]=e[t+1]*o,n[r+2]=e[t+2]*o,n[r+3]=1},i=function(e,t,n,r){const i=e[t+3],o=Math.pow(2,i-128)/255;n[r+0]=jN.toHalfFloat(Math.min(e[t+0]*o,65504)),n[r+1]=jN.toHalfFloat(Math.min(e[t+1]*o,65504)),n[r+2]=jN.toHalfFloat(Math.min(e[t+2]*o,65504)),n[r+3]=jN.toHalfFloat(1)},o=new Uint8Array(e);o.pos=0;const a=function(e){const r=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,i=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*FORMAT=(\S+)\s*$/,a=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,s={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,c;if(e.pos>=e.byteLength||!(l=n(e)))return t(1,"no header found");if(!(c=l.match(/^#\?(\S+)/)))return t(3,"bad initial token");for(s.valid|=1,s.programtype=c[1],s.string+=l+"\n";l=n(e),!1!==l;)if(s.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(r))&&(s.gamma=parseFloat(c[1])),(c=l.match(i))&&(s.exposure=parseFloat(c[1])),(c=l.match(o))&&(s.valid|=2,s.format=c[1]),(c=l.match(a))&&(s.valid|=4,s.height=parseInt(c[1],10),s.width=parseInt(c[2],10)),2&s.valid&&4&s.valid)break}else s.comments+=l+"\n";return 2&s.valid?4&s.valid?s:t(3,"missing image size specifier"):t(3,"missing format specifier")}(o);if(-1!==a){const e=a.width,n=a.height,s=function(e,n,r){const i=n;if(i<8||i>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(i!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");const o=new Uint8Array(4*n*r);if(!o.length)return t(4,"unable to allocate buffer space");let a=0,s=0;const l=4*i,c=new Uint8Array(4),u=new Uint8Array(l);let d=r;for(;d>0&&s<e.byteLength;){if(s+4>e.byteLength)return t(1);if(c[0]=e[s++],c[1]=e[s++],c[2]=e[s++],c[3]=e[s++],2!=c[0]||2!=c[1]||(c[2]<<8|c[3])!=i)return t(3,"bad rgbe scanline format");let n,r=0;for(;r<l&&s<e.byteLength;){n=e[s++];const i=n>128;if(i&&(n-=128),0===n||r+n>l)return t(3,"bad scanline data");if(i){const t=e[s++];for(let e=0;e<n;e++)u[r++]=t}else u.set(e.subarray(s,s+n),r),r+=n,s+=n}const f=i;for(let e=0;e<f;e++){let t=0;o[a]=u[e+t],t+=i,o[a+1]=u[e+t],t+=i,o[a+2]=u[e+t],t+=i,o[a+3]=u[e+t],a+=4}d--}return o}(o.subarray(o.pos),e,n);if(-1!==s){let t,o,l;switch(this.type){case Px:l=s.length/4;const e=new Float32Array(4*l);for(let t=0;t<l;t++)r(s,4*t,e,4*t);t=e,o=Px;break;case Nx:l=s.length/4;const n=new Uint16Array(4*l);for(let e=0;e<l;e++)i(s,4*e,n,4*e);t=n,o=Nx;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:e,height:n,data:t,header:a.string,gamma:a.gamma,exposure:a.exposure,type:o}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,r){return super.load(e,(function(e,n){switch(e.type){case Px:case Nx:e.encoding=DS,e.minFilter=Sx,e.magFilter=Sx,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,r)}}const Aj={sunset:"venice/venice_sunset_1k.hdr",dawn:"kiara/kiara_1_dawn_1k.hdr",night:"dikhololo/dikhololo_night_1k.hdr",warehouse:"empty-wharehouse/empty_warehouse_01_1k.hdr",forest:"forrest-slope/forest_slope_1k.hdr",apartment:"lebombo/lebombo_1k.hdr",studio:"studio-small-3/studio_small_03_1k.hdr",city:"potsdamer-platz/potsdamer_platz_1k.hdr",park:"rooitou/rooitou_park_1k.hdr",lobby:"st-fagans/st_fagans_interior_1k.hdr"},Ej=e=>{return(t=e).current&&t.current.isScene?e.current:e;var t};function Cj(e){return e.map?u.createElement(kj,e):e.children?u.createElement(Tj,e):u.createElement(Ij,e)}function kj({scene:e,background:t=!1,map:n}){const r=tB((e=>e.scene));return u.useLayoutEffect((()=>{if(n){const i=Ej(e||r),o=i.background,a=i.environment;return"only"!==t&&(i.environment=n),t&&(i.background=n),()=>{"only"!==t&&(i.environment=a),t&&(i.background=o)}}}),[e,n]),null}function Tj({children:e,near:t=1,far:n=1e3,resolution:r=256,frames:i=1,background:o=!1,scene:a,files:s,path:l,preset:c,extensions:d}){const f=tB((e=>e.gl)),h=tB((e=>e.scene)),p=u.useRef(null),[m]=u.useState((()=>new hT)),g=u.useMemo((()=>{const e=new _E(r);return e.texture.type=Nx,e}),[r]);u.useLayoutEffect((()=>{1===i&&p.current.update(f,m);const e=Ej(a||h),t=e.background,n=e.environment;return"only"!==o&&(e.environment=g.texture),o&&(e.background=g.texture),()=>{"only"!==o&&(e.environment=n),o&&(e.background=t)}}),[e,a]);let v=1;return nB((()=>{(i===1/0||v<i)&&(p.current.update(f,m),v++)})),u.createElement(u.Fragment,null,gB(u.createElement(u.Fragment,null,e,u.createElement("cubeCamera",{ref:p,args:[t,n,g]}),(s||c)&&u.createElement(kj,{background:!0,files:s,preset:c,path:l,extensions:d,scene:m})),m))}function Ij({background:e=!1,files:t=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"],path:n="",preset:r,scene:i,extensions:o}){if(r){if(!(r in Aj))throw new Error("Preset must be one of: "+Object.keys(Aj).join(", "));t=Aj[r],n="https://market-assets.fra1.cdn.digitaloceanspaces.com/market-assets/hdris/"}const a=tB((e=>e.scene)),s=Array.isArray(t),l=aB(s?OR:_j,s?[t]:t,(e=>{e.setPath(n),null==e.setDataType||e.setDataType(Px),o&&o(e)})),c=s?l[0]:l;return c.mapping=s?cx:dx,u.useLayoutEffect((()=>{const t=Ej(i||a),n=t.background,r=t.environment;return"only"!==e&&(t.environment=c),e&&(t.background=c),()=>{"only"!==e&&(t.environment=r),e&&(t.background=n)}}),[c,e,i]),null}u=a("85Hg2");function Oj(e){return Oj="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Oj(e)}function Rj(e,t){if("object"!==Oj(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==Oj(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function Pj(e){var t=Rj(e,"string");return"symbol"===Oj(t)?t:String(t)}function Nj(e,t,n){return(t=Pj(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const Lj=(e,t)=>(e%t+t)%t;class Dj extends bM{constructor(e,t){super(),Nj(this,"object",void 0),Nj(this,"domElement",void 0),Nj(this,"enabled",!0),Nj(this,"target",new d_),Nj(this,"minDistance",0),Nj(this,"maxDistance",1/0),Nj(this,"minZoom",0),Nj(this,"maxZoom",1/0),Nj(this,"minPolarAngle",0),Nj(this,"maxPolarAngle",Math.PI),Nj(this,"minAzimuthAngle",-1/0),Nj(this,"maxAzimuthAngle",1/0),Nj(this,"enableDamping",!1),Nj(this,"dampingFactor",.05),Nj(this,"enableZoom",!0),Nj(this,"zoomSpeed",1),Nj(this,"enableRotate",!0),Nj(this,"rotateSpeed",1),Nj(this,"enablePan",!0),Nj(this,"panSpeed",1),Nj(this,"screenSpacePanning",!0),Nj(this,"keyPanSpeed",7),Nj(this,"autoRotate",!1),Nj(this,"autoRotateSpeed",2),Nj(this,"reverseOrbit",!1),Nj(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),Nj(this,"mouseButtons",{LEFT:uw.ROTATE,MIDDLE:uw.DOLLY,RIGHT:uw.PAN}),Nj(this,"touches",{ONE:dw.ROTATE,TWO:dw.DOLLY_PAN}),Nj(this,"target0",void 0),Nj(this,"position0",void 0),Nj(this,"zoom0",void 0),Nj(this,"_domElementKeyEvents",null),Nj(this,"getPolarAngle",void 0),Nj(this,"getAzimuthalAngle",void 0),Nj(this,"setPolarAngle",void 0),Nj(this,"setAzimuthalAngle",void 0),Nj(this,"getDistance",void 0),Nj(this,"listenToKeyEvents",void 0),Nj(this,"saveState",void 0),Nj(this,"reset",void 0),Nj(this,"update",void 0),Nj(this,"connect",void 0),Nj(this,"dispose",void 0),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object instanceof wE?this.object.zoom:1,this.getPolarAngle=()=>c.phi,this.getAzimuthalAngle=()=>c.theta,this.setPolarAngle=e=>{let t=Lj(e,2*Math.PI),r=c.phi;r<0&&(r+=2*Math.PI),t<0&&(t+=2*Math.PI);let i=Math.abs(t-r);2*Math.PI-i<i&&(t<r?t+=2*Math.PI:r+=2*Math.PI),u.phi=t-r,n.update()},this.setAzimuthalAngle=e=>{let t=Lj(e,2*Math.PI),r=c.theta;r<0&&(r+=2*Math.PI),t<0&&(t+=2*Math.PI);let i=Math.abs(t-r);2*Math.PI-i<i&&(t<r?t+=2*Math.PI:r+=2*Math.PI),u.theta=t-r,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=e=>{e.addEventListener("keydown",q),this._domElementKeyEvents=e},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object instanceof wE?n.object.zoom:1},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object instanceof wE&&(n.object.zoom=n.zoom0,n.object.updateProjectionMatrix()),n.dispatchEvent(r),n.update(),s=a.NONE},this.update=(()=>{const t=new d_,i=(new u_).setFromUnitVectors(e.up,new d_(0,1,0)),o=i.clone().invert(),p=new d_,m=new u_,g=2*Math.PI;return function(){const e=n.object.position;t.copy(e).sub(n.target),t.applyQuaternion(i),c.setFromVector3(t),n.autoRotate&&s===a.NONE&&E(2*Math.PI/60/60*n.autoRotateSpeed),n.enableDamping?(c.theta+=u.theta*n.dampingFactor,c.phi+=u.phi*n.dampingFactor):(c.theta+=u.theta,c.phi+=u.phi);let v=n.minAzimuthAngle,y=n.maxAzimuthAngle;return isFinite(v)&&isFinite(y)&&(v<-Math.PI?v+=g:v>Math.PI&&(v-=g),y<-Math.PI?y+=g:y>Math.PI&&(y-=g),c.theta=v<=y?Math.max(v,Math.min(y,c.theta)):c.theta>(v+y)/2?Math.max(v,c.theta):Math.min(y,c.theta)),c.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,c.phi)),c.makeSafe(),c.radius*=d,c.radius=Math.max(n.minDistance,Math.min(n.maxDistance,c.radius)),!0===n.enableDamping?n.target.addScaledVector(f,n.dampingFactor):n.target.add(f),t.setFromSpherical(c),t.applyQuaternion(o),e.copy(n.target).add(t),n.object.lookAt(n.target),!0===n.enableDamping?(u.theta*=1-n.dampingFactor,u.phi*=1-n.dampingFactor,f.multiplyScalar(1-n.dampingFactor)):(u.set(0,0,0),f.set(0,0,0)),d=1,!!(h||p.distanceToSquared(n.object.position)>l||8*(1-m.dot(n.object.quaternion))>l)&&(n.dispatchEvent(r),p.copy(n.object.position),m.copy(n.object.quaternion),h=!1,!0)}})(),this.connect=e=>{e===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),n.domElement=e,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",K),n.domElement.addEventListener("pointerdown",z),n.domElement.addEventListener("pointercancel",W),n.domElement.addEventListener("wheel",G)},this.dispose=()=>{var e,t,r,i,o,a;null===(e=n.domElement)||void 0===e||e.removeEventListener("contextmenu",K),null===(t=n.domElement)||void 0===t||t.removeEventListener("pointerdown",z),null===(r=n.domElement)||void 0===r||r.removeEventListener("pointercancel",W),null===(i=n.domElement)||void 0===i||i.removeEventListener("wheel",G),null===(o=n.domElement)||void 0===o||o.ownerDocument.removeEventListener("pointermove",H),null===(a=n.domElement)||void 0===a||a.ownerDocument.removeEventListener("pointerup",V),null!==n._domElementKeyEvents&&n._domElementKeyEvents.removeEventListener("keydown",q)};const n=this,r={type:"change"},i={type:"start"},o={type:"end"},a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=a.NONE;const l=1e-6,c=new XP,u=new XP;let d=1;const f=new d_;let h=!1;const p=new NM,m=new NM,g=new NM,v=new NM,y=new NM,b=new NM,w=new NM,x=new NM,S=new NM,M=[],_={};function A(){return Math.pow(.95,n.zoomSpeed)}function E(e){n.reverseOrbit?u.theta+=e:u.theta-=e}function C(e){n.reverseOrbit?u.phi+=e:u.phi-=e}const k=(()=>{const e=new d_;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),f.add(e)}})(),T=(()=>{const e=new d_;return function(t,r){!0===n.screenSpacePanning?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),f.add(e)}})(),I=(()=>{const e=new d_;return function(t,r){const i=n.domElement;if(i&&n.object instanceof wE&&n.object.isPerspectiveCamera){const o=n.object.position;e.copy(o).sub(n.target);let a=e.length();a*=Math.tan(n.object.fov/2*Math.PI/180),k(2*t*a/i.clientHeight,n.object.matrix),T(2*r*a/i.clientHeight,n.object.matrix)}else i&&n.object instanceof WE&&n.object.isOrthographicCamera?(k(t*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),T(r*(n.object.top-n.object.bottom)/n.object.zoom/i.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function O(e){n.object instanceof wE&&n.object.isPerspectiveCamera?d/=e:n.object instanceof WE&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*e)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function R(e){n.object instanceof wE&&n.object.isPerspectiveCamera?d*=e:n.object instanceof WE&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/e)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function P(e){p.set(e.clientX,e.clientY)}function N(e){v.set(e.clientX,e.clientY)}function L(){if(1==M.length)p.set(M[0].pageX,M[0].pageY);else{const e=.5*(M[0].pageX+M[1].pageX),t=.5*(M[0].pageY+M[1].pageY);p.set(e,t)}}function D(){if(1==M.length)v.set(M[0].pageX,M[0].pageY);else{const e=.5*(M[0].pageX+M[1].pageX),t=.5*(M[0].pageY+M[1].pageY);v.set(e,t)}}function B(){const e=M[0].pageX-M[1].pageX,t=M[0].pageY-M[1].pageY,n=Math.sqrt(e*e+t*t);w.set(0,n)}function j(e){if(1==M.length)m.set(e.pageX,e.pageY);else{const t=Q(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);m.set(n,r)}g.subVectors(m,p).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(E(2*Math.PI*g.x/t.clientHeight),C(2*Math.PI*g.y/t.clientHeight)),p.copy(m)}function F(e){if(1==M.length)y.set(e.pageX,e.pageY);else{const t=Q(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);y.set(n,r)}b.subVectors(y,v).multiplyScalar(n.panSpeed),I(b.x,b.y),v.copy(y)}function U(e){const t=Q(e),r=e.pageX-t.x,i=e.pageY-t.y,o=Math.sqrt(r*r+i*i);x.set(0,o),S.set(0,Math.pow(x.y/w.y,n.zoomSpeed)),O(S.y),w.copy(x)}function z(e){if(!1!==n.enabled){var t,r;if(0===M.length)null===(t=n.domElement)||void 0===t||t.ownerDocument.addEventListener("pointermove",H),null===(r=n.domElement)||void 0===r||r.ownerDocument.addEventListener("pointerup",V);!function(e){M.push(e)}(e),"touch"===e.pointerType?function(e){switch(J(e),M.length){case 1:switch(n.touches.ONE){case dw.ROTATE:if(!1===n.enableRotate)return;L(),s=a.TOUCH_ROTATE;break;case dw.PAN:if(!1===n.enablePan)return;D(),s=a.TOUCH_PAN;break;default:s=a.NONE}break;case 2:switch(n.touches.TWO){case dw.DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&B(),n.enablePan&&D(),s=a.TOUCH_DOLLY_PAN;break;case dw.DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&B(),n.enableRotate&&L(),s=a.TOUCH_DOLLY_ROTATE;break;default:s=a.NONE}break;default:s=a.NONE}s!==a.NONE&&n.dispatchEvent(i)}(e):function(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case uw.DOLLY:if(!1===n.enableZoom)return;!function(e){w.set(e.clientX,e.clientY)}(e),s=a.DOLLY;break;case uw.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;N(e),s=a.PAN}else{if(!1===n.enableRotate)return;P(e),s=a.ROTATE}break;case uw.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;P(e),s=a.ROTATE}else{if(!1===n.enablePan)return;N(e),s=a.PAN}break;default:s=a.NONE}s!==a.NONE&&n.dispatchEvent(i)}(e)}}function H(e){!1!==n.enabled&&("touch"===e.pointerType?function(e){switch(J(e),s){case a.TOUCH_ROTATE:if(!1===n.enableRotate)return;j(e),n.update();break;case a.TOUCH_PAN:if(!1===n.enablePan)return;F(e),n.update();break;case a.TOUCH_DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(e){n.enableZoom&&U(e),n.enablePan&&F(e)}(e),n.update();break;case a.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(e){n.enableZoom&&U(e),n.enableRotate&&j(e)}(e),n.update();break;default:s=a.NONE}}(e):function(e){if(!1===n.enabled)return;switch(s){case a.ROTATE:if(!1===n.enableRotate)return;!function(e){m.set(e.clientX,e.clientY),g.subVectors(m,p).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(E(2*Math.PI*g.x/t.clientHeight),C(2*Math.PI*g.y/t.clientHeight)),p.copy(m),n.update()}(e);break;case a.DOLLY:if(!1===n.enableZoom)return;!function(e){x.set(e.clientX,e.clientY),S.subVectors(x,w),S.y>0?O(A()):S.y<0&&R(A()),w.copy(x),n.update()}(e);break;case a.PAN:if(!1===n.enablePan)return;!function(e){y.set(e.clientX,e.clientY),b.subVectors(y,v).multiplyScalar(n.panSpeed),I(b.x,b.y),v.copy(y),n.update()}(e)}}(e))}function V(e){var t,r,i;(Y(e),0===M.length)&&(null===(t=n.domElement)||void 0===t||t.releasePointerCapture(e.pointerId),null===(r=n.domElement)||void 0===r||r.ownerDocument.removeEventListener("pointermove",H),null===(i=n.domElement)||void 0===i||i.ownerDocument.removeEventListener("pointerup",V));n.dispatchEvent(o),s=a.NONE}function W(e){Y(e)}function G(e){!1===n.enabled||!1===n.enableZoom||s!==a.NONE&&s!==a.ROTATE||(e.preventDefault(),n.dispatchEvent(i),function(e){e.deltaY<0?R(A()):e.deltaY>0&&O(A()),n.update()}(e),n.dispatchEvent(o))}function q(e){!1!==n.enabled&&!1!==n.enablePan&&function(e){let t=!1;switch(e.code){case n.keys.UP:I(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:I(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:I(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:I(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function K(e){!1!==n.enabled&&e.preventDefault()}function Y(e){delete _[e.pointerId];for(let t=0;t<M.length;t++)if(M[t].pointerId==e.pointerId)return void M.splice(t,1)}function J(e){let t=_[e.pointerId];void 0===t&&(t=new NM,_[e.pointerId]=t),t.set(e.pageX,e.pageY)}function Q(e){const t=e.pointerId===M[0].pointerId?M[1]:M[0];return _[t.pointerId]}void 0!==t&&this.connect(t),this.update()}}const Bj=u.forwardRef((({makeDefault:e,camera:t,regress:n,domElement:r,enableDamping:i=!0,onChange:o,onStart:a,onEnd:s,...l},c)=>{const d=tB((e=>e.invalidate)),f=tB((e=>e.camera)),h=tB((e=>e.gl)),p=tB((e=>e.events)),m=tB((e=>e.set)),g=tB((e=>e.get)),v=tB((e=>e.performance)),y=t||f,b=r||p.connected||h.domElement,w=u.useMemo((()=>new Dj(y)),[y]);return nB((()=>{w.enabled&&w.update()})),u.useEffect((()=>(w.connect(b),()=>{w.dispose()})),[b,n,w,d]),u.useEffect((()=>{const e=e=>{d(),n&&v.regress(),o&&o(e)};return w.addEventListener("change",e),a&&w.addEventListener("start",a),s&&w.addEventListener("end",s),()=>{a&&w.removeEventListener("start",a),s&&w.removeEventListener("end",s),w.removeEventListener("change",e)}}),[o,a,s]),u.useEffect((()=>{if(e){const e=g().controls;return m({controls:w}),()=>m({controls:e})}}),[e,w]),u.createElement("primitive",cj({ref:c,object:w,enableDamping:i},l))})),jj={width:"250px",height:"250px",backgroundColor:"white",borderRadius:"100%"},Fj={width:"500px",height:"500px",backgroundColor:"white"};function Uj({url:e,sex:t,fallbackImg:n,style:r,rotateAvatar:i,eyeBlink:o,headMovement:a,speaking:l,fallback:c,halfBody:d=!0,animation:f}){const h=d?jj:Fj;return(0,s.jsx)($D,{style:r||h,camera:d?{fov:40,position:[0,0,.6]}:{fov:40,position:[0,175e-7,3]},children:(0,s.jsxs)(u.Suspense,{fallback:c||(0,s.jsx)(wj,{fallbackImg:n}),children:["android"===((null===(p=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===p?void 0:p.platform)||(null===navigator||void 0===navigator?void 0:navigator.platform)||"unknown").toLowerCase()||navigator.userAgent.includes("Android")?(0,s.jsx)(Mj,{distance:100,position:[-.3,.2,1.25],angle:Math.PI/2,attenuation:5,anglePower:5}):(0,s.jsx)(Cj,{preset:"sunset"}),i&&d&&(0,s.jsx)(Bj,{enablePan:!1,enableZoom:!1}),d?(0,s.jsx)(JB,{url:e,eyeBlink:o,headMovement:a,speaking:l}):(0,s.jsx)(aj,{url:e,sex:t,eyeBlink:o,headMovement:a,speaking:l,animation:f})]})});var p}Jd=a("4IUwl");var zj=({avatar:e,speaking:t=!1})=>(0,s.jsxs)("div",{className:r(Jd)("memori-blob",{"memori-blob--speaking":t}),children:[e&&(0,s.jsx)("figure",{children:(0,s.jsx)("img",{src:e,alt:"",role:"presentation"})}),(0,s.jsx)("div",{className:"mainDiv"}),(0,s.jsx)("div",{className:"mainDiv"}),(0,s.jsx)("div",{className:"mainDiv"}),(0,s.jsx)("div",{className:"mainDiv"}),(0,s.jsx)("div",{className:"mainDiv"})]});var Hj=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z"})});var Vj=({className:e,title:t})=>(0,s.jsxs)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:[(0,s.jsx)("path",{d:"M942.2 486.2Q889.47 375.11 816.7 305l-50.88 50.88C807.31 395.53 843.45 447.4 874.7 512 791.5 684.2 673.4 766 512 766q-72.67 0-133.87-22.38L323 798.75Q408 838 512 838q288.3 0 430.2-300.3a60.29 60.29 0 000-51.5zm-63.57-320.64L836 122.88a8 8 0 00-11.32 0L715.31 232.2Q624.86 186 512 186q-288.3 0-430.2 300.3a60.3 60.3 0 000 51.5q56.69 119.4 136.5 191.41L112.48 835a8 8 0 000 11.31L155.17 889a8 8 0 0011.31 0l712.15-712.12a8 8 0 000-11.32zM149.3 512C232.6 339.8 350.7 258 512 258c54.54 0 104.13 9.36 149.12 28.39l-70.3 70.3a176 176 0 00-238.13 238.13l-83.42 83.42C223.1 637.49 183.3 582.28 149.3 512zm246.7 0a112.11 112.11 0 01146.2-106.69L401.31 546.2A112 112 0 01396 512z"}),(0,s.jsx)("path",{d:"M508 624c-3.46 0-6.87-.16-10.25-.47l-52.82 52.82a176.09 176.09 0 00227.42-227.42l-52.82 52.82c.31 3.38.47 6.79.47 10.25a111.94 111.94 0 01-112 112z"})]});var Wj=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"})});Jd=a("4IUwl");var Gj=(0,u.memo)((({memori:e,integration:t,integrationConfig:n,tenant:i,instruct:o=!1,avatar3dVisible:a=!1,setAvatar3dVisible:l,hasUserActivatedSpeak:c=!1,isPlayingAudio:d=!1,loading:f=!1,baseUrl:h,apiUrl:p})=>{const{t:m}=Te(),[g,v]=(0,u.useState)(!1);(0,u.useEffect)((()=>{v(!0)}),[]);const y=(0,u.useMemo)((()=>d?["Talk 1","Talk 2","Talk 3"][Math.round(2*Math.random())]:f?"Loading":["Idle","Idle 1","Idle 2","Idle 3"][Math.round(3*Math.random())]),[d,f]);return(0,s.jsxs)(s.Fragment,{children:["readyplayerme"!==(null==n?void 0:n.avatar)&&"readyplayerme-full"!==(null==n?void 0:n.avatar)&&"customglb"!==(null==n?void 0:n.avatar)||!(null==n?void 0:n.avatarURL)?(0,s.jsx)("div",{className:"memori--blob-container",children:g&&(0,s.jsx)(zj,{avatar:"userAvatar"===(null==n?void 0:n.avatar)&&e.avatarURL&&e.avatarURL.length>0?jm({type:"avatar",tenantID:null==i?void 0:i.id,resourceURI:e.avatarURL,baseURL:h,apiURL:p}):void 0})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:r(Jd)("memori--avatar-wrapper",{hidden:!a}),children:[g&&("readyplayerme"===n.avatar||"readyplayerme-full"===n.avatar)&&(0,s.jsx)(sw,{fallback:(0,s.jsx)("div",{className:"memori--blob-container",children:g&&(0,s.jsx)(zj,{speaking:d,avatar:"userAvatar"===(null==n?void 0:n.avatar)&&e.avatarURL&&e.avatarURL.length>0?jm({type:"avatar",tenantID:null==i?void 0:i.id,resourceURI:e.avatarURL,baseURL:h,apiURL:p}):void 0})}),children:(0,s.jsx)(Uj,{url:n.avatarURL,sex:"FEMALE"===e.voiceType?"FEMALE":"MALE",fallbackImg:jm({type:"avatar",tenantID:null==i?void 0:i.id,resourceURI:e.avatarURL,baseURL:h,apiURL:p}),headMovement:!0,eyeBlink:!0,halfBody:"readyplayerme"===n.avatar,animation:y,speaking:d,style:"readyplayerme"===n.avatar?{width:"300px",height:"300px",backgroundColor:"none",borderRadius:"100%",boxShadow:"none"}:{width:"600px",height:"600px",backgroundColor:"none"}})}),g&&"customglb"===n.avatar&&(0,s.jsx)(Cg,{poster:jm({type:"avatar",tenantID:null==i?void 0:i.id,resourceURI:e.avatarURL,baseURL:h,apiURL:p}),src:n.avatarURL,alt:""})]}),(0,s.jsx)("div",{className:"memori--avatar-toggle",children:(0,s.jsx)(Zd,{ghost:!0,onClick:()=>l(!a),icon:a?(0,s.jsx)(Vj,{}):(0,s.jsx)(Hj,{}),children:(0,s.jsx)("span",{className:"memori--avatar-toggle-text",children:m(a?"hide":"show")})})})]}),o&&!c&&e.isGiver&&(null==i?void 0:i.id)&&(0,s.jsx)("div",{className:"memori--avatar-link-to-integrations",children:(0,s.jsx)("a",{className:"memori-button memori-button--circle memori-button--outlined",href:`https://${i.id}/${"it-IT"===e.culture?"it":"en"}/${e.ownerUserName}/${e.name}/integrations${(null==t?void 0:t.integrationID)?`?integration=${t.integrationID}&openAvatarModal=true`:""}`,children:(0,s.jsx)(zm,{content:m("widgetgoToIntegrationsToCustomizeAvatar"),children:(0,s.jsx)("span",{className:"memori-button--icon",children:(0,s.jsx)(Wj,{})})})})})]})}),((e,t)=>JSON.stringify(e)===JSON.stringify(t)));var qj=({instruct:e,canInstruct:t,onChangeMode:n})=>{const{t:r}=Te();return t?(0,s.jsx)("div",{className:"memori--changeMode-instruct",children:(0,s.jsxs)(Sb,{name:"instruct",value:e?"instruct":"test",defaultValue:e?"instruct":"test",className:"memori--changeMode-instruct-radio",onChange:n,children:[(0,s.jsx)(Sb.Option,{value:"instruct",className:"memori--changeMode-instruct-radio-button",children:({checked:e})=>(0,s.jsx)(Zd,{primary:e,children:r("widget.instruct")||"Instruct"})}),(0,s.jsx)(Sb.Option,{value:"test",className:"memori--changeMode-instruct-radio-button",children:({checked:e})=>(0,s.jsx)(Zd,{primary:e,children:r("widget.test")||"Test"})})]})}):null};u=a("85Hg2"),Jd=a("4IUwl");var Kj=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",className:e,"aria-label":t,children:(0,s.jsx)("path",{fill:"currentColor",d:"M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z"})});var Yj=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",viewBox:"0 0 40 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M25.085.277c-.264 0-.531.071-.777.236L8.482 10.857H1.161a.716.716 0 00-.715.714V24.43c0 .392.322.714.715.714h7.321l15.826 10.344c.246.16.518.236.777.236.745 0 1.433-.593 1.433-1.433V1.71c0-.84-.688-1.433-1.433-1.433zM23.304 30.99l-13.063-8.54-.803-.522H3.66V14.07h5.777l.799-.522 13.067-8.54V30.99zM39.534 15.148L36.967 18l2.567 2.852a1.09 1.09 0 010 1.427l-1.283 1.426a.845.845 0 01-1.284 0L34.4 20.852l-2.567 2.852a.845.845 0 01-1.283 0l-1.284-1.426a1.09 1.09 0 010-1.426L31.833 18l-2.567-2.852a1.09 1.09 0 010-1.426l1.283-1.427a.845.845 0 011.284 0l2.567 2.853 2.567-2.853a.845.845 0 011.284 0l1.283 1.427a1.09 1.09 0 010 1.426z",fill:"currentColor"})});var Jj,Qj=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M625.9 115c-5.9 0-11.9 1.6-17.4 5.3L254 352H90c-8.8 0-16 7.2-16 16v288c0 8.8 7.2 16 16 16h164l354.5 231.7c5.5 3.6 11.6 5.3 17.4 5.3 16.7 0 32.1-13.3 32.1-32.1V147.1c0-18.8-15.4-32.1-32.1-32.1zM586 803L293.4 611.7l-18-11.7H146V424h129.4l17.9-11.7L586 221v582zm348-327H806c-8.8 0-16 7.2-16 16v40c0 8.8 7.2 16 16 16h128c8.8 0 16-7.2 16-16v-40c0-8.8-7.2-16-16-16zm-41.9 261.8l-110.3-63.7a15.9 15.9 0 00-21.7 5.9l-19.9 34.5c-4.4 7.6-1.8 17.4 5.8 21.8L856.3 800a15.9 15.9 0 0021.7-5.9l19.9-34.5c4.4-7.6 1.7-17.4-5.8-21.8zM760 344a15.9 15.9 0 0021.7 5.9L892 286.2c7.6-4.4 10.2-14.2 5.8-21.8L878 230a15.9 15.9 0 00-21.7-5.9L746 287.8a15.99 15.99 0 00-5.8 21.8L760 344z"})}),Xj=(u=a("85Hg2"),(Jj=Xj||{})[Jj.Open=0]="Open",Jj[Jj.Closed=1]="Closed",Jj),Zj=(e=>(e[e.TogglePopover=0]="TogglePopover",e[e.ClosePopover=1]="ClosePopover",e[e.SetButton=2]="SetButton",e[e.SetButtonId=3]="SetButtonId",e[e.SetPanel=4]="SetPanel",e[e.SetPanelId=5]="SetPanelId",e))(Zj||{});let $j={0:e=>({...e,popoverState:$d(e.popoverState,{0:1,1:0})}),1:e=>1===e.popoverState?e:{...e,popoverState:1},2:(e,t)=>e.button===t.button?e:{...e,button:t.button},3:(e,t)=>e.buttonId===t.buttonId?e:{...e,buttonId:t.buttonId},4:(e,t)=>e.panel===t.panel?e:{...e,panel:t.panel},5:(e,t)=>e.panelId===t.panelId?e:{...e,panelId:t.panelId}},eF=(0,u.createContext)(null);function tF(e){let t=(0,u.useContext)(eF);if(null===t){let t=new Error(`<${e} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,tF),t}return t}eF.displayName="PopoverContext";let nF=(0,u.createContext)(null);function rF(e){let t=(0,u.useContext)(nF);if(null===t){let t=new Error(`<${e} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,rF),t}return t}nF.displayName="PopoverAPIContext";let iF=(0,u.createContext)(null);function oF(){return(0,u.useContext)(iF)}iF.displayName="PopoverGroupContext";let aF=(0,u.createContext)(null);function sF(e,t){return $d(t.type,$j,e,t)}aF.displayName="PopoverPanelContext";let lF=lf((function(e,t){var n;let i=`headlessui-popover-button-${nh()}`,o=`headlessui-popover-panel-${nh()}`,a=(0,u.useRef)(null),s=_f(t,Mf((e=>{a.current=e}))),l=(0,u.useReducer)(sF,{popoverState:1,button:null,buttonId:i,panel:null,panelId:o,beforePanelSentinel:(0,u.createRef)(),afterPanelSentinel:(0,u.createRef)()}),[{popoverState:c,button:d,panel:f,beforePanelSentinel:h,afterPanelSentinel:p},m]=l,g=Mh(null!=(n=a.current)?n:d);(0,u.useEffect)((()=>m({type:3,buttonId:i})),[i,m]),(0,u.useEffect)((()=>m({type:5,panelId:o})),[o,m]);let v=(0,u.useMemo)((()=>{if(!d||!f)return!1;for(let e of document.querySelectorAll("body > *"))if(Number(null==e?void 0:e.contains(d))^Number(null==e?void 0:e.contains(f)))return!0;let e=dh(),t=e.indexOf(d),n=(t+e.length-1)%e.length,r=(t+1)%e.length,i=e[n],o=e[r];return!f.contains(i)&&!f.contains(o)}),[d,f]),y=(0,u.useMemo)((()=>({buttonId:i,panelId:o,close:()=>m({type:1})})),[i,o,m]),b=oF(),w=null==b?void 0:b.registerPopover,x=xf((()=>{var e;return null!=(e=null==b?void 0:b.isFocusWithinPopoverGroup())?e:(null==g?void 0:g.activeElement)&&((null==d?void 0:d.contains(g.activeElement))||(null==f?void 0:f.contains(g.activeElement)))}));(0,u.useEffect)((()=>null==w?void 0:w(y)),[w,y]),_h(null==g?void 0:g.defaultView,"focus",(e=>{var t,n,r,i;0===c&&(x()||!d||!f||null!=(n=null==(t=h.current)?void 0:t.contains)&&n.call(t,e.target)||null!=(i=null==(r=p.current)?void 0:r.contains)&&i.call(r,e.target)||m({type:1}))}),!0),Qh([d,f],((e,t)=>{m({type:1}),hh(t,fh.Loose)||(e.preventDefault(),null==d||d.focus())}),0===c);let S=xf((e=>{m({type:1});let t=e?e instanceof HTMLElement?e:"current"in e&&e.current instanceof HTMLElement?e.current:d:d;null==t||t.focus()})),M=(0,u.useMemo)((()=>({close:S,isPortalled:v})),[S,v]),_=(0,u.useMemo)((()=>({open:0===c,close:S})),[c,S]),A=e,E={ref:s};return r(u).createElement(eF.Provider,{value:l},r(u).createElement(nF.Provider,{value:M},r(u).createElement(pf,{value:$d(c,{0:ff.Open,1:ff.Closed})},of({ourProps:E,theirProps:A,slot:_,defaultTag:"div",name:"Popover"}))))})),cF=lf((function(e,t){let[n,i]=tF("Popover.Button"),{isPortalled:o}=rF("Popover.Button"),a=(0,u.useRef)(null),s=`headlessui-focus-sentinel-${nh()}`,l=oF(),c=null==l?void 0:l.closeOthers,d=(0,u.useContext)(aF),f=null!==d&&d===n.panelId,h=_f(a,t,f?null:e=>e&&i({type:2,button:e})),p=_f(a,t),m=Mh(a),g=xf((e=>{var t,r,o;if(f){if(1===n.popoverState)return;switch(e.key){case Xf.Space:case Xf.Enter:e.preventDefault(),null==(r=(t=e.target).click)||r.call(t),i({type:1}),null==(o=n.button)||o.focus()}}else switch(e.key){case Xf.Space:case Xf.Enter:e.preventDefault(),e.stopPropagation(),1===n.popoverState&&(null==c||c(n.buttonId)),i({type:0});break;case Xf.Escape:if(0!==n.popoverState)return null==c?void 0:c(n.buttonId);if(!a.current||(null==m?void 0:m.activeElement)&&!a.current.contains(m.activeElement))return;e.preventDefault(),e.stopPropagation(),i({type:1})}})),v=xf((e=>{f||e.key===Xf.Space&&e.preventDefault()})),y=xf((t=>{var r,o;Zf(t.currentTarget)||e.disabled||(f?(i({type:1}),null==(r=n.button)||r.focus()):(t.preventDefault(),t.stopPropagation(),1===n.popoverState&&(null==c||c(n.buttonId)),i({type:0}),null==(o=n.button)||o.focus()))})),b=xf((e=>{e.preventDefault(),e.stopPropagation()})),w=0===n.popoverState,x=(0,u.useMemo)((()=>({open:w})),[w]),S=qm(e,a),M=e,_=f?{ref:p,type:S,onKeyDown:g,onClick:y}:{ref:h,id:n.buttonId,type:S,"aria-expanded":e.disabled?void 0:0===n.popoverState,"aria-controls":n.panel?n.panelId:void 0,onKeyDown:g,onKeyUp:v,onClick:y,onMouseDown:b},A=Sh(),E=xf((()=>{let e=n.panel;e&&$d(A.current,{[xh.Forwards]:()=>bh(e,lh.First),[xh.Backwards]:()=>bh(e,lh.Last)})}));return r(u).createElement(r(u).Fragment,null,of({ourProps:_,theirProps:M,slot:x,defaultTag:"button",name:"Popover.Button"}),w&&!f&&o&&r(u).createElement(ih,{id:s,features:rh.Focusable,as:"button",type:"button",onFocus:E}))})),uF=nf.RenderStrategy|nf.Static,dF=lf((function(e,t){let[{popoverState:n},r]=tF("Popover.Overlay"),i=_f(t),o=`headlessui-popover-overlay-${nh()}`,a=hf(),s=null!==a?a===ff.Open:0===n;return of({ourProps:{ref:i,id:o,"aria-hidden":!0,onClick:xf((e=>{if(Zf(e.currentTarget))return e.preventDefault();r({type:1})}))},theirProps:e,slot:(0,u.useMemo)((()=>({open:0===n})),[n]),defaultTag:"div",features:uF,visible:s,name:"Popover.Overlay"})})),fF=nf.RenderStrategy|nf.Static,hF=lf((function(e,t){let{focus:n=!1,...i}=e,[o,a]=tF("Popover.Panel"),{close:s,isPortalled:l}=rF("Popover.Panel"),c=`headlessui-focus-sentinel-before-${nh()}`,d=`headlessui-focus-sentinel-after-${nh()}`,f=(0,u.useRef)(null),h=_f(f,t,(e=>{a({type:4,panel:e})})),p=Mh(f),m=hf(),g=null!==m?m===ff.Open:0===o.popoverState,v=xf((e=>{var t;if(e.key===Xf.Escape){if(0!==o.popoverState||!f.current||(null==p?void 0:p.activeElement)&&!f.current.contains(p.activeElement))return;e.preventDefault(),e.stopPropagation(),a({type:1}),null==(t=o.button)||t.focus()}}));(0,u.useEffect)((()=>{var t;e.static||1===o.popoverState&&(null==(t=e.unmount)||t)&&a({type:4,panel:null})}),[o.popoverState,e.unmount,e.static,a]),(0,u.useEffect)((()=>{if(!n||0!==o.popoverState||!f.current)return;let e=null==p?void 0:p.activeElement;f.current.contains(e)||bh(f.current,lh.First)}),[n,f,o.popoverState]);let y=(0,u.useMemo)((()=>({open:0===o.popoverState,close:s})),[o,s]),b={ref:h,id:o.panelId,onKeyDown:v,onBlur:n&&0===o.popoverState?e=>{var t,n,r,i,s;let l=e.relatedTarget;!l||!f.current||null!=(t=f.current)&&t.contains(l)||(a({type:1}),((null==(r=null==(n=o.beforePanelSentinel.current)?void 0:n.contains)?void 0:r.call(n,l))||(null==(s=null==(i=o.afterPanelSentinel.current)?void 0:i.contains)?void 0:s.call(i,l)))&&l.focus({preventScroll:!0}))}:void 0,tabIndex:-1},w=Sh(),x=xf((()=>{let e=f.current;e&&$d(w.current,{[xh.Forwards]:()=>{bh(e,lh.First)},[xh.Backwards]:()=>{var e;null==(e=o.button)||e.focus({preventScroll:!0})}})})),S=xf((()=>{let e=f.current;e&&$d(w.current,{[xh.Forwards]:()=>{var e,t,n;if(!o.button)return;let r=dh(),i=r.indexOf(o.button),a=r.slice(0,i+1),s=[...r.slice(i+1),...a];for(let r of s.slice())if((null==(t=null==(e=null==r?void 0:r.id)?void 0:e.startsWith)?void 0:t.call(e,"headlessui-focus-sentinel-"))||(null==(n=o.panel)?void 0:n.contains(r))){let e=s.indexOf(r);-1!==e&&s.splice(e,1)}bh(s,lh.First,!1)},[xh.Backwards]:()=>bh(e,lh.Last)})}));return r(u).createElement(aF.Provider,{value:o.panelId},g&&l&&r(u).createElement(ih,{id:c,ref:o.beforePanelSentinel,features:rh.Focusable,as:"button",type:"button",onFocus:x}),of({ourProps:b,theirProps:i,slot:y,defaultTag:"div",features:fF,visible:g,name:"Popover.Panel"}),g&&l&&r(u).createElement(ih,{id:d,ref:o.afterPanelSentinel,features:rh.Focusable,as:"button",type:"button",onFocus:S}))})),pF=lf((function(e,t){let n=(0,u.useRef)(null),i=_f(n,t),[o,a]=(0,u.useState)([]),s=xf((e=>{a((t=>{let n=t.indexOf(e);if(-1!==n){let e=t.slice();return e.splice(n,1),e}return t}))})),l=xf((e=>(a((t=>[...t,e])),()=>s(e)))),c=xf((()=>{var e;let t=oh(n);if(!t)return!1;let r=t.activeElement;return!(null==(e=n.current)||!e.contains(r))||o.some((e=>{var n,i;return(null==(n=t.getElementById(e.buttonId))?void 0:n.contains(r))||(null==(i=t.getElementById(e.panelId))?void 0:i.contains(r))}))})),d=xf((e=>{for(let t of o)t.buttonId!==e&&t.close()})),f=(0,u.useMemo)((()=>({registerPopover:l,unregisterPopover:s,isFocusWithinPopoverGroup:c,closeOthers:d})),[l,s,c,d]),h=(0,u.useMemo)((()=>({})),[]),p=e,m={ref:i};return r(u).createElement(iF.Provider,{value:f},of({ourProps:m,theirProps:p,slot:h,defaultTag:"div",name:"Popover.Group"}))})),mF=Object.assign(lF,{Button:cF,Overlay:dF,Panel:hF,Group:pF});var gF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M464 512a48 48 0 1096 0 48 48 0 10-96 0zm200 0a48 48 0 1096 0 48 48 0 10-96 0zm-400 0a48 48 0 1096 0 48 48 0 10-96 0zm661.2-173.6c-22.6-53.7-55-101.9-96.3-143.3a444.35 444.35 0 00-143.3-96.3C630.6 75.7 572.2 64 512 64h-2c-60.6.3-119.3 12.3-174.5 35.9a445.35 445.35 0 00-142 96.5c-40.9 41.3-73 89.3-95.2 142.8-23 55.4-34.6 114.3-34.3 174.9A449.4 449.4 0 00112 714v152a46 46 0 0046 46h152.1A449.4 449.4 0 00510 960h2.1c59.9 0 118-11.6 172.7-34.3a444.48 444.48 0 00142.8-95.2c41.3-40.9 73.8-88.7 96.5-142 23.6-55.2 35.6-113.9 35.9-174.5.3-60.9-11.5-120-34.8-175.6zm-151.1 438C704 845.8 611 884 512 884h-1.7c-60.3-.3-120.2-15.3-173.1-43.5l-8.4-4.5H188V695.2l-4.5-8.4C155.3 633.9 140.3 574 140 513.7c-.4-99.7 37.7-193.3 107.6-263.8 69.8-70.5 163.1-109.5 262.8-109.9h1.7c50 0 98.5 9.7 144.2 28.9 44.6 18.7 84.6 45.6 119 80 34.3 34.3 61.3 74.4 80 119 19.4 46.2 29.1 95.2 28.9 145.8-.6 99.6-39.7 192.9-110.1 262.7z"})});Jd=a("4IUwl");var vF=({history:e,memori:t,className:n,buttonClassName:i,icon:o,disabled:a=!1,align:l="right",filename:c})=>{const{t:u}=Te(),d=`${u("write_and_speak.conversationStartedLabel")} ${new Intl.DateTimeFormat("it",{dateStyle:"short",timeStyle:"short"}).format(new Date)}\n\n`.concat(e.map((e=>`${e.fromUser?"YOU":t.name}: ${e.text}`)).join("\n"));return(0,s.jsx)(mF,{title:u("write_and_speak.exportChatHistoryMessage"),className:r(Jd)("memori-export-history-button",n,{"memori-export-history-button--align-left":"left"===l}),children:({close:e})=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(mF.Button,{disabled:a,className:r(Jd)("memori-button","memori-button--circle","memori-button--icon-only",i,{"memori-button--disabled":a,"memori-button--primary":!a}),children:(0,s.jsx)("div",{className:"memori-button--icon",children:o||(0,s.jsx)(gF,{})})}),(0,s.jsxs)(mF.Panel,{className:"memori-export-history-button--panel",children:[(0,s.jsx)("p",{children:u("write_and_speak.exportChatHistory")}),(0,s.jsx)(Zd,{primary:!0,onClick:()=>((e,t="export-chat.txt")=>{const n=new Blob([e],{type:"text/plain"}),r=URL.createObjectURL(n),i=document.createElement("a");i.setAttribute("href",r),i.setAttribute("download",t),i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i)})(d,c||`${t.name.replace(/\W+/g,"-")}-export-chat.txt`),children:u("yes")||"Yes"}),(0,s.jsx)(Zd,{onClick:()=>e(),children:u("no")||"No"})]})]})})};var yF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M924.8 625.7l-65.5-56c3.1-19 4.7-38.4 4.7-57.8s-1.6-38.8-4.7-57.8l65.5-56a32.03 32.03 0 009.3-35.2l-.9-2.6a443.74 443.74 0 00-79.7-137.9l-1.8-2.1a32.12 32.12 0 00-35.1-9.5l-81.3 28.9c-30-24.6-63.5-44-99.7-57.6l-15.7-85a32.05 32.05 0 00-25.8-25.7l-2.7-.5c-52.1-9.4-106.9-9.4-159 0l-2.7.5a32.05 32.05 0 00-25.8 25.7l-15.8 85.4a351.86 351.86 0 00-99 57.4l-81.9-29.1a32 32 0 00-35.1 9.5l-1.8 2.1a446.02 446.02 0 00-79.7 137.9l-.9 2.6c-4.5 12.5-.8 26.5 9.3 35.2l66.3 56.6c-3.1 18.8-4.6 38-4.6 57.1 0 19.2 1.5 38.4 4.6 57.1L99 625.5a32.03 32.03 0 00-9.3 35.2l.9 2.6c18.1 50.4 44.9 96.9 79.7 137.9l1.8 2.1a32.12 32.12 0 0035.1 9.5l81.9-29.1c29.8 24.5 63.1 43.9 99 57.4l15.8 85.4a32.05 32.05 0 0025.8 25.7l2.7.5a449.4 449.4 0 00159 0l2.7-.5a32.05 32.05 0 0025.8-25.7l15.7-85a350 350 0 0099.7-57.6l81.3 28.9a32 32 0 0035.1-9.5l1.8-2.1c34.8-41.1 61.6-87.5 79.7-137.9l.9-2.6c4.5-12.3.8-26.3-9.3-35zM788.3 465.9c2.5 15.1 3.8 30.6 3.8 46.1s-1.3 31-3.8 46.1l-6.6 40.1 74.7 63.9a370.03 370.03 0 01-42.6 73.6L721 702.8l-31.4 25.8c-23.9 19.6-50.5 35-79.3 45.8l-38.1 14.3-17.9 97a377.5 377.5 0 01-85 0l-17.9-97.2-37.8-14.5c-28.5-10.8-55-26.2-78.7-45.7l-31.4-25.9-93.4 33.2c-17-22.9-31.2-47.6-42.6-73.6l75.5-64.5-6.5-40c-2.4-14.9-3.7-30.3-3.7-45.5 0-15.3 1.2-30.6 3.7-45.5l6.5-40-75.5-64.5c11.3-26.1 25.6-50.7 42.6-73.6l93.4 33.2 31.4-25.9c23.7-19.5 50.2-34.9 78.7-45.7l37.9-14.3 17.9-97.2c28.1-3.2 56.8-3.2 85 0l17.9 97 38.1 14.3c28.7 10.8 55.4 26.2 79.3 45.8l31.4 25.8 92.8-32.9c17 22.9 31.2 47.6 42.6 73.6L781.8 426l6.5 39.9zM512 326c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm79.2 255.2A111.6 111.6 0 01512 614c-29.9 0-58-11.7-79.2-32.8A111.6 111.6 0 01400 502c0-29.9 11.7-58 32.8-79.2C454 401.6 482.1 390 512 390c29.9 0 58 11.6 79.2 32.8A111.6 111.6 0 01624 502c0 29.9-11.7 58-32.8 79.2z"})});u=a("85Hg2");var bF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-32 736H663.9V602.2h104l15.6-120.7H663.9v-77.1c0-35 9.7-58.8 59.8-58.8h63.9v-108c-11.1-1.5-49-4.8-93.2-4.8-92.2 0-155.3 56.3-155.3 159.6v89H434.9v120.7h104.3V848H176V176h672v672z"})});var wF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M928 254.3c-30.6 13.2-63.9 22.7-98.2 26.4a170.1 170.1 0 0 0 75-94 336.64 336.64 0 0 1-108.2 41.2A170.1 170.1 0 0 0 672 174c-94.5 0-170.5 76.6-170.5 170.6 0 13.2 1.6 26.4 4.2 39.1-141.5-7.4-267.7-75-351.6-178.5a169.32 169.32 0 0 0-23.2 86.1c0 59.2 30.1 111.4 76 142.1a172 172 0 0 1-77.1-21.7v2.1c0 82.9 58.6 151.6 136.7 167.4a180.6 180.6 0 0 1-44.9 5.8c-11.1 0-21.6-1.1-32.2-2.6C211 652 273.9 701.1 348.8 702.7c-58.6 45.9-132 72.9-211.7 72.9-14.3 0-27.5-.5-41.2-2.1C171.5 822 261.2 850 357.8 850 671.4 850 843 590.2 843 364.7c0-7.4 0-14.8-.5-22.2 33.2-24.3 62.3-54.4 85.5-88.2z"})});var xF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M847.7 112H176.3c-35.5 0-64.3 28.8-64.3 64.3v671.4c0 35.5 28.8 64.3 64.3 64.3h671.4c35.5 0 64.3-28.8 64.3-64.3V176.3c0-35.5-28.8-64.3-64.3-64.3zm0 736c-447.8-.1-671.7-.2-671.7-.3.1-447.8.2-671.7.3-671.7 447.8.1 671.7.2 671.7.3-.1 447.8-.2 671.7-.3 671.7zM230.6 411.9h118.7v381.8H230.6zm59.4-52.2c37.9 0 68.8-30.8 68.8-68.8a68.8 68.8 0 1 0-137.6 0c-.1 38 30.7 68.8 68.8 68.8zm252.3 245.1c0-49.8 9.5-98 71.2-98 60.8 0 61.7 56.9 61.7 101.2v185.7h118.6V584.3c0-102.8-22.2-181.9-142.3-181.9-57.7 0-96.4 31.7-112.3 61.7h-1.6v-52.2H423.7v381.8h118.6V604.8z"})});var SF=({className:e,title:t})=>(0,s.jsxs)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:[(0,s.jsx)("path",{d:"M713.5 599.9c-10.9-5.6-65.2-32.2-75.3-35.8-10.1-3.8-17.5-5.6-24.8 5.6-7.4 11.1-28.4 35.8-35 43.3-6.4 7.4-12.9 8.3-23.8 2.8-64.8-32.4-107.3-57.8-150-131.1-11.3-19.5 11.3-18.1 32.4-60.2 3.6-7.4 1.8-13.7-1-19.3-2.8-5.6-24.8-59.8-34-81.9-8.9-21.5-18.1-18.5-24.8-18.9-6.4-.4-13.7-.4-21.1-.4-7.4 0-19.3 2.8-29.4 13.7-10.1 11.1-38.6 37.8-38.6 92s39.5 106.7 44.9 114.1c5.6 7.4 77.7 118.6 188.4 166.5 70 30.2 97.4 32.8 132.4 27.6 21.3-3.2 65.2-26.6 74.3-52.5 9.1-25.8 9.1-47.9 6.4-52.5-2.7-4.9-10.1-7.7-21-13z"}),(0,s.jsx)("path",{d:"M925.2 338.4c-22.6-53.7-55-101.9-96.3-143.3-41.3-41.3-89.5-73.8-143.3-96.3C630.6 75.7 572.2 64 512 64h-2c-60.6.3-119.3 12.3-174.5 35.9-53.3 22.8-101.1 55.2-142 96.5-40.9 41.3-73 89.3-95.2 142.8-23 55.4-34.6 114.3-34.3 174.9.3 69.4 16.9 138.3 48 199.9v152c0 25.4 20.6 46 46 46h152.1c61.6 31.1 130.5 47.7 199.9 48h2.1c59.9 0 118-11.6 172.7-34.3 53.5-22.3 101.6-54.3 142.8-95.2 41.3-40.9 73.8-88.7 96.5-142 23.6-55.2 35.6-113.9 35.9-174.5.3-60.9-11.5-120-34.8-175.6zm-151.1 438C704 845.8 611 884 512 884h-1.7c-60.3-.3-120.2-15.3-173.1-43.5l-8.4-4.5H188V695.2l-4.5-8.4C155.3 633.9 140.3 574 140 513.7c-.4-99.7 37.7-193.3 107.6-263.8 69.8-70.5 163.1-109.5 262.8-109.9h1.7c50 0 98.5 9.7 144.2 28.9 44.6 18.7 84.6 45.6 119 80 34.3 34.3 61.3 74.4 80 119 19.4 46.2 29.1 95.2 28.9 145.8-.6 99.6-39.7 192.9-110.1 262.7z"})]});var MF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zm-40 110.8V792H136V270.8l-27.6-21.5 39.3-50.5 42.8 33.3h643.1l42.8-33.3 39.3 50.5-27.7 21.5zM833.6 232L512 482 190.4 232l-42.8-33.3-39.3 50.5 27.6 21.5 341.6 265.6a55.99 55.99 0 0 0 68.7 0L888 270.8l27.6-21.5-39.3-50.5-42.7 33.2z"})});var _F=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M752 664c-28.5 0-54.8 10-75.4 26.7L469.4 540.8a160.68 160.68 0 0 0 0-57.6l207.2-149.9C697.2 350 723.5 360 752 360c66.2 0 120-53.8 120-120s-53.8-120-120-120-120 53.8-120 120c0 11.6 1.6 22.7 4.7 33.3L439.9 415.8C410.7 377.1 364.3 352 312 352c-88.4 0-160 71.6-160 160s71.6 160 160 160c52.3 0 98.7-25.1 127.9-63.8l196.8 142.5c-3.1 10.6-4.7 21.8-4.7 33.3 0 66.2 53.8 120 120 120s120-53.8 120-120-53.8-120-120-120zm0-476c28.7 0 52 23.3 52 52s-23.3 52-52 52-52-23.3-52-52 23.3-52 52-52zM312 600c-48.5 0-88-39.5-88-88s39.5-88 88-88 88 39.5 88 88-39.5 88-88 88zm440 236c-28.7 0-52-23.3-52-52s23.3-52 52-52 52 23.3 52 52-23.3 52-52 52z"})});var AF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M505.7 661a8 8 0 0012.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"})});var EF,CF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",className:e,"aria-label":t,children:(0,s.jsx)("path",{fill:"currentColor",d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm121.8 169.9l-40.7 191.8c-3 13.6-11.1 16.9-22.4 10.5l-62-45.7-29.9 28.8c-3.3 3.3-6.1 6.1-12.5 6.1l4.4-63.1 114.9-103.8c5-4.4-1.1-6.9-7.7-2.5l-142 89.4-61.2-19.1c-13.3-4.2-13.6-13.3 2.8-19.7l239.1-92.2c11.1-4 20.8 2.7 17.2 19.5z"})}),kF=(u=a("85Hg2"),Object.defineProperty),TF=Object.getOwnPropertySymbols,IF=Object.prototype.hasOwnProperty,OF=Object.prototype.propertyIsEnumerable,RF=(e,t,n)=>t in e?kF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,PF=(e,t)=>{for(var n in t||(t={}))IF.call(t,n)&&RF(e,n,t[n]);if(TF)for(var n of TF(t))OF.call(t,n)&&RF(e,n,t[n]);return e},NF=(e,t)=>{var n={};for(var r in e)IF.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&TF)for(var r of TF(e))t.indexOf(r)<0&&OF.call(e,r)&&(n[r]=e[r]);return n};(e=>{const t=class{constructor(e,n,r,i){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version value out of range");if(i<-1||i>7)throw new RangeError("Mask value out of range");this.size=4*e+17;let a=[];for(let e=0;e<this.size;e++)a.push(!1);for(let e=0;e<this.size;e++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();const s=this.addEccAndInterleave(r);if(this.drawCodewords(s),-1==i){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);const n=this.getPenaltyScore();n<e&&(i=t,e=n),this.applyMask(t)}}o(0<=i&&i<=7),this.mask=i,this.applyMask(i),this.drawFormatBits(i),this.isFunction=[]}static encodeText(n,r){const i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){const i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,n,i=1,a=40,l=-1,c=!0){if(!(t.MIN_VERSION<=i&&i<=a&&a<=t.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let u,d;for(u=i;;u++){const r=8*t.getNumDataCodewords(u,n),i=s.getTotalBits(e,u);if(i<=r){d=i;break}if(u>=a)throw new RangeError("Data too long")}for(const e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])c&&d<=8*t.getNumDataCodewords(u,e)&&(n=e);let f=[];for(const t of e){r(t.mode.modeBits,4,f),r(t.numChars,t.mode.numCharCountBits(u),f);for(const e of t.getData())f.push(e)}o(f.length==d);const h=8*t.getNumDataCodewords(u,n);o(f.length<=h),r(0,Math.min(4,h-f.length),f),r(0,(8-f.length%8)%8,f),o(f.length%8==0);for(let e=236;f.length<h;e^=253)r(e,8,f);let p=[];for(;8*p.length<f.length;)p.push(0);return f.forEach(((e,t)=>p[t>>>3]|=e<<7-(7&t))),new t(u,n,p,l)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)0==n&&0==r||0==n&&r==t-1||n==t-1&&0==r||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const t=this.errorCorrectionLevel.formatBits<<3|e;let n=t;for(let e=0;e<10;e++)n=n<<1^1335*(n>>>9);const r=21522^(t<<10|n);o(r>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,i(r,e));this.setFunctionModule(8,7,i(r,6)),this.setFunctionModule(8,8,i(r,7)),this.setFunctionModule(7,8,i(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,i(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,i(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,i(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^7973*(e>>>11);const t=this.version<<12|e;o(t>>>18==0);for(let e=0;e<18;e++){const n=i(t,e),r=this.size-11+e%3,o=Math.floor(e/3);this.setFunctionModule(r,o,n),this.setFunctionModule(o,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){const i=Math.max(Math.abs(r),Math.abs(n)),o=e+r,a=t+n;0<=o&&o<this.size&&0<=a&&a<this.size&&this.setFunctionModule(o,a,2!=i&&4!=i)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,1!=Math.max(Math.abs(r),Math.abs(n)))}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){const n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw new RangeError("Invalid argument");const i=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],a=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),l=i-s%i,c=Math.floor(s/i);let u=[];const d=t.reedSolomonComputeDivisor(a);for(let n=0,r=0;n<i;n++){let i=e.slice(r,r+c-a+(n<l?0:1));r+=i.length;const o=t.reedSolomonComputeRemainder(i,d);n<l&&i.push(0),u.push(i.concat(o))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach(((t,n)=>{(e!=c-a||n>=l)&&f.push(t[e])}));return o(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let t=this.size-1;t>=1;t-=2){6==t&&(t=5);for(let r=0;r<this.size;r++)for(let o=0;o<2;o++){const a=t-o,s=0==(t+1&2)?this.size-1-r:r;!this.isFunction[s][a]&&n<8*e.length&&(this.modules[s][a]=i(e[n>>>3],7-(7&n)),n++)}}o(n==8*e.length)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,o=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[n][a]==r?(i++,5==i?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,o),r||(e+=this.finderPenaltyCountPatterns(o)*t.PENALTY_N3),r=this.modules[n][a],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,o)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,o=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][n]==r?(i++,5==i?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,o),r||(e+=this.finderPenaltyCountPatterns(o)*t.PENALTY_N3),r=this.modules[a][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,o)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){const i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(const e of this.modules)n=e.reduce(((e,t)=>e+(t?1:0)),n);const r=this.size*this.size,i=Math.ceil(Math.abs(20*n-10*r)/r)-1;return o(0<=i&&i<=9),e+=i*t.PENALTY_N4,o(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(1==this.version)return[];{const e=Math.floor(this.version/7)+2,t=32==this.version?26:2*Math.ceil((4*this.version+4)/(2*e-2));let n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return o(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map((e=>0));for(const i of e){const e=i^r.shift();r.push(0),n.forEach(((n,i)=>r[i]^=t.reedSolomonMultiply(n,e)))}return r}static reedSolomonMultiply(e,t){if(e>>>8!=0||t>>>8!=0)throw new RangeError("Byte out of range");let n=0;for(let r=7;r>=0;r--)n=n<<1^285*(n>>>7),n^=(t>>>r&1)*e;return o(n>>>8==0),n}finderPenaltyCountPatterns(e){const t=e[1];o(t<=3*this.size);const n=t>0&&e[2]==t&&e[3]==3*t&&e[4]==t&&e[5]==t;return(n&&e[0]>=4*t&&e[6]>=t?1:0)+(n&&e[6]>=4*t&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){0==t[0]&&(e+=this.size),t.pop(),t.unshift(e)}};let n=t;function r(e,t,n){if(t<0||t>31||e>>>t!=0)throw new RangeError("Value out of range");for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function i(e,t){return 0!=(e>>>t&1)}function o(e){if(!e)throw new Error("Assertion error")}n.MIN_VERSION=1,n.MAX_VERSION=40,n.PENALTY_N1=3,n.PENALTY_N2=3,n.PENALTY_N3=40,n.PENALTY_N4=10,n.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],n.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=n;const a=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw new RangeError("Invalid argument");this.bitData=n.slice()}static makeBytes(e){let t=[];for(const n of e)r(n,8,t);return new a(a.Mode.BYTE,e.length,t)}static makeNumeric(e){if(!a.isNumeric(e))throw new RangeError("String contains non-numeric characters");let t=[];for(let n=0;n<e.length;){const i=Math.min(e.length-n,3);r(parseInt(e.substr(n,i),10),3*i+1,t),n+=i}return new a(a.Mode.NUMERIC,e.length,t)}static makeAlphanumeric(e){if(!a.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let t,n=[];for(t=0;t+2<=e.length;t+=2){let i=45*a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t));i+=a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),r(i,11,n)}return t<e.length&&r(a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,n),new a(a.Mode.ALPHANUMERIC,e.length,n)}static makeSegments(e){return""==e?[]:a.isNumeric(e)?[a.makeNumeric(e)]:a.isAlphanumeric(e)?[a.makeAlphanumeric(e)]:[a.makeBytes(a.toUtf8ByteArray(e))]}static makeEci(e){let t=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)r(e,8,t);else if(e<16384)r(2,2,t),r(e,14,t);else{if(!(e<1e6))throw new RangeError("ECI assignment value out of range");r(6,3,t),r(e,21,t)}return new a(a.Mode.ECI,0,t)}static isNumeric(e){return a.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return a.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(const r of e){const e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)"%"!=e.charAt(n)?t.push(e.charCodeAt(n)):(t.push(parseInt(e.substr(n+1,2),16)),n+=2);return t}};let s=a;s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",e.QrSegment=s})(EF||(EF={})),(e=>{let t;(e=>{const t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};let n=t;n.LOW=new t(0,1),n.MEDIUM=new t(1,0),n.QUARTILE=new t(2,3),n.HIGH=new t(3,2),e.Ecc=n})(t=e.QrCode||(e.QrCode={}))})(EF||(EF={})),(e=>{let t;(e=>{const t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};let n=t;n.NUMERIC=new t(1,[10,12,14]),n.ALPHANUMERIC=new t(2,[9,11,13]),n.BYTE=new t(4,[8,16,16]),n.KANJI=new t(8,[8,10,12]),n.ECI=new t(7,[0,0,0]),e.Mode=n})(t=e.QrSegment||(e.QrSegment={}))})(EF||(EF={}));var LF=EF,DF={L:LF.QrCode.Ecc.LOW,M:LF.QrCode.Ecc.MEDIUM,Q:LF.QrCode.Ecc.QUARTILE,H:LF.QrCode.Ecc.HIGH},BF=128,jF="L",FF="#FFFFFF",UF="#000000",zF=!1;
|
|
103
|
+
const cw="144",uw={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},dw={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},fw=0,hw=1,pw=2,mw=3,gw=0,vw=1,yw=2,bw=3,ww=0,xw=1,Sw=2,Mw=0,_w=1,Aw=2,Ew=3,Cw=4,kw=5,Tw=100,Iw=101,Ow=102,Rw=103,Pw=104,Nw=200,Lw=201,Dw=202,Bw=203,jw=204,Fw=205,Uw=206,zw=207,Hw=208,Vw=209,Ww=210,Gw=0,qw=1,Kw=2,Yw=3,Jw=4,Qw=5,Xw=6,Zw=7,$w=0,ex=1,tx=2,nx=0,rx=1,ix=2,ox=3,ax=4,sx=5,lx=300,cx=301,ux=302,dx=303,fx=304,hx=306,px=1e3,mx=1001,gx=1002,vx=1003,yx=1004,bx=1004,wx=1005,xx=1005,Sx=1006,Mx=1007,_x=1007,Ax=1008,Ex=1008,Cx=1009,kx=1010,Tx=1011,Ix=1012,Ox=1013,Rx=1014,Px=1015,Nx=1016,Lx=1017,Dx=1018,Bx=1020,jx=1021,Fx=1022,Ux=1023,zx=1024,Hx=1025,Vx=1026,Wx=1027,Gx=1028,qx=1029,Kx=1030,Yx=1031,Jx=1033,Qx=33776,Xx=33777,Zx=33778,$x=33779,eS=35840,tS=35841,nS=35842,rS=35843,iS=36196,oS=37492,aS=37496,sS=37808,lS=37809,cS=37810,uS=37811,dS=37812,fS=37813,hS=37814,pS=37815,mS=37816,gS=37817,vS=37818,yS=37819,bS=37820,wS=37821,xS=36492,SS=2200,MS=2201,_S=2202,AS=2300,ES=2301,CS=2302,kS=2400,TS=2401,IS=2402,OS=2500,RS=2501,PS=0,NS=1,LS=2,DS=3e3,BS=3001,jS=3200,FS=3201,US=0,zS=1,HS="",VS="srgb",WS="srgb-linear",GS=0,qS=7680,KS=7681,YS=7682,JS=7683,QS=34055,XS=34056,ZS=5386,$S=512,eM=513,tM=514,nM=515,rM=516,iM=517,oM=518,aM=519,sM=35044,lM=35048,cM=35040,uM=35045,dM=35049,fM=35041,hM=35046,pM=35050,mM=35042,gM="100",vM="300 es",yM=1035;class bM{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,r=n.length;t<r;t++)n[t].call(this,e);e.target=null}}}const wM=["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 xM=1234567;const SM=Math.PI/180,MM=180/Math.PI;function _M(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(wM[255&e]+wM[e>>8&255]+wM[e>>16&255]+wM[e>>24&255]+"-"+wM[255&t]+wM[t>>8&255]+"-"+wM[t>>16&15|64]+wM[t>>24&255]+"-"+wM[63&n|128]+wM[n>>8&255]+"-"+wM[n>>16&255]+wM[n>>24&255]+wM[255&r]+wM[r>>8&255]+wM[r>>16&255]+wM[r>>24&255]).toLowerCase()}function AM(e,t,n){return Math.max(t,Math.min(n,e))}function EM(e,t){return(e%t+t)%t}function CM(e,t,n){return(1-n)*e+n*t}function kM(e){return 0==(e&e-1)&&0!==e}function TM(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function IM(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function OM(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function RM(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}var PM=Object.freeze({__proto__:null,DEG2RAD:SM,RAD2DEG:MM,generateUUID:_M,clamp:AM,euclideanModulo:EM,mapLinear:function(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:CM,damp:function(e,t,n,r){return CM(e,t,1-Math.exp(-n*r))},pingpong:function(e,t=1){return t-Math.abs(EM(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(xM=e);let t=xM+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*SM},radToDeg:function(e){return e*MM},isPowerOfTwo:kM,ceilPowerOfTwo:TM,floorPowerOfTwo:IM,setQuaternionFromProperEuler:function(e,t,n,r,i){const o=Math.cos,a=Math.sin,s=o(n/2),l=a(n/2),c=o((t+r)/2),u=a((t+r)/2),d=o((t-r)/2),f=a((t-r)/2),h=o((r-t)/2),p=a((r-t)/2);switch(i){case"XYX":e.set(s*u,l*d,l*f,s*c);break;case"YZY":e.set(l*f,s*u,l*d,s*c);break;case"ZXZ":e.set(l*d,l*f,s*u,s*c);break;case"XZX":e.set(s*u,l*p,l*h,s*c);break;case"YXY":e.set(l*h,s*u,l*p,s*c);break;case"ZYZ":e.set(l*p,l*h,s*u,s*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}},normalize:RM,denormalize:OM});class NM{constructor(e=0,t=0){NM.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,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}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),r=Math.sin(t),i=this.x-e.x,o=this.y-e.y;return this.x=i*n-o*r+e.x,this.y=i*r+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class LM{constructor(){LM.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,n,r,i,o,a,s,l){const c=this.elements;return c[0]=e,c[1]=r,c[2]=a,c[3]=t,c[4]=i,c[5]=s,c[6]=n,c[7]=o,c[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,r=t.elements,i=this.elements,o=n[0],a=n[3],s=n[6],l=n[1],c=n[4],u=n[7],d=n[2],f=n[5],h=n[8],p=r[0],m=r[3],g=r[6],v=r[1],y=r[4],b=r[7],w=r[2],x=r[5],S=r[8];return i[0]=o*p+a*v+s*w,i[3]=o*m+a*y+s*x,i[6]=o*g+a*b+s*S,i[1]=l*p+c*v+u*w,i[4]=l*m+c*y+u*x,i[7]=l*g+c*b+u*S,i[2]=d*p+f*v+h*w,i[5]=d*m+f*y+h*x,i[8]=d*g+f*b+h*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],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8];return t*o*c-t*a*l-n*i*c+n*a*s+r*i*l-r*o*s}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],u=c*o-a*l,d=a*s-c*i,f=l*i-o*s,h=t*u+n*d+r*f;if(0===h)return this.set(0,0,0,0,0,0,0,0,0);const p=1/h;return e[0]=u*p,e[1]=(r*l-c*n)*p,e[2]=(a*n-r*o)*p,e[3]=d*p,e[4]=(c*t-r*s)*p,e[5]=(r*i-a*t)*p,e[6]=f*p,e[7]=(n*s-l*t)*p,e[8]=(o*t-n*i)*p,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,r,i,o,a){const s=Math.cos(i),l=Math.sin(i);return this.set(n*s,n*l,-n*(s*o+l*a)+o+e,-r*l,r*s,-r*(-l*o+s*a)+a+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),r=this.elements,i=r[0],o=r[3],a=r[6],s=r[1],l=r[4],c=r[7];return r[0]=t*i+n*s,r[3]=t*o+n*l,r[6]=t*a+n*c,r[1]=-n*i+t*s,r[4]=-n*o+t*l,r[7]=-n*a+t*c,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])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)}}function DM(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}const BM={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function jM(e,t){return new BM[e](t)}function FM(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function UM(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function zM(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const HM={[VS]:{[WS]:UM},[WS]:{[VS]:zM}},VM={legacyMode:!0,get workingColorSpace(){return WS},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(this.legacyMode||t===n||!t||!n)return e;if(HM[t]&&void 0!==HM[t][n]){const r=HM[t][n];return e.r=r(e.r),e.g=r(e.g),e.b=r(e.b),e}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}},WM={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},GM={r:0,g:0,b:0},qM={h:0,s:0,l:0},KM={h:0,s:0,l:0};function YM(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function JM(e,t){return t.r=e.r,t.g=e.g,t.b=e.b,t}class QM{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=VS){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,VM.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=WS){return this.r=e,this.g=t,this.b=n,VM.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=WS){if(e=EM(e,1),t=AM(t,0,1),n=AM(n,0,1),0===t)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=YM(i,r,e+1/3),this.g=YM(i,r,e),this.b=YM(i,r,e-1/3)}return VM.toWorkingColorSpace(this,r),this}setStyle(e,t=VS){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const i=r[1],o=r[2];switch(i){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,VM.toWorkingColorSpace(this,t),n(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,VM.toWorkingColorSpace(this,t),n(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){const r=parseFloat(e[1])/360,i=parseFloat(e[2])/100,o=parseFloat(e[3])/100;return n(e[4]),this.setHSL(r,i,o,t)}}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=r[1],n=e.length;if(3===n)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,VM.toWorkingColorSpace(this,t),this;if(6===n)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,VM.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=VS){const n=WM[e.toLowerCase()];return void 0!==n?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=UM(e.r),this.g=UM(e.g),this.b=UM(e.b),this}copyLinearToSRGB(e){return this.r=zM(e.r),this.g=zM(e.g),this.b=zM(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=VS){return VM.fromWorkingColorSpace(JM(this,GM),e),AM(255*GM.r,0,255)<<16^AM(255*GM.g,0,255)<<8^AM(255*GM.b,0,255)<<0}getHexString(e=VS){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=WS){VM.fromWorkingColorSpace(JM(this,GM),t);const n=GM.r,r=GM.g,i=GM.b,o=Math.max(n,r,i),a=Math.min(n,r,i);let s,l;const c=(a+o)/2;if(a===o)s=0,l=0;else{const e=o-a;switch(l=c<=.5?e/(o+a):e/(2-o-a),o){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4}s/=6}return e.h=s,e.s=l,e.l=c,e}getRGB(e,t=WS){return VM.fromWorkingColorSpace(JM(this,GM),t),e.r=GM.r,e.g=GM.g,e.b=GM.b,e}getStyle(e=VS){return VM.fromWorkingColorSpace(JM(this,GM),e),e!==VS?`color(${e} ${GM.r} ${GM.g} ${GM.b})`:`rgb(${255*GM.r|0},${255*GM.g|0},${255*GM.b|0})`}offsetHSL(e,t,n){return this.getHSL(qM),qM.h+=e,qM.s+=t,qM.l+=n,this.setHSL(qM.h,qM.s,qM.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(qM),e.getHSL(KM);const n=CM(qM.h,KM.h,t),r=CM(qM.s,KM.s,t),i=CM(qM.l,KM.l,t);return this.setHSL(n,r,i),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}let XM;QM.NAMES=WM;class ZM{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===XM&&(XM=FM("canvas")),XM.width=e.width,XM.height=e.height;const n=XM.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=XM}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=FM("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=255*UM(i[e]/255);return n.putImageData(r,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*UM(t[e]/255)):t[e]=UM(t[e]);return{data:t,width:e.width,height:e.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}class $M{constructor(e=null){this.isSource=!0,this.uuid=_M(),this.data=e,this.version=0}set needsUpdate(e){!0===e&&this.version++}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(null!==r){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(e_(r[t].image)):e.push(e_(r[t]))}else e=e_(r);n.url=e}return t||(e.images[this.uuid]=n),n}}function e_(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?ZM.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let t_=0;class n_ extends bM{constructor(e=n_.DEFAULT_IMAGE,t=n_.DEFAULT_MAPPING,n=mx,r=mx,i=Sx,o=Ax,a=Ux,s=Cx,l=1,c=DS){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:t_++}),this.uuid=_M(),this.name="",this.source=new $M(e),this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=s,this.offset=new NM(0,0),this.repeat=new NM(1,1),this.center=new NM(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new LM,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}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.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.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,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,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==lx)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case px:e.x=e.x-Math.floor(e.x);break;case mx:e.x=e.x<0?0:1;break;case gx:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case px:e.y=e.y-Math.floor(e.y);break;case mx:e.y=e.y<0?0:1;break;case gx:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}}n_.DEFAULT_IMAGE=null,n_.DEFAULT_MAPPING=lx;class r_{constructor(e=0,t=0,n=0,r=1){r_.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}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,r){return this.x=e,this.y=t,this.z=n,this.w=r,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=void 0!==e.w?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,r=this.z,i=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r+o[12]*i,this.y=o[1]*t+o[5]*n+o[9]*r+o[13]*i,this.z=o[2]*t+o[6]*n+o[10]*r+o[14]*i,this.w=o[3]*t+o[7]*n+o[11]*r+o[15]*i,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,r,i;const o=.01,a=.1,s=e.elements,l=s[0],c=s[4],u=s[8],d=s[1],f=s[5],h=s[9],p=s[2],m=s[6],g=s[10];if(Math.abs(c-d)<o&&Math.abs(u-p)<o&&Math.abs(h-m)<o){if(Math.abs(c+d)<a&&Math.abs(u+p)<a&&Math.abs(h+m)<a&&Math.abs(l+f+g-3)<a)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,s=(f+1)/2,v=(g+1)/2,y=(c+d)/4,b=(u+p)/4,w=(h+m)/4;return e>s&&e>v?e<o?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=y/n,i=b/n):s>v?s<o?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=y/r,i=w/r):v<o?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(v),n=b/i,r=w/i),this.set(n,r,i,t),this}let v=Math.sqrt((m-h)*(m-h)+(u-p)*(u-p)+(d-c)*(d-c));return Math.abs(v)<.001&&(v=1),this.x=(m-h)/v,this.y=(u-p)/v,this.z=(d-c)/v,this.w=Math.acos((l+f+g-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class i_ extends bM{constructor(e,t,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new r_(0,0,e,t),this.scissorTest=!1,this.viewport=new r_(0,0,e,t);const r={width:e,height:t,depth:1};this.texture=new n_(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.internalFormat=void 0!==n.internalFormat?n.internalFormat:null,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:Sx,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null,this.samples=void 0!==n.samples?n.samples:0}setSize(e,t,n=1){this.width===e&&this.height===t&&this.depth===n||(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new $M(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class o_ extends n_{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=vx,this.minFilter=vx,this.wrapR=mx,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class a_ extends i_{constructor(e,t,n){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new o_(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class s_ extends n_{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=vx,this.minFilter=vx,this.wrapR=mx,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class l_ extends i_{constructor(e,t,n){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new s_(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class c_ extends i_{constructor(e,t,n,r={}){super(e,t,r),this.isWebGLMultipleRenderTargets=!0;const i=this.texture;this.texture=[];for(let e=0;e<n;e++)this.texture[e]=i.clone(),this.texture[e].isRenderTargetTexture=!0}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.texture.length;r<i;r++)this.texture[r].image.width=e,this.texture[r].image.height=t,this.texture[r].image.depth=n;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.texture.length=0;for(let t=0,n=e.texture.length;t<n;t++)this.texture[t]=e.texture[t].clone(),this.texture[t].isRenderTargetTexture=!0;return this}}class u_{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,o,a){let s=n[r+0],l=n[r+1],c=n[r+2],u=n[r+3];const d=i[o+0],f=i[o+1],h=i[o+2],p=i[o+3];if(0===a)return e[t+0]=s,e[t+1]=l,e[t+2]=c,void(e[t+3]=u);if(1===a)return e[t+0]=d,e[t+1]=f,e[t+2]=h,void(e[t+3]=p);if(u!==p||s!==d||l!==f||c!==h){let e=1-a;const t=s*d+l*f+c*h+u*p,n=t>=0?1:-1,r=1-t*t;if(r>Number.EPSILON){const i=Math.sqrt(r),o=Math.atan2(i,t*n);e=Math.sin(e*o)/i,a=Math.sin(a*o)/i}const i=a*n;if(s=s*e+d*i,l=l*e+f*i,c=c*e+h*i,u=u*e+p*i,e===1-a){const e=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=e,l*=e,c*=e,u*=e}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,o){const a=n[r],s=n[r+1],l=n[r+2],c=n[r+3],u=i[o],d=i[o+1],f=i[o+2],h=i[o+3];return e[t]=a*h+c*u+s*f-l*d,e[t+1]=s*h+c*d+l*u-a*f,e[t+2]=l*h+c*f+a*d-s*u,e[t+3]=c*h-a*u-s*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,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,r=e._y,i=e._z,o=e._order,a=Math.cos,s=Math.sin,l=a(n/2),c=a(r/2),u=a(i/2),d=s(n/2),f=s(r/2),h=s(i/2);switch(o){case"XYZ":this._x=d*c*u+l*f*h,this._y=l*f*u-d*c*h,this._z=l*c*h+d*f*u,this._w=l*c*u-d*f*h;break;case"YXZ":this._x=d*c*u+l*f*h,this._y=l*f*u-d*c*h,this._z=l*c*h-d*f*u,this._w=l*c*u+d*f*h;break;case"ZXY":this._x=d*c*u-l*f*h,this._y=l*f*u+d*c*h,this._z=l*c*h+d*f*u,this._w=l*c*u-d*f*h;break;case"ZYX":this._x=d*c*u-l*f*h,this._y=l*f*u+d*c*h,this._z=l*c*h-d*f*u,this._w=l*c*u+d*f*h;break;case"YZX":this._x=d*c*u+l*f*h,this._y=l*f*u+d*c*h,this._z=l*c*h-d*f*u,this._w=l*c*u-d*f*h;break;case"XZY":this._x=d*c*u-l*f*h,this._y=l*f*u-d*c*h,this._z=l*c*h+d*f*u,this._w=l*c*u+d*f*h;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],i=t[8],o=t[1],a=t[5],s=t[9],l=t[2],c=t[6],u=t[10],d=n+a+u;if(d>0){const e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(c-s)*e,this._y=(i-l)*e,this._z=(o-r)*e}else if(n>a&&n>u){const e=2*Math.sqrt(1+n-a-u);this._w=(c-s)/e,this._x=.25*e,this._y=(r+o)/e,this._z=(i+l)/e}else if(a>u){const e=2*Math.sqrt(1+a-n-u);this._w=(i-l)/e,this._x=(r+o)/e,this._y=.25*e,this._z=(s+c)/e}else{const e=2*Math.sqrt(1+u-n-a);this._w=(o-r)/e,this._x=(i+l)/e,this._y=(s+c)/e,this._z=.25*e}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(AM(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const r=Math.min(1,t/n);return this.slerp(e,r),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 0===e?(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,r=e._y,i=e._z,o=e._w,a=t._x,s=t._y,l=t._z,c=t._w;return this._x=n*c+o*a+r*l-i*s,this._y=r*c+o*s+i*a-n*l,this._z=i*c+o*l+n*s-r*a,this._w=o*c-n*a-r*s-i*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,r=this._y,i=this._z,o=this._w;let a=o*e._w+n*e._x+r*e._y+i*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=r,this._z=i,this;const s=1-a*a;if(s<=Number.EPSILON){const e=1-t;return this._w=e*o+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),c=Math.atan2(l,a),u=Math.sin((1-t)*c)/l,d=Math.sin(t*c)/l;return this._w=o*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),r=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(t*Math.cos(r),n*Math.sin(i),n*Math.cos(i),t*Math.sin(r))}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}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class d_{constructor(e=0,t=0,n=0){d_.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(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(h_.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(h_.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=e.elements,o=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*o,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*o,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,i=e.x,o=e.y,a=e.z,s=e.w,l=s*t+o*r-a*n,c=s*n+a*t-i*r,u=s*r+i*n-o*t,d=-i*t-o*n-a*r;return this.x=l*s+d*-i+c*-a-u*-o,this.y=c*s+d*-o+u*-i-l*-a,this.z=u*s+d*-a+l*-o-c*-i,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,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,i=e.z,o=t.x,a=t.y,s=t.z;return this.x=r*s-i*a,this.y=i*o-n*s,this.z=n*a-r*o,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return f_.copy(this).projectOnVector(e),this.sub(f_)}reflect(e){return this.sub(f_.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(AM(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}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 r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*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(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,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=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const f_=new d_,h_=new u_;class p_{constructor(e=new d_(1/0,1/0,1/0),t=new d_(-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){let t=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0;for(let s=0,l=e.length;s<l;s+=3){const l=e[s],c=e[s+1],u=e[s+2];l<t&&(t=l),c<n&&(n=c),u<r&&(r=u),l>i&&(i=l),c>o&&(o=c),u>a&&(a=u)}return this.min.set(t,n,r),this.max.set(i,o,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0;for(let s=0,l=e.count;s<l;s++){const l=e.getX(s),c=e.getY(s),u=e.getZ(s);l<t&&(t=l),c<n&&(n=c),u<r&&(r=u),l>i&&(i=l),c>o&&(o=c),u>a&&(a=u)}return this.min.set(t,n,r),this.max.set(i,o,a),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=g_.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(void 0!==n)if(t&&null!=n.attributes&&void 0!==n.attributes.position){const t=n.attributes.position;for(let n=0,r=t.count;n<r;n++)g_.fromBufferAttribute(t,n).applyMatrix4(e.matrixWorld),this.expandByPoint(g_)}else null===n.boundingBox&&n.computeBoundingBox(),v_.copy(n.boundingBox),v_.applyMatrix4(e.matrixWorld),this.union(v_);const r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],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,g_),g_.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(__),A_.subVectors(this.max,__),y_.subVectors(e.a,__),b_.subVectors(e.b,__),w_.subVectors(e.c,__),x_.subVectors(b_,y_),S_.subVectors(w_,b_),M_.subVectors(y_,w_);let t=[0,-x_.z,x_.y,0,-S_.z,S_.y,0,-M_.z,M_.y,x_.z,0,-x_.x,S_.z,0,-S_.x,M_.z,0,-M_.x,-x_.y,x_.x,0,-S_.y,S_.x,0,-M_.y,M_.x,0];return!!k_(t,y_,b_,w_,A_)&&(t=[1,0,0,0,1,0,0,0,1],!!k_(t,y_,b_,w_,A_)&&(E_.crossVectors(x_,S_),t=[E_.x,E_.y,E_.z],k_(t,y_,b_,w_,A_)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return g_.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(g_).length(),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()||(m_[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),m_[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),m_[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),m_[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),m_[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),m_[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),m_[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),m_[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(m_)),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 m_=[new d_,new d_,new d_,new d_,new d_,new d_,new d_,new d_],g_=new d_,v_=new p_,y_=new d_,b_=new d_,w_=new d_,x_=new d_,S_=new d_,M_=new d_,__=new d_,A_=new d_,E_=new d_,C_=new d_;function k_(e,t,n,r,i){for(let o=0,a=e.length-3;o<=a;o+=3){C_.fromArray(e,o);const a=i.x*Math.abs(C_.x)+i.y*Math.abs(C_.y)+i.z*Math.abs(C_.z),s=t.dot(C_),l=n.dot(C_),c=r.dot(C_);if(Math.max(-Math.max(s,l,c),Math.min(s,l,c))>a)return!1}return!0}const T_=new p_,I_=new d_,O_=new d_,R_=new d_;class P_{constructor(e=new d_,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):T_.setFromPoints(e).getCenter(n);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),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){R_.subVectors(e,this.center);const t=R_.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.add(R_.multiplyScalar(n/e)),this.radius+=n}return this}union(e){return!0===this.center.equals(e.center)?O_.set(0,0,1).multiplyScalar(e.radius):O_.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(I_.copy(e.center).add(O_)),this.expandByPoint(I_.copy(e.center).sub(O_)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const N_=new d_,L_=new d_,D_=new d_,B_=new d_,j_=new d_,F_=new d_,U_=new d_;class z_{constructor(e=new d_,t=new d_(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.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,N_)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=N_.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(N_.copy(this.direction).multiplyScalar(t).add(this.origin),N_.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){L_.copy(e).add(t).multiplyScalar(.5),D_.copy(t).sub(e).normalize(),B_.copy(this.origin).sub(L_);const i=.5*e.distanceTo(t),o=-this.direction.dot(D_),a=B_.dot(this.direction),s=-B_.dot(D_),l=B_.lengthSq(),c=Math.abs(1-o*o);let u,d,f,h;if(c>0)if(u=o*s-a,d=o*a-s,h=i*c,u>=0)if(d>=-h)if(d<=h){const e=1/c;u*=e,d*=e,f=u*(u+o*d+2*a)+d*(o*u+d+2*s)+l}else d=i,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*s)+l;else d=-i,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*s)+l;else d<=-h?(u=Math.max(0,-(-o*i+a)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+l):d<=h?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+l):(u=Math.max(0,-(o*i+a)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+l);else d=o>0?-i:i,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*s)+l;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),r&&r.copy(D_).multiplyScalar(d).add(L_),f}intersectSphere(e,t){N_.subVectors(e.center,this.origin);const n=N_.dot(this.direction),r=N_.dot(N_)-n*n,i=e.radius*e.radius;if(r>i)return null;const o=Math.sqrt(i-r),a=n-o,s=n+o;return a<0&&s<0?null:a<0?this.at(s,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?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 null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,o,a,s;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),c>=0?(i=(e.min.y-d.y)*c,o=(e.max.y-d.y)*c):(i=(e.max.y-d.y)*c,o=(e.min.y-d.y)*c),n>o||i>r?null:((i>n||n!=n)&&(n=i),(o<r||r!=r)&&(r=o),u>=0?(a=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||a>r?null:((a>n||n!=n)&&(n=a),(s<r||r!=r)&&(r=s),r<0?null:this.at(n>=0?n:r,t)))}intersectsBox(e){return null!==this.intersectBox(e,N_)}intersectTriangle(e,t,n,r,i){j_.subVectors(t,e),F_.subVectors(n,e),U_.crossVectors(j_,F_);let o,a=this.direction.dot(U_);if(a>0){if(r)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}B_.subVectors(this.origin,e);const s=o*this.direction.dot(F_.crossVectors(B_,F_));if(s<0)return null;const l=o*this.direction.dot(j_.cross(B_));if(l<0)return null;if(s+l>a)return null;const c=-o*B_.dot(U_);return c<0?null:this.at(c/a,i)}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 H_{constructor(){H_.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,n,r,i,o,a,s,l,c,u,d,f,h,p,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=l,g[6]=c,g[10]=u,g[14]=d,g[3]=f,g[7]=h,g[11]=p,g[15]=m,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 H_).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,r=1/V_.setFromMatrixColumn(e,0).length(),i=1/V_.setFromMatrixColumn(e,1).length(),o=1/V_.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,i=e.z,o=Math.cos(n),a=Math.sin(n),s=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i);if("XYZ"===e.order){const e=o*c,n=o*u,r=a*c,i=a*u;t[0]=s*c,t[4]=-s*u,t[8]=l,t[1]=n+r*l,t[5]=e-i*l,t[9]=-a*s,t[2]=i-e*l,t[6]=r+n*l,t[10]=o*s}else if("YXZ"===e.order){const e=s*c,n=s*u,r=l*c,i=l*u;t[0]=e+i*a,t[4]=r*a-n,t[8]=o*l,t[1]=o*u,t[5]=o*c,t[9]=-a,t[2]=n*a-r,t[6]=i+e*a,t[10]=o*s}else if("ZXY"===e.order){const e=s*c,n=s*u,r=l*c,i=l*u;t[0]=e-i*a,t[4]=-o*u,t[8]=r+n*a,t[1]=n+r*a,t[5]=o*c,t[9]=i-e*a,t[2]=-o*l,t[6]=a,t[10]=o*s}else if("ZYX"===e.order){const e=o*c,n=o*u,r=a*c,i=a*u;t[0]=s*c,t[4]=r*l-n,t[8]=e*l+i,t[1]=s*u,t[5]=i*l+e,t[9]=n*l-r,t[2]=-l,t[6]=a*s,t[10]=o*s}else if("YZX"===e.order){const e=o*s,n=o*l,r=a*s,i=a*l;t[0]=s*c,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=o*c,t[9]=-a*c,t[2]=-l*c,t[6]=n*u+r,t[10]=e-i*u}else if("XZY"===e.order){const e=o*s,n=o*l,r=a*s,i=a*l;t[0]=s*c,t[4]=-u,t[8]=l*c,t[1]=e*u+i,t[5]=o*c,t[9]=n*u-r,t[2]=r*u-n,t[6]=a*c,t[10]=i*u+e}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(G_,e,q_)}lookAt(e,t,n){const r=this.elements;return J_.subVectors(e,t),0===J_.lengthSq()&&(J_.z=1),J_.normalize(),K_.crossVectors(n,J_),0===K_.lengthSq()&&(1===Math.abs(n.z)?J_.x+=1e-4:J_.z+=1e-4,J_.normalize(),K_.crossVectors(n,J_)),K_.normalize(),Y_.crossVectors(J_,K_),r[0]=K_.x,r[4]=Y_.x,r[8]=J_.x,r[1]=K_.y,r[5]=Y_.y,r[9]=J_.y,r[2]=K_.z,r[6]=Y_.z,r[10]=J_.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,o=n[0],a=n[4],s=n[8],l=n[12],c=n[1],u=n[5],d=n[9],f=n[13],h=n[2],p=n[6],m=n[10],g=n[14],v=n[3],y=n[7],b=n[11],w=n[15],x=r[0],S=r[4],M=r[8],_=r[12],A=r[1],E=r[5],C=r[9],k=r[13],T=r[2],I=r[6],O=r[10],R=r[14],P=r[3],N=r[7],L=r[11],D=r[15];return i[0]=o*x+a*A+s*T+l*P,i[4]=o*S+a*E+s*I+l*N,i[8]=o*M+a*C+s*O+l*L,i[12]=o*_+a*k+s*R+l*D,i[1]=c*x+u*A+d*T+f*P,i[5]=c*S+u*E+d*I+f*N,i[9]=c*M+u*C+d*O+f*L,i[13]=c*_+u*k+d*R+f*D,i[2]=h*x+p*A+m*T+g*P,i[6]=h*S+p*E+m*I+g*N,i[10]=h*M+p*C+m*O+g*L,i[14]=h*_+p*k+m*R+g*D,i[3]=v*x+y*A+b*T+w*P,i[7]=v*S+y*E+b*I+w*N,i[11]=v*M+y*C+b*O+w*L,i[15]=v*_+y*k+b*R+w*D,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],o=e[1],a=e[5],s=e[9],l=e[13],c=e[2],u=e[6],d=e[10],f=e[14];return e[3]*(+i*s*u-r*l*u-i*a*d+n*l*d+r*a*f-n*s*f)+e[7]*(+t*s*f-t*l*d+i*o*d-r*o*f+r*l*c-i*s*c)+e[11]*(+t*l*u-t*a*f-i*o*u+n*o*f+i*a*c-n*l*c)+e[15]*(-r*a*c-t*s*u+t*a*d+r*o*u-n*o*d+n*s*c)}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 r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],u=e[9],d=e[10],f=e[11],h=e[12],p=e[13],m=e[14],g=e[15],v=u*m*l-p*d*l+p*s*f-a*m*f-u*s*g+a*d*g,y=h*d*l-c*m*l-h*s*f+o*m*f+c*s*g-o*d*g,b=c*p*l-h*u*l+h*a*f-o*p*f-c*a*g+o*u*g,w=h*u*s-c*p*s-h*a*d+o*p*d+c*a*m-o*u*m,x=t*v+n*y+r*b+i*w;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/x;return e[0]=v*S,e[1]=(p*d*i-u*m*i-p*r*f+n*m*f+u*r*g-n*d*g)*S,e[2]=(a*m*i-p*s*i+p*r*l-n*m*l-a*r*g+n*s*g)*S,e[3]=(u*s*i-a*d*i-u*r*l+n*d*l+a*r*f-n*s*f)*S,e[4]=y*S,e[5]=(c*m*i-h*d*i+h*r*f-t*m*f-c*r*g+t*d*g)*S,e[6]=(h*s*i-o*m*i-h*r*l+t*m*l+o*r*g-t*s*g)*S,e[7]=(o*d*i-c*s*i+c*r*l-t*d*l-o*r*f+t*s*f)*S,e[8]=b*S,e[9]=(h*u*i-c*p*i-h*n*f+t*p*f+c*n*g-t*u*g)*S,e[10]=(o*p*i-h*a*i+h*n*l-t*p*l-o*n*g+t*a*g)*S,e[11]=(c*a*i-o*u*i-c*n*l+t*u*l+o*n*f-t*a*f)*S,e[12]=w*S,e[13]=(c*p*r-h*u*r+h*n*d-t*p*d-c*n*m+t*u*m)*S,e[14]=(h*a*r-o*p*r-h*n*s+t*p*s+o*n*m-t*a*m)*S,e[15]=(o*u*r-c*a*r+c*n*s-t*u*s-o*n*d+t*a*d)*S,this}scale(e){const t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,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],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return 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),r=Math.sin(t),i=1-n,o=e.x,a=e.y,s=e.z,l=i*o,c=i*a;return this.set(l*o+n,l*a-r*s,l*s+r*a,0,l*a+r*s,c*a+n,c*s-r*o,0,l*s-r*a,c*s+r*o,i*s*s+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,r,i,o){return this.set(1,n,i,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,i=t._x,o=t._y,a=t._z,s=t._w,l=i+i,c=o+o,u=a+a,d=i*l,f=i*c,h=i*u,p=o*c,m=o*u,g=a*u,v=s*l,y=s*c,b=s*u,w=n.x,x=n.y,S=n.z;return r[0]=(1-(p+g))*w,r[1]=(f+b)*w,r[2]=(h-y)*w,r[3]=0,r[4]=(f-b)*x,r[5]=(1-(d+g))*x,r[6]=(m+v)*x,r[7]=0,r[8]=(h+y)*S,r[9]=(m-v)*S,r[10]=(1-(d+p))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let i=V_.set(r[0],r[1],r[2]).length();const o=V_.set(r[4],r[5],r[6]).length(),a=V_.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],W_.copy(this);const s=1/i,l=1/o,c=1/a;return W_.elements[0]*=s,W_.elements[1]*=s,W_.elements[2]*=s,W_.elements[4]*=l,W_.elements[5]*=l,W_.elements[6]*=l,W_.elements[8]*=c,W_.elements[9]*=c,W_.elements[10]*=c,t.setFromRotationMatrix(W_),n.x=i,n.y=o,n.z=a,this}makePerspective(e,t,n,r,i,o){const a=this.elements,s=2*i/(t-e),l=2*i/(n-r),c=(t+e)/(t-e),u=(n+r)/(n-r),d=-(o+i)/(o-i),f=-2*o*i/(o-i);return a[0]=s,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=l,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,r,i,o){const a=this.elements,s=1/(t-e),l=1/(n-r),c=1/(o-i),u=(t+e)*s,d=(n+r)*l,f=(o+i)*c;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])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 V_=new d_,W_=new H_,G_=new d_(0,0,0),q_=new d_(1,1,1),K_=new d_,Y_=new d_,J_=new d_,Q_=new H_,X_=new u_;class Z_{constructor(e=0,t=0,n=0,r=Z_.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}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,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,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 r=e.elements,i=r[0],o=r[4],a=r[8],s=r[1],l=r[5],c=r[9],u=r[2],d=r[6],f=r[10];switch(t){case"XYZ":this._y=Math.asin(AM(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,f),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-AM(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(s,l)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(AM(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(s,i));break;case"ZYX":this._y=Math.asin(-AM(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(AM(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-AM(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,i)):(this._x=Math.atan2(-c,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Q_.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Q_,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return X_.setFromEuler(this),this.setFromQuaternion(X_,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],void 0!==e[3]&&(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}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}Z_.DefaultOrder="XYZ",Z_.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class $_{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 0!=(this.mask&e.mask)}isEnabled(e){return 0!=(this.mask&(1<<e|0))}}let eA=0;const tA=new d_,nA=new u_,rA=new H_,iA=new d_,oA=new d_,aA=new d_,sA=new u_,lA=new d_(1,0,0),cA=new d_(0,1,0),uA=new d_(0,0,1),dA={type:"added"},fA={type:"removed"};class hA extends bM{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:eA++}),this.uuid=_M(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=hA.DefaultUp.clone();const e=new d_,t=new Z_,n=new u_,r=new d_(1,1,1);t._onChange((function(){n.setFromEuler(t,!1)})),n._onChange((function(){t.setFromQuaternion(n,void 0,!1)})),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:r},modelViewMatrix:{value:new H_},normalMatrix:{value:new LM}}),this.matrix=new H_,this.matrixWorld=new H_,this.matrixAutoUpdate=hA.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=hA.DefaultMatrixWorldAutoUpdate,this.layers=new $_,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return nA.setFromAxisAngle(e,t),this.quaternion.multiply(nA),this}rotateOnWorldAxis(e,t){return nA.setFromAxisAngle(e,t),this.quaternion.premultiply(nA),this}rotateX(e){return this.rotateOnAxis(lA,e)}rotateY(e){return this.rotateOnAxis(cA,e)}rotateZ(e){return this.rotateOnAxis(uA,e)}translateOnAxis(e,t){return tA.copy(e).applyQuaternion(this.quaternion),this.position.add(tA.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(lA,e)}translateY(e){return this.translateOnAxis(cA,e)}translateZ(e){return this.translateOnAxis(uA,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(rA.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?iA.copy(e):iA.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),oA.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?rA.lookAt(oA,iA,this.up):rA.lookAt(iA,oA,this.up),this.quaternion.setFromRotationMatrix(rA),r&&(rA.extractRotation(r.matrixWorld),nA.setFromRotationMatrix(rA),this.quaternion.premultiply(nA.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);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?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(dA)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(fA)),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(fA)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),rA.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),rA.multiply(e.parent.matrixWorld)),e.applyMatrix4(rA),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const r=this.children[n].getObjectByProperty(e,t);if(void 0!==r)return r}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(oA,e,aA),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(oA,sA,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,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(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)&&(null===this.parent?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,r=t.length;n<r;n++){const r=t[n];!0!==r.matrixWorldAutoUpdate&&!0!==e||r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(!0===e&&null!==n&&!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){const e=this.children;for(let t=0,n=e.length;t<n;t++){const n=e[t];!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=void 0===e||"string"==typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const r={};function i(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),!0===this.castShadow&&(r.castShadow=!0),!0===this.receiveShadow&&(r.receiveShadow=!0),!1===this.visible&&(r.visible=!1),!1===this.frustumCulled&&(r.frustumCulled=!1),0!==this.renderOrder&&(r.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(r.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){const r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){const n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){const t=o(e.geometries),r=o(e.materials),i=o(e.textures),a=o(e.images),s=o(e.shapes),l=o(e.skeletons),c=o(e.animations),u=o(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),a.length>0&&(n.images=a),s.length>0&&(n.shapes=s),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),u.length>0&&(n.nodes=u)}return n.object=r,n;function o(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){const n=e.children[t];this.add(n.clone())}return this}}hA.DefaultUp=new d_(0,1,0),hA.DefaultMatrixAutoUpdate=!0,hA.DefaultMatrixWorldAutoUpdate=!0;const pA=new d_,mA=new d_,gA=new d_,vA=new d_,yA=new d_,bA=new d_,wA=new d_,xA=new d_,SA=new d_,MA=new d_;class _A{constructor(e=new d_,t=new d_,n=new d_){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),pA.subVectors(e,t),r.cross(pA);const i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){pA.subVectors(r,t),mA.subVectors(n,t),gA.subVectors(e,t);const o=pA.dot(pA),a=pA.dot(mA),s=pA.dot(gA),l=mA.dot(mA),c=mA.dot(gA),u=o*l-a*a;if(0===u)return i.set(-2,-1,-1);const d=1/u,f=(l*s-a*c)*d,h=(o*c-a*s)*d;return i.set(1-f-h,h,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,vA),vA.x>=0&&vA.y>=0&&vA.x+vA.y<=1}static getUV(e,t,n,r,i,o,a,s){return this.getBarycoord(e,t,n,r,vA),s.set(0,0),s.addScaledVector(i,vA.x),s.addScaledVector(o,vA.y),s.addScaledVector(a,vA.z),s}static isFrontFacing(e,t,n,r){return pA.subVectors(n,t),mA.subVectors(e,t),pA.cross(mA).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),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 pA.subVectors(this.c,this.b),mA.subVectors(this.a,this.b),.5*pA.cross(mA).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return _A.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return _A.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,r,i){return _A.getUV(e,this.a,this.b,this.c,t,n,r,i)}containsPoint(e){return _A.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return _A.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,i=this.c;let o,a;yA.subVectors(r,n),bA.subVectors(i,n),xA.subVectors(e,n);const s=yA.dot(xA),l=bA.dot(xA);if(s<=0&&l<=0)return t.copy(n);SA.subVectors(e,r);const c=yA.dot(SA),u=bA.dot(SA);if(c>=0&&u<=c)return t.copy(r);const d=s*u-c*l;if(d<=0&&s>=0&&c<=0)return o=s/(s-c),t.copy(n).addScaledVector(yA,o);MA.subVectors(e,i);const f=yA.dot(MA),h=bA.dot(MA);if(h>=0&&f<=h)return t.copy(i);const p=f*l-s*h;if(p<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(bA,a);const m=c*h-f*u;if(m<=0&&u-c>=0&&f-h>=0)return wA.subVectors(i,r),a=(u-c)/(u-c+(f-h)),t.copy(r).addScaledVector(wA,a);const g=1/(m+p+d);return o=p*g,a=d*g,t.copy(n).addScaledVector(yA,o).addScaledVector(bA,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let AA=0;class EA extends bM{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:AA++}),this.uuid=_M(),this.name="",this.type="Material",this.blending=_w,this.side=ww,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=jw,this.blendDst=Fw,this.blendEquation=Tw,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Yw,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=aM,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=qS,this.stencilZFail=qS,this.stencilZPass=qS,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}const r=this[t];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(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()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(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.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,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==_w&&(n.blending=this.blending),this.side!==ww&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t){const t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let r=0;r!==e;++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.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,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){!0===e&&this.version++}}class CA extends EA{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new QM(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$w,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const kA=new d_,TA=new NM;class IA{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===n,this.usage=sM,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,n=this.count;t<n;t++)TA.fromBufferAttribute(this,t),TA.applyMatrix3(e),this.setXY(t,TA.x,TA.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)kA.fromBufferAttribute(this,t),kA.applyMatrix3(e),this.setXYZ(t,kA.x,kA.y,kA.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)kA.fromBufferAttribute(this,t),kA.applyMatrix4(e),this.setXYZ(t,kA.x,kA.y,kA.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)kA.fromBufferAttribute(this,t),kA.applyNormalMatrix(e),this.setXYZ(t,kA.x,kA.y,kA.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)kA.fromBufferAttribute(this,t),kA.transformDirection(e),this.setXYZ(t,kA.x,kA.y,kA.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=OM(t,this.array)),t}setX(e,t){return this.normalized&&(t=RM(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=OM(t,this.array)),t}setY(e,t){return this.normalized&&(t=RM(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=OM(t,this.array)),t}setZ(e,t){return this.normalized&&(t=RM(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=OM(t,this.array)),t}setW(e,t){return this.normalized&&(t=RM(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=RM(t,this.array),n=RM(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=RM(t,this.array),n=RM(n,this.array),r=RM(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=RM(t,this.array),n=RM(n,this.array),r=RM(r,this.array),i=RM(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,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!==sM&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}}class OA extends IA{constructor(e,t,n){super(new Int8Array(e),t,n)}}class RA extends IA{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class PA extends IA{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class NA extends IA{constructor(e,t,n){super(new Int16Array(e),t,n)}}class LA extends IA{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class DA extends IA{constructor(e,t,n){super(new Int32Array(e),t,n)}}class BA extends IA{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class jA extends IA{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}}class FA extends IA{constructor(e,t,n){super(new Float32Array(e),t,n)}}class UA extends IA{constructor(e,t,n){super(new Float64Array(e),t,n)}}let zA=0;const HA=new H_,VA=new hA,WA=new d_,GA=new p_,qA=new p_,KA=new d_;class YA extends bM{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:zA++}),this.uuid=_M(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(DM(e)?BA:LA)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}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;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const t=(new LM).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(e),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return HA.makeRotationFromQuaternion(e),this.applyMatrix4(HA),this}rotateX(e){return HA.makeRotationX(e),this.applyMatrix4(HA),this}rotateY(e){return HA.makeRotationY(e),this.applyMatrix4(HA),this}rotateZ(e){return HA.makeRotationZ(e),this.applyMatrix4(HA),this}translate(e,t,n){return HA.makeTranslation(e,t,n),this.applyMatrix4(HA),this}scale(e,t,n){return HA.makeScale(e,t,n),this.applyMatrix4(HA),this}lookAt(e){return VA.lookAt(e),VA.updateMatrix(),this.applyMatrix4(VA.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(WA).negate(),this.translate(WA.x,WA.y,WA.z),this}setFromPoints(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new FA(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new p_);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new d_(-1/0,-1/0,-1/0),new d_(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];GA.setFromBufferAttribute(n),this.morphTargetsRelative?(KA.addVectors(this.boundingBox.min,GA.min),this.boundingBox.expandByPoint(KA),KA.addVectors(this.boundingBox.max,GA.max),this.boundingBox.expandByPoint(KA)):(this.boundingBox.expandByPoint(GA.min),this.boundingBox.expandByPoint(GA.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(){null===this.boundingSphere&&(this.boundingSphere=new P_);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new d_,1/0);if(e){const n=this.boundingSphere.center;if(GA.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];qA.setFromBufferAttribute(n),this.morphTargetsRelative?(KA.addVectors(GA.min,qA.min),GA.expandByPoint(KA),KA.addVectors(GA.max,qA.max),GA.expandByPoint(KA)):(GA.expandByPoint(qA.min),GA.expandByPoint(qA.max))}GA.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)KA.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(KA));if(t)for(let i=0,o=t.length;i<o;i++){const o=t[i],a=this.morphTargetsRelative;for(let t=0,i=o.count;t<i;t++)KA.fromBufferAttribute(o,t),a&&(WA.fromBufferAttribute(e,t),KA.add(WA)),r=Math.max(r,n.distanceToSquared(KA))}this.boundingSphere.radius=Math.sqrt(r),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(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.array,r=t.position.array,i=t.normal.array,o=t.uv.array,a=r.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new IA(new Float32Array(4*a),4));const s=this.getAttribute("tangent").array,l=[],c=[];for(let e=0;e<a;e++)l[e]=new d_,c[e]=new d_;const u=new d_,d=new d_,f=new d_,h=new NM,p=new NM,m=new NM,g=new d_,v=new d_;function y(e,t,n){u.fromArray(r,3*e),d.fromArray(r,3*t),f.fromArray(r,3*n),h.fromArray(o,2*e),p.fromArray(o,2*t),m.fromArray(o,2*n),d.sub(u),f.sub(u),p.sub(h),m.sub(h);const i=1/(p.x*m.y-m.x*p.y);isFinite(i)&&(g.copy(d).multiplyScalar(m.y).addScaledVector(f,-p.y).multiplyScalar(i),v.copy(f).multiplyScalar(p.x).addScaledVector(d,-m.x).multiplyScalar(i),l[e].add(g),l[t].add(g),l[n].add(g),c[e].add(v),c[t].add(v),c[n].add(v))}let b=this.groups;0===b.length&&(b=[{start:0,count:n.length}]);for(let e=0,t=b.length;e<t;++e){const t=b[e],r=t.start;for(let e=r,i=r+t.count;e<i;e+=3)y(n[e+0],n[e+1],n[e+2])}const w=new d_,x=new d_,S=new d_,M=new d_;function _(e){S.fromArray(i,3*e),M.copy(S);const t=l[e];w.copy(t),w.sub(S.multiplyScalar(S.dot(t))).normalize(),x.crossVectors(M,t);const n=x.dot(c[e])<0?-1:1;s[4*e]=w.x,s[4*e+1]=w.y,s[4*e+2]=w.z,s[4*e+3]=n}for(let e=0,t=b.length;e<t;++e){const t=b[e],r=t.start;for(let e=r,i=r+t.count;e<i;e+=3)_(n[e+0]),_(n[e+1]),_(n[e+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let n=this.getAttribute("normal");if(void 0===n)n=new IA(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);const r=new d_,i=new d_,o=new d_,a=new d_,s=new d_,l=new d_,c=new d_,u=new d_;if(e)for(let d=0,f=e.count;d<f;d+=3){const f=e.getX(d+0),h=e.getX(d+1),p=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,h),o.fromBufferAttribute(t,p),c.subVectors(o,i),u.subVectors(r,i),c.cross(u),a.fromBufferAttribute(n,f),s.fromBufferAttribute(n,h),l.fromBufferAttribute(n,p),a.add(c),s.add(c),l.add(c),n.setXYZ(f,a.x,a.y,a.z),n.setXYZ(h,s.x,s.y,s.z),n.setXYZ(p,l.x,l.y,l.z)}else for(let e=0,a=t.count;e<a;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),o.fromBufferAttribute(t,e+2),c.subVectors(o,i),u.subVectors(r,i),c.cross(u),n.setXYZ(e+0,c.x,c.y,c.z),n.setXYZ(e+1,c.x,c.y,c.z),n.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeBufferGeometries() instead."),this}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)KA.fromBufferAttribute(e,t),KA.normalize(),e.setXYZ(t,KA.x,KA.y,KA.z)}toNonIndexed(){function e(e,t){const n=e.array,r=e.itemSize,i=e.normalized,o=new n.constructor(t.length*r);let a=0,s=0;for(let i=0,l=t.length;i<l;i++){a=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)o[s++]=n[a++]}return new IA(o,r,i)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new YA,n=this.index.array,r=this.attributes;for(const i in r){const o=e(r[i],n);t.setAttribute(i,o)}const i=this.morphAttributes;for(const r in i){const o=[],a=i[r];for(let t=0,r=a.length;t<r;t++){const r=e(a[t],n);o.push(r)}t.morphAttributes[r]=o}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let e=0,n=o.length;e<n;e++){const n=o[e];t.addGroup(n.start,n.count,n.materialIndex)}return t}toJSON(){const e={metadata:{version:4.5,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),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const r=n[t];e.data.attributes[t]=r.toJSON(e.data)}const r={};let i=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],o=[];for(let t=0,r=n.length;t<r;t++){const r=n[t];o.push(r.toJSON(e.data))}o.length>0&&(r[t]=o,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const r=e.attributes;for(const e in r){const n=r[e];this.setAttribute(e,n.clone(t))}const i=e.morphAttributes;for(const e in i){const n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let e=0,t=o.length;e<t;e++){const t=o[e];this.addGroup(t.start,t.count,t.materialIndex)}const a=e.boundingBox;null!==a&&(this.boundingBox=a.clone());const s=e.boundingSphere;return null!==s&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,void 0!==e.parameters&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}const JA=new H_,QA=new z_,XA=new P_,ZA=new d_,$A=new d_,eE=new d_,tE=new d_,nE=new d_,rE=new d_,iE=new d_,oE=new d_,aE=new d_,sE=new NM,lE=new NM,cE=new NM,uE=new d_,dE=new d_;class fE extends hA{constructor(e=new YA,t=new CA){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}raycast(e,t){const n=this.geometry,r=this.material,i=this.matrixWorld;if(void 0===r)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),XA.copy(n.boundingSphere),XA.applyMatrix4(i),!1===e.ray.intersectsSphere(XA))return;if(JA.copy(i).invert(),QA.copy(e.ray).applyMatrix4(JA),null!==n.boundingBox&&!1===QA.intersectsBox(n.boundingBox))return;let o;const a=n.index,s=n.attributes.position,l=n.morphAttributes.position,c=n.morphTargetsRelative,u=n.attributes.uv,d=n.attributes.uv2,f=n.groups,h=n.drawRange;if(null!==a)if(Array.isArray(r))for(let n=0,i=f.length;n<i;n++){const i=f[n],p=r[i.materialIndex];for(let n=Math.max(i.start,h.start),r=Math.min(a.count,Math.min(i.start+i.count,h.start+h.count));n<r;n+=3){const r=a.getX(n),f=a.getX(n+1),h=a.getX(n+2);o=hE(this,p,e,QA,s,l,c,u,d,r,f,h),o&&(o.faceIndex=Math.floor(n/3),o.face.materialIndex=i.materialIndex,t.push(o))}}else{for(let n=Math.max(0,h.start),i=Math.min(a.count,h.start+h.count);n<i;n+=3){const i=a.getX(n),f=a.getX(n+1),h=a.getX(n+2);o=hE(this,r,e,QA,s,l,c,u,d,i,f,h),o&&(o.faceIndex=Math.floor(n/3),t.push(o))}}else if(void 0!==s)if(Array.isArray(r))for(let n=0,i=f.length;n<i;n++){const i=f[n],a=r[i.materialIndex];for(let n=Math.max(i.start,h.start),r=Math.min(s.count,Math.min(i.start+i.count,h.start+h.count));n<r;n+=3){o=hE(this,a,e,QA,s,l,c,u,d,n,n+1,n+2),o&&(o.faceIndex=Math.floor(n/3),o.face.materialIndex=i.materialIndex,t.push(o))}}else{for(let n=Math.max(0,h.start),i=Math.min(s.count,h.start+h.count);n<i;n+=3){o=hE(this,r,e,QA,s,l,c,u,d,n,n+1,n+2),o&&(o.faceIndex=Math.floor(n/3),t.push(o))}}}}function hE(e,t,n,r,i,o,a,s,l,c,u,d){ZA.fromBufferAttribute(i,c),$A.fromBufferAttribute(i,u),eE.fromBufferAttribute(i,d);const f=e.morphTargetInfluences;if(o&&f){iE.set(0,0,0),oE.set(0,0,0),aE.set(0,0,0);for(let e=0,t=o.length;e<t;e++){const t=f[e],n=o[e];0!==t&&(tE.fromBufferAttribute(n,c),nE.fromBufferAttribute(n,u),rE.fromBufferAttribute(n,d),a?(iE.addScaledVector(tE,t),oE.addScaledVector(nE,t),aE.addScaledVector(rE,t)):(iE.addScaledVector(tE.sub(ZA),t),oE.addScaledVector(nE.sub($A),t),aE.addScaledVector(rE.sub(eE),t)))}ZA.add(iE),$A.add(oE),eE.add(aE)}e.isSkinnedMesh&&(e.boneTransform(c,ZA),e.boneTransform(u,$A),e.boneTransform(d,eE));const h=function(e,t,n,r,i,o,a,s){let l;if(l=t.side===xw?r.intersectTriangle(a,o,i,!0,s):r.intersectTriangle(i,o,a,t.side!==Sw,s),null===l)return null;dE.copy(s),dE.applyMatrix4(e.matrixWorld);const c=n.ray.origin.distanceTo(dE);return c<n.near||c>n.far?null:{distance:c,point:dE.clone(),object:e}}(e,t,n,r,ZA,$A,eE,uE);if(h){s&&(sE.fromBufferAttribute(s,c),lE.fromBufferAttribute(s,u),cE.fromBufferAttribute(s,d),h.uv=_A.getUV(uE,ZA,$A,eE,sE,lE,cE,new NM)),l&&(sE.fromBufferAttribute(l,c),lE.fromBufferAttribute(l,u),cE.fromBufferAttribute(l,d),h.uv2=_A.getUV(uE,ZA,$A,eE,sE,lE,cE,new NM));const e={a:c,b:u,c:d,normal:new d_,materialIndex:0};_A.getNormal(ZA,$A,eE,e.normal),h.face=e}return h}class pE extends YA{constructor(e=1,t=1,n=1,r=1,i=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:o};const a=this;r=Math.floor(r),i=Math.floor(i),o=Math.floor(o);const s=[],l=[],c=[],u=[];let d=0,f=0;function h(e,t,n,r,i,o,h,p,m,g,v){const y=o/m,b=h/g,w=o/2,x=h/2,S=p/2,M=m+1,_=g+1;let A=0,E=0;const C=new d_;for(let o=0;o<_;o++){const a=o*b-x;for(let s=0;s<M;s++){const d=s*y-w;C[e]=d*r,C[t]=a*i,C[n]=S,l.push(C.x,C.y,C.z),C[e]=0,C[t]=0,C[n]=p>0?1:-1,c.push(C.x,C.y,C.z),u.push(s/m),u.push(1-o/g),A+=1}}for(let e=0;e<g;e++)for(let t=0;t<m;t++){const n=d+t+M*e,r=d+t+M*(e+1),i=d+(t+1)+M*(e+1),o=d+(t+1)+M*e;s.push(n,r,o),s.push(r,i,o),E+=6}a.addGroup(f,E,v),f+=E,d+=A}h("z","y","x",-1,-1,n,t,e,o,i,0),h("z","y","x",1,-1,n,t,-e,o,i,1),h("x","z","y",1,1,e,n,t,r,o,2),h("x","z","y",1,-1,e,n,-t,r,o,3),h("x","y","z",1,-1,e,t,n,r,i,4),h("x","y","z",-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute("position",new FA(l,3)),this.setAttribute("normal",new FA(c,3)),this.setAttribute("uv",new FA(u,2))}static fromJSON(e){return new pE(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function mE(e){const t={};for(const n in e){t[n]={};for(const r in e[n]){const i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}}return t}function gE(e){const t={};for(let n=0;n<e.length;n++){const r=mE(e[n]);for(const e in r)t[e]=r[e]}return t}const vE={clone:mE,merge:gE};class yE extends EA{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=mE(e.uniforms),this.uniformsGroups=function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}(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 n in this.uniforms){const r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:"m4",value:r.toArray()}:t.uniforms[n]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class bE extends hA{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new H_,this.projectionMatrix=new H_,this.projectionMatrixInverse=new H_}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class wE extends bE{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,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=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*MM*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*SM*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*MM*Math.atan(Math.tan(.5*SM*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,r,i,o){this.aspect=e/t,null===this.view&&(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=r,this.view.width=i,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*SM*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r;const o=this.view;if(null!==this.view&&this.view.enabled){const e=o.fullWidth,a=o.fullHeight;i+=o.offsetX*r/e,t-=o.offsetY*n/a,r*=o.width/e,n*=o.height/a}const a=this.filmOffset;0!==a&&(i+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far),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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const xE=90;class SE extends hA{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n;const r=new wE(xE,1,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new d_(1,0,0)),this.add(r);const i=new wE(xE,1,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new d_(-1,0,0)),this.add(i);const o=new wE(xE,1,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new d_(0,1,0)),this.add(o);const a=new wE(xE,1,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new d_(0,-1,0)),this.add(a);const s=new wE(xE,1,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new d_(0,0,1)),this.add(s);const l=new wE(xE,1,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new d_(0,0,-1)),this.add(l)}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[r,i,o,a,s,l]=this.children,c=e.getRenderTarget(),u=e.toneMapping,d=e.xr.enabled;e.toneMapping=nx,e.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,r),e.setRenderTarget(n,1),e.render(t,i),e.setRenderTarget(n,2),e.render(t,o),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=f,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(c),e.toneMapping=u,e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class ME extends n_{constructor(e,t,n,r,i,o,a,s,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:cx,n,r,i,o,a,s,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class _E extends i_{constructor(e,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new ME(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:Sx}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},r=new pE(5,5,5),i=new yE({name:"CubemapFromEquirect",uniforms:mE(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:xw,blending:Mw});i.uniforms.tEquirect.value=t;const o=new fE(r,i),a=t.minFilter;t.minFilter===Ax&&(t.minFilter=Sx);return new SE(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,r){const i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}}const AE=new d_,EE=new d_,CE=new LM;class kE{constructor(e=new d_(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,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=AE.subVectors(n,t).cross(EE.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,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(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const n=e.delta(AE),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(n).multiplyScalar(i).add(e.start)}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||CE.getNormalMatrix(e),r=this.coplanarPoint(AE).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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 TE=new P_,IE=new d_;class OE{constructor(e=new kE,t=new kE,n=new kE,r=new kE,i=new kE,o=new kE){this.planes=[e,t,n,r,i,o]}set(e,t,n,r,i,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(r),a[4].copy(i),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],c=n[6],u=n[7],d=n[8],f=n[9],h=n[10],p=n[11],m=n[12],g=n[13],v=n[14],y=n[15];return t[0].setComponents(a-r,u-s,p-d,y-m).normalize(),t[1].setComponents(a+r,u+s,p+d,y+m).normalize(),t[2].setComponents(a+i,u+l,p+f,y+g).normalize(),t[3].setComponents(a-i,u-l,p-f,y-g).normalize(),t[4].setComponents(a-o,u-c,p-h,y-v).normalize(),t[5].setComponents(a+o,u+c,p+h,y+v).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),TE.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(TE)}intersectsSprite(e){return TE.center.set(0,0,0),TE.radius=.7071067811865476,TE.applyMatrix4(e.matrixWorld),this.intersectsSphere(TE)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)<r)return!1}return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(IE.x=r.normal.x>0?e.max.x:e.min.x,IE.y=r.normal.y>0?e.max.y:e.min.y,IE.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(IE)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function RE(){let e=null,t=!1,n=null,r=null;function i(t,o){n(t,o),r=e.requestAnimationFrame(i)}return{start:function(){!0!==t&&null!==n&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function PE(e,t){const n=t.isWebGL2,r=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),r.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=r.get(t);n&&(e.deleteBuffer(n.buffer),r.delete(t))},update:function(t,i){if(t.isGLBufferAttribute){const e=r.get(t);return void((!e||e.version<t.version)&&r.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const o=r.get(t);void 0===o?r.set(t,function(t,r){const i=t.array,o=t.usage,a=e.createBuffer();let s;if(e.bindBuffer(r,a),e.bufferData(r,i,o),t.onUploadCallback(),i instanceof Float32Array)s=5126;else if(i instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!n)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");s=5131}else s=5123;else if(i instanceof Int16Array)s=5122;else if(i instanceof Uint32Array)s=5125;else if(i instanceof Int32Array)s=5124;else if(i instanceof Int8Array)s=5120;else if(i instanceof Uint8Array)s=5121;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);s=5121}return{buffer:a,type:s,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}(t,i)):o.version<t.version&&(!function(t,r,i){const o=r.array,a=r.updateRange;e.bindBuffer(i,t),-1===a.count?e.bufferSubData(i,0,o):(n?e.bufferSubData(i,a.offset*o.BYTES_PER_ELEMENT,o,a.offset,a.count):e.bufferSubData(i,a.offset*o.BYTES_PER_ELEMENT,o.subarray(a.offset,a.offset+a.count)),a.count=-1)}(o.buffer,t,i),o.version=t.version)}}}class NE extends YA{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const i=e/2,o=t/2,a=Math.floor(n),s=Math.floor(r),l=a+1,c=s+1,u=e/a,d=t/s,f=[],h=[],p=[],m=[];for(let e=0;e<c;e++){const t=e*d-o;for(let n=0;n<l;n++){const r=n*u-i;h.push(r,-t,0),p.push(0,0,1),m.push(n/a),m.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<a;t++){const n=t+l*e,r=t+l*(e+1),i=t+1+l*(e+1),o=t+1+l*e;f.push(n,r,o),f.push(r,i,o)}this.setIndex(f),this.setAttribute("position",new FA(h,3)),this.setAttribute("normal",new FA(p,3)),this.setAttribute("uv",new FA(m,2))}static fromJSON(e){return new NE(e.width,e.height,e.widthSegments,e.heightSegments)}}const LE={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\n#ifdef USE_IRIDESCENCE\n\tvec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\t return vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat R21 = R12;\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = dFdy( surf_pos.xyz );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert\n#define Material_LightProbeLOD( material )\t(0)",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid 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 ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );\n\t#else\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if defined( USE_SHADOWMAP ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_COORDS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef texture2DLodEXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tgl_FragColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tgl_FragColor = vec4( mix( pow( gl_FragColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), gl_FragColor.rgb * 0.0773993808, vec3( lessThanEqual( gl_FragColor.rgb, vec3( 0.04045 ) ) ) ), gl_FragColor.w );\n\t#endif\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}"},DE={common:{diffuse:{value:new QM(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new LM},uv2Transform:{value:new LM},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new NM(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new QM(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new QM(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new LM}},sprite:{diffuse:{value:new QM(16777215)},opacity:{value:1},center:{value:new NM(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new LM}}},BE={basic:{uniforms:gE([DE.common,DE.specularmap,DE.envmap,DE.aomap,DE.lightmap,DE.fog]),vertexShader:LE.meshbasic_vert,fragmentShader:LE.meshbasic_frag},lambert:{uniforms:gE([DE.common,DE.specularmap,DE.envmap,DE.aomap,DE.lightmap,DE.emissivemap,DE.bumpmap,DE.normalmap,DE.displacementmap,DE.fog,DE.lights,{emissive:{value:new QM(0)}}]),vertexShader:LE.meshlambert_vert,fragmentShader:LE.meshlambert_frag},phong:{uniforms:gE([DE.common,DE.specularmap,DE.envmap,DE.aomap,DE.lightmap,DE.emissivemap,DE.bumpmap,DE.normalmap,DE.displacementmap,DE.fog,DE.lights,{emissive:{value:new QM(0)},specular:{value:new QM(1118481)},shininess:{value:30}}]),vertexShader:LE.meshphong_vert,fragmentShader:LE.meshphong_frag},standard:{uniforms:gE([DE.common,DE.envmap,DE.aomap,DE.lightmap,DE.emissivemap,DE.bumpmap,DE.normalmap,DE.displacementmap,DE.roughnessmap,DE.metalnessmap,DE.fog,DE.lights,{emissive:{value:new QM(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:LE.meshphysical_vert,fragmentShader:LE.meshphysical_frag},toon:{uniforms:gE([DE.common,DE.aomap,DE.lightmap,DE.emissivemap,DE.bumpmap,DE.normalmap,DE.displacementmap,DE.gradientmap,DE.fog,DE.lights,{emissive:{value:new QM(0)}}]),vertexShader:LE.meshtoon_vert,fragmentShader:LE.meshtoon_frag},matcap:{uniforms:gE([DE.common,DE.bumpmap,DE.normalmap,DE.displacementmap,DE.fog,{matcap:{value:null}}]),vertexShader:LE.meshmatcap_vert,fragmentShader:LE.meshmatcap_frag},points:{uniforms:gE([DE.points,DE.fog]),vertexShader:LE.points_vert,fragmentShader:LE.points_frag},dashed:{uniforms:gE([DE.common,DE.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:LE.linedashed_vert,fragmentShader:LE.linedashed_frag},depth:{uniforms:gE([DE.common,DE.displacementmap]),vertexShader:LE.depth_vert,fragmentShader:LE.depth_frag},normal:{uniforms:gE([DE.common,DE.bumpmap,DE.normalmap,DE.displacementmap,{opacity:{value:1}}]),vertexShader:LE.meshnormal_vert,fragmentShader:LE.meshnormal_frag},sprite:{uniforms:gE([DE.sprite,DE.fog]),vertexShader:LE.sprite_vert,fragmentShader:LE.sprite_frag},background:{uniforms:{uvTransform:{value:new LM},t2D:{value:null}},vertexShader:LE.background_vert,fragmentShader:LE.background_frag},cube:{uniforms:gE([DE.envmap,{opacity:{value:1}}]),vertexShader:LE.cube_vert,fragmentShader:LE.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:LE.equirect_vert,fragmentShader:LE.equirect_frag},distanceRGBA:{uniforms:gE([DE.common,DE.displacementmap,{referencePosition:{value:new d_},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:LE.distanceRGBA_vert,fragmentShader:LE.distanceRGBA_frag},shadow:{uniforms:gE([DE.lights,DE.fog,{color:{value:new QM(0)},opacity:{value:1}}]),vertexShader:LE.shadow_vert,fragmentShader:LE.shadow_frag}};function jE(e,t,n,r,i,o){const a=new QM(0);let s,l,c=!0===i?0:1,u=null,d=0,f=null;function h(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,o)}return{getClearColor:function(){return a},setClearColor:function(e,t=1){a.set(e),c=t,h(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,h(a,c)},render:function(n,i){let o=!1,p=!0===i.isScene?i.background:null;p&&p.isTexture&&(p=t.get(p));const m=e.xr,g=m.getSession&&m.getSession();g&&"additive"===g.environmentBlendMode&&(p=null),null===p?h(a,c):p&&p.isColor&&(h(p,1),o=!0),(e.autoClear||o)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),p&&(p.isCubeTexture||p.mapping===hx)?(void 0===l&&(l=new fE(new pE(1,1,1),new yE({name:"BackgroundCubeMaterial",uniforms:mE(BE.cube.uniforms),vertexShader:BE.cube.vertexShader,fragmentShader:BE.cube.fragmentShader,side:xw,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=p,l.material.uniforms.flipEnvMap.value=p.isCubeTexture&&!1===p.isRenderTargetTexture?-1:1,u===p&&d===p.version&&f===e.toneMapping||(l.material.needsUpdate=!0,u=p,d=p.version,f=e.toneMapping),l.layers.enableAll(),n.unshift(l,l.geometry,l.material,0,0,null)):p&&p.isTexture&&(void 0===s&&(s=new fE(new NE(2,2),new yE({name:"BackgroundMaterial",uniforms:mE(BE.background.uniforms),vertexShader:BE.background.vertexShader,fragmentShader:BE.background.fragmentShader,side:ww,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(s)),s.material.uniforms.t2D.value=p,!0===p.matrixAutoUpdate&&p.updateMatrix(),s.material.uniforms.uvTransform.value.copy(p.matrix),u===p&&d===p.version&&f===e.toneMapping||(s.material.needsUpdate=!0,u=p,d=p.version,f=e.toneMapping),s.layers.enableAll(),n.unshift(s,s.geometry,s.material,0,0,null))}}}function FE(e,t,n,r){const i=e.getParameter(34921),o=r.isWebGL2?null:t.get("OES_vertex_array_object"),a=r.isWebGL2||null!==o,s={},l=h(null);let c=l,u=!1;function d(t){return r.isWebGL2?e.bindVertexArray(t):o.bindVertexArrayOES(t)}function f(t){return r.isWebGL2?e.deleteVertexArray(t):o.deleteVertexArrayOES(t)}function h(e){const t=[],n=[],r=[];for(let e=0;e<i;e++)t[e]=0,n[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:r,object:e,attributes:{},index:null}}function p(){const e=c.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function m(e){g(e,0)}function g(n,i){const o=c.newAttributes,a=c.enabledAttributes,s=c.attributeDivisors;if(o[n]=1,0===a[n]&&(e.enableVertexAttribArray(n),a[n]=1),s[n]!==i){(r.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,i),s[n]=i}}function v(){const t=c.newAttributes,n=c.enabledAttributes;for(let r=0,i=n.length;r<i;r++)n[r]!==t[r]&&(e.disableVertexAttribArray(r),n[r]=0)}function y(t,n,i,o,a,s){!0!==r.isWebGL2||5124!==i&&5125!==i?e.vertexAttribPointer(t,n,i,o,a,s):e.vertexAttribIPointer(t,n,i,a,s)}function b(){w(),u=!0,c!==l&&(c=l,d(c.object))}function w(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(i,l,f,b,w){let x=!1;if(a){const t=function(t,n,i){const a=!0===i.wireframe;let l=s[t.id];void 0===l&&(l={},s[t.id]=l);let c=l[n.id];void 0===c&&(c={},l[n.id]=c);let u=c[a];void 0===u&&(u=h(r.isWebGL2?e.createVertexArray():o.createVertexArrayOES()),c[a]=u);return u}(b,f,l);c!==t&&(c=t,d(c.object)),x=function(e,t,n,r){const i=c.attributes,o=t.attributes;let a=0;const s=n.getAttributes();for(const t in s){if(s[t].location>=0){const n=i[t];let r=o[t];if(void 0===r&&("instanceMatrix"===t&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(r=e.instanceColor)),void 0===n)return!0;if(n.attribute!==r)return!0;if(r&&n.data!==r.data)return!0;a++}}return c.attributesNum!==a||c.index!==r}(i,b,f,w),x&&function(e,t,n,r){const i={},o=t.attributes;let a=0;const s=n.getAttributes();for(const t in s){if(s[t].location>=0){let n=o[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,a++}}c.attributes=i,c.attributesNum=a,c.index=r}(i,b,f,w)}else{const e=!0===l.wireframe;c.geometry===b.id&&c.program===f.id&&c.wireframe===e||(c.geometry=b.id,c.program=f.id,c.wireframe=e,x=!0)}null!==w&&n.update(w,34963),(x||u)&&(u=!1,function(i,o,a,s){if(!1===r.isWebGL2&&(i.isInstancedMesh||s.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;p();const l=s.attributes,c=a.getAttributes(),u=o.defaultAttributeValues;for(const t in c){const r=c[t];if(r.location>=0){let o=l[t];if(void 0===o&&("instanceMatrix"===t&&i.instanceMatrix&&(o=i.instanceMatrix),"instanceColor"===t&&i.instanceColor&&(o=i.instanceColor)),void 0!==o){const t=o.normalized,a=o.itemSize,l=n.get(o);if(void 0===l)continue;const c=l.buffer,u=l.type,d=l.bytesPerElement;if(o.isInterleavedBufferAttribute){const n=o.data,l=n.stride,f=o.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e<r.locationSize;e++)g(r.location+e,n.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let e=0;e<r.locationSize;e++)m(r.location+e);e.bindBuffer(34962,c);for(let e=0;e<r.locationSize;e++)y(r.location+e,a/r.locationSize,u,t,l*d,(f+a/r.locationSize*e)*d)}else{if(o.isInstancedBufferAttribute){for(let e=0;e<r.locationSize;e++)g(r.location+e,o.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let e=0;e<r.locationSize;e++)m(r.location+e);e.bindBuffer(34962,c);for(let e=0;e<r.locationSize;e++)y(r.location+e,a/r.locationSize,u,t,a*d,a/r.locationSize*e*d)}}else if(void 0!==u){const n=u[t];if(void 0!==n)switch(n.length){case 2:e.vertexAttrib2fv(r.location,n);break;case 3:e.vertexAttrib3fv(r.location,n);break;case 4:e.vertexAttrib4fv(r.location,n);break;default:e.vertexAttrib1fv(r.location,n)}}}}v()}(i,l,f,b),null!==w&&e.bindBuffer(34963,n.get(w).buffer))},reset:b,resetDefaultState:w,dispose:function(){b();for(const e in s){const t=s[e];for(const e in t){const n=t[e];for(const e in n)f(n[e].object),delete n[e];delete t[e]}delete s[e]}},releaseStatesOfGeometry:function(e){if(void 0===s[e.id])return;const t=s[e.id];for(const e in t){const n=t[e];for(const e in n)f(n[e].object),delete n[e];delete t[e]}delete s[e.id]},releaseStatesOfProgram:function(e){for(const t in s){const n=s[t];if(void 0===n[e.id])continue;const r=n[e.id];for(const e in r)f(r[e].object),delete r[e];delete n[e.id]}},initAttributes:p,enableAttribute:m,disableUnusedAttributes:v}}function UE(e,t,n,r){const i=r.isWebGL2;let o;this.setMode=function(e){o=e},this.render=function(t,r){e.drawArrays(o,t,r),n.update(r,o,1)},this.renderInstances=function(r,a,s){if(0===s)return;let l,c;if(i)l=e,c="drawArraysInstanced";else if(l=t.get("ANGLE_instanced_arrays"),c="drawArraysInstancedANGLE",null===l)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[c](o,r,a,s),n.update(a,o,s)}}function zE(e,t,n){let r;function i(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let a=void 0!==n.precision?n.precision:"highp";const s=i(a);s!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);const l=o||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,u=e.getParameter(34930),d=e.getParameter(35660),f=e.getParameter(3379),h=e.getParameter(34076),p=e.getParameter(34921),m=e.getParameter(36347),g=e.getParameter(36348),v=e.getParameter(36349),y=d>0,b=o||t.has("OES_texture_float");return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:i,precision:a,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:b,floatVertexTextures:y&&b,maxSamples:o?e.getParameter(36183):0}}function HE(e){const t=this;let n=null,r=0,i=!1,o=!1;const a=new kE,s=new LM,l={value:null,needsUpdate:!1};function c(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){const o=null!==e?e.length:0;let c=null;if(0!==o){if(c=l.value,!0!==i||null===c){const t=r+4*o,i=n.matrixWorldInverse;s.getNormalMatrix(i),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,n=r;t!==o;++t,n+=4)a.copy(e[t]).applyMatrix4(i,s),a.normal.toArray(c,n),c[n+3]=a.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=o,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,o){const a=0!==e.length||t||0!==r||i;return i=t,n=u(e,o,0),r=e.length,a},this.beginShadows=function(){o=!0,u(null)},this.endShadows=function(){o=!1,c()},this.setState=function(t,a,s){const d=t.clippingPlanes,f=t.clipIntersection,h=t.clipShadows,p=e.get(t);if(!i||null===d||0===d.length||o&&!h)o?u(null):c();else{const e=o?0:r,t=4*e;let i=p.clippingState||null;l.value=i,i=u(d,a,t,s);for(let e=0;e!==t;++e)i[e]=n[e];p.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}}}function VE(e){let t=new WeakMap;function n(e,t){return t===dx?e.mapping=cx:t===fx&&(e.mapping=ux),e}function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture&&!1===i.isRenderTargetTexture){const o=i.mapping;if(o===dx||o===fx){if(t.has(i)){return n(t.get(i).texture,i.mapping)}{const o=i.image;if(o&&o.height>0){const a=new _E(o.height/2);return a.fromEquirectangularTexture(e,i),t.set(i,a),i.addEventListener("dispose",r),n(a.texture,i.mapping)}return null}}}return i},dispose:function(){t=new WeakMap}}}BE.physical={uniforms:gE([BE.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new NM(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new QM(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new NM},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new QM(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new QM(1,1,1)},specularColorMap:{value:null}}]),vertexShader:LE.meshphysical_vert,fragmentShader:LE.meshphysical_frag};class WE extends bE{constructor(e=-1,t=1,n=1,r=-1,i=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,o){null===this.view&&(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=r,this.view.width=i,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(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,r=(this.top+this.bottom)/2;let i=n-e,o=n+e,a=r+t,s=r-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,o=i+e*this.view.width,a-=t*this.view.offsetY,s=a-t*this.view.height}this.projectionMatrix.makeOrthographic(i,o,a,s,this.near,this.far),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,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}const GE=[.125,.215,.35,.446,.526,.582],qE=20,KE=new WE,YE=new QM;let JE=null;const QE=(1+Math.sqrt(5))/2,XE=1/QE,ZE=[new d_(1,1,1),new d_(-1,1,1),new d_(1,1,-1),new d_(-1,1,-1),new d_(0,QE,XE),new d_(0,QE,-XE),new d_(XE,0,QE),new d_(-XE,0,QE),new d_(QE,XE,0),new d_(-QE,XE,0)];class $E{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,r=100){JE=this._renderer.getRenderTarget(),this._setSize(256);const i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,n,r,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=rC(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=nC(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(JE),e.scissorTest=!1,tC(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===cx||e.mapping===ux?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),JE=this._renderer.getRenderTarget();const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Sx,minFilter:Sx,generateMipmaps:!1,type:Nx,format:Ux,encoding:DS,depthBuffer:!1},r=eC(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=eC(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(e){const t=[],n=[],r=[];let i=e;const o=e-4+1+GE.length;for(let a=0;a<o;a++){const o=Math.pow(2,i);n.push(o);let s=1/o;a>e-4?s=GE[a-e+4-1]:0===a&&(s=0),r.push(s);const l=1/(o-2),c=-l,u=1+l,d=[c,c,u,c,u,u,c,c,u,u,c,u],f=6,h=6,p=3,m=2,g=1,v=new Float32Array(p*h*f),y=new Float32Array(m*h*f),b=new Float32Array(g*h*f);for(let e=0;e<f;e++){const t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(r,p*h*e),y.set(d,m*h*e);const i=[e,e,e,e,e,e];b.set(i,g*h*e)}const w=new YA;w.setAttribute("position",new IA(v,p)),w.setAttribute("uv",new IA(y,m)),w.setAttribute("faceIndex",new IA(b,g)),t.push(w),i>4&&i--}return{lodPlanes:t,sizeLods:n,sigmas:r}}(r)),this._blurMaterial=function(e,t,n){const r=new Float32Array(qE),i=new d_(0,1,0),o=new yE({name:"SphericalGaussianBlur",defines:{n:qE,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:iC(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:Mw,depthTest:!1,depthWrite:!1});return o}(r,e,t)}return r}_compileMaterial(e){const t=new fE(this._lodPlanes[0],e);this._renderer.compile(t,KE)}_sceneToCubeUV(e,t,n,r){const i=new wE(90,1,t,n),o=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],s=this._renderer,l=s.autoClear,c=s.toneMapping;s.getClearColor(YE),s.toneMapping=nx,s.autoClear=!1;const u=new CA({name:"PMREM.Background",side:xw,depthWrite:!1,depthTest:!1}),d=new fE(new pE,u);let f=!1;const h=e.background;h?h.isColor&&(u.color.copy(h),e.background=null,f=!0):(u.color.copy(YE),f=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(i.up.set(0,o[t],0),i.lookAt(a[t],0,0)):1===n?(i.up.set(0,0,o[t]),i.lookAt(0,a[t],0)):(i.up.set(0,o[t],0),i.lookAt(0,0,a[t]));const l=this._cubeSize;tC(r,n*l,t>2?l:0,l,l),s.setRenderTarget(r),f&&s.render(d,i),s.render(e,i)}d.geometry.dispose(),d.material.dispose(),s.toneMapping=c,s.autoClear=l,e.background=h}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===cx||e.mapping===ux;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=rC()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=nC());const i=r?this._cubemapMaterial:this._equirectMaterial,o=new fE(this._lodPlanes[0],i);i.uniforms.envMap.value=e;const a=this._cubeSize;tC(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(o,KE)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t<this._lodPlanes.length;t++){const n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),r=ZE[(t-1)%ZE.length];this._blur(e,t-1,t,n,r)}t.autoClear=n}_blur(e,t,n,r,i){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,r,"latitudinal",i),this._halfBlur(o,e,n,n,r,"longitudinal",i)}_halfBlur(e,t,n,r,i,o,a){const s=this._renderer,l=this._blurMaterial;"latitudinal"!==o&&"longitudinal"!==o&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new fE(this._lodPlanes[r],l),u=l.uniforms,d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/39,h=i/f,p=isFinite(i)?1+Math.floor(3*h):qE;p>qE&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${p} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<qE;++e){const t=e/h,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e<p&&(g+=2*n)}for(let e=0;e<m.length;e++)m[e]=m[e]/g;u.envMap.value=e.texture,u.samples.value=p,u.weights.value=m,u.latitudinal.value="latitudinal"===o,a&&(u.poleAxis.value=a);const{_lodMax:v}=this;u.dTheta.value=f,u.mipInt.value=v-n;const y=this._sizeLods[r];tC(t,3*y*(r>v-4?r-v+4:0),4*(this._cubeSize-y),3*y,2*y),s.setRenderTarget(t),s.render(c,KE)}}function eC(e,t,n){const r=new i_(e,t,n);return r.texture.mapping=hx,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function tC(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function nC(){return new yE({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:iC(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:Mw,depthTest:!1,depthWrite:!1})}function rC(){return new yE({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:iC(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:Mw,depthTest:!1,depthWrite:!1})}function iC(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function oC(e){let t=new WeakMap,n=null;function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture){const o=i.mapping,a=o===dx||o===fx,s=o===cx||o===ux;if(a||s){if(i.isRenderTargetTexture&&!0===i.needsPMREMUpdate){i.needsPMREMUpdate=!1;let r=t.get(i);return null===n&&(n=new $E(e)),r=a?n.fromEquirectangular(i,r):n.fromCubemap(i,r),t.set(i,r),r.texture}if(t.has(i))return t.get(i).texture;{const o=i.image;if(a&&o&&o.height>0||s&&o&&function(e){let t=0;const n=6;for(let r=0;r<n;r++)void 0!==e[r]&&t++;return t===n}(o)){null===n&&(n=new $E(e));const o=a?n.fromEquirectangular(i):n.fromCubemap(i);return t.set(i,o),i.addEventListener("dispose",r),o.texture}return null}}}return i},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function aC(e){const t={};function n(n){if(void 0!==t[n])return t[n];let r;switch(n){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function sC(e,t,n,r){const i={},o=new WeakMap;function a(e){const s=e.target;null!==s.index&&t.remove(s.index);for(const e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener("dispose",a),delete i[s.id];const l=o.get(s);l&&(t.remove(l),o.delete(s)),r.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){const n=[],r=e.index,i=e.attributes.position;let a=0;if(null!==r){const e=r.array;a=r.version;for(let t=0,r=e.length;t<r;t+=3){const r=e[t+0],i=e[t+1],o=e[t+2];n.push(r,i,i,o,o,r)}}else{const e=i.array;a=i.version;for(let t=0,r=e.length/3-1;t<r;t+=3){const e=t+0,r=t+1,i=t+2;n.push(e,r,r,i,i,e)}}const s=new(DM(n)?BA:LA)(n,1);s.version=a;const l=o.get(e);l&&t.remove(l),o.set(e,s)}return{get:function(e,t){return!0===i[t.id]||(t.addEventListener("dispose",a),i[t.id]=!0,n.memory.geometries++),t},update:function(e){const n=e.attributes;for(const e in n)t.update(n[e],34962);const r=e.morphAttributes;for(const e in r){const n=r[e];for(let e=0,r=n.length;e<r;e++)t.update(n[e],34962)}},getWireframeAttribute:function(e){const t=o.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&s(e)}else s(e);return o.get(e)}}}function lC(e,t,n,r){const i=r.isWebGL2;let o,a,s;this.setMode=function(e){o=e},this.setIndex=function(e){a=e.type,s=e.bytesPerElement},this.render=function(t,r){e.drawElements(o,r,a,t*s),n.update(r,o,1)},this.renderInstances=function(r,l,c){if(0===c)return;let u,d;if(i)u=e,d="drawElementsInstanced";else if(u=t.get("ANGLE_instanced_arrays"),d="drawElementsInstancedANGLE",null===u)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");u[d](o,l,a,r*s,c),n.update(l,o,c)}}function cC(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(e,n,r){switch(t.calls++,n){case 4:t.triangles+=r*(e/3);break;case 1:t.lines+=r*(e/2);break;case 3:t.lines+=r*(e-1);break;case 2:t.lines+=r*e;break;case 0:t.points+=r*e;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function uC(e,t){return e[0]-t[0]}function dC(e,t){return Math.abs(t[1])-Math.abs(e[1])}function fC(e,t,n){const r={},i=new Float32Array(8),o=new WeakMap,a=new r_,s=[];for(let e=0;e<8;e++)s[e]=[e,0];return{update:function(l,c,u,d){const f=l.morphTargetInfluences;if(!0===t.isWebGL2){const r=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,i=void 0!==r?r.length:0;let s=o.get(c);if(void 0===s||s.count!==i){void 0!==s&&s.texture.dispose();const e=void 0!==c.morphAttributes.position,n=void 0!==c.morphAttributes.normal,r=void 0!==c.morphAttributes.color,l=c.morphAttributes.position||[],u=c.morphAttributes.normal||[],d=c.morphAttributes.color||[];let f=0;!0===e&&(f=1),!0===n&&(f=2),!0===r&&(f=3);let h=c.attributes.position.count*f,p=1;h>t.maxTextureSize&&(p=Math.ceil(h/t.maxTextureSize),h=t.maxTextureSize);const m=new Float32Array(h*p*4*i),g=new o_(m,h,p,i);g.type=Px,g.needsUpdate=!0;const v=4*f;for(let t=0;t<i;t++){const i=l[t],o=u[t],s=d[t],c=h*p*4*t;for(let t=0;t<i.count;t++){const l=t*v;!0===e&&(a.fromBufferAttribute(i,t),m[c+l+0]=a.x,m[c+l+1]=a.y,m[c+l+2]=a.z,m[c+l+3]=0),!0===n&&(a.fromBufferAttribute(o,t),m[c+l+4]=a.x,m[c+l+5]=a.y,m[c+l+6]=a.z,m[c+l+7]=0),!0===r&&(a.fromBufferAttribute(s,t),m[c+l+8]=a.x,m[c+l+9]=a.y,m[c+l+10]=a.z,m[c+l+11]=4===s.itemSize?a.w:1)}}s={count:i,texture:g,size:new NM(h,p)},o.set(c,s),c.addEventListener("dispose",(function e(){g.dispose(),o.delete(c),c.removeEventListener("dispose",e)}))}let l=0;for(let e=0;e<f.length;e++)l+=f[e];const u=c.morphTargetsRelative?1:1-l;d.getUniforms().setValue(e,"morphTargetBaseInfluence",u),d.getUniforms().setValue(e,"morphTargetInfluences",f),d.getUniforms().setValue(e,"morphTargetsTexture",s.texture,n),d.getUniforms().setValue(e,"morphTargetsTextureSize",s.size)}else{const t=void 0===f?0:f.length;let n=r[c.id];if(void 0===n||n.length!==t){n=[];for(let e=0;e<t;e++)n[e]=[e,0];r[c.id]=n}for(let e=0;e<t;e++){const t=n[e];t[0]=e,t[1]=f[e]}n.sort(dC);for(let e=0;e<8;e++)e<t&&n[e][1]?(s[e][0]=n[e][0],s[e][1]=n[e][1]):(s[e][0]=Number.MAX_SAFE_INTEGER,s[e][1]=0);s.sort(uC);const o=c.morphAttributes.position,a=c.morphAttributes.normal;let l=0;for(let e=0;e<8;e++){const t=s[e],n=t[0],r=t[1];n!==Number.MAX_SAFE_INTEGER&&r?(o&&c.getAttribute("morphTarget"+e)!==o[n]&&c.setAttribute("morphTarget"+e,o[n]),a&&c.getAttribute("morphNormal"+e)!==a[n]&&c.setAttribute("morphNormal"+e,a[n]),i[e]=r,l+=r):(o&&!0===c.hasAttribute("morphTarget"+e)&&c.deleteAttribute("morphTarget"+e),a&&!0===c.hasAttribute("morphNormal"+e)&&c.deleteAttribute("morphNormal"+e),i[e]=0)}const u=c.morphTargetsRelative?1:1-l;d.getUniforms().setValue(e,"morphTargetBaseInfluence",u),d.getUniforms().setValue(e,"morphTargetInfluences",i)}}}}function hC(e,t,n,r){let i=new WeakMap;function o(e){const t=e.target;t.removeEventListener("dispose",o),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(e){const a=r.render.frame,s=e.geometry,l=t.get(e,s);return i.get(l)!==a&&(t.update(l),i.set(l,a)),e.isInstancedMesh&&(!1===e.hasEventListener("dispose",o)&&e.addEventListener("dispose",o),n.update(e.instanceMatrix,34962),null!==e.instanceColor&&n.update(e.instanceColor,34962)),l},dispose:function(){i=new WeakMap}}}const pC=new n_,mC=new o_,gC=new s_,vC=new ME,yC=[],bC=[],wC=new Float32Array(16),xC=new Float32Array(9),SC=new Float32Array(4);function MC(e,t,n){const r=e[0];if(r<=0||r>0)return e;const i=t*n;let o=yC[i];if(void 0===o&&(o=new Float32Array(i),yC[i]=o),0!==t){r.toArray(o,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(o,i)}return o}function _C(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function AC(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n]}function EC(e,t){let n=bC[t];void 0===n&&(n=new Int32Array(t),bC[t]=n);for(let r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function CC(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function kC(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(_C(n,t))return;e.uniform2fv(this.addr,t),AC(n,t)}}function TC(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(_C(n,t))return;e.uniform3fv(this.addr,t),AC(n,t)}}function IC(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(_C(n,t))return;e.uniform4fv(this.addr,t),AC(n,t)}}function OC(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(_C(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),AC(n,t)}else{if(_C(n,r))return;SC.set(r),e.uniformMatrix2fv(this.addr,!1,SC),AC(n,r)}}function RC(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(_C(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),AC(n,t)}else{if(_C(n,r))return;xC.set(r),e.uniformMatrix3fv(this.addr,!1,xC),AC(n,r)}}function PC(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(_C(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),AC(n,t)}else{if(_C(n,r))return;wC.set(r),e.uniformMatrix4fv(this.addr,!1,wC),AC(n,r)}}function NC(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function LC(e,t){const n=this.cache;_C(n,t)||(e.uniform2iv(this.addr,t),AC(n,t))}function DC(e,t){const n=this.cache;_C(n,t)||(e.uniform3iv(this.addr,t),AC(n,t))}function BC(e,t){const n=this.cache;_C(n,t)||(e.uniform4iv(this.addr,t),AC(n,t))}function jC(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function FC(e,t){const n=this.cache;_C(n,t)||(e.uniform2uiv(this.addr,t),AC(n,t))}function UC(e,t){const n=this.cache;_C(n,t)||(e.uniform3uiv(this.addr,t),AC(n,t))}function zC(e,t){const n=this.cache;_C(n,t)||(e.uniform4uiv(this.addr,t),AC(n,t))}function HC(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2D(t||pC,i)}function VC(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||gC,i)}function WC(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(t||vC,i)}function GC(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||mC,i)}function qC(e,t){e.uniform1fv(this.addr,t)}function KC(e,t){const n=MC(t,this.size,2);e.uniform2fv(this.addr,n)}function YC(e,t){const n=MC(t,this.size,3);e.uniform3fv(this.addr,n)}function JC(e,t){const n=MC(t,this.size,4);e.uniform4fv(this.addr,n)}function QC(e,t){const n=MC(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function XC(e,t){const n=MC(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function ZC(e,t){const n=MC(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function $C(e,t){e.uniform1iv(this.addr,t)}function ek(e,t){e.uniform2iv(this.addr,t)}function tk(e,t){e.uniform3iv(this.addr,t)}function nk(e,t){e.uniform4iv(this.addr,t)}function rk(e,t){e.uniform1uiv(this.addr,t)}function ik(e,t){e.uniform2uiv(this.addr,t)}function ok(e,t){e.uniform3uiv(this.addr,t)}function ak(e,t){e.uniform4uiv(this.addr,t)}function sk(e,t,n){const r=t.length,i=EC(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTexture2D(t[e]||pC,i[e])}function lk(e,t,n){const r=t.length,i=EC(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTexture3D(t[e]||gC,i[e])}function ck(e,t,n){const r=t.length,i=EC(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTextureCube(t[e]||vC,i[e])}function uk(e,t,n){const r=t.length,i=EC(n,r);e.uniform1iv(this.addr,i);for(let e=0;e!==r;++e)n.setTexture2DArray(t[e]||mC,i[e])}class dk{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=function(e){switch(e){case 5126:return CC;case 35664:return kC;case 35665:return TC;case 35666:return IC;case 35674:return OC;case 35675:return RC;case 35676:return PC;case 5124:case 35670:return NC;case 35667:case 35671:return LC;case 35668:case 35672:return DC;case 35669:case 35673:return BC;case 5125:return jC;case 36294:return FC;case 36295:return UC;case 36296:return zC;case 35678:case 36198:case 36298:case 36306:case 35682:return HC;case 35679:case 36299:case 36307:return VC;case 35680:case 36300:case 36308:case 36293:return WC;case 36289:case 36303:case 36311:case 36292:return GC}}(t.type)}}class fk{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=function(e){switch(e){case 5126:return qC;case 35664:return KC;case 35665:return YC;case 35666:return JC;case 35674:return QC;case 35675:return XC;case 35676:return ZC;case 5124:case 35670:return $C;case 35667:case 35671:return ek;case 35668:case 35672:return tk;case 35669:case 35673:return nk;case 5125:return rk;case 36294:return ik;case 36295:return ok;case 36296:return ak;case 35678:case 36198:case 36298:case 36306:case 35682:return sk;case 35679:case 36299:case 36307:return lk;case 35680:case 36300:case 36308:case 36293:return ck;case 36289:case 36303:case 36311:case 36292:return uk}}(t.type)}}class hk{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let i=0,o=r.length;i!==o;++i){const o=r[i];o.setValue(e,t[o.id],n)}}}const pk=/(\w+)(\])?(\[|\.)?/g;function mk(e,t){e.seq.push(t),e.map[t.id]=t}function gk(e,t,n){const r=e.name,i=r.length;for(pk.lastIndex=0;;){const o=pk.exec(r),a=pk.lastIndex;let s=o[1];const l="]"===o[2],c=o[3];if(l&&(s|=0),void 0===c||"["===c&&a+2===i){mk(n,void 0===c?new dk(s,e,t):new fk(s,e,t));break}{let e=n.map[s];void 0===e&&(e=new hk(s),mk(n,e)),n=e}}}class vk{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,35718);for(let r=0;r<n;++r){const n=e.getActiveUniform(t,r);gk(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,r){const i=this.map[t];void 0!==i&&i.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];void 0!==r&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,o=t.length;i!==o;++i){const o=t[i],a=n[o.id];!1!==a.needsUpdate&&o.setValue(e,a.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,i=e.length;r!==i;++r){const i=e[r];i.id in t&&n.push(i)}return n}}function yk(e,t,n){const r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}let bk=0;function wk(e,t,n){const r=e.getShaderParameter(t,35713),i=e.getShaderInfoLog(t).trim();if(r&&""===i)return"";const o=/ERROR: 0:(\d+)/.exec(i);if(o){const r=parseInt(o[1]);return n.toUpperCase()+"\n\n"+i+"\n\n"+function(e,t){const n=e.split("\n"),r=[],i=Math.max(t-6,0),o=Math.min(t+6,n.length);for(let e=i;e<o;e++){const i=e+1;r.push(`${i===t?">":" "} ${i}: ${n[e]}`)}return r.join("\n")}(e.getShaderSource(t),r)}return i}function xk(e,t){const n=function(e){switch(e){case DS:return["Linear","( value )"];case BS:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function Sk(e,t){let n;switch(t){case rx:n="Linear";break;case ix:n="Reinhard";break;case ox:n="OptimizedCineon";break;case ax:n="ACESFilmic";break;case sx:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Mk(e){return""!==e}function _k(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Ak(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Ek=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ck(e){return e.replace(Ek,kk)}function kk(e,t){const n=LE[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return Ck(n)}const Tk=/#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 Ik(e){return e.replace(Tk,Ok)}function Ok(e,t,n,r){let i="";for(let e=parseInt(t);e<parseInt(n);e++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return i}function Rk(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Pk(e,t,n,r){const i=e.getContext(),o=n.defines;let a=n.vertexShader,s=n.fragmentShader;const l=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===vw?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===yw?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===bw&&(t="SHADOWMAP_TYPE_VSM"),t}(n),c=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case cx:case ux:t="ENVMAP_TYPE_CUBE";break;case hx:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),u=function(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===ux&&(t="ENVMAP_MODE_REFRACTION");return t}(n),d=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case $w:t="ENVMAP_BLENDING_MULTIPLY";break;case ex:t="ENVMAP_BLENDING_MIX";break;case tx:t="ENVMAP_BLENDING_ADD"}return t}(n),f=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const n=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:r,maxMip:n}}(n),h=n.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Mk).join("\n")}(n),p=function(e){const t=[];for(const n in e){const r=e[n];!1!==r&&t.push("#define "+n+" "+r)}return t.join("\n")}(o),m=i.createProgram();let g,v,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(g=[p].filter(Mk).join("\n"),g.length>0&&(g+="\n"),v=[h,p].filter(Mk).join("\n"),v.length>0&&(v+="\n")):(g=[Rk(n),"#define SHADER_NAME "+n.shaderName,p,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Mk).join("\n"),v=[h,Rk(n),"#define SHADER_NAME "+n.shaderName,p,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==nx?"#define TONE_MAPPING":"",n.toneMapping!==nx?LE.tonemapping_pars_fragment:"",n.toneMapping!==nx?Sk("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",LE.encodings_pars_fragment,xk("linearToOutputTexel",n.outputEncoding),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Mk).join("\n")),a=Ck(a),a=_k(a,n),a=Ak(a,n),s=Ck(s),s=_k(s,n),s=Ak(s,n),a=Ik(a),s=Ik(s),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===vM?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===vM?"":"#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("\n")+"\n"+v);const b=y+v+s,w=yk(i,35633,y+g+a),x=yk(i,35632,b);if(i.attachShader(m,w),i.attachShader(m,x),void 0!==n.index0AttributeName?i.bindAttribLocation(m,0,n.index0AttributeName):!0===n.morphTargets&&i.bindAttribLocation(m,0,"position"),i.linkProgram(m),e.debug.checkShaderErrors){const e=i.getProgramInfoLog(m).trim(),t=i.getShaderInfoLog(w).trim(),n=i.getShaderInfoLog(x).trim();let r=!0,o=!0;if(!1===i.getProgramParameter(m,35714)){r=!1;const t=wk(i,w,"vertex"),n=wk(i,x,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(m,35715)+"\n\nProgram Info Log: "+e+"\n"+t+"\n"+n)}else""!==e?console.warn("THREE.WebGLProgram: Program Info Log:",e):""!==t&&""!==n||(o=!1);o&&(this.diagnostics={runnable:r,programLog:e,vertexShader:{log:t,prefix:g},fragmentShader:{log:n,prefix:v}})}let S,M;return i.deleteShader(w),i.deleteShader(x),this.getUniforms=function(){return void 0===S&&(S=new vk(i,m)),S},this.getAttributes=function(){return void 0===M&&(M=function(e,t){const n={},r=e.getProgramParameter(t,35721);for(let i=0;i<r;i++){const r=e.getActiveAttrib(t,i),o=r.name;let a=1;35674===r.type&&(a=2),35675===r.type&&(a=3),35676===r.type&&(a=4),n[o]={type:r.type,location:e.getAttribLocation(t,o),locationSize:a}}return n}(i,m)),M},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.name=n.shaderName,this.id=bk++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=x,this}let Nk=0;class Lk{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return!1===o.has(r)&&(o.add(r),r.usedTimes++),!1===o.has(i)&&(o.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.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 void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return void 0===n&&(n=new Dk(e),t.set(e,n)),n}}class Dk{constructor(e){this.id=Nk++,this.code=e,this.usedTimes=0}}function Bk(e,t,n,r,i,o,a){const s=new $_,l=new Lk,c=[],u=i.isWebGL2,d=i.logarithmicDepthBuffer,f=i.vertexTextures;let h=i.precision;const p={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"};return{getParameters:function(o,s,c,m,g){const v=m.fog,y=g.geometry,b=o.isMeshStandardMaterial?m.environment:null,w=(o.isMeshStandardMaterial?n:t).get(o.envMap||b),x=w&&w.mapping===hx?w.image.height:null,S=p[o.type];null!==o.precision&&(h=i.getMaxPrecision(o.precision),h!==o.precision&&console.warn("THREE.WebGLProgram.getParameters:",o.precision,"not supported, using",h,"instead."));const M=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,_=void 0!==M?M.length:0;let A,E,C,k,T=0;if(void 0!==y.morphAttributes.position&&(T=1),void 0!==y.morphAttributes.normal&&(T=2),void 0!==y.morphAttributes.color&&(T=3),S){const e=BE[S];A=e.vertexShader,E=e.fragmentShader}else A=o.vertexShader,E=o.fragmentShader,l.update(o),C=l.getVertexShaderID(o),k=l.getFragmentShaderID(o);const I=e.getRenderTarget(),O=o.alphaTest>0,R=o.clearcoat>0,P=o.iridescence>0;return{isWebGL2:u,shaderID:S,shaderName:o.type,vertexShader:A,fragmentShader:E,defines:o.defines,customVertexShaderID:C,customFragmentShaderID:k,isRawShaderMaterial:!0===o.isRawShaderMaterial,glslVersion:o.glslVersion,precision:h,instancing:!0===g.isInstancedMesh,instancingColor:!0===g.isInstancedMesh&&null!==g.instanceColor,supportsVertexTextures:f,outputEncoding:null===I?e.outputEncoding:!0===I.isXRRenderTarget?I.texture.encoding:DS,map:!!o.map,matcap:!!o.matcap,envMap:!!w,envMapMode:w&&w.mapping,envMapCubeUVHeight:x,lightMap:!!o.lightMap,aoMap:!!o.aoMap,emissiveMap:!!o.emissiveMap,bumpMap:!!o.bumpMap,normalMap:!!o.normalMap,objectSpaceNormalMap:o.normalMapType===zS,tangentSpaceNormalMap:o.normalMapType===US,decodeVideoTexture:!!o.map&&!0===o.map.isVideoTexture&&o.map.encoding===BS,clearcoat:R,clearcoatMap:R&&!!o.clearcoatMap,clearcoatRoughnessMap:R&&!!o.clearcoatRoughnessMap,clearcoatNormalMap:R&&!!o.clearcoatNormalMap,iridescence:P,iridescenceMap:P&&!!o.iridescenceMap,iridescenceThicknessMap:P&&!!o.iridescenceThicknessMap,displacementMap:!!o.displacementMap,roughnessMap:!!o.roughnessMap,metalnessMap:!!o.metalnessMap,specularMap:!!o.specularMap,specularIntensityMap:!!o.specularIntensityMap,specularColorMap:!!o.specularColorMap,opaque:!1===o.transparent&&o.blending===_w,alphaMap:!!o.alphaMap,alphaTest:O,gradientMap:!!o.gradientMap,sheen:o.sheen>0,sheenColorMap:!!o.sheenColorMap,sheenRoughnessMap:!!o.sheenRoughnessMap,transmission:o.transmission>0,transmissionMap:!!o.transmissionMap,thicknessMap:!!o.thicknessMap,combine:o.combine,vertexTangents:!!o.normalMap&&!!y.attributes.tangent,vertexColors:o.vertexColors,vertexAlphas:!0===o.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,vertexUvs:!!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatMap||o.clearcoatRoughnessMap||o.clearcoatNormalMap||o.iridescenceMap||o.iridescenceThicknessMap||o.displacementMap||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularColorMap||o.sheenColorMap||o.sheenRoughnessMap),uvsVertexOnly:!(o.map||o.bumpMap||o.normalMap||o.specularMap||o.alphaMap||o.emissiveMap||o.roughnessMap||o.metalnessMap||o.clearcoatNormalMap||o.iridescenceMap||o.iridescenceThicknessMap||o.transmission>0||o.transmissionMap||o.thicknessMap||o.specularIntensityMap||o.specularColorMap||o.sheen>0||o.sheenColorMap||o.sheenRoughnessMap||!o.displacementMap),fog:!!v,useFog:!0===o.fog,fogExp2:v&&v.isFogExp2,flatShading:!!o.flatShading,sizeAttenuation:o.sizeAttenuation,logarithmicDepthBuffer:d,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:_,morphTextureStride:T,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:o.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:o.toneMapped?e.toneMapping:nx,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:o.premultipliedAlpha,doubleSided:o.side===Sw,flipSided:o.side===xw,useDepthPacking:!!o.depthPacking,depthPacking:o.depthPacking||0,index0AttributeName:o.index0AttributeName,extensionDerivatives:o.extensions&&o.extensions.derivatives,extensionFragDepth:o.extensions&&o.extensions.fragDepth,extensionDrawBuffers:o.extensions&&o.extensions.drawBuffers,extensionShaderTextureLOD:o.extensions&&o.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||r.has("EXT_shader_texture_lod"),customProgramCacheKey:o.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputEncoding),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.combine),e.push(t.vertexUvs),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){s.disableAll(),t.isWebGL2&&s.enable(0);t.supportsVertexTextures&&s.enable(1);t.instancing&&s.enable(2);t.instancingColor&&s.enable(3);t.map&&s.enable(4);t.matcap&&s.enable(5);t.envMap&&s.enable(6);t.lightMap&&s.enable(7);t.aoMap&&s.enable(8);t.emissiveMap&&s.enable(9);t.bumpMap&&s.enable(10);t.normalMap&&s.enable(11);t.objectSpaceNormalMap&&s.enable(12);t.tangentSpaceNormalMap&&s.enable(13);t.clearcoat&&s.enable(14);t.clearcoatMap&&s.enable(15);t.clearcoatRoughnessMap&&s.enable(16);t.clearcoatNormalMap&&s.enable(17);t.iridescence&&s.enable(18);t.iridescenceMap&&s.enable(19);t.iridescenceThicknessMap&&s.enable(20);t.displacementMap&&s.enable(21);t.specularMap&&s.enable(22);t.roughnessMap&&s.enable(23);t.metalnessMap&&s.enable(24);t.gradientMap&&s.enable(25);t.alphaMap&&s.enable(26);t.alphaTest&&s.enable(27);t.vertexColors&&s.enable(28);t.vertexAlphas&&s.enable(29);t.vertexUvs&&s.enable(30);t.vertexTangents&&s.enable(31);t.uvsVertexOnly&&s.enable(32);e.push(s.mask),s.disableAll(),t.fog&&s.enable(0);t.useFog&&s.enable(1);t.flatShading&&s.enable(2);t.logarithmicDepthBuffer&&s.enable(3);t.skinning&&s.enable(4);t.morphTargets&&s.enable(5);t.morphNormals&&s.enable(6);t.morphColors&&s.enable(7);t.premultipliedAlpha&&s.enable(8);t.shadowMapEnabled&&s.enable(9);t.physicallyCorrectLights&&s.enable(10);t.doubleSided&&s.enable(11);t.flipSided&&s.enable(12);t.useDepthPacking&&s.enable(13);t.dithering&&s.enable(14);t.specularIntensityMap&&s.enable(15);t.specularColorMap&&s.enable(16);t.transmission&&s.enable(17);t.transmissionMap&&s.enable(18);t.thicknessMap&&s.enable(19);t.sheen&&s.enable(20);t.sheenColorMap&&s.enable(21);t.sheenRoughnessMap&&s.enable(22);t.decodeVideoTexture&&s.enable(23);t.opaque&&s.enable(24);e.push(s.mask)}(n,t),n.push(e.outputEncoding)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=p[e.type];let n;if(t){const e=BE[t];n=vE.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let r;for(let e=0,t=c.length;e<t;e++){const t=c[e];if(t.cacheKey===n){r=t,++r.usedTimes;break}}return void 0===r&&(r=new Pk(e,n,t,o),c.push(r)),r},releaseProgram:function(e){if(0==--e.usedTimes){const t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:c,dispose:function(){l.dispose()}}}function jk(){let e=new WeakMap;return{get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,r){e.get(t)[n]=r},dispose:function(){e=new WeakMap}}}function Fk(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Uk(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function zk(){const e=[];let t=0;const n=[],r=[],i=[];function o(n,r,i,o,a,s){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:r,material:i,groupOrder:o,renderOrder:n.renderOrder,z:a,group:s},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.groupOrder=o,l.renderOrder=n.renderOrder,l.z=a,l.group=s),t++,l}return{opaque:n,transmissive:r,transparent:i,init:function(){t=0,n.length=0,r.length=0,i.length=0},push:function(e,t,a,s,l,c){const u=o(e,t,a,s,l,c);a.transmission>0?r.push(u):!0===a.transparent?i.push(u):n.push(u)},unshift:function(e,t,a,s,l,c){const u=o(e,t,a,s,l,c);a.transmission>0?r.unshift(u):!0===a.transparent?i.unshift(u):n.unshift(u)},finish:function(){for(let n=t,r=e.length;n<r;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||Fk),r.length>1&&r.sort(t||Uk),i.length>1&&i.sort(t||Uk)}}}function Hk(){let e=new WeakMap;return{get:function(t,n){const r=e.get(t);let i;return void 0===r?(i=new zk,e.set(t,[i])):n>=r.length?(i=new zk,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function Vk(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new d_,color:new QM};break;case"SpotLight":n={position:new d_,direction:new d_,color:new QM,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new d_,color:new QM,distance:0,decay:0};break;case"HemisphereLight":n={direction:new d_,skyColor:new QM,groundColor:new QM};break;case"RectAreaLight":n={color:new QM,position:new d_,halfWidth:new d_,halfHeight:new d_}}return e[t.id]=n,n}}}let Wk=0;function Gk(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function qk(e,t){const n=new Vk,r=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new NM};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new NM,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let e=0;e<9;e++)i.probe.push(new d_);const o=new d_,a=new H_,s=new H_;return{setup:function(o,a){let s=0,l=0,c=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let u=0,d=0,f=0,h=0,p=0,m=0,g=0,v=0,y=0,b=0;o.sort(Gk);const w=!0!==a?Math.PI:1;for(let e=0,t=o.length;e<t;e++){const t=o[e],a=t.color,x=t.intensity,S=t.distance,M=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)s+=a.r*x*w,l+=a.g*x*w,c+=a.b*x*w;else if(t.isLightProbe)for(let e=0;e<9;e++)i.probe[e].addScaledVector(t.sh.coefficients[e],x);else if(t.isDirectionalLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*w),t.castShadow){const e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,i.directionalShadow[u]=n,i.directionalShadowMap[u]=M,i.directionalShadowMatrix[u]=t.shadow.matrix,m++}i.directional[u]=e,u++}else if(t.isSpotLight){const e=n.get(t);e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(a).multiplyScalar(x*w),e.distance=S,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,i.spot[f]=e;const o=t.shadow;if(t.map&&(i.spotLightMap[y]=t.map,y++,o.updateMatrices(t),t.castShadow&&b++),i.spotLightMatrix[f]=o.matrix,t.castShadow){const e=r.get(t);e.shadowBias=o.bias,e.shadowNormalBias=o.normalBias,e.shadowRadius=o.radius,e.shadowMapSize=o.mapSize,i.spotShadow[f]=e,i.spotShadowMap[f]=M,v++}f++}else if(t.isRectAreaLight){const e=n.get(t);e.color.copy(a).multiplyScalar(x),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),i.rectArea[h]=e,h++}else if(t.isPointLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*w),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,n.shadowCameraNear=e.camera.near,n.shadowCameraFar=e.camera.far,i.pointShadow[d]=n,i.pointShadowMap[d]=M,i.pointShadowMatrix[d]=t.shadow.matrix,g++}i.point[d]=e,d++}else if(t.isHemisphereLight){const e=n.get(t);e.skyColor.copy(t.color).multiplyScalar(x*w),e.groundColor.copy(t.groundColor).multiplyScalar(x*w),i.hemi[p]=e,p++}}h>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=DE.LTC_FLOAT_1,i.rectAreaLTC2=DE.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(i.rectAreaLTC1=DE.LTC_HALF_1,i.rectAreaLTC2=DE.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=s,i.ambient[1]=l,i.ambient[2]=c;const x=i.hash;x.directionalLength===u&&x.pointLength===d&&x.spotLength===f&&x.rectAreaLength===h&&x.hemiLength===p&&x.numDirectionalShadows===m&&x.numPointShadows===g&&x.numSpotShadows===v&&x.numSpotMaps===y||(i.directional.length=u,i.spot.length=f,i.rectArea.length=h,i.point.length=d,i.hemi.length=p,i.directionalShadow.length=m,i.directionalShadowMap.length=m,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=v,i.spotShadowMap.length=v,i.directionalShadowMatrix.length=m,i.pointShadowMatrix.length=g,i.spotLightMatrix.length=v+y-b,i.spotLightMap.length=y,i.numSpotLightShadowsWithMaps=b,x.directionalLength=u,x.pointLength=d,x.spotLength=f,x.rectAreaLength=h,x.hemiLength=p,x.numDirectionalShadows=m,x.numPointShadows=g,x.numSpotShadows=v,x.numSpotMaps=y,i.version=Wk++)},setupView:function(e,t){let n=0,r=0,l=0,c=0,u=0;const d=t.matrixWorldInverse;for(let t=0,f=e.length;t<f;t++){const f=e[t];if(f.isDirectionalLight){const e=i.directional[n];e.direction.setFromMatrixPosition(f.matrixWorld),o.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(d),n++}else if(f.isSpotLight){const e=i.spot[l];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),e.direction.setFromMatrixPosition(f.matrixWorld),o.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(d),l++}else if(f.isRectAreaLight){const e=i.rectArea[c];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),s.identity(),a.copy(f.matrixWorld),a.premultiply(d),s.extractRotation(a),e.halfWidth.set(.5*f.width,0,0),e.halfHeight.set(0,.5*f.height,0),e.halfWidth.applyMatrix4(s),e.halfHeight.applyMatrix4(s),c++}else if(f.isPointLight){const e=i.point[r];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(d),r++}else if(f.isHemisphereLight){const e=i.hemi[u];e.direction.setFromMatrixPosition(f.matrixWorld),e.direction.transformDirection(d),u++}}},state:i}}function Kk(e,t){const n=new qk(e,t),r=[],i=[];return{init:function(){r.length=0,i.length=0},state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:function(e){n.setup(r,e)},setupLightsView:function(e){n.setupView(r,e)},pushLight:function(e){r.push(e)},pushShadow:function(e){i.push(e)}}}function Yk(e,t){let n=new WeakMap;return{get:function(r,i=0){const o=n.get(r);let a;return void 0===o?(a=new Kk(e,t),n.set(r,[a])):i>=o.length?(a=new Kk(e,t),o.push(a)):a=o[i],a},dispose:function(){n=new WeakMap}}}class Jk extends EA{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=jS,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 Qk extends EA{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new d_,this.nearDistance=1,this.farDistance=1e3,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.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Xk(e,t,n){let r=new OE;const i=new NM,o=new NM,a=new r_,s=new Jk({depthPacking:FS}),l=new Qk,c={},u=n.maxTextureSize,d={0:xw,1:ww,2:Sw},f=new yE({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new NM},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),h=f.clone();h.defines.HORIZONTAL_PASS=1;const p=new YA;p.setAttribute("position",new IA(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const m=new fE(p,f),g=this;function v(n,r){const o=t.update(m);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,h.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,h.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new i_(i.x,i.y)),f.uniforms.shadow_pass.value=n.map.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,o,f,m,null),h.uniforms.shadow_pass.value=n.mapPass.texture,h.uniforms.resolution.value=n.mapSize,h.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,o,h,m,null)}function y(t,n,r,i,o,a){let u=null;const f=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(u=void 0!==f?f:!0===r.isPointLight?l:s,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0){const e=u.uuid,t=n.uuid;let r=c[e];void 0===r&&(r={},c[e]=r);let i=r[t];void 0===i&&(i=u.clone(),r[t]=i),u=i}return u.visible=n.visible,u.wireframe=n.wireframe,u.side=a===bw?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:d[n.side],u.alphaMap=n.alphaMap,u.alphaTest=n.alphaTest,u.clipShadows=n.clipShadows,u.clippingPlanes=n.clippingPlanes,u.clipIntersection=n.clipIntersection,u.displacementMap=n.displacementMap,u.displacementScale=n.displacementScale,u.displacementBias=n.displacementBias,u.wireframeLinewidth=n.wireframeLinewidth,u.linewidth=n.linewidth,!0===r.isPointLight&&!0===u.isMeshDistanceMaterial&&(u.referencePosition.setFromMatrixPosition(r.matrixWorld),u.nearDistance=i,u.farDistance=o),u}function b(n,i,o,a,s){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===bw)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n.matrixWorld);const r=t.update(n),i=n.material;if(Array.isArray(i)){const t=r.groups;for(let l=0,c=t.length;l<c;l++){const c=t[l],u=i[c.materialIndex];if(u&&u.visible){const t=y(n,u,a,o.near,o.far,s);e.renderBufferDirect(o,null,r,t,n,c)}}}else if(i.visible){const t=y(n,i,a,o.near,o.far,s);e.renderBufferDirect(o,null,r,t,n,null)}}const l=n.children;for(let e=0,t=l.length;e<t;e++)b(l[e],i,o,a,s)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=vw,this.render=function(t,n,s){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===t.length)return;const l=e.getRenderTarget(),c=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(Mw),f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);for(let l=0,c=t.length;l<c;l++){const c=t[l],d=c.shadow;if(void 0===d){console.warn("THREE.WebGLShadowMap:",c,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;i.copy(d.mapSize);const h=d.getFrameExtents();if(i.multiply(h),o.copy(d.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(o.x=Math.floor(u/h.x),i.x=o.x*h.x,d.mapSize.x=o.x),i.y>u&&(o.y=Math.floor(u/h.y),i.y=o.y*h.y,d.mapSize.y=o.y)),null===d.map){const e=this.type!==bw?{minFilter:vx,magFilter:vx}:{};d.map=new i_(i.x,i.y,e),d.map.texture.name=c.name+".shadowMap",d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();const p=d.getViewportCount();for(let e=0;e<p;e++){const t=d.getViewport(e);a.set(o.x*t.x,o.y*t.y,o.x*t.z,o.y*t.w),f.viewport(a),d.updateMatrices(c,e),r=d.getFrustum(),b(n,s,d.camera,c,this.type)}!0!==d.isPointLightShadow&&this.type===bw&&v(d,s),d.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(l,c,d)}}function Zk(e,t,n){const r=n.isWebGL2;const i=new function(){let t=!1;const n=new r_;let r=null;const i=new r_(0,0,0,0);return{setMask:function(n){r===n||t||(e.colorMask(n,n,n,n),r=n)},setLocked:function(e){t=e},setClear:function(t,r,o,a,s){!0===s&&(t*=a,r*=a,o*=a),n.set(t,r,o,a),!1===i.equals(n)&&(e.clearColor(t,r,o,a),i.copy(n))},reset:function(){t=!1,r=null,i.set(-1,0,0,0)}}},o=new function(){let t=!1,n=null,r=null,i=null;return{setTest:function(e){e?U(2929):z(2929)},setMask:function(r){n===r||t||(e.depthMask(r),n=r)},setFunc:function(t){if(r!==t){if(t)switch(t){case Gw:e.depthFunc(512);break;case qw:e.depthFunc(519);break;case Kw:e.depthFunc(513);break;case Yw:e.depthFunc(515);break;case Jw:e.depthFunc(514);break;case Qw:e.depthFunc(518);break;case Xw:e.depthFunc(516);break;case Zw:e.depthFunc(517);break;default:e.depthFunc(515)}else e.depthFunc(515);r=t}},setLocked:function(e){t=e},setClear:function(t){i!==t&&(e.clearDepth(t),i=t)},reset:function(){t=!1,n=null,r=null,i=null}}},a=new function(){let t=!1,n=null,r=null,i=null,o=null,a=null,s=null,l=null,c=null;return{setTest:function(e){t||(e?U(2960):z(2960))},setMask:function(r){n===r||t||(e.stencilMask(r),n=r)},setFunc:function(t,n,a){r===t&&i===n&&o===a||(e.stencilFunc(t,n,a),r=t,i=n,o=a)},setOp:function(t,n,r){a===t&&s===n&&l===r||(e.stencilOp(t,n,r),a=t,s=n,l=r)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,r=null,i=null,o=null,a=null,s=null,l=null,c=null}}},s=new WeakMap,l=new WeakMap;let c={},u={},d=new WeakMap,f=[],h=null,p=!1,m=null,g=null,v=null,y=null,b=null,w=null,x=null,S=!1,M=null,_=null,A=null,E=null,C=null;const k=e.getParameter(35661);let T=!1,I=0;const O=e.getParameter(7938);-1!==O.indexOf("WebGL")?(I=parseFloat(/^WebGL (\d)/.exec(O)[1]),T=I>=1):-1!==O.indexOf("OpenGL ES")&&(I=parseFloat(/^OpenGL ES (\d)/.exec(O)[1]),T=I>=2);let R=null,P={};const N=e.getParameter(3088),L=e.getParameter(2978),D=(new r_).fromArray(N),B=(new r_).fromArray(L);function j(t,n,r){const i=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;t<r;t++)e.texImage2D(n+t,0,6408,1,1,0,6408,5121,i);return o}const F={};function U(t){!0!==c[t]&&(e.enable(t),c[t]=!0)}function z(t){!1!==c[t]&&(e.disable(t),c[t]=!1)}F[3553]=j(3553,3553,1),F[34067]=j(34067,34069,6),i.setClear(0,0,0,1),o.setClear(1),a.setClear(0),U(2929),o.setFunc(Yw),G(!1),q(hw),U(2884),W(Mw);const H={[Tw]:32774,[Iw]:32778,[Ow]:32779};if(r)H[Rw]=32775,H[Pw]=32776;else{const e=t.get("EXT_blend_minmax");null!==e&&(H[Rw]=e.MIN_EXT,H[Pw]=e.MAX_EXT)}const V={[Nw]:0,[Lw]:1,[Dw]:768,[jw]:770,[Ww]:776,[Hw]:774,[Uw]:772,[Bw]:769,[Fw]:771,[Vw]:775,[zw]:773};function W(t,n,r,i,o,a,s,l){if(t!==Mw){if(!1===p&&(U(3042),p=!0),t===kw)o=o||n,a=a||r,s=s||i,n===g&&o===b||(e.blendEquationSeparate(H[n],H[o]),g=n,b=o),r===v&&i===y&&a===w&&s===x||(e.blendFuncSeparate(V[r],V[i],V[a],V[s]),v=r,y=i,w=a,x=s),m=t,S=null;else if(t!==m||l!==S){if(g===Tw&&b===Tw||(e.blendEquation(32774),g=Tw,b=Tw),l)switch(t){case _w:e.blendFuncSeparate(1,771,1,771);break;case Aw:e.blendFunc(1,1);break;case Ew:e.blendFuncSeparate(0,769,0,1);break;case Cw:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case _w:e.blendFuncSeparate(770,771,1,771);break;case Aw:e.blendFunc(770,1);break;case Ew:e.blendFuncSeparate(0,769,0,1);break;case Cw:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}v=null,y=null,w=null,x=null,m=t,S=l}}else!0===p&&(z(3042),p=!1)}function G(t){M!==t&&(t?e.frontFace(2304):e.frontFace(2305),M=t)}function q(t){t!==fw?(U(2884),t!==_&&(t===hw?e.cullFace(1029):t===pw?e.cullFace(1028):e.cullFace(1032))):z(2884),_=t}function K(t,n,r){t?(U(32823),E===n&&C===r||(e.polygonOffset(n,r),E=n,C=r)):z(32823)}function Y(t){void 0===t&&(t=33984+k-1),R!==t&&(e.activeTexture(t),R=t)}return{buffers:{color:i,depth:o,stencil:a},enable:U,disable:z,bindFramebuffer:function(t,n){return u[t]!==n&&(e.bindFramebuffer(t,n),u[t]=n,r&&(36009===t&&(u[36160]=n),36160===t&&(u[36009]=n)),!0)},drawBuffers:function(r,i){let o=f,a=!1;if(r)if(o=d.get(i),void 0===o&&(o=[],d.set(i,o)),r.isWebGLMultipleRenderTargets){const e=r.texture;if(o.length!==e.length||36064!==o[0]){for(let t=0,n=e.length;t<n;t++)o[t]=36064+t;o.length=e.length,a=!0}}else 36064!==o[0]&&(o[0]=36064,a=!0);else 1029!==o[0]&&(o[0]=1029,a=!0);a&&(n.isWebGL2?e.drawBuffers(o):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(o))},useProgram:function(t){return h!==t&&(e.useProgram(t),h=t,!0)},setBlending:W,setMaterial:function(e,t){e.side===Sw?z(2884):U(2884);let n=e.side===xw;t&&(n=!n),G(n),e.blending===_w&&!1===e.transparent?W(Mw):W(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),o.setFunc(e.depthFunc),o.setTest(e.depthTest),o.setMask(e.depthWrite),i.setMask(e.colorWrite);const r=e.stencilWrite;a.setTest(r),r&&(a.setMask(e.stencilWriteMask),a.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),a.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),K(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?U(32926):z(32926)},setFlipSided:G,setCullFace:q,setLineWidth:function(t){t!==A&&(T&&e.lineWidth(t),A=t)},setPolygonOffset:K,setScissorTest:function(e){e?U(3089):z(3089)},activeTexture:Y,bindTexture:function(t,n){null===R&&Y();let r=P[R];void 0===r&&(r={type:void 0,texture:void 0},P[R]=r),r.type===t&&r.texture===n||(e.bindTexture(t,n||F[t]),r.type=t,r.texture=n)},unbindTexture:function(){const t=P[R];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},updateUBOMapping:function(t,n){let r=l.get(n);void 0===r&&(r=new WeakMap,l.set(n,r));let i=r.get(t);void 0===i&&(i=e.getUniformBlockIndex(n,t.name),r.set(t,i))},uniformBlockBinding:function(t,n){const r=l.get(n).get(t);s.get(t)!==r&&(e.uniformBlockBinding(n,r,t.__bindingPointIndex),s.set(t,r))},texStorage2D:function(){try{e.texStorage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===D.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),D.copy(t))},viewport:function(t){!1===B.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),B.copy(t))},reset:function(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),!0===r&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),c={},R=null,P={},u={},d=new WeakMap,f=[],h=null,p=!1,m=null,g=null,v=null,y=null,b=null,w=null,x=null,S=!1,M=null,_=null,A=null,E=null,C=null,D.set(0,0,e.canvas.width,e.canvas.height),B.set(0,0,e.canvas.width,e.canvas.height),i.reset(),o.reset(),a.reset()}}}function $k(e,t,n,r,i,o,a){const s=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,u=i.maxTextureSize,d=i.maxSamples,f=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,h=/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap;let m;const g=new WeakMap;let v=!1;try{v="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function y(e,t){return v?new OffscreenCanvas(e,t):FM("canvas")}function b(e,t,n,r){let i=1;if((e.width>r||e.height>r)&&(i=r/Math.max(e.width,e.height)),i<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const r=t?IM:Math.floor,o=r(i*e.width),a=r(i*e.height);void 0===m&&(m=y(o,a));const s=n?y(o,a):m;s.width=o,s.height=a;return s.getContext("2d").drawImage(e,0,0,o,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+a+")."),s}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function w(e){return kM(e.width)&&kM(e.height)}function x(e,t){return e.generateMipmaps&&t&&e.minFilter!==vx&&e.minFilter!==Sx}function S(t){e.generateMipmap(t)}function M(n,r,i,o,a=!1){if(!1===s)return r;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=r;return 6403===r&&(5126===i&&(l=33326),5131===i&&(l=33325),5121===i&&(l=33321)),33319===r&&(5126===i&&(l=33328),5131===i&&(l=33327),5121===i&&(l=33323)),6408===r&&(5126===i&&(l=34836),5131===i&&(l=34842),5121===i&&(l=o===BS&&!1===a?35907:32856),32819===i&&(l=32854),32820===i&&(l=32855)),33325!==l&&33326!==l&&33327!==l&&33328!==l&&34842!==l&&34836!==l||t.get("EXT_color_buffer_float"),l}function _(e,t,n){return!0===x(e,n)||e.isFramebufferTexture&&e.minFilter!==vx&&e.minFilter!==Sx?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function A(e){return e===vx||e===yx||e===wx?9728:9729}function E(e){const t=e.target;t.removeEventListener("dispose",E),function(e){const t=r.get(e);if(void 0===t.__webglInit)return;const n=e.source,i=g.get(n);if(i){const r=i[t.__cacheKey];r.usedTimes--,0===r.usedTimes&&k(e),0===Object.keys(i).length&&g.delete(n)}r.remove(e)}(t),t.isVideoTexture&&p.delete(t)}function C(t){const n=t.target;n.removeEventListener("dispose",C),function(t){const n=t.texture,i=r.get(t),o=r.get(n);void 0!==o.__webglTexture&&(e.deleteTexture(o.__webglTexture),a.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(i.__webglFramebuffer[t]),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer[t]);else{if(e.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&e.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let t=0;t<i.__webglColorRenderbuffer.length;t++)i.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(i.__webglColorRenderbuffer[t]);i.__webglDepthRenderbuffer&&e.deleteRenderbuffer(i.__webglDepthRenderbuffer)}if(t.isWebGLMultipleRenderTargets)for(let t=0,i=n.length;t<i;t++){const i=r.get(n[t]);i.__webglTexture&&(e.deleteTexture(i.__webglTexture),a.memory.textures--),r.remove(n[t])}r.remove(n),r.remove(t)}(n)}function k(t){const n=r.get(t);e.deleteTexture(n.__webglTexture);const i=t.source;delete g.get(i)[n.__cacheKey],a.memory.textures--}let T=0;function I(e,t){const i=r.get(e);if(e.isVideoTexture&&function(e){const t=a.render.frame;p.get(e)!==t&&(p.set(e,t),e.update())}(e),!1===e.isRenderTargetTexture&&e.version>0&&i.__version!==e.version){const n=e.image;if(null===n)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==n.complete)return void L(i,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+t),n.bindTexture(3553,i.__webglTexture)}const O={[px]:10497,[mx]:33071,[gx]:33648},R={[vx]:9728,[yx]:9984,[wx]:9986,[Sx]:9729,[Mx]:9985,[Ax]:9987};function P(n,o,a){if(a?(e.texParameteri(n,10242,O[o.wrapS]),e.texParameteri(n,10243,O[o.wrapT]),32879!==n&&35866!==n||e.texParameteri(n,32882,O[o.wrapR]),e.texParameteri(n,10240,R[o.magFilter]),e.texParameteri(n,10241,R[o.minFilter])):(e.texParameteri(n,10242,33071),e.texParameteri(n,10243,33071),32879!==n&&35866!==n||e.texParameteri(n,32882,33071),o.wrapS===mx&&o.wrapT===mx||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,10240,A(o.magFilter)),e.texParameteri(n,10241,A(o.minFilter)),o.minFilter!==vx&&o.minFilter!==Sx&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===t.has("EXT_texture_filter_anisotropic")){const a=t.get("EXT_texture_filter_anisotropic");if(o.type===Px&&!1===t.has("OES_texture_float_linear"))return;if(!1===s&&o.type===Nx&&!1===t.has("OES_texture_half_float_linear"))return;(o.anisotropy>1||r.get(o).__currentAnisotropy)&&(e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,i.getMaxAnisotropy())),r.get(o).__currentAnisotropy=o.anisotropy)}}function N(t,n){let r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",E));const i=n.source;let o=g.get(i);void 0===o&&(o={},g.set(i,o));const s=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.encoding),t.join()}(n);if(s!==t.__cacheKey){void 0===o[s]&&(o[s]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,r=!0),o[s].usedTimes++;const i=o[t.__cacheKey];void 0!==i&&(o[t.__cacheKey].usedTimes--,0===i.usedTimes&&k(n)),t.__cacheKey=s,t.__webglTexture=o[s].texture}return r}function L(t,r,i){let a=3553;r.isDataArrayTexture&&(a=35866),r.isData3DTexture&&(a=32879);const l=N(t,r),c=r.source;if(n.activeTexture(33984+i),n.bindTexture(a,t.__webglTexture),c.version!==c.__currentVersion||!0===l){e.pixelStorei(37440,r.flipY),e.pixelStorei(37441,r.premultiplyAlpha),e.pixelStorei(3317,r.unpackAlignment),e.pixelStorei(37443,0);const t=function(e){return!s&&(e.wrapS!==mx||e.wrapT!==mx||e.minFilter!==vx&&e.minFilter!==Sx)}(r)&&!1===w(r.image);let i=b(r.image,t,!1,u);i=z(r,i);const d=w(i)||s,f=o.convert(r.format,r.encoding);let h,p=o.convert(r.type),m=M(r.internalFormat,f,p,r.encoding,r.isVideoTexture);P(a,r,d);const g=r.mipmaps,v=s&&!0!==r.isVideoTexture,y=void 0===c.__currentVersion||!0===l,A=_(r,i,d);if(r.isDepthTexture)m=6402,s?m=r.type===Px?36012:r.type===Rx?33190:r.type===Bx?35056:33189:r.type===Px&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===Vx&&6402===m&&r.type!==Ix&&r.type!==Rx&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Rx,p=o.convert(r.type)),r.format===Wx&&6402===m&&(m=34041,r.type!==Bx&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Bx,p=o.convert(r.type))),y&&(v?n.texStorage2D(3553,1,m,i.width,i.height):n.texImage2D(3553,0,m,i.width,i.height,0,f,p,null));else if(r.isDataTexture)if(g.length>0&&d){v&&y&&n.texStorage2D(3553,A,m,g[0].width,g[0].height);for(let e=0,t=g.length;e<t;e++)h=g[e],v?n.texSubImage2D(3553,e,0,0,h.width,h.height,f,p,h.data):n.texImage2D(3553,e,m,h.width,h.height,0,f,p,h.data);r.generateMipmaps=!1}else v?(y&&n.texStorage2D(3553,A,m,i.width,i.height),n.texSubImage2D(3553,0,0,0,i.width,i.height,f,p,i.data)):n.texImage2D(3553,0,m,i.width,i.height,0,f,p,i.data);else if(r.isCompressedTexture){v&&y&&n.texStorage2D(3553,A,m,g[0].width,g[0].height);for(let e=0,t=g.length;e<t;e++)h=g[e],r.format!==Ux?null!==f?v?n.compressedTexSubImage2D(3553,e,0,0,h.width,h.height,f,h.data):n.compressedTexImage2D(3553,e,m,h.width,h.height,0,h.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):v?n.texSubImage2D(3553,e,0,0,h.width,h.height,f,p,h.data):n.texImage2D(3553,e,m,h.width,h.height,0,f,p,h.data)}else if(r.isDataArrayTexture)v?(y&&n.texStorage3D(35866,A,m,i.width,i.height,i.depth),n.texSubImage3D(35866,0,0,0,0,i.width,i.height,i.depth,f,p,i.data)):n.texImage3D(35866,0,m,i.width,i.height,i.depth,0,f,p,i.data);else if(r.isData3DTexture)v?(y&&n.texStorage3D(32879,A,m,i.width,i.height,i.depth),n.texSubImage3D(32879,0,0,0,0,i.width,i.height,i.depth,f,p,i.data)):n.texImage3D(32879,0,m,i.width,i.height,i.depth,0,f,p,i.data);else if(r.isFramebufferTexture){if(y)if(v)n.texStorage2D(3553,A,m,i.width,i.height);else{let e=i.width,t=i.height;for(let r=0;r<A;r++)n.texImage2D(3553,r,m,e,t,0,f,p,null),e>>=1,t>>=1}}else if(g.length>0&&d){v&&y&&n.texStorage2D(3553,A,m,g[0].width,g[0].height);for(let e=0,t=g.length;e<t;e++)h=g[e],v?n.texSubImage2D(3553,e,0,0,f,p,h):n.texImage2D(3553,e,m,f,p,h);r.generateMipmaps=!1}else v?(y&&n.texStorage2D(3553,A,m,i.width,i.height),n.texSubImage2D(3553,0,0,0,f,p,i)):n.texImage2D(3553,0,m,f,p,i);x(r,d)&&S(a),c.__currentVersion=c.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}function D(t,i,a,s,l){const c=o.convert(a.format,a.encoding),u=o.convert(a.type),d=M(a.internalFormat,c,u,a.encoding);r.get(i).__hasExternalTextures||(32879===l||35866===l?n.texImage3D(l,0,d,i.width,i.height,i.depth,0,c,u,null):n.texImage2D(l,0,d,i.width,i.height,0,c,u,null)),n.bindFramebuffer(36160,t),U(i)?f.framebufferTexture2DMultisampleEXT(36160,s,l,r.get(a).__webglTexture,0,F(i)):e.framebufferTexture2D(36160,s,l,r.get(a).__webglTexture,0),n.bindFramebuffer(36160,null)}function B(t,n,r){if(e.bindRenderbuffer(36161,t),n.depthBuffer&&!n.stencilBuffer){let i=33189;if(r||U(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===Px?i=36012:t.type===Rx&&(i=33190));const r=F(n);U(n)?f.renderbufferStorageMultisampleEXT(36161,r,i,n.width,n.height):e.renderbufferStorageMultisample(36161,r,i,n.width,n.height)}else e.renderbufferStorage(36161,i,n.width,n.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(n.depthBuffer&&n.stencilBuffer){const i=F(n);r&&!1===U(n)?e.renderbufferStorageMultisample(36161,i,35056,n.width,n.height):U(n)?f.renderbufferStorageMultisampleEXT(36161,i,35056,n.width,n.height):e.renderbufferStorage(36161,34041,n.width,n.height),e.framebufferRenderbuffer(36160,33306,36161,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let i=0;i<t.length;i++){const a=t[i],s=o.convert(a.format,a.encoding),l=o.convert(a.type),c=M(a.internalFormat,s,l,a.encoding),u=F(n);r&&!1===U(n)?e.renderbufferStorageMultisample(36161,u,c,n.width,n.height):U(n)?f.renderbufferStorageMultisampleEXT(36161,u,c,n.width,n.height):e.renderbufferStorage(36161,c,n.width,n.height)}}e.bindRenderbuffer(36161,null)}function j(t){const i=r.get(t),o=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(o)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,i){if(i&&i.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(36160,t),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(i.depthTexture).__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),I(i.depthTexture,0);const o=r.get(i.depthTexture).__webglTexture,a=F(i);if(i.depthTexture.format===Vx)U(i)?f.framebufferTexture2DMultisampleEXT(36160,36096,3553,o,0,a):e.framebufferTexture2D(36160,36096,3553,o,0);else{if(i.depthTexture.format!==Wx)throw new Error("Unknown depthTexture format");U(i)?f.framebufferTexture2DMultisampleEXT(36160,33306,3553,o,0,a):e.framebufferTexture2D(36160,33306,3553,o,0)}}(i.__webglFramebuffer,t)}else if(o){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)n.bindFramebuffer(36160,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]=e.createRenderbuffer(),B(i.__webglDepthbuffer[r],t,!1)}else n.bindFramebuffer(36160,i.__webglFramebuffer),i.__webglDepthbuffer=e.createRenderbuffer(),B(i.__webglDepthbuffer,t,!1);n.bindFramebuffer(36160,null)}function F(e){return Math.min(d,e.samples)}function U(e){const n=r.get(e);return s&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function z(e,n){const r=e.encoding,i=e.format,o=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===yM||r!==DS&&(r===BS?!1===s?!0===t.has("EXT_sRGB")&&i===Ux?(e.format=yM,e.minFilter=Sx,e.generateMipmaps=!1):n=ZM.sRGBToLinear(n):i===Ux&&o===Cx||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",r)),n}this.allocateTextureUnit=function(){const e=T;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),T+=1,e},this.resetTextureUnits=function(){T=0},this.setTexture2D=I,this.setTexture2DArray=function(e,t){const i=r.get(e);e.version>0&&i.__version!==e.version?L(i,e,t):(n.activeTexture(33984+t),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(e,t){const i=r.get(e);e.version>0&&i.__version!==e.version?L(i,e,t):(n.activeTexture(33984+t),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=function(t,i){const a=r.get(t);t.version>0&&a.__version!==t.version?function(t,r,i){if(6!==r.image.length)return;const a=N(t,r),l=r.source;if(n.activeTexture(33984+i),n.bindTexture(34067,t.__webglTexture),l.version!==l.__currentVersion||!0===a){e.pixelStorei(37440,r.flipY),e.pixelStorei(37441,r.premultiplyAlpha),e.pixelStorei(3317,r.unpackAlignment),e.pixelStorei(37443,0);const t=r.isCompressedTexture||r.image[0].isCompressedTexture,i=r.image[0]&&r.image[0].isDataTexture,u=[];for(let e=0;e<6;e++)u[e]=t||i?i?r.image[e].image:r.image[e]:b(r.image[e],!1,!0,c),u[e]=z(r,u[e]);const d=u[0],f=w(d)||s,h=o.convert(r.format,r.encoding),p=o.convert(r.type),m=M(r.internalFormat,h,p,r.encoding),g=s&&!0!==r.isVideoTexture,v=void 0===l.__currentVersion||!0===a;let y,A=_(r,d,f);if(P(34067,r,f),t){g&&v&&n.texStorage2D(34067,A,m,d.width,d.height);for(let e=0;e<6;e++){y=u[e].mipmaps;for(let t=0;t<y.length;t++){const i=y[t];r.format!==Ux?null!==h?g?n.compressedTexSubImage2D(34069+e,t,0,0,i.width,i.height,h,i.data):n.compressedTexImage2D(34069+e,t,m,i.width,i.height,0,i.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):g?n.texSubImage2D(34069+e,t,0,0,i.width,i.height,h,p,i.data):n.texImage2D(34069+e,t,m,i.width,i.height,0,h,p,i.data)}}}else{y=r.mipmaps,g&&v&&(y.length>0&&A++,n.texStorage2D(34067,A,m,u[0].width,u[0].height));for(let e=0;e<6;e++)if(i){g?n.texSubImage2D(34069+e,0,0,0,u[e].width,u[e].height,h,p,u[e].data):n.texImage2D(34069+e,0,m,u[e].width,u[e].height,0,h,p,u[e].data);for(let t=0;t<y.length;t++){const r=y[t].image[e].image;g?n.texSubImage2D(34069+e,t+1,0,0,r.width,r.height,h,p,r.data):n.texImage2D(34069+e,t+1,m,r.width,r.height,0,h,p,r.data)}}else{g?n.texSubImage2D(34069+e,0,0,0,h,p,u[e]):n.texImage2D(34069+e,0,m,h,p,u[e]);for(let t=0;t<y.length;t++){const r=y[t];g?n.texSubImage2D(34069+e,t+1,0,0,h,p,r.image[e]):n.texImage2D(34069+e,t+1,m,h,p,r.image[e])}}}x(r,f)&&S(34067),l.__currentVersion=l.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}(a,t,i):(n.activeTexture(33984+i),n.bindTexture(34067,a.__webglTexture))},this.rebindTextures=function(e,t,n){const i=r.get(e);void 0!==t&&D(i.__webglFramebuffer,e,e.texture,36064,3553),void 0!==n&&j(e)},this.setupRenderTarget=function(t){const l=t.texture,c=r.get(t),u=r.get(l);t.addEventListener("dispose",C),!0!==t.isWebGLMultipleRenderTargets&&(void 0===u.__webglTexture&&(u.__webglTexture=e.createTexture()),u.__version=l.version,a.memory.textures++);const d=!0===t.isWebGLCubeRenderTarget,f=!0===t.isWebGLMultipleRenderTargets,h=w(t)||s;if(d){c.__webglFramebuffer=[];for(let t=0;t<6;t++)c.__webglFramebuffer[t]=e.createFramebuffer()}else{if(c.__webglFramebuffer=e.createFramebuffer(),f)if(i.drawBuffers){const n=t.texture;for(let t=0,i=n.length;t<i;t++){const i=r.get(n[t]);void 0===i.__webglTexture&&(i.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(s&&t.samples>0&&!1===U(t)){const r=f?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(36160,c.__webglMultisampledFramebuffer);for(let n=0;n<r.length;n++){const i=r[n];c.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(36161,c.__webglColorRenderbuffer[n]);const a=o.convert(i.format,i.encoding),s=o.convert(i.type),l=M(i.internalFormat,a,s,i.encoding),u=F(t);e.renderbufferStorageMultisample(36161,u,l,t.width,t.height),e.framebufferRenderbuffer(36160,36064+n,36161,c.__webglColorRenderbuffer[n])}e.bindRenderbuffer(36161,null),t.depthBuffer&&(c.__webglDepthRenderbuffer=e.createRenderbuffer(),B(c.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(36160,null)}}if(d){n.bindTexture(34067,u.__webglTexture),P(34067,l,h);for(let e=0;e<6;e++)D(c.__webglFramebuffer[e],t,l,36064,34069+e);x(l,h)&&S(34067),n.unbindTexture()}else if(f){const e=t.texture;for(let i=0,o=e.length;i<o;i++){const o=e[i],a=r.get(o);n.bindTexture(3553,a.__webglTexture),P(3553,o,h),D(c.__webglFramebuffer,t,o,36064+i,3553),x(o,h)&&S(3553)}n.unbindTexture()}else{let e=3553;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(s?e=t.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(e,u.__webglTexture),P(e,l,h),D(c.__webglFramebuffer,t,l,36064,e),x(l,h)&&S(e),n.unbindTexture()}t.depthBuffer&&j(t)},this.updateRenderTargetMipmap=function(e){const t=w(e)||s,i=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let o=0,a=i.length;o<a;o++){const a=i[o];if(x(a,t)){const t=e.isWebGLCubeRenderTarget?34067:3553,i=r.get(a).__webglTexture;n.bindTexture(t,i),S(t),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(s&&t.samples>0&&!1===U(t)){const i=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],o=t.width,a=t.height;let s=16384;const l=[],c=t.stencilBuffer?33306:36096,u=r.get(t),d=!0===t.isWebGLMultipleRenderTargets;if(d)for(let t=0;t<i.length;t++)n.bindFramebuffer(36160,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+t,36161,null),n.bindFramebuffer(36160,u.__webglFramebuffer),e.framebufferTexture2D(36009,36064+t,3553,null,0);n.bindFramebuffer(36008,u.__webglMultisampledFramebuffer),n.bindFramebuffer(36009,u.__webglFramebuffer);for(let n=0;n<i.length;n++){l.push(36064+n),t.depthBuffer&&l.push(c);const f=void 0!==u.__ignoreDepthValues&&u.__ignoreDepthValues;if(!1===f&&(t.depthBuffer&&(s|=256),t.stencilBuffer&&(s|=1024)),d&&e.framebufferRenderbuffer(36008,36064,36161,u.__webglColorRenderbuffer[n]),!0===f&&(e.invalidateFramebuffer(36008,[c]),e.invalidateFramebuffer(36009,[c])),d){const t=r.get(i[n]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,t,0)}e.blitFramebuffer(0,0,o,a,0,0,o,a,s,9728),h&&e.invalidateFramebuffer(36008,l)}if(n.bindFramebuffer(36008,null),n.bindFramebuffer(36009,null),d)for(let t=0;t<i.length;t++){n.bindFramebuffer(36160,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+t,36161,u.__webglColorRenderbuffer[t]);const o=r.get(i[t]).__webglTexture;n.bindFramebuffer(36160,u.__webglFramebuffer),e.framebufferTexture2D(36009,36064+t,3553,o,0)}n.bindFramebuffer(36009,u.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=j,this.setupFrameBufferTexture=D,this.useMultisampledRTT=U}function eT(e,t,n){const r=n.isWebGL2;return{convert:function(n,i=null){let o;if(n===Cx)return 5121;if(n===Lx)return 32819;if(n===Dx)return 32820;if(n===kx)return 5120;if(n===Tx)return 5122;if(n===Ix)return 5123;if(n===Ox)return 5124;if(n===Rx)return 5125;if(n===Px)return 5126;if(n===Nx)return r?5131:(o=t.get("OES_texture_half_float"),null!==o?o.HALF_FLOAT_OES:null);if(n===jx)return 6406;if(n===Ux)return 6408;if(n===zx)return 6409;if(n===Hx)return 6410;if(n===Vx)return 6402;if(n===Wx)return 34041;if(n===Gx)return 6403;if(n===Fx)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(n===yM)return o=t.get("EXT_sRGB"),null!==o?o.SRGB_ALPHA_EXT:null;if(n===qx)return 36244;if(n===Kx)return 33319;if(n===Yx)return 33320;if(n===Jx)return 36249;if(n===Qx||n===Xx||n===Zx||n===$x)if(i===BS){if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===o)return null;if(n===Qx)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Xx)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Zx)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===$x)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(o=t.get("WEBGL_compressed_texture_s3tc"),null===o)return null;if(n===Qx)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Xx)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Zx)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===$x)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===eS||n===tS||n===nS||n===rS){if(o=t.get("WEBGL_compressed_texture_pvrtc"),null===o)return null;if(n===eS)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===tS)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===nS)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===rS)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===iS)return o=t.get("WEBGL_compressed_texture_etc1"),null!==o?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===oS||n===aS){if(o=t.get("WEBGL_compressed_texture_etc"),null===o)return null;if(n===oS)return i===BS?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===aS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}if(n===sS||n===lS||n===cS||n===uS||n===dS||n===fS||n===hS||n===pS||n===mS||n===gS||n===vS||n===yS||n===bS||n===wS){if(o=t.get("WEBGL_compressed_texture_astc"),null===o)return null;if(n===sS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===lS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===cS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===uS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===dS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===fS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===hS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===pS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===mS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===gS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===vS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===yS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===bS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===wS)return i===BS?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===xS){if(o=t.get("EXT_texture_compression_bptc"),null===o)return null;if(n===xS)return i===BS?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}return n===Bx?r?34042:(o=t.get("WEBGL_depth_texture"),null!==o?o.UNSIGNED_INT_24_8_WEBGL:null):void 0!==e[n]?e[n]:null}}}class tT extends wE{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class nT extends hA{constructor(){super(),this.isGroup=!0,this.type="Group"}}const rT={type:"move"};class iT{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new nT,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new nT,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new d_,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new d_),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new nT,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new d_,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new d_),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,o=null;const a=this._targetRay,s=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){o=!0;for(const r of e.hand.values()){const e=t.getJointPose(r,n);if(void 0===l.joints[r.jointName]){const e=new nT;e.matrixAutoUpdate=!1,e.visible=!1,l.joints[r.jointName]=e,l.add(e)}const i=l.joints[r.jointName];null!==e&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.jointRadius=e.radius),i.visible=null!==e}const r=l.joints["index-finger-tip"],i=l.joints["thumb-tip"],a=r.position.distanceTo(i.position),s=.02,c=.005;l.inputState.pinching&&a>s+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=s-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));null!==a&&(r=t.getPose(e.targetRaySpace,n),null===r&&null!==i&&(r=i),null!==r&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(rT)))}return null!==a&&(a.visible=null!==r),null!==s&&(s.visible=null!==i),null!==l&&(l.visible=null!==o),this}}class oT extends n_{constructor(e,t,n,r,i,o,a,s,l,c){if((c=void 0!==c?c:Vx)!==Vx&&c!==Wx)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===Vx&&(n=Rx),void 0===n&&c===Wx&&(n=Bx),super(null,r,i,o,a,s,c,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==a?a:vx,this.minFilter=void 0!==s?s:vx,this.flipY=!1,this.generateMipmaps=!1}}class aT extends bM{constructor(e,t){super();const n=this;let r=null,i=1,o=null,a="local-floor",s=null,l=null,c=null,u=null,d=null,f=null;const h=t.getContextAttributes();let p=null,m=null;const g=[],v=[],y=new wE;y.layers.enable(1),y.viewport=new r_;const b=new wE;b.layers.enable(2),b.viewport=new r_;const w=[y,b],x=new tT;x.layers.enable(1),x.layers.enable(2);let S=null,M=null;function _(e){const t=v.indexOf(e.inputSource);if(-1===t)return;const n=g[t];void 0!==n&&n.dispatchEvent({type:e.type,data:e.inputSource})}function A(){r.removeEventListener("select",_),r.removeEventListener("selectstart",_),r.removeEventListener("selectend",_),r.removeEventListener("squeeze",_),r.removeEventListener("squeezestart",_),r.removeEventListener("squeezeend",_),r.removeEventListener("end",A),r.removeEventListener("inputsourceschange",E);for(let e=0;e<g.length;e++){const t=v[e];null!==t&&(v[e]=null,g[e].disconnect(t))}S=null,M=null,e.setRenderTarget(p),d=null,u=null,c=null,r=null,m=null,O.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function E(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],r=v.indexOf(n);r>=0&&(v[r]=null,g[r].dispatchEvent({type:"disconnected",data:n}))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let r=v.indexOf(n);if(-1===r){for(let e=0;e<g.length;e++){if(e>=v.length){v.push(n),r=e;break}if(null===v[e]){v[e]=n,r=e;break}}if(-1===r)break}const i=g[r];i&&i.dispatchEvent({type:"connected",data:n})}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=g[e];return void 0===t&&(t=new iT,g[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=g[e];return void 0===t&&(t=new iT,g[e]=t),t.getGripSpace()},this.getHand=function(e){let t=g[e];return void 0===t&&(t=new iT,g[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){i=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s||o},this.setReferenceSpace=function(e){s=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return f},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,null!==r){if(p=e.getRenderTarget(),r.addEventListener("select",_),r.addEventListener("selectstart",_),r.addEventListener("selectend",_),r.addEventListener("squeeze",_),r.addEventListener("squeezestart",_),r.addEventListener("squeezeend",_),r.addEventListener("end",A),r.addEventListener("inputsourceschange",E),!0!==h.xrCompatible&&await t.makeXRCompatible(),void 0===r.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==r.renderState.layers||h.antialias,alpha:h.alpha,depth:h.depth,stencil:h.stencil,framebufferScaleFactor:i};d=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:d}),m=new i_(d.framebufferWidth,d.framebufferHeight,{format:Ux,type:Cx,encoding:e.outputEncoding,stencilBuffer:h.stencil})}else{let n=null,o=null,a=null;h.depth&&(a=h.stencil?35056:33190,n=h.stencil?Wx:Vx,o=h.stencil?Bx:Rx);const s={colorFormat:32856,depthFormat:a,scaleFactor:i};c=new XRWebGLBinding(r,t),u=c.createProjectionLayer(s),r.updateRenderState({layers:[u]}),m=new i_(u.textureWidth,u.textureHeight,{format:Ux,type:Cx,depthTexture:new oT(u.textureWidth,u.textureHeight,o,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:h.stencil,encoding:e.outputEncoding,samples:h.antialias?4:0});e.properties.get(m).__ignoreDepthValues=u.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(1),s=null,o=await r.requestReferenceSpace(a),O.setContext(r),O.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};const C=new d_,k=new d_;function T(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===r)return;x.near=b.near=y.near=e.near,x.far=b.far=y.far=e.far,S===x.near&&M===x.far||(r.updateRenderState({depthNear:x.near,depthFar:x.far}),S=x.near,M=x.far);const t=e.parent,n=x.cameras;T(x,t);for(let e=0;e<n.length;e++)T(n[e],t);x.matrixWorld.decompose(x.position,x.quaternion,x.scale),e.matrix.copy(x.matrix),e.matrix.decompose(e.position,e.quaternion,e.scale);const i=e.children;for(let e=0,t=i.length;e<t;e++)i[e].updateMatrixWorld(!0);2===n.length?function(e,t,n){C.setFromMatrixPosition(t.matrixWorld),k.setFromMatrixPosition(n.matrixWorld);const r=C.distanceTo(k),i=t.projectionMatrix.elements,o=n.projectionMatrix.elements,a=i[14]/(i[10]-1),s=i[14]/(i[10]+1),l=(i[9]+1)/i[5],c=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(o[8]+1)/o[0],f=a*u,h=a*d,p=r/(-u+d),m=p*-u;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(p),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const g=a+p,v=s+p,y=f-m,b=h+(r-m),w=l*s/v*g,x=c*s/v*g;e.projectionMatrix.makePerspective(y,b,w,x,g,v)}(x,y,b):x.projectionMatrix.copy(y.projectionMatrix)},this.getCamera=function(){return x},this.getFoveation=function(){return null!==u?u.fixedFoveation:null!==d?d.fixedFoveation:void 0},this.setFoveation=function(e){null!==u&&(u.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)};let I=null;const O=new RE;O.setAnimationLoop((function(t,n){if(l=n.getViewerPose(s||o),f=n,null!==l){const t=l.views;null!==d&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let n=!1;t.length!==x.cameras.length&&(x.cameras.length=0,n=!0);for(let r=0;r<t.length;r++){const i=t[r];let o=null;if(null!==d)o=d.getViewport(i);else{const t=c.getViewSubImage(u,i);o=t.viewport,0===r&&(e.setRenderTargetTextures(m,t.colorTexture,u.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(m))}let a=w[r];void 0===a&&(a=new wE,a.layers.enable(r),a.viewport=new r_,w[r]=a),a.matrix.fromArray(i.transform.matrix),a.projectionMatrix.fromArray(i.projectionMatrix),a.viewport.set(o.x,o.y,o.width,o.height),0===r&&x.matrix.copy(a.matrix),!0===n&&x.cameras.push(a)}}for(let e=0;e<g.length;e++){const t=v[e],r=g[e];null!==t&&void 0!==r&&r.update(t,n,s||o)}I&&I(t,n),f=null})),this.setAnimationLoop=function(e){I=e},this.dispose=function(){}}}function sT(e,t){function n(n,r){n.opacity.value=r.opacity,r.color&&n.diffuse.value.copy(r.color),r.emissive&&n.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(n.map.value=r.map),r.alphaMap&&(n.alphaMap.value=r.alphaMap),r.bumpMap&&(n.bumpMap.value=r.bumpMap,n.bumpScale.value=r.bumpScale,r.side===xw&&(n.bumpScale.value*=-1)),r.displacementMap&&(n.displacementMap.value=r.displacementMap,n.displacementScale.value=r.displacementScale,n.displacementBias.value=r.displacementBias),r.emissiveMap&&(n.emissiveMap.value=r.emissiveMap),r.normalMap&&(n.normalMap.value=r.normalMap,n.normalScale.value.copy(r.normalScale),r.side===xw&&n.normalScale.value.negate()),r.specularMap&&(n.specularMap.value=r.specularMap),r.alphaTest>0&&(n.alphaTest.value=r.alphaTest);const i=t.get(r).envMap;if(i&&(n.envMap.value=i,n.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,n.reflectivity.value=r.reflectivity,n.ior.value=r.ior,n.refractionRatio.value=r.refractionRatio),r.lightMap){n.lightMap.value=r.lightMap;const t=!0!==e.physicallyCorrectLights?Math.PI:1;n.lightMapIntensity.value=r.lightMapIntensity*t}let o,a;r.aoMap&&(n.aoMap.value=r.aoMap,n.aoMapIntensity.value=r.aoMapIntensity),r.map?o=r.map:r.specularMap?o=r.specularMap:r.displacementMap?o=r.displacementMap:r.normalMap?o=r.normalMap:r.bumpMap?o=r.bumpMap:r.roughnessMap?o=r.roughnessMap:r.metalnessMap?o=r.metalnessMap:r.alphaMap?o=r.alphaMap:r.emissiveMap?o=r.emissiveMap:r.clearcoatMap?o=r.clearcoatMap:r.clearcoatNormalMap?o=r.clearcoatNormalMap:r.clearcoatRoughnessMap?o=r.clearcoatRoughnessMap:r.iridescenceMap?o=r.iridescenceMap:r.iridescenceThicknessMap?o=r.iridescenceThicknessMap:r.specularIntensityMap?o=r.specularIntensityMap:r.specularColorMap?o=r.specularColorMap:r.transmissionMap?o=r.transmissionMap:r.thicknessMap?o=r.thicknessMap:r.sheenColorMap?o=r.sheenColorMap:r.sheenRoughnessMap&&(o=r.sheenRoughnessMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),n.uvTransform.value.copy(o.matrix)),r.aoMap?a=r.aoMap:r.lightMap&&(a=r.lightMap),void 0!==a&&(a.isWebGLRenderTarget&&(a=a.texture),!0===a.matrixAutoUpdate&&a.updateMatrix(),n.uv2Transform.value.copy(a.matrix))}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function(e,r,i,o,a){r.isMeshBasicMaterial||r.isMeshLambertMaterial?n(e,r):r.isMeshToonMaterial?(n(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(n(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(n(e,r),function(e,n){e.roughness.value=n.roughness,e.metalness.value=n.metalness,n.roughnessMap&&(e.roughnessMap.value=n.roughnessMap);n.metalnessMap&&(e.metalnessMap.value=n.metalnessMap);const r=t.get(n).envMap;r&&(e.envMapIntensity.value=n.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,n){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap),t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,t.side===xw&&e.clearcoatNormalScale.value.negate()));t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=n.texture,e.transmissionSamplerSize.value.set(n.width,n.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap);t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap)}(e,r,a)):r.isMeshMatcapMaterial?(n(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?n(e,r):r.isMeshDistanceMaterial?(n(e,r),function(e,t){e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(e,r)):r.isMeshNormalMaterial?n(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,n,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=.5*r,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let i;t.map?i=t.map:t.alphaMap&&(i=t.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix))}(e,r,i,o):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let n;t.map?n=t.map:t.alphaMap&&(n=t.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function lT(e,t,n,r){let i={},o={},a=[];const s=n.isWebGL2?e.getParameter(35375):0;function l(e,t,n){const r=e.value;if(void 0===n[t])return n[t]="number"==typeof r?r:r.clone(),!0;if("number"==typeof r){if(n[t]!==r)return n[t]=r,!0}else{const e=n[t];if(!1===e.equals(r))return e.copy(r),!0}return!1}function c(e){const t=e.value,n={boundary:0,storage:0};return"number"==typeof t?(n.boundary=4,n.storage=4):t.isVector2?(n.boundary=8,n.storage=8):t.isVector3||t.isColor?(n.boundary=16,n.storage=12):t.isVector4?(n.boundary=16,n.storage=16):t.isMatrix3?(n.boundary=48,n.storage=48):t.isMatrix4?(n.boundary=64,n.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),n}function u(t){const n=t.target;n.removeEventListener("dispose",u);const r=a.indexOf(n.__bindingPointIndex);a.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete o[n.id]}return{bind:function(e,t){const n=t.program;r.uniformBlockBinding(e,n)},update:function(n,d){let f=i[n.id];void 0===f&&(!function(e){const t=e.uniforms;let n=0;const r=16;let i=0;for(let e=0,o=t.length;e<o;e++){const o=t[e],a=c(o);if(o.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),o.__offset=n,e>0){i=n%r;0!==i&&r-i-a.boundary<0&&(n+=r-i,o.__offset=n)}n+=a.storage}i=n%r,i>0&&(n+=r-i);e.__size=n,e.__cache={}}(n),f=function(t){const n=function(){for(let e=0;e<s;e++)if(-1===a.indexOf(e))return a.push(e),e;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const r=e.createBuffer(),i=t.__size,o=t.usage;return e.bindBuffer(35345,r),e.bufferData(35345,i,o),e.bindBuffer(35345,null),e.bindBufferBase(35345,n,r),r}(n),i[n.id]=f,n.addEventListener("dispose",u));const h=d.program;r.updateUBOMapping(n,h);const p=t.render.frame;o[n.id]!==p&&(!function(t){const n=i[t.id],r=t.uniforms,o=t.__cache;e.bindBuffer(35345,n);for(let t=0,n=r.length;t<n;t++){const n=r[t];if(!0===l(n,t,o)){const t=n.value,r=n.__offset;"number"==typeof t?(n.__data[0]=t,e.bufferSubData(35345,r,n.__data)):(n.value.isMatrix3?(n.__data[0]=n.value.elements[0],n.__data[1]=n.value.elements[1],n.__data[2]=n.value.elements[2],n.__data[3]=n.value.elements[0],n.__data[4]=n.value.elements[3],n.__data[5]=n.value.elements[4],n.__data[6]=n.value.elements[5],n.__data[7]=n.value.elements[0],n.__data[8]=n.value.elements[6],n.__data[9]=n.value.elements[7],n.__data[10]=n.value.elements[8],n.__data[11]=n.value.elements[0]):t.toArray(n.__data),e.bufferSubData(35345,r,n.__data))}}e.bindBuffer(35345,null)}(n),o[n.id]=p)},dispose:function(){for(const t in i)e.deleteBuffer(i[t]);a=[],i={},o={}}}}function cT(e={}){this.isWebGLRenderer=!0;const t=void 0!==e.canvas?e.canvas:function(){const e=FM("canvas");return e.style.display="block",e}(),n=void 0!==e.context?e.context:null,r=void 0===e.depth||e.depth,i=void 0===e.stencil||e.stencil,o=void 0!==e.antialias&&e.antialias,a=void 0===e.premultipliedAlpha||e.premultipliedAlpha,s=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,l=void 0!==e.powerPreference?e.powerPreference:"default",c=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let u;u=null!==n?n.getContextAttributes().alpha:void 0!==e.alpha&&e.alpha;let d=null,f=null;const h=[],p=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=DS,this.physicallyCorrectLights=!1,this.toneMapping=nx,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});const m=this;let g=!1,v=0,y=0,b=null,w=-1,x=null;const S=new r_,M=new r_;let _=null,A=t.width,E=t.height,C=1,k=null,T=null;const I=new r_(0,0,A,E),O=new r_(0,0,A,E);let R=!1;const P=new OE;let N=!1,L=!1,D=null;const B=new H_,j=new NM,F=new d_,U={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function z(){return null===b?C:1}let H,V,W,G,q,K,Y,J,Q,X,Z,$,ee,te,ne,re,ie,oe,ae,se,le,ce,ue,de,fe=n;function he(e,n){for(let r=0;r<e.length;r++){const i=e[r],o=t.getContext(i,n);if(null!==o)return o}return null}try{const e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:s,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${cw}`),t.addEventListener("webglcontextlost",ge,!1),t.addEventListener("webglcontextrestored",ve,!1),t.addEventListener("webglcontextcreationerror",ye,!1),null===fe){const t=["webgl2","webgl","experimental-webgl"];if(!0===m.isWebGL1Renderer&&t.shift(),fe=he(t,e),null===fe)throw he(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===fe.getShaderPrecisionFormat&&(fe.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function pe(){H=new aC(fe),V=new zE(fe,H,e),H.init(V),ce=new eT(fe,H,V),W=new Zk(fe,H,V),G=new cC,q=new jk,K=new $k(fe,H,W,q,V,ce,G),Y=new VE(m),J=new oC(m),Q=new PE(fe,V),ue=new FE(fe,H,Q,V),X=new sC(fe,Q,G,ue),Z=new hC(fe,X,Q,G),ae=new fC(fe,V,K),re=new HE(q),$=new Bk(m,Y,J,H,V,ue,re),ee=new sT(m,q),te=new Hk,ne=new Yk(H,V),oe=new jE(m,Y,W,Z,u,a),ie=new Xk(m,Z,V),de=new lT(fe,G,V,W),se=new UE(fe,H,G,V),le=new lC(fe,H,G,V),G.programs=$.programs,m.capabilities=V,m.extensions=H,m.properties=q,m.renderLists=te,m.shadowMap=ie,m.state=W,m.info=G}pe();const me=new aT(m,fe);function ge(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function ve(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;const e=G.autoReset,t=ie.enabled,n=ie.autoUpdate,r=ie.needsUpdate,i=ie.type;pe(),G.autoReset=e,ie.enabled=t,ie.autoUpdate=n,ie.needsUpdate=r,ie.type=i}function ye(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function be(e){const t=e.target;t.removeEventListener("dispose",be),function(e){(function(e){const t=q.get(e).programs;void 0!==t&&(t.forEach((function(e){$.releaseProgram(e)})),e.isShaderMaterial&&$.releaseShaderCache(e))})(e),q.remove(e)}(t)}this.xr=me,this.getContext=function(){return fe},this.getContextAttributes=function(){return fe.getContextAttributes()},this.forceContextLoss=function(){const e=H.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=H.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(e){void 0!==e&&(C=e,this.setSize(A,E,!1))},this.getSize=function(e){return e.set(A,E)},this.setSize=function(e,n,r){me.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(A=e,E=n,t.width=Math.floor(e*C),t.height=Math.floor(n*C),!1!==r&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(A*C,E*C).floor()},this.setDrawingBufferSize=function(e,n,r){A=e,E=n,C=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(S)},this.getViewport=function(e){return e.copy(I)},this.setViewport=function(e,t,n,r){e.isVector4?I.set(e.x,e.y,e.z,e.w):I.set(e,t,n,r),W.viewport(S.copy(I).multiplyScalar(C).floor())},this.getScissor=function(e){return e.copy(O)},this.setScissor=function(e,t,n,r){e.isVector4?O.set(e.x,e.y,e.z,e.w):O.set(e,t,n,r),W.scissor(M.copy(O).multiplyScalar(C).floor())},this.getScissorTest=function(){return R},this.setScissorTest=function(e){W.setScissorTest(R=e)},this.setOpaqueSort=function(e){k=e},this.setTransparentSort=function(e){T=e},this.getClearColor=function(e){return e.copy(oe.getClearColor())},this.setClearColor=function(){oe.setClearColor.apply(oe,arguments)},this.getClearAlpha=function(){return oe.getClearAlpha()},this.setClearAlpha=function(){oe.setClearAlpha.apply(oe,arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;e&&(r|=16384),t&&(r|=256),n&&(r|=1024),fe.clear(r)},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",ge,!1),t.removeEventListener("webglcontextrestored",ve,!1),t.removeEventListener("webglcontextcreationerror",ye,!1),te.dispose(),ne.dispose(),q.dispose(),Y.dispose(),J.dispose(),Z.dispose(),ue.dispose(),de.dispose(),$.dispose(),me.dispose(),me.removeEventListener("sessionstart",xe),me.removeEventListener("sessionend",Se),D&&(D.dispose(),D=null),Me.stop()},this.renderBufferDirect=function(e,t,n,r,i,o){null===t&&(t=U);const a=i.isMesh&&i.matrixWorld.determinant()<0,s=function(e,t,n,r,i){!0!==t.isScene&&(t=U);K.resetTextureUnits();const o=t.fog,a=r.isMeshStandardMaterial?t.environment:null,s=null===b?m.outputEncoding:!0===b.isXRRenderTarget?b.texture.encoding:DS,l=(r.isMeshStandardMaterial?J:Y).get(r.envMap||a),c=!0===r.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!r.normalMap&&!!n.attributes.tangent,d=!!n.morphAttributes.position,h=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,g=r.toneMapped?m.toneMapping:nx,v=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,y=void 0!==v?v.length:0,S=q.get(r),M=f.state.lights;if(!0===N&&(!0===L||e!==x)){const t=e===x&&r.id===w;re.setState(r,e,t)}let _=!1;r.version===S.__version?S.needsLights&&S.lightsStateVersion!==M.state.version||S.outputEncoding!==s||i.isInstancedMesh&&!1===S.instancing?_=!0:i.isInstancedMesh||!0!==S.instancing?i.isSkinnedMesh&&!1===S.skinning?_=!0:i.isSkinnedMesh||!0!==S.skinning?S.envMap!==l||!0===r.fog&&S.fog!==o?_=!0:void 0===S.numClippingPlanes||S.numClippingPlanes===re.numPlanes&&S.numIntersection===re.numIntersection?(S.vertexAlphas!==c||S.vertexTangents!==u||S.morphTargets!==d||S.morphNormals!==h||S.morphColors!==p||S.toneMapping!==g||!0===V.isWebGL2&&S.morphTargetsCount!==y)&&(_=!0):_=!0:_=!0:_=!0:(_=!0,S.__version=r.version);let A=S.currentProgram;!0===_&&(A=ke(r,t,i));let k=!1,T=!1,I=!1;const O=A.getUniforms(),R=S.uniforms;W.useProgram(A.program)&&(k=!0,T=!0,I=!0);r.id!==w&&(w=r.id,T=!0);if(k||x!==e){if(O.setValue(fe,"projectionMatrix",e.projectionMatrix),V.logarithmicDepthBuffer&&O.setValue(fe,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),x!==e&&(x=e,T=!0,I=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshStandardMaterial||r.envMap){const t=O.map.cameraPosition;void 0!==t&&t.setValue(fe,F.setFromMatrixPosition(e.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(fe,"isOrthographic",!0===e.isOrthographicCamera),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.isShadowMaterial||i.isSkinnedMesh)&&O.setValue(fe,"viewMatrix",e.matrixWorldInverse)}if(i.isSkinnedMesh){O.setOptional(fe,i,"bindMatrix"),O.setOptional(fe,i,"bindMatrixInverse");const e=i.skeleton;e&&(V.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),O.setValue(fe,"boneTexture",e.boneTexture,K),O.setValue(fe,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const P=n.morphAttributes;(void 0!==P.position||void 0!==P.normal||void 0!==P.color&&!0===V.isWebGL2)&&ae.update(i,n,r,A);(T||S.receiveShadow!==i.receiveShadow)&&(S.receiveShadow=i.receiveShadow,O.setValue(fe,"receiveShadow",i.receiveShadow));r.isMeshGouraudMaterial&&null!==r.envMap&&(R.envMap.value=l,R.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);T&&(O.setValue(fe,"toneMappingExposure",m.toneMappingExposure),S.needsLights&&(j=I,(B=R).ambientLightColor.needsUpdate=j,B.lightProbe.needsUpdate=j,B.directionalLights.needsUpdate=j,B.directionalLightShadows.needsUpdate=j,B.pointLights.needsUpdate=j,B.pointLightShadows.needsUpdate=j,B.spotLights.needsUpdate=j,B.spotLightShadows.needsUpdate=j,B.rectAreaLights.needsUpdate=j,B.hemisphereLights.needsUpdate=j),o&&!0===r.fog&&ee.refreshFogUniforms(R,o),ee.refreshMaterialUniforms(R,r,C,E,D),vk.upload(fe,S.uniformsList,R,K));var B,j;r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(vk.upload(fe,S.uniformsList,R,K),r.uniformsNeedUpdate=!1);r.isSpriteMaterial&&O.setValue(fe,"center",i.center);if(O.setValue(fe,"modelViewMatrix",i.modelViewMatrix),O.setValue(fe,"normalMatrix",i.normalMatrix),O.setValue(fe,"modelMatrix",i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){const e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++)if(V.isWebGL2){const n=e[t];de.update(n,A),de.bind(n,A)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return A}(e,t,n,r,i);W.setMaterial(r,a);let l=n.index;const c=n.attributes.position;if(null===l){if(void 0===c||0===c.count)return}else if(0===l.count)return;let u,d=1;!0===r.wireframe&&(l=X.getWireframeAttribute(n),d=2),ue.setup(i,r,s,n,l);let h=se;null!==l&&(u=Q.get(l),h=le,h.setIndex(u));const p=null!==l?l.count:c.count,g=n.drawRange.start*d,v=n.drawRange.count*d,y=null!==o?o.start*d:0,S=null!==o?o.count*d:1/0,M=Math.max(g,y),_=Math.min(p,g+v,y+S)-1,A=Math.max(0,_-M+1);if(0!==A){if(i.isMesh)!0===r.wireframe?(W.setLineWidth(r.wireframeLinewidth*z()),h.setMode(1)):h.setMode(4);else if(i.isLine){let e=r.linewidth;void 0===e&&(e=1),W.setLineWidth(e*z()),i.isLineSegments?h.setMode(1):i.isLineLoop?h.setMode(2):h.setMode(3)}else i.isPoints?h.setMode(0):i.isSprite&&h.setMode(4);if(i.isInstancedMesh)h.renderInstances(M,A,i.count);else if(n.isInstancedBufferGeometry){const e=Math.min(n.instanceCount,n._maxInstanceCount);h.renderInstances(M,A,e)}else h.render(M,A)}},this.compile=function(e,t){function n(e,t,n){!0===e.transparent&&e.side===Sw?(e.side=xw,e.needsUpdate=!0,ke(e,t,n),e.side=ww,e.needsUpdate=!0,ke(e,t,n),e.side=Sw):ke(e,t,n)}f=ne.get(e),f.init(),p.push(f),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(f.pushLight(e),e.castShadow&&f.pushShadow(e))})),f.setupLights(m.physicallyCorrectLights),e.traverse((function(t){const r=t.material;if(r)if(Array.isArray(r))for(let i=0;i<r.length;i++){n(r[i],e,t)}else n(r,e,t)})),p.pop(),f=null};let we=null;function xe(){Me.stop()}function Se(){Me.start()}const Me=new RE;function _e(e,t,n,r){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)f.pushLight(e),e.castShadow&&f.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||P.intersectsSprite(e)){r&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(B);const t=Z.update(e),i=e.material;i.visible&&d.push(e,t,i,n,F.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.frame!==G.render.frame&&(e.skeleton.update(),e.skeleton.frame=G.render.frame),!e.frustumCulled||P.intersectsObject(e))){r&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(B);const t=Z.update(e),i=e.material;if(Array.isArray(i)){const r=t.groups;for(let o=0,a=r.length;o<a;o++){const a=r[o],s=i[a.materialIndex];s&&s.visible&&d.push(e,t,s,n,F.z,a)}}else i.visible&&d.push(e,t,i,n,F.z,null)}const i=e.children;for(let e=0,o=i.length;e<o;e++)_e(i[e],t,n,r)}function Ae(e,t,n,r){const i=e.opaque,a=e.transmissive,s=e.transparent;f.setupLightsView(n),a.length>0&&function(e,t,n){const r=V.isWebGL2;null===D&&(D=new i_(1,1,{generateMipmaps:!0,type:H.has("EXT_color_buffer_half_float")?Nx:Cx,minFilter:Ax,samples:r&&!0===o?4:0}));m.getDrawingBufferSize(j),r?D.setSize(j.x,j.y):D.setSize(IM(j.x),IM(j.y));const i=m.getRenderTarget();m.setRenderTarget(D),m.clear();const a=m.toneMapping;m.toneMapping=nx,Ee(e,t,n),m.toneMapping=a,K.updateMultisampleRenderTarget(D),K.updateRenderTargetMipmap(D),m.setRenderTarget(i)}(i,t,n),r&&W.viewport(S.copy(r)),i.length>0&&Ee(i,t,n),a.length>0&&Ee(a,t,n),s.length>0&&Ee(s,t,n),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function Ee(e,t,n){const r=!0===t.isScene?t.overrideMaterial:null;for(let i=0,o=e.length;i<o;i++){const o=e[i],a=o.object,s=o.geometry,l=null===r?o.material:r,c=o.group;a.layers.test(n.layers)&&Ce(a,t,n,s,l,c)}}function Ce(e,t,n,r,i,o){e.onBeforeRender(m,t,n,r,i,o),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(m,t,n,r,e,o),!0===i.transparent&&i.side===Sw?(i.side=xw,i.needsUpdate=!0,m.renderBufferDirect(n,t,r,i,e,o),i.side=ww,i.needsUpdate=!0,m.renderBufferDirect(n,t,r,i,e,o),i.side=Sw):m.renderBufferDirect(n,t,r,i,e,o),e.onAfterRender(m,t,n,r,i,o)}function ke(e,t,n){!0!==t.isScene&&(t=U);const r=q.get(e),i=f.state.lights,o=f.state.shadowsArray,a=i.state.version,s=$.getParameters(e,i.state,o,t,n),l=$.getProgramCacheKey(s);let c=r.programs;r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=(e.isMeshStandardMaterial?J:Y).get(e.envMap||r.environment),void 0===c&&(e.addEventListener("dispose",be),c=new Map,r.programs=c);let u=c.get(l);if(void 0!==u){if(r.currentProgram===u&&r.lightsStateVersion===a)return Te(e,s),u}else s.uniforms=$.getUniforms(e),e.onBuild(n,s,m),e.onBeforeCompile(s,m),u=$.acquireProgram(s,l),c.set(l,u),r.uniforms=s.uniforms;const d=r.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(d.clippingPlanes=re.uniform),Te(e,s),r.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),r.lightsStateVersion=a,r.needsLights&&(d.ambientLightColor.value=i.state.ambient,d.lightProbe.value=i.state.probe,d.directionalLights.value=i.state.directional,d.directionalLightShadows.value=i.state.directionalShadow,d.spotLights.value=i.state.spot,d.spotLightShadows.value=i.state.spotShadow,d.rectAreaLights.value=i.state.rectArea,d.ltc_1.value=i.state.rectAreaLTC1,d.ltc_2.value=i.state.rectAreaLTC2,d.pointLights.value=i.state.point,d.pointLightShadows.value=i.state.pointShadow,d.hemisphereLights.value=i.state.hemi,d.directionalShadowMap.value=i.state.directionalShadowMap,d.directionalShadowMatrix.value=i.state.directionalShadowMatrix,d.spotShadowMap.value=i.state.spotShadowMap,d.spotLightMatrix.value=i.state.spotLightMatrix,d.spotLightMap.value=i.state.spotLightMap,d.pointShadowMap.value=i.state.pointShadowMap,d.pointShadowMatrix.value=i.state.pointShadowMatrix);const h=u.getUniforms(),p=vk.seqWithValue(h.seq,d);return r.currentProgram=u,r.uniformsList=p,u}function Te(e,t){const n=q.get(e);n.outputEncoding=t.outputEncoding,n.instancing=t.instancing,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}Me.setAnimationLoop((function(e){we&&we(e)})),"undefined"!=typeof self&&Me.setContext(self),this.setAnimationLoop=function(e){we=e,me.setAnimationLoop(e),null===e?Me.stop():Me.start()},me.addEventListener("sessionstart",xe),me.addEventListener("sessionend",Se),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===g)return;!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===me.enabled&&!0===me.isPresenting&&(!0===me.cameraAutoUpdate&&me.updateCamera(t),t=me.getCamera()),!0===e.isScene&&e.onBeforeRender(m,e,t,b),f=ne.get(e,p.length),f.init(),p.push(f),B.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),P.setFromProjectionMatrix(B),L=this.localClippingEnabled,N=re.init(this.clippingPlanes,L,t),d=te.get(e,h.length),d.init(),h.push(d),_e(e,t,0,m.sortObjects),d.finish(),!0===m.sortObjects&&d.sort(k,T),!0===N&&re.beginShadows();const n=f.state.shadowsArray;if(ie.render(n,e,t),!0===N&&re.endShadows(),!0===this.info.autoReset&&this.info.reset(),oe.render(d,e),f.setupLights(m.physicallyCorrectLights),t.isArrayCamera){const n=t.cameras;for(let t=0,r=n.length;t<r;t++){const r=n[t];Ae(d,e,r,r.viewport)}}else Ae(d,e,t);null!==b&&(K.updateMultisampleRenderTarget(b),K.updateRenderTargetMipmap(b)),!0===e.isScene&&e.onAfterRender(m,e,t),ue.resetDefaultState(),w=-1,x=null,p.pop(),f=p.length>0?p[p.length-1]:null,h.pop(),d=h.length>0?h[h.length-1]:null},this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(e,t,n){q.get(e.texture).__webglTexture=t,q.get(e.depthTexture).__webglTexture=n;const r=q.get(e);r.__hasExternalTextures=!0,r.__hasExternalTextures&&(r.__autoAllocateDepthBuffer=void 0===n,r.__autoAllocateDepthBuffer||!0===H.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),r.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const n=q.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){b=e,v=t,y=n;let r=!0;if(e){const t=q.get(e);void 0!==t.__useDefaultFramebuffer?(W.bindFramebuffer(36160,null),r=!1):void 0===t.__webglFramebuffer?K.setupRenderTarget(e):t.__hasExternalTextures&&K.rebindTextures(e,q.get(e.texture).__webglTexture,q.get(e.depthTexture).__webglTexture)}let i=null,o=!1,a=!1;if(e){const n=e.texture;(n.isData3DTexture||n.isDataArrayTexture)&&(a=!0);const r=q.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=r[t],o=!0):i=V.isWebGL2&&e.samples>0&&!1===K.useMultisampledRTT(e)?q.get(e).__webglMultisampledFramebuffer:r,S.copy(e.viewport),M.copy(e.scissor),_=e.scissorTest}else S.copy(I).multiplyScalar(C).floor(),M.copy(O).multiplyScalar(C).floor(),_=R;if(W.bindFramebuffer(36160,i)&&V.drawBuffers&&r&&W.drawBuffers(e,i),W.viewport(S),W.scissor(M),W.setScissorTest(_),o){const r=q.get(e.texture);fe.framebufferTexture2D(36160,36064,34069+t,r.__webglTexture,n)}else if(a){const r=q.get(e.texture),i=t||0;fe.framebufferTextureLayer(36160,36064,r.__webglTexture,n||0,i)}w=-1},this.readRenderTargetPixels=function(e,t,n,r,i,o,a){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let s=q.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(s=s[a]),s){W.bindFramebuffer(36160,s);try{const a=e.texture,s=a.format,l=a.type;if(s!==Ux&&ce.convert(s)!==fe.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===Nx&&(H.has("EXT_color_buffer_half_float")||V.isWebGL2&&H.has("EXT_color_buffer_float"));if(!(l===Cx||ce.convert(l)===fe.getParameter(35738)||l===Px&&(V.isWebGL2||H.has("OES_texture_float")||H.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&fe.readPixels(t,n,r,i,ce.convert(s),ce.convert(l),o)}finally{const e=null!==b?q.get(b).__webglFramebuffer:null;W.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const r=Math.pow(2,-n),i=Math.floor(t.image.width*r),o=Math.floor(t.image.height*r);K.setTexture2D(t,0),fe.copyTexSubImage2D(3553,n,0,0,e.x,e.y,i,o),W.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r=0){const i=t.image.width,o=t.image.height,a=ce.convert(n.format),s=ce.convert(n.type);K.setTexture2D(n,0),fe.pixelStorei(37440,n.flipY),fe.pixelStorei(37441,n.premultiplyAlpha),fe.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?fe.texSubImage2D(3553,r,e.x,e.y,i,o,a,s,t.image.data):t.isCompressedTexture?fe.compressedTexSubImage2D(3553,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):fe.texSubImage2D(3553,r,e.x,e.y,a,s,t.image),0===r&&n.generateMipmaps&&fe.generateMipmap(3553),W.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,r,i=0){if(m.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const o=e.max.x-e.min.x+1,a=e.max.y-e.min.y+1,s=e.max.z-e.min.z+1,l=ce.convert(r.format),c=ce.convert(r.type);let u;if(r.isData3DTexture)K.setTexture3D(r,0),u=32879;else{if(!r.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");K.setTexture2DArray(r,0),u=35866}fe.pixelStorei(37440,r.flipY),fe.pixelStorei(37441,r.premultiplyAlpha),fe.pixelStorei(3317,r.unpackAlignment);const d=fe.getParameter(3314),f=fe.getParameter(32878),h=fe.getParameter(3316),p=fe.getParameter(3315),g=fe.getParameter(32877),v=n.isCompressedTexture?n.mipmaps[0]:n.image;fe.pixelStorei(3314,v.width),fe.pixelStorei(32878,v.height),fe.pixelStorei(3316,e.min.x),fe.pixelStorei(3315,e.min.y),fe.pixelStorei(32877,e.min.z),n.isDataTexture||n.isData3DTexture?fe.texSubImage3D(u,i,t.x,t.y,t.z,o,a,s,l,c,v.data):n.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),fe.compressedTexSubImage3D(u,i,t.x,t.y,t.z,o,a,s,l,v.data)):fe.texSubImage3D(u,i,t.x,t.y,t.z,o,a,s,l,c,v),fe.pixelStorei(3314,d),fe.pixelStorei(32878,f),fe.pixelStorei(3316,h),fe.pixelStorei(3315,p),fe.pixelStorei(32877,g),0===i&&r.generateMipmaps&&fe.generateMipmap(u),W.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?K.setTextureCube(e,0):e.isData3DTexture?K.setTexture3D(e,0):e.isDataArrayTexture?K.setTexture2DArray(e,0):K.setTexture2D(e,0),W.unbindTexture()},this.resetState=function(){v=0,y=0,b=null,W.reset(),ue.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class uT extends cT{}uT.prototype.isWebGL1Renderer=!0;class dT{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new QM(e),this.density=t}clone(){return new dT(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class fT{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new QM(e),this.near=t,this.far=n}clone(){return new fT(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class hT extends hA{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}}class pT{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=sM,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=_M()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=_M()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(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 void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=_M()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(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 mT=new d_;class gT{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=!0===r}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++)mT.fromBufferAttribute(this,t),mT.applyMatrix4(e),this.setXYZ(t,mT.x,mT.y,mT.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)mT.fromBufferAttribute(this,t),mT.applyNormalMatrix(e),this.setXYZ(t,mT.x,mT.y,mT.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)mT.fromBufferAttribute(this,t),mT.transformDirection(e),this.setXYZ(t,mT.x,mT.y,mT.z);return this}setX(e,t){return this.normalized&&(t=RM(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=RM(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=RM(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=RM(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=OM(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=OM(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=OM(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=OM(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=RM(t,this.array),n=RM(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=RM(t,this.array),n=RM(n,this.array),r=RM(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=RM(t,this.array),n=RM(n,this.array),r=RM(r,this.array),i=RM(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new IA(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new gT(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class vT extends EA{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new QM(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let yT;const bT=new d_,wT=new d_,xT=new d_,ST=new NM,MT=new NM,_T=new H_,AT=new d_,ET=new d_,CT=new d_,kT=new NM,TT=new NM,IT=new NM;class OT extends hA{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",void 0===yT){yT=new YA;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new pT(e,5);yT.setIndex([0,1,2,0,2,3]),yT.setAttribute("position",new gT(t,3,0,!1)),yT.setAttribute("uv",new gT(t,2,3,!1))}this.geometry=yT,this.material=void 0!==e?e:new vT,this.center=new NM(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),wT.setFromMatrixScale(this.matrixWorld),_T.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),xT.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&wT.multiplyScalar(-xT.z);const n=this.material.rotation;let r,i;0!==n&&(i=Math.cos(n),r=Math.sin(n));const o=this.center;RT(AT.set(-.5,-.5,0),xT,o,wT,r,i),RT(ET.set(.5,-.5,0),xT,o,wT,r,i),RT(CT.set(.5,.5,0),xT,o,wT,r,i),kT.set(0,0),TT.set(1,0),IT.set(1,1);let a=e.ray.intersectTriangle(AT,ET,CT,!1,bT);if(null===a&&(RT(ET.set(-.5,.5,0),xT,o,wT,r,i),TT.set(0,1),a=e.ray.intersectTriangle(AT,CT,ET,!1,bT),null===a))return;const s=e.ray.origin.distanceTo(bT);s<e.near||s>e.far||t.push({distance:s,point:bT.clone(),uv:_A.getUV(bT,AT,ET,CT,kT,TT,IT,new NM),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function RT(e,t,n,r,i,o){ST.subVectors(e,n).addScalar(.5).multiply(r),void 0!==i?(MT.x=o*ST.x-i*ST.y,MT.y=i*ST.x+o*ST.y):MT.copy(ST),e.copy(t),e.x+=MT.x,e.y+=MT.y,e.applyMatrix4(_T)}const PT=new d_,NT=new d_;class LT extends hA{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,n=t.length;e<n;e++){const n=t[e];this.addLevel(n.object.clone(),n.distance)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0){t=Math.abs(t);const n=this.levels;let r;for(r=0;r<n.length&&!(t<n[r].distance);r++);return n.splice(r,0,{distance:t,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r&&!(e<t[n].distance);n++);return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){PT.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(PT);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){PT.setFromMatrixPosition(e.matrixWorld),NT.setFromMatrixPosition(this.matrixWorld);const n=PT.distanceTo(NT)/e.zoom;let r,i;for(t[0].object.visible=!0,r=1,i=t.length;r<i&&n>=t[r].distance;r++)t[r-1].object.visible=!1,t[r].object.visible=!0;for(this._currentLevel=r-1;r<i;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let e=0,r=n.length;e<r;e++){const r=n[e];t.object.levels.push({object:r.object.uuid,distance:r.distance})}return t}}const DT=new d_,BT=new r_,jT=new r_,FT=new d_,UT=new H_;class zT extends fE{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new H_,this.bindMatrixInverse=new H_}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,this}bind(e,t){this.skeleton=e,void 0===t&&(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 r_,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;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),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,t){const n=this.skeleton,r=this.geometry;BT.fromBufferAttribute(r.attributes.skinIndex,e),jT.fromBufferAttribute(r.attributes.skinWeight,e),DT.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const r=jT.getComponent(e);if(0!==r){const i=BT.getComponent(e);UT.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(FT.copy(DT).applyMatrix4(UT),r)}}return t.applyMatrix4(this.bindMatrixInverse)}}class HT extends hA{constructor(){super(),this.isBone=!0,this.type="Bone"}}class VT extends n_{constructor(e=null,t=1,n=1,r,i,o,a,s,l=vx,c=vx,u,d){super(null,o,a,s,l,c,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const WT=new H_,GT=new H_;class qT{constructor(e=[],t=[]){this.uuid=_M(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)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 e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new H_)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new H_;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=e.length;r<i;r++){const i=e[r]?e[r].matrixWorld:GT;WT.multiplyMatrices(i,t[r]),WT.toArray(n,16*r)}null!==r&&(r.needsUpdate=!0)}clone(){return new qT(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=TM(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new VT(t,e,e,Ux,Px);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const r=e.bones[n];let i=t[r];void 0===i&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),i=new HT),this.bones.push(i),this.boneInverses.push((new H_).fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){const i=t[r];e.bones.push(i.uuid);const o=n[r];e.boneInverses.push(o.toArray())}return e}}class KT extends IA{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}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 YT=new H_,JT=new H_,QT=[],XT=new fE;class ZT extends fE{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new KT(new Float32Array(16*n),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){const n=this.matrixWorld,r=this.count;if(XT.geometry=this.geometry,XT.material=this.material,void 0!==XT.material)for(let i=0;i<r;i++){this.getMatrixAt(i,YT),JT.multiplyMatrices(n,YT),XT.matrixWorld=JT,XT.raycast(e,QT);for(let e=0,n=QT.length;e<n;e++){const n=QT[e];n.instanceId=i,n.object=this,t.push(n)}QT.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new KT(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class $T extends EA{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new QM(16777215),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.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const eI=new d_,tI=new d_,nI=new H_,rI=new z_,iI=new P_;class oI extends hA{constructor(e=new YA,t=new $T){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)eI.fromBufferAttribute(t,e-1),tI.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=eI.distanceTo(tI);e.setAttribute("lineDistance",new FA(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,o=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),iI.copy(n.boundingSphere),iI.applyMatrix4(r),iI.radius+=i,!1===e.ray.intersectsSphere(iI))return;nI.copy(r).invert(),rI.copy(e.ray).applyMatrix4(nI);const a=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=a*a,l=new d_,c=new d_,u=new d_,d=new d_,f=this.isLineSegments?2:1,h=n.index,p=n.attributes.position;if(null!==h){for(let n=Math.max(0,o.start),r=Math.min(h.count,o.start+o.count)-1;n<r;n+=f){const r=h.getX(n),i=h.getX(n+1);l.fromBufferAttribute(p,r),c.fromBufferAttribute(p,i);if(rI.distanceSqToSegment(l,c,d,u)>s)continue;d.applyMatrix4(this.matrixWorld);const o=e.ray.origin.distanceTo(d);o<e.near||o>e.far||t.push({distance:o,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else{for(let n=Math.max(0,o.start),r=Math.min(p.count,o.start+o.count)-1;n<r;n+=f){l.fromBufferAttribute(p,n),c.fromBufferAttribute(p,n+1);if(rI.distanceSqToSegment(l,c,d,u)>s)continue;d.applyMatrix4(this.matrixWorld);const r=e.ray.origin.distanceTo(d);r<e.near||r>e.far||t.push({distance:r,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}const aI=new d_,sI=new d_;class lI extends oI{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)aI.fromBufferAttribute(t,e),sI.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+aI.distanceTo(sI);e.setAttribute("lineDistance",new FA(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class cI extends oI{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class uI extends EA{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new QM(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 dI=new H_,fI=new z_,hI=new P_,pI=new d_;class mI extends hA{constructor(e=new YA,t=new uI){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,o=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),hI.copy(n.boundingSphere),hI.applyMatrix4(r),hI.radius+=i,!1===e.ray.intersectsSphere(hI))return;dI.copy(r).invert(),fI.copy(e.ray).applyMatrix4(dI);const a=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=a*a,l=n.index,c=n.attributes.position;if(null!==l){for(let n=Math.max(0,o.start),i=Math.min(l.count,o.start+o.count);n<i;n++){const i=l.getX(n);pI.fromBufferAttribute(c,i),gI(pI,i,s,r,e,t,this)}}else{for(let n=Math.max(0,o.start),i=Math.min(c.count,o.start+o.count);n<i;n++)pI.fromBufferAttribute(c,n),gI(pI,n,s,r,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function gI(e,t,n,r,i,o,a){const s=fI.distanceSqToPoint(e);if(s<n){const n=new d_;fI.closestPointToPoint(e,n),n.applyMatrix4(r);const l=i.ray.origin.distanceTo(n);if(l<i.near||l>i.far)return;o.push({distance:l,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:a})}}class vI extends n_{constructor(e,t,n,r,i,o,a,s,l){super(e,t,n,r,i,o,a,s,l),this.isVideoTexture=!0,this.minFilter=void 0!==o?o:Sx,this.magFilter=void 0!==i?i:Sx,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class yI extends n_{constructor(e,t,n){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=n,this.magFilter=vx,this.minFilter=vx,this.generateMipmaps=!1,this.needsUpdate=!0}}class bI extends n_{constructor(e,t,n,r,i,o,a,s,l,c,u,d){super(null,o,a,s,l,c,r,i,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class wI extends n_{constructor(e,t,n,r,i,o,a,s,l){super(e,t,n,r,i,o,a,s,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class xI{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),i=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const i=n.length;let o;o=t||e*n[i-1];let a,s=0,l=i-1;for(;s<=l;)if(r=Math.floor(s+(l-s)/2),a=n[r]-o,a<0)s=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(r=l,n[r]===o)return r/(i-1);const c=n[r];return(r+(o-c)/(n[r+1]-c))/(i-1)}getTangent(e,t){const n=1e-4;let r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);const o=this.getPoint(r),a=this.getPoint(i),s=t||(o.isVector2?new NM:new d_);return s.copy(a).sub(o).normalize(),s}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new d_,r=[],i=[],o=[],a=new d_,s=new H_;for(let t=0;t<=e;t++){const n=t/e;r[t]=this.getTangentAt(n,new d_)}i[0]=new d_,o[0]=new d_;let l=Number.MAX_VALUE;const c=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);c<=l&&(l=c,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),d<=l&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],a),o[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),o[t]=o[t-1].clone(),a.crossVectors(r[t-1],r[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(AM(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(a,e))}o[t].crossVectors(r[t],i[t])}if(!0===t){let t=Math.acos(AM(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(a.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),o[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:o}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class SI extends xI{constructor(e=0,t=0,n=1,r=1,i=0,o=2*Math.PI,a=!1,s=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s}getPoint(e,t){const n=t||new NM,r=2*Math.PI;let i=this.aEndAngle-this.aStartAngle;const o=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=r;for(;i>r;)i-=r;i<Number.EPSILON&&(i=o?0:r),!0!==this.aClockwise||o||(i===r?i=-r:i-=r);const a=this.aStartAngle+e*i;let s=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=l-this.aY;s=n*e-r*t+this.aX,l=n*t+r*e+this.aY}return n.set(s,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class MI extends SI{constructor(e,t,n,r,i,o){super(e,t,n,n,r,i,o),this.isArcCurve=!0,this.type="ArcCurve"}}function _I(){let e=0,t=0,n=0,r=0;function i(i,o,a,s){e=i,t=a,n=-3*i+3*o-2*a-s,r=2*i-2*o+a+s}return{initCatmullRom:function(e,t,n,r,o){i(t,n,o*(n-e),o*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,o,a,s){let l=(t-e)/o-(n-e)/(o+a)+(n-t)/a,c=(n-t)/a-(r-t)/(a+s)+(r-n)/s;l*=a,c*=a,i(t,n,l,c)},calc:function(i){const o=i*i;return e+t*i+n*o+r*(o*i)}}}const AI=new d_,EI=new _I,CI=new _I,kI=new _I;class TI extends xI{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new d_){const n=t,r=this.points,i=r.length,o=(i-(this.closed?0:1))*e;let a,s,l=Math.floor(o),c=o-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/i)+1)*i:0===c&&l===i-1&&(l=i-2,c=1),this.closed||l>0?a=r[(l-1)%i]:(AI.subVectors(r[0],r[1]).add(r[0]),a=AI);const u=r[l%i],d=r[(l+1)%i];if(this.closed||l+2<i?s=r[(l+2)%i]:(AI.subVectors(r[i-1],r[i-2]).add(r[i-1]),s=AI),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(a.distanceToSquared(u),e),n=Math.pow(u.distanceToSquared(d),e),r=Math.pow(d.distanceToSquared(s),e);n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),EI.initNonuniformCatmullRom(a.x,u.x,d.x,s.x,t,n,r),CI.initNonuniformCatmullRom(a.y,u.y,d.y,s.y,t,n,r),kI.initNonuniformCatmullRom(a.z,u.z,d.z,s.z,t,n,r)}else"catmullrom"===this.curveType&&(EI.initCatmullRom(a.x,u.x,d.x,s.x,this.tension),CI.initCatmullRom(a.y,u.y,d.y,s.y,this.tension),kI.initCatmullRom(a.z,u.z,d.z,s.z,this.tension));return n.set(EI.calc(c),CI.calc(c),kI.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new d_).fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function II(e,t,n,r,i){const o=.5*(r-t),a=.5*(i-n),s=e*e;return(2*n-2*r+o+a)*(e*s)+(-3*n+3*r-2*o-a)*s+o*e+n}function OI(e,t,n,r){return function(e,t){const n=1-e;return n*n*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,n)+function(e,t){return e*e*t}(e,r)}function RI(e,t,n,r,i){return function(e,t){const n=1-e;return n*n*n*t}(e,t)+function(e,t){const n=1-e;return 3*n*n*e*t}(e,n)+function(e,t){return 3*(1-e)*e*e*t}(e,r)+function(e,t){return e*e*e*t}(e,i)}class PI extends xI{constructor(e=new NM,t=new NM,n=new NM,r=new NM){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new NM){const n=t,r=this.v0,i=this.v1,o=this.v2,a=this.v3;return n.set(RI(e,r.x,i.x,o.x,a.x),RI(e,r.y,i.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class NI extends xI{constructor(e=new d_,t=new d_,n=new d_,r=new d_){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new d_){const n=t,r=this.v0,i=this.v1,o=this.v2,a=this.v3;return n.set(RI(e,r.x,i.x,o.x,a.x),RI(e,r.y,i.y,o.y,a.y),RI(e,r.z,i.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class LI extends xI{constructor(e=new NM,t=new NM){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new NM){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){const n=t||new NM;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class DI extends xI{constructor(e=new d_,t=new d_){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new d_){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class BI extends xI{constructor(e=new NM,t=new NM,n=new NM){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new NM){const n=t,r=this.v0,i=this.v1,o=this.v2;return n.set(OI(e,r.x,i.x,o.x),OI(e,r.y,i.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class jI extends xI{constructor(e=new d_,t=new d_,n=new d_){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new d_){const n=t,r=this.v0,i=this.v1,o=this.v2;return n.set(OI(e,r.x,i.x,o.x),OI(e,r.y,i.y,o.y),OI(e,r.z,i.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class FI extends xI{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new NM){const n=t,r=this.points,i=(r.length-1)*e,o=Math.floor(i),a=i-o,s=r[0===o?o:o-1],l=r[o],c=r[o>r.length-2?r.length-1:o+1],u=r[o>r.length-3?r.length-1:o+2];return n.set(II(a,s.x,l.x,c.x,u.x),II(a,s.y,l.y,c.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new NM).fromArray(n))}return this}}var UI=Object.freeze({__proto__:null,ArcCurve:MI,CatmullRomCurve3:TI,CubicBezierCurve:PI,CubicBezierCurve3:NI,EllipseCurve:SI,LineCurve:LI,LineCurve3:DI,QuadraticBezierCurve:BI,QuadraticBezierCurve3:jI,SplineCurve:FI});class zI extends xI{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new LI(t,e))}getPoint(e,t){const n=e*this.getLength(),r=this.getCurveLengths();let i=0;for(;i<r.length;){if(r[i]>=n){const e=r[i]-n,o=this.curves[i],a=o.getLength(),s=0===a?0:1-e/a;return o.getPointAt(s,t)}i++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let r=0,i=this.curves;r<i.length;r++){const o=i[r],a=o.isEllipseCurve?2*e:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,s=o.getPoints(a);for(let e=0;e<s.length;e++){const r=s[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push((new UI[n.type]).fromJSON(n))}return this}}class HI extends zI{constructor(e){super(),this.type="Path",this.currentPoint=new NM,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new LI(this.currentPoint.clone(),new NM(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const i=new BI(this.currentPoint.clone(),new NM(e,t),new NM(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,o){const a=new PI(this.currentPoint.clone(),new NM(e,t),new NM(n,r),new NM(i,o));return this.curves.push(a),this.currentPoint.set(i,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new FI(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,o){const a=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+a,t+s,n,r,i,o),this}absarc(e,t,n,r,i,o){return this.absellipse(e,t,n,n,r,i,o),this}ellipse(e,t,n,r,i,o,a,s){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+l,t+c,n,r,i,o,a,s),this}absellipse(e,t,n,r,i,o,a,s){const l=new SI(e,t,n,r,i,o,a,s);if(this.curves.length>0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class VI extends YA{constructor(e=[new NM(0,-.5),new NM(.5,0),new NM(0,.5)],t=12,n=0,r=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=AM(r,0,2*Math.PI);const i=[],o=[],a=[],s=[],l=[],c=1/t,u=new d_,d=new NM,f=new d_,h=new d_,p=new d_;let m=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=1*g,f.y=-m,f.z=0*g,p.copy(f),f.normalize(),s.push(f.x,f.y,f.z);break;case e.length-1:s.push(p.x,p.y,p.z);break;default:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=1*g,f.y=-m,f.z=0*g,h.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),s.push(f.x,f.y,f.z),p.copy(h)}for(let i=0;i<=t;i++){const f=n+i*c*r,h=Math.sin(f),p=Math.cos(f);for(let n=0;n<=e.length-1;n++){u.x=e[n].x*h,u.y=e[n].y,u.z=e[n].x*p,o.push(u.x,u.y,u.z),d.x=i/t,d.y=n/(e.length-1),a.push(d.x,d.y);const r=s[3*n+0]*h,c=s[3*n+1],f=s[3*n+0]*p;l.push(r,c,f)}}for(let n=0;n<t;n++)for(let t=0;t<e.length-1;t++){const r=t+n*e.length,o=r,a=r+e.length,s=r+e.length+1,l=r+1;i.push(o,a,l),i.push(s,l,a)}this.setIndex(i),this.setAttribute("position",new FA(o,3)),this.setAttribute("uv",new FA(a,2)),this.setAttribute("normal",new FA(l,3))}static fromJSON(e){return new VI(e.points,e.segments,e.phiStart,e.phiLength)}}class WI extends VI{constructor(e=1,t=1,n=4,r=8){const i=new HI;i.absarc(0,-t/2,e,1.5*Math.PI,0),i.absarc(0,t/2,e,0,.5*Math.PI),super(i.getPoints(n),r),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:r}}static fromJSON(e){return new WI(e.radius,e.length,e.capSegments,e.radialSegments)}}class GI extends YA{constructor(e=1,t=8,n=0,r=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const i=[],o=[],a=[],s=[],l=new d_,c=new NM;o.push(0,0,0),a.push(0,0,1),s.push(.5,.5);for(let i=0,u=3;i<=t;i++,u+=3){const d=n+i/t*r;l.x=e*Math.cos(d),l.y=e*Math.sin(d),o.push(l.x,l.y,l.z),a.push(0,0,1),c.x=(o[u]/e+1)/2,c.y=(o[u+1]/e+1)/2,s.push(c.x,c.y)}for(let e=1;e<=t;e++)i.push(e,e+1,0);this.setIndex(i),this.setAttribute("position",new FA(o,3)),this.setAttribute("normal",new FA(a,3)),this.setAttribute("uv",new FA(s,2))}static fromJSON(e){return new GI(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class qI extends YA{constructor(e=1,t=1,n=1,r=8,i=1,o=!1,a=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:o,thetaStart:a,thetaLength:s};const l=this;r=Math.floor(r),i=Math.floor(i);const c=[],u=[],d=[],f=[];let h=0;const p=[],m=n/2;let g=0;function v(n){const i=h,o=new NM,p=new d_;let v=0;const y=!0===n?e:t,b=!0===n?1:-1;for(let e=1;e<=r;e++)u.push(0,m*b,0),d.push(0,b,0),f.push(.5,.5),h++;const w=h;for(let e=0;e<=r;e++){const t=e/r*s+a,n=Math.cos(t),i=Math.sin(t);p.x=y*i,p.y=m*b,p.z=y*n,u.push(p.x,p.y,p.z),d.push(0,b,0),o.x=.5*n+.5,o.y=.5*i*b+.5,f.push(o.x,o.y),h++}for(let e=0;e<r;e++){const t=i+e,r=w+e;!0===n?c.push(r,r+1,t):c.push(r+1,r,t),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}!function(){const o=new d_,v=new d_;let y=0;const b=(t-e)/n;for(let l=0;l<=i;l++){const c=[],g=l/i,y=g*(t-e)+e;for(let e=0;e<=r;e++){const t=e/r,i=t*s+a,l=Math.sin(i),p=Math.cos(i);v.x=y*l,v.y=-g*n+m,v.z=y*p,u.push(v.x,v.y,v.z),o.set(l,b,p).normalize(),d.push(o.x,o.y,o.z),f.push(t,1-g),c.push(h++)}p.push(c)}for(let e=0;e<r;e++)for(let t=0;t<i;t++){const n=p[t][e],r=p[t+1][e],i=p[t+1][e+1],o=p[t][e+1];c.push(n,r,o),c.push(r,i,o),y+=6}l.addGroup(g,y,0),g+=y}(),!1===o&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new FA(u,3)),this.setAttribute("normal",new FA(d,3)),this.setAttribute("uv",new FA(f,2))}static fromJSON(e){return new qI(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class KI extends qI{constructor(e=1,t=1,n=8,r=1,i=!1,o=0,a=2*Math.PI){super(0,e,t,n,r,i,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:o,thetaLength:a}}static fromJSON(e){return new KI(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class YI extends YA{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};const i=[],o=[];function a(e,t,n,r){const i=r+1,o=[];for(let r=0;r<=i;r++){o[r]=[];const a=e.clone().lerp(n,r/i),s=t.clone().lerp(n,r/i),l=i-r;for(let e=0;e<=l;e++)o[r][e]=0===e&&r===i?a:a.clone().lerp(s,e/l)}for(let e=0;e<i;e++)for(let t=0;t<2*(i-e)-1;t++){const n=Math.floor(t/2);t%2==0?(s(o[e][n+1]),s(o[e+1][n]),s(o[e][n])):(s(o[e][n+1]),s(o[e+1][n+1]),s(o[e+1][n]))}}function s(e){i.push(e.x,e.y,e.z)}function l(t,n){const r=3*t;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function c(e,t,n,r){r<0&&1===e.x&&(o[t]=e.x-1),0===n.x&&0===n.z&&(o[t]=r/2/Math.PI+.5)}function u(e){return Math.atan2(e.z,-e.x)}!function(e){const n=new d_,r=new d_,i=new d_;for(let o=0;o<t.length;o+=3)l(t[o+0],n),l(t[o+1],r),l(t[o+2],i),a(n,r,i,e)}(r),function(e){const t=new d_;for(let n=0;n<i.length;n+=3)t.x=i[n+0],t.y=i[n+1],t.z=i[n+2],t.normalize().multiplyScalar(e),i[n+0]=t.x,i[n+1]=t.y,i[n+2]=t.z}(n),function(){const e=new d_;for(let n=0;n<i.length;n+=3){e.x=i[n+0],e.y=i[n+1],e.z=i[n+2];const r=u(e)/2/Math.PI+.5,a=(t=e,Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))/Math.PI+.5);o.push(r,1-a)}var t;(function(){const e=new d_,t=new d_,n=new d_,r=new d_,a=new NM,s=new NM,l=new NM;for(let d=0,f=0;d<i.length;d+=9,f+=6){e.set(i[d+0],i[d+1],i[d+2]),t.set(i[d+3],i[d+4],i[d+5]),n.set(i[d+6],i[d+7],i[d+8]),a.set(o[f+0],o[f+1]),s.set(o[f+2],o[f+3]),l.set(o[f+4],o[f+5]),r.copy(e).add(t).add(n).divideScalar(3);const h=u(r);c(a,f+0,e,h),c(s,f+2,t,h),c(l,f+4,n,h)}})(),function(){for(let e=0;e<o.length;e+=6){const t=o[e+0],n=o[e+2],r=o[e+4],i=Math.max(t,n,r),a=Math.min(t,n,r);i>.9&&a<.1&&(t<.2&&(o[e+0]+=1),n<.2&&(o[e+2]+=1),r<.2&&(o[e+4]+=1))}}()}(),this.setAttribute("position",new FA(i,3)),this.setAttribute("normal",new FA(i.slice(),3)),this.setAttribute("uv",new FA(o,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(e){return new YI(e.vertices,e.indices,e.radius,e.details)}}class JI extends YI{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new JI(e.radius,e.detail)}}const QI=new d_,XI=new d_,ZI=new d_,$I=new _A;class eO extends YA{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=4,r=Math.pow(10,n),i=Math.cos(SM*t),o=e.getIndex(),a=e.getAttribute("position"),s=o?o.count:a.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),d={},f=[];for(let e=0;e<s;e+=3){o?(l[0]=o.getX(e),l[1]=o.getX(e+1),l[2]=o.getX(e+2)):(l[0]=e,l[1]=e+1,l[2]=e+2);const{a:t,b:n,c:s}=$I;if(t.fromBufferAttribute(a,l[0]),n.fromBufferAttribute(a,l[1]),s.fromBufferAttribute(a,l[2]),$I.getNormal(ZI),u[0]=`${Math.round(t.x*r)},${Math.round(t.y*r)},${Math.round(t.z*r)}`,u[1]=`${Math.round(n.x*r)},${Math.round(n.y*r)},${Math.round(n.z*r)}`,u[2]=`${Math.round(s.x*r)},${Math.round(s.y*r)},${Math.round(s.z*r)}`,u[0]!==u[1]&&u[1]!==u[2]&&u[2]!==u[0])for(let e=0;e<3;e++){const t=(e+1)%3,n=u[e],r=u[t],o=$I[c[e]],a=$I[c[t]],s=`${n}_${r}`,h=`${r}_${n}`;h in d&&d[h]?(ZI.dot(d[h].normal)<=i&&(f.push(o.x,o.y,o.z),f.push(a.x,a.y,a.z)),d[h]=null):s in d||(d[s]={index0:l[e],index1:l[t],normal:ZI.clone()})}}for(const e in d)if(d[e]){const{index0:t,index1:n}=d[e];QI.fromBufferAttribute(a,t),XI.fromBufferAttribute(a,n),f.push(QI.x,QI.y,QI.z),f.push(XI.x,XI.y,XI.z)}this.setAttribute("position",new FA(f,3))}}}class tO extends HI{constructor(e){super(e),this.uuid=_M(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push((new HI).fromJSON(n))}return this}}const nO=function(e,t,n=2){const r=t&&t.length,i=r?t[0]*n:e.length;let o=rO(e,0,i,n,!0);const a=[];if(!o||o.next===o.prev)return a;let s,l,c,u,d,f,h;if(r&&(o=function(e,t,n,r){const i=[];let o,a,s,l,c;for(o=0,a=t.length;o<a;o++)s=t[o]*r,l=o<a-1?t[o+1]*r:e.length,c=rO(e,s,l,r,!1),c===c.next&&(c.steiner=!0),i.push(pO(c));for(i.sort(uO),o=0;o<i.length;o++)dO(i[o],n),n=iO(n,n.next);return n}(e,t,o,n)),e.length>80*n){s=c=e[0],l=u=e[1];for(let t=n;t<i;t+=n)d=e[t],f=e[t+1],d<s&&(s=d),f<l&&(l=f),d>c&&(c=d),f>u&&(u=f);h=Math.max(c-s,u-l),h=0!==h?1/h:0}return oO(o,a,n,s,l,h),a};function rO(e,t,n,r,i){let o,a;if(i===function(e,t,n,r){let i=0;for(let o=t,a=n-r;o<n;o+=r)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}(e,t,n,r)>0)for(o=t;o<n;o+=r)a=_O(o,e[o],e[o+1],a);else for(o=n-r;o>=t;o-=r)a=_O(o,e[o],e[o+1],a);return a&&yO(a,a.next)&&(AO(a),a=a.next),a}function iO(e,t){if(!e)return e;t||(t=e);let n,r=e;do{if(n=!1,r.steiner||!yO(r,r.next)&&0!==vO(r.prev,r,r.next))r=r.next;else{if(AO(r),r=t=r.prev,r===r.next)break;n=!0}}while(n||r!==t);return t}function oO(e,t,n,r,i,o,a){if(!e)return;!a&&o&&function(e,t,n,r){let i=e;do{null===i.z&&(i.z=hO(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,n,r,i,o,a,s,l,c=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,r=n,s=0,t=0;t<c&&(s++,r=r.nextZ,r);t++);for(l=c;s>0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,c*=2}while(a>1)}(i)}(e,r,i,o);let s,l,c=e;for(;e.prev!==e.next;)if(s=e.prev,l=e.next,o?sO(e,r,i,o):aO(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),AO(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?oO(e=lO(iO(e),t,n),t,n,r,i,o,2):2===a&&cO(e,t,n,r,i,o):oO(iO(e),t,n,r,i,o,1);break}}function aO(e){const t=e.prev,n=e,r=e.next;if(vO(t,n,r)>=0)return!1;let i=e.next.next;for(;i!==e.prev;){if(mO(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&vO(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function sO(e,t,n,r){const i=e.prev,o=e,a=e.next;if(vO(i,o,a)>=0)return!1;const s=i.x<o.x?i.x<a.x?i.x:a.x:o.x<a.x?o.x:a.x,l=i.y<o.y?i.y<a.y?i.y:a.y:o.y<a.y?o.y:a.y,c=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,u=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,d=hO(s,l,t,n,r),f=hO(c,u,t,n,r);let h=e.prevZ,p=e.nextZ;for(;h&&h.z>=d&&p&&p.z<=f;){if(h!==e.prev&&h!==e.next&&mO(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&vO(h.prev,h,h.next)>=0)return!1;if(h=h.prevZ,p!==e.prev&&p!==e.next&&mO(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&vO(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;h&&h.z>=d;){if(h!==e.prev&&h!==e.next&&mO(i.x,i.y,o.x,o.y,a.x,a.y,h.x,h.y)&&vO(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;p&&p.z<=f;){if(p!==e.prev&&p!==e.next&&mO(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&vO(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function lO(e,t,n){let r=e;do{const i=r.prev,o=r.next.next;!yO(i,o)&&bO(i,r,r.next,o)&&SO(i,o)&&SO(o,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(o.i/n),AO(r),AO(r.next),r=e=o),r=r.next}while(r!==e);return iO(r)}function cO(e,t,n,r,i,o){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&gO(a,e)){let s=MO(a,e);return a=iO(a,a.next),s=iO(s,s.next),oO(a,t,n,r,i,o),void oO(s,t,n,r,i,o)}e=e.next}a=a.next}while(a!==e)}function uO(e,t){return e.x-t.x}function dO(e,t){if(t=function(e,t){let n=t;const r=e.x,i=e.y;let o,a=-1/0;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){const e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a){if(a=e,e===r){if(i===n.y)return n;if(i===n.next.y)return n.next}o=n.x<n.next.x?n:n.next}}n=n.next}while(n!==t);if(!o)return null;if(r===a)return o;const s=o,l=o.x,c=o.y;let u,d=1/0;n=o;do{r>=n.x&&n.x>=l&&r!==n.x&&mO(i<c?r:a,i,l,c,i<c?a:r,i,n.x,n.y)&&(u=Math.abs(i-n.y)/(r-n.x),SO(n,e)&&(u<d||u===d&&(n.x>o.x||n.x===o.x&&fO(o,n)))&&(o=n,d=u)),n=n.next}while(n!==s);return o}(e,t),t){const n=MO(t,e);iO(t,t.next),iO(n,n.next)}}function fO(e,t){return vO(e.prev,e,t.prev)<0&&vO(t.next,e,e.next)<0}function hO(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function pO(e){let t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function mO(e,t,n,r,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(r-s)-(n-a)*(t-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function gO(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&bO(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(SO(e,t)&&SO(t,e)&&function(e,t){let n=e,r=!1;const i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(vO(e.prev,e,t.prev)||vO(e,t.prev,t))||yO(e,t)&&vO(e.prev,e,e.next)>0&&vO(t.prev,t,t.next)>0)}function vO(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function yO(e,t){return e.x===t.x&&e.y===t.y}function bO(e,t,n,r){const i=xO(vO(e,t,n)),o=xO(vO(e,t,r)),a=xO(vO(n,r,e)),s=xO(vO(n,r,t));return i!==o&&a!==s||(!(0!==i||!wO(e,n,t))||(!(0!==o||!wO(e,r,t))||(!(0!==a||!wO(n,e,r))||!(0!==s||!wO(n,t,r)))))}function wO(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function xO(e){return e>0?1:e<0?-1:0}function SO(e,t){return vO(e.prev,e,e.next)<0?vO(e,t,e.next)>=0&&vO(e,e.prev,t)>=0:vO(e,t,e.prev)<0||vO(e,e.next,t)<0}function MO(e,t){const n=new EO(e.i,e.x,e.y),r=new EO(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function _O(e,t,n,r){const i=new EO(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function AO(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function EO(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class CO{static area(e){const t=e.length;let n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return.5*n}static isClockWise(e){return CO.area(e)<0}static triangulateShape(e,t){const n=[],r=[],i=[];kO(e),TO(n,e);let o=e.length;t.forEach(kO);for(let e=0;e<t.length;e++)r.push(o),o+=t[e].length,TO(n,t[e]);const a=nO(n,r);for(let e=0;e<a.length;e+=3)i.push(a.slice(e,e+3));return i}}function kO(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function TO(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}class IO extends YA{constructor(e=new tO([new NM(.5,.5),new NM(-.5,.5),new NM(-.5,-.5),new NM(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,r=[],i=[];for(let t=0,n=e.length;t<n;t++){o(e[t])}function o(e){const o=[],a=void 0!==t.curveSegments?t.curveSegments:12,s=void 0!==t.steps?t.steps:1,l=void 0!==t.depth?t.depth:1;let c=void 0===t.bevelEnabled||t.bevelEnabled,u=void 0!==t.bevelThickness?t.bevelThickness:.2,d=void 0!==t.bevelSize?t.bevelSize:u-.1,f=void 0!==t.bevelOffset?t.bevelOffset:0,h=void 0!==t.bevelSegments?t.bevelSegments:3;const p=t.extrudePath,m=void 0!==t.UVGenerator?t.UVGenerator:OO;let g,v,y,b,w,x=!1;p&&(g=p.getSpacedPoints(s),x=!0,c=!1,v=p.computeFrenetFrames(s,!1),y=new d_,b=new d_,w=new d_),c||(h=0,u=0,d=0,f=0);const S=e.extractPoints(a);let M=S.shape;const _=S.holes;if(!CO.isClockWise(M)){M=M.reverse();for(let e=0,t=_.length;e<t;e++){const t=_[e];CO.isClockWise(t)&&(_[e]=t.reverse())}}const A=CO.triangulateShape(M,_),E=M;for(let e=0,t=_.length;e<t;e++){const t=_[e];M=M.concat(t)}function C(e,t,n){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(n).add(e)}const k=M.length,T=A.length;function I(e,t,n){let r,i,o;const a=e.x-t.x,s=e.y-t.y,l=n.x-e.x,c=n.y-e.y,u=a*a+s*s,d=a*c-s*l;if(Math.abs(d)>Number.EPSILON){const d=Math.sqrt(u),f=Math.sqrt(l*l+c*c),h=t.x-s/d,p=t.y+a/d,m=((n.x-c/f-h)*c-(n.y+l/f-p)*l)/(a*c-s*l);r=h+a*m-e.x,i=p+s*m-e.y;const g=r*r+i*i;if(g<=2)return new NM(r,i);o=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(s)===Math.sign(c)&&(e=!0),e?(r=-s,i=a,o=Math.sqrt(u)):(r=a,i=s,o=Math.sqrt(u/2))}return new NM(r/o,i/o)}const O=[];for(let e=0,t=E.length,n=t-1,r=e+1;e<t;e++,n++,r++)n===t&&(n=0),r===t&&(r=0),O[e]=I(E[e],E[n],E[r]);const R=[];let P,N=O.concat();for(let e=0,t=_.length;e<t;e++){const t=_[e];P=[];for(let e=0,n=t.length,r=n-1,i=e+1;e<n;e++,r++,i++)r===n&&(r=0),i===n&&(i=0),P[e]=I(t[e],t[r],t[i]);R.push(P),N=N.concat(P)}for(let e=0;e<h;e++){const t=e/h,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=E.length;e<t;e++){const t=C(E[e],O[e],r);B(t.x,t.y,-n)}for(let e=0,t=_.length;e<t;e++){const t=_[e];P=R[e];for(let e=0,i=t.length;e<i;e++){const i=C(t[e],P[e],r);B(i.x,i.y,-n)}}}const L=d+f;for(let e=0;e<k;e++){const t=c?C(M[e],N[e],L):M[e];x?(b.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),w.copy(g[0]).add(b).add(y),B(w.x,w.y,w.z)):B(t.x,t.y,0)}for(let e=1;e<=s;e++)for(let t=0;t<k;t++){const n=c?C(M[t],N[t],L):M[t];x?(b.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),w.copy(g[e]).add(b).add(y),B(w.x,w.y,w.z)):B(n.x,n.y,l/s*e)}for(let e=h-1;e>=0;e--){const t=e/h,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=E.length;e<t;e++){const t=C(E[e],O[e],r);B(t.x,t.y,l+n)}for(let e=0,t=_.length;e<t;e++){const t=_[e];P=R[e];for(let e=0,i=t.length;e<i;e++){const i=C(t[e],P[e],r);x?B(i.x,i.y+g[s-1].y,g[s-1].x+n):B(i.x,i.y,l+n)}}}function D(e,t){let n=e.length;for(;--n>=0;){const r=n;let i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+2*h;e<n;e++){const n=k*e,o=k*(e+1);F(t+r+n,t+i+n,t+i+o,t+r+o)}}}function B(e,t,n){o.push(e),o.push(t),o.push(n)}function j(e,t,i){U(e),U(t),U(i);const o=r.length/3,a=m.generateTopUV(n,r,o-3,o-2,o-1);z(a[0]),z(a[1]),z(a[2])}function F(e,t,i,o){U(e),U(t),U(o),U(t),U(i),U(o);const a=r.length/3,s=m.generateSideWallUV(n,r,a-6,a-3,a-2,a-1);z(s[0]),z(s[1]),z(s[3]),z(s[1]),z(s[2]),z(s[3])}function U(e){r.push(o[3*e+0]),r.push(o[3*e+1]),r.push(o[3*e+2])}function z(e){i.push(e.x),i.push(e.y)}!function(){const e=r.length/3;if(c){let e=0,t=k*e;for(let e=0;e<T;e++){const n=A[e];j(n[2]+t,n[1]+t,n[0]+t)}e=s+2*h,t=k*e;for(let e=0;e<T;e++){const n=A[e];j(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<T;e++){const t=A[e];j(t[2],t[1],t[0])}for(let e=0;e<T;e++){const t=A[e];j(t[0]+k*s,t[1]+k*s,t[2]+k*s)}}n.addGroup(e,r.length/3-e,0)}(),function(){const e=r.length/3;let t=0;D(E,t),t+=E.length;for(let e=0,n=_.length;e<n;e++){const n=_[e];D(n,t),t+=n.length}n.addGroup(e,r.length/3-e,1)}()}this.setAttribute("position",new FA(r,3)),this.setAttribute("uv",new FA(i,2)),this.computeVertexNormals()}toJSON(){const e=super.toJSON();return function(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,r=e.length;t<r;t++){const r=e[t];n.shapes.push(r.uuid)}else n.shapes.push(e.uuid);n.options=Object.assign({},t),void 0!==t.extrudePath&&(n.options.extrudePath=t.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){const n=[];for(let r=0,i=e.shapes.length;r<i;r++){const i=t[e.shapes[r]];n.push(i)}const r=e.options.extrudePath;return void 0!==r&&(e.options.extrudePath=(new UI[r.type]).fromJSON(r)),new IO(n,e.options)}}const OO={generateTopUV:function(e,t,n,r,i){const o=t[3*n],a=t[3*n+1],s=t[3*r],l=t[3*r+1],c=t[3*i],u=t[3*i+1];return[new NM(o,a),new NM(s,l),new NM(c,u)]},generateSideWallUV:function(e,t,n,r,i,o){const a=t[3*n],s=t[3*n+1],l=t[3*n+2],c=t[3*r],u=t[3*r+1],d=t[3*r+2],f=t[3*i],h=t[3*i+1],p=t[3*i+2],m=t[3*o],g=t[3*o+1],v=t[3*o+2];return Math.abs(s-u)<Math.abs(a-c)?[new NM(a,1-l),new NM(c,1-d),new NM(f,1-p),new NM(m,1-v)]:[new NM(s,1-l),new NM(u,1-d),new NM(h,1-p),new NM(g,1-v)]}};class RO extends YI{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new RO(e.radius,e.detail)}}class PO extends YI{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new PO(e.radius,e.detail)}}class NO extends YA{constructor(e=.5,t=1,n=8,r=1,i=0,o=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:o},n=Math.max(3,n);const a=[],s=[],l=[],c=[];let u=e;const d=(t-e)/(r=Math.max(1,r)),f=new d_,h=new NM;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){const r=i+e/n*o;f.x=u*Math.cos(r),f.y=u*Math.sin(r),s.push(f.x,f.y,f.z),l.push(0,0,1),h.x=(f.x/t+1)/2,h.y=(f.y/t+1)/2,c.push(h.x,h.y)}u+=d}for(let e=0;e<r;e++){const t=e*(n+1);for(let e=0;e<n;e++){const r=e+t,i=r,o=r+n+1,s=r+n+2,l=r+1;a.push(i,o,l),a.push(o,s,l)}}this.setIndex(a),this.setAttribute("position",new FA(s,3)),this.setAttribute("normal",new FA(l,3)),this.setAttribute("uv",new FA(c,2))}static fromJSON(e){return new NO(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class LO extends YA{constructor(e=new tO([new NM(0,.5),new NM(-.5,-.5),new NM(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],r=[],i=[],o=[];let a=0,s=0;if(!1===Array.isArray(e))l(e);else for(let t=0;t<e.length;t++)l(e[t]),this.addGroup(a,s,t),a+=s,s=0;function l(e){const a=r.length/3,l=e.extractPoints(t);let c=l.shape;const u=l.holes;!1===CO.isClockWise(c)&&(c=c.reverse());for(let e=0,t=u.length;e<t;e++){const t=u[e];!0===CO.isClockWise(t)&&(u[e]=t.reverse())}const d=CO.triangulateShape(c,u);for(let e=0,t=u.length;e<t;e++){const t=u[e];c=c.concat(t)}for(let e=0,t=c.length;e<t;e++){const t=c[e];r.push(t.x,t.y,0),i.push(0,0,1),o.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){const t=d[e],r=t[0]+a,i=t[1]+a,o=t[2]+a;n.push(r,i,o),s+=3}}this.setIndex(n),this.setAttribute("position",new FA(r,3)),this.setAttribute("normal",new FA(i,3)),this.setAttribute("uv",new FA(o,2))}toJSON(){const e=super.toJSON();return function(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){const r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}(this.parameters.shapes,e)}static fromJSON(e,t){const n=[];for(let r=0,i=e.shapes.length;r<i;r++){const i=t[e.shapes[r]];n.push(i)}return new LO(n,e.curveSegments)}}class DO extends YA{constructor(e=1,t=32,n=16,r=0,i=2*Math.PI,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const s=Math.min(o+a,Math.PI);let l=0;const c=[],u=new d_,d=new d_,f=[],h=[],p=[],m=[];for(let f=0;f<=n;f++){const g=[],v=f/n;let y=0;0==f&&0==o?y=.5/t:f==n&&s==Math.PI&&(y=-.5/t);for(let n=0;n<=t;n++){const s=n/t;u.x=-e*Math.cos(r+s*i)*Math.sin(o+v*a),u.y=e*Math.cos(o+v*a),u.z=e*Math.sin(r+s*i)*Math.sin(o+v*a),h.push(u.x,u.y,u.z),d.copy(u).normalize(),p.push(d.x,d.y,d.z),m.push(s+y,1-v),g.push(l++)}c.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){const t=c[e][r+1],i=c[e][r],a=c[e+1][r],l=c[e+1][r+1];(0!==e||o>0)&&f.push(t,i,l),(e!==n-1||s<Math.PI)&&f.push(i,a,l)}this.setIndex(f),this.setAttribute("position",new FA(h,3)),this.setAttribute("normal",new FA(p,3)),this.setAttribute("uv",new FA(m,2))}static fromJSON(e){return new DO(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class BO extends YI{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new BO(e.radius,e.detail)}}class jO extends YA{constructor(e=1,t=.4,n=8,r=6,i=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:i},n=Math.floor(n),r=Math.floor(r);const o=[],a=[],s=[],l=[],c=new d_,u=new d_,d=new d_;for(let o=0;o<=n;o++)for(let f=0;f<=r;f++){const h=f/r*i,p=o/n*Math.PI*2;u.x=(e+t*Math.cos(p))*Math.cos(h),u.y=(e+t*Math.cos(p))*Math.sin(h),u.z=t*Math.sin(p),a.push(u.x,u.y,u.z),c.x=e*Math.cos(h),c.y=e*Math.sin(h),d.subVectors(u,c).normalize(),s.push(d.x,d.y,d.z),l.push(f/r),l.push(o/n)}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){const n=(r+1)*e+t-1,i=(r+1)*(e-1)+t-1,a=(r+1)*(e-1)+t,s=(r+1)*e+t;o.push(n,i,s),o.push(i,a,s)}this.setIndex(o),this.setAttribute("position",new FA(a,3)),this.setAttribute("normal",new FA(s,3)),this.setAttribute("uv",new FA(l,2))}static fromJSON(e){return new jO(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class FO extends YA{constructor(e=1,t=.4,n=64,r=8,i=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:i,q:o},n=Math.floor(n),r=Math.floor(r);const a=[],s=[],l=[],c=[],u=new d_,d=new d_,f=new d_,h=new d_,p=new d_,m=new d_,g=new d_;for(let a=0;a<=n;++a){const y=a/n*i*Math.PI*2;v(y,i,o,e,f),v(y+.01,i,o,e,h),m.subVectors(h,f),g.addVectors(h,f),p.crossVectors(m,g),g.crossVectors(p,m),p.normalize(),g.normalize();for(let e=0;e<=r;++e){const i=e/r*Math.PI*2,o=-t*Math.cos(i),h=t*Math.sin(i);u.x=f.x+(o*g.x+h*p.x),u.y=f.y+(o*g.y+h*p.y),u.z=f.z+(o*g.z+h*p.z),s.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),l.push(d.x,d.y,d.z),c.push(a/n),c.push(e/r)}}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){const n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),o=(r+1)*e+t,s=(r+1)*(e-1)+t;a.push(n,i,s),a.push(i,o,s)}function v(e,t,n,r,i){const o=Math.cos(e),a=Math.sin(e),s=n/t*e,l=Math.cos(s);i.x=r*(2+l)*.5*o,i.y=r*(2+l)*a*.5,i.z=r*Math.sin(s)*.5}this.setIndex(a),this.setAttribute("position",new FA(s,3)),this.setAttribute("normal",new FA(l,3)),this.setAttribute("uv",new FA(c,2))}static fromJSON(e){return new FO(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class UO extends YA{constructor(e=new jI(new d_(-1,-1,0),new d_(-1,1,0),new d_(1,1,0)),t=64,n=1,r=8,i=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:i};const o=e.computeFrenetFrames(t,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new d_,s=new d_,l=new NM;let c=new d_;const u=[],d=[],f=[],h=[];function p(i){c=e.getPointAt(i/t,c);const l=o.normals[i],f=o.binormals[i];for(let e=0;e<=r;e++){const t=e/r*Math.PI*2,i=Math.sin(t),o=-Math.cos(t);s.x=o*l.x+i*f.x,s.y=o*l.y+i*f.y,s.z=o*l.z+i*f.z,s.normalize(),d.push(s.x,s.y,s.z),a.x=c.x+n*s.x,a.y=c.y+n*s.y,a.z=c.z+n*s.z,u.push(a.x,a.y,a.z)}}!function(){for(let e=0;e<t;e++)p(e);p(!1===i?t:0),function(){for(let e=0;e<=t;e++)for(let n=0;n<=r;n++)l.x=e/t,l.y=n/r,f.push(l.x,l.y)}(),function(){for(let e=1;e<=t;e++)for(let t=1;t<=r;t++){const n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),o=(r+1)*e+t,a=(r+1)*(e-1)+t;h.push(n,i,a),h.push(i,o,a)}}()}(),this.setIndex(h),this.setAttribute("position",new FA(u,3)),this.setAttribute("normal",new FA(d,3)),this.setAttribute("uv",new FA(f,2))}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new UO((new UI[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class zO extends YA{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){const t=[],n=new Set,r=new d_,i=new d_;if(null!==e.index){const o=e.attributes.position,a=e.index;let s=e.groups;0===s.length&&(s=[{start:0,count:a.count,materialIndex:0}]);for(let e=0,l=s.length;e<l;++e){const l=s[e],c=l.start;for(let e=c,s=c+l.count;e<s;e+=3)for(let s=0;s<3;s++){const l=a.getX(e+s),c=a.getX(e+(s+1)%3);r.fromBufferAttribute(o,l),i.fromBufferAttribute(o,c),!0===HO(r,i,n)&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}}else{const o=e.attributes.position;for(let e=0,a=o.count/3;e<a;e++)for(let a=0;a<3;a++){const s=3*e+a,l=3*e+(a+1)%3;r.fromBufferAttribute(o,s),i.fromBufferAttribute(o,l),!0===HO(r,i,n)&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}this.setAttribute("position",new FA(t,3))}}}function HO(e,t,n){const r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return!0!==n.has(r)&&!0!==n.has(i)&&(n.add(r),n.add(i),!0)}var VO=Object.freeze({__proto__:null,BoxGeometry:pE,CapsuleGeometry:WI,CircleGeometry:GI,ConeGeometry:KI,CylinderGeometry:qI,DodecahedronGeometry:JI,EdgesGeometry:eO,ExtrudeGeometry:IO,IcosahedronGeometry:RO,LatheGeometry:VI,OctahedronGeometry:PO,PlaneGeometry:NE,PolyhedronGeometry:YI,RingGeometry:NO,ShapeGeometry:LO,SphereGeometry:DO,TetrahedronGeometry:BO,TorusGeometry:jO,TorusKnotGeometry:FO,TubeGeometry:UO,WireframeGeometry:zO});class WO extends EA{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new QM(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class GO extends yE{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class qO extends EA{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new QM(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 QM(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=US,this.normalScale=new NM(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class KO extends qO{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new NM(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return AM(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new QM(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new QM(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new QM(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._iridescence=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=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 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.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class YO extends EA{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new QM(16777215),this.specular=new QM(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new QM(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=US,this.normalScale=new NM(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$w,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class JO extends EA{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new QM(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new QM(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=US,this.normalScale=new NM(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class QO extends EA{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=US,this.normalScale=new NM(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class XO extends EA{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new QM(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new QM(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=US,this.normalScale=new NM(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=$w,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class ZO extends EA{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new QM(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=US,this.normalScale=new NM(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class $O extends $T{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function eR(e,t,n){return nR(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function tR(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function nR(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function rR(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n}function iR(e,t,n){const r=e.length,i=new e.constructor(r);for(let o=0,a=0;a!==r;++o){const r=n[o]*t;for(let n=0;n!==t;++n)i[a++]=e[r+n]}return i}function oR(e,t,n,r){let i=1,o=e[0];for(;void 0!==o&&void 0===o[r];)o=e[i++];if(void 0===o)return;let a=o[r];if(void 0!==a)if(Array.isArray(a))do{a=o[r],void 0!==a&&(t.push(o.time),n.push.apply(n,a)),o=e[i++]}while(void 0!==o);else if(void 0!==a.toArray)do{a=o[r],void 0!==a&&(t.push(o.time),a.toArray(n,n.length)),o=e[i++]}while(void 0!==o);else do{a=o[r],void 0!==a&&(t.push(o.time),n.push(a)),o=e[i++]}while(void 0!==o)}var aR=Object.freeze({__proto__:null,arraySlice:eR,convertArray:tR,isTypedArray:nR,getKeyframeOrder:rR,sortedArray:iR,flattenJSON:oR,subclip:function(e,t,n,r,i=30){const o=e.clone();o.name=t;const a=[];for(let e=0;e<o.tracks.length;++e){const t=o.tracks[e],s=t.getValueSize(),l=[],c=[];for(let e=0;e<t.times.length;++e){const o=t.times[e]*i;if(!(o<n||o>=r)){l.push(t.times[e]);for(let n=0;n<s;++n)c.push(t.values[e*s+n])}}0!==l.length&&(t.times=tR(l,t.times.constructor),t.values=tR(c,t.values.constructor),a.push(t))}o.tracks=a;let s=1/0;for(let e=0;e<o.tracks.length;++e)s>o.tracks[e].times[0]&&(s=o.tracks[e].times[0]);for(let e=0;e<o.tracks.length;++e)o.tracks[e].shift(-1*s);return o.resetDuration(),o},makeClipAdditive:function(e,t=0,n=e,r=30){r<=0&&(r=30);const i=n.tracks.length,o=t/r;for(let t=0;t<i;++t){const r=n.tracks[t],i=r.ValueTypeName;if("bool"===i||"string"===i)continue;const a=e.tracks.find((function(e){return e.name===r.name&&e.ValueTypeName===i}));if(void 0===a)continue;let s=0;const l=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=l/3);let c=0;const u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=u/3);const d=r.times.length-1;let f;if(o<=r.times[0]){const e=s,t=l-s;f=eR(r.values,e,t)}else if(o>=r.times[d]){const e=d*l+s,t=e+l-s;f=eR(r.values,e,t)}else{const e=r.createInterpolant(),t=s,n=l-s;e.evaluate(o),f=eR(e.resultBuffer,t,n)}if("quaternion"===i){(new u_).fromArray(f).normalize().conjugate().toArray(f)}const h=a.times.length;for(let e=0;e<h;++e){const t=e*u+c;if("quaternion"===i)u_.multiplyQuaternionsFlat(a.values,t,f,0,a.values,t);else{const e=u-2*c;for(let n=0;n<e;++n)a.values[t+n]-=f[n]}}}return e.blendMode=RS,e}});class sR{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r: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,r=t[n],i=t[n-1];e:{t:{let o;n:{r:if(!(e<r)){for(let o=n+2;;){if(void 0===r){if(e<i)break r;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(i=r,r=t[++n],e<r)break t}o=t.length;break n}if(e>=i)break e;{const a=t[1];e<a&&(n=2,i=a);for(let o=n-2;;){if(void 0===i)return this._cachedIndex=0,this.copySampleValue_(0);if(n===o)break;if(r=i,i=t[--n-1],e>=i)break t}o=n,n=0}}for(;n<o;){const r=n+o>>>1;e<t[r]?o=r:n=r+1}if(r=t[n],i=t[n-1],void 0===i)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===r)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class lR extends sR{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:kS,endingEnd:kS}}intervalChanged_(e,t,n){const r=this.parameterPositions;let i=e-2,o=e+1,a=r[i],s=r[o];if(void 0===a)switch(this.getSettings_().endingStart){case TS:i=e,a=2*t-n;break;case IS:i=r.length-2,a=t+r[i]-r[i+1];break;default:i=e,a=n}if(void 0===s)switch(this.getSettings_().endingEnd){case TS:o=e,s=2*n-t;break;case IS:o=1,s=n+r[1]-r[0];break;default:o=e-1,s=t}const l=.5*(n-t),c=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(s-n),this._offsetPrev=i*c,this._offsetNext=o*c}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=e*a,l=s-a,c=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,h=(n-t)/(r-t),p=h*h,m=p*h,g=-d*m+2*d*p-d*h,v=(1+d)*m+(-1.5-2*d)*p+(-.5+d)*h+1,y=(-1-f)*m+(1.5+f)*p+.5*h,b=f*m-f*p;for(let e=0;e!==a;++e)i[e]=g*o[c+e]+v*o[l+e]+y*o[s+e]+b*o[u+e];return i}}class cR extends sR{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=e*a,l=s-a,c=(n-t)/(r-t),u=1-c;for(let e=0;e!==a;++e)i[e]=o[l+e]*u+o[s+e]*c;return i}}class uR extends sR{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class dR{constructor(e,t,n,r){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=tR(t,this.TimeBufferType),this.values=tR(n,this.ValueBufferType),this.setInterpolation(r||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:tR(e.times,Array),values:tR(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new uR(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new cR(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new lR(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case AS:t=this.InterpolantFactoryMethodDiscrete;break;case ES:t=this.InterpolantFactoryMethodLinear;break;case CS:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return AS;case this.InterpolantFactoryMethodLinear:return ES;case this.InterpolantFactoryMethodSmooth:return CS}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let i=0,o=r-1;for(;i!==r&&n[i]<e;)++i;for(;-1!==o&&n[o]>t;)--o;if(++o,0!==i||o!==r){i>=o&&(o=Math.max(o,1),i=o-1);const e=this.getValueSize();this.times=eR(n,i,o),this.values=eR(this.values,i*e,o*e)}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,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let t=0;t!==i;t++){const r=n[t];if("number"==typeof r&&isNaN(r)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,r),e=!1;break}if(null!==o&&o>r){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,r,o),e=!1;break}o=r}if(void 0!==r&&nR(r))for(let t=0,n=r.length;t!==n;++t){const n=r[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=eR(this.times),t=eR(this.values),n=this.getValueSize(),r=this.getInterpolation()===CS,i=e.length-1;let o=1;for(let a=1;a<i;++a){let i=!1;const s=e[a];if(s!==e[a+1]&&(1!==a||s!==e[0]))if(r)i=!0;else{const e=a*n,r=e-n,o=e+n;for(let a=0;a!==n;++a){const n=t[e+a];if(n!==t[r+a]||n!==t[o+a]){i=!0;break}}}if(i){if(a!==o){e[o]=e[a];const r=a*n,i=o*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++o}}if(i>0){e[o]=e[i];for(let e=i*n,r=o*n,a=0;a!==n;++a)t[r+a]=t[e+a];++o}return o!==e.length?(this.times=eR(e,0,o),this.values=eR(t,0,o*n)):(this.times=e,this.values=t),this}clone(){const e=eR(this.times,0),t=eR(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}dR.prototype.TimeBufferType=Float32Array,dR.prototype.ValueBufferType=Float32Array,dR.prototype.DefaultInterpolation=ES;class fR extends dR{}fR.prototype.ValueTypeName="bool",fR.prototype.ValueBufferType=Array,fR.prototype.DefaultInterpolation=AS,fR.prototype.InterpolantFactoryMethodLinear=void 0,fR.prototype.InterpolantFactoryMethodSmooth=void 0;class hR extends dR{}hR.prototype.ValueTypeName="color";class pR extends dR{}pR.prototype.ValueTypeName="number";class mR extends sR{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=(n-t)/(r-t);let l=e*a;for(let e=l+a;l!==e;l+=4)u_.slerpFlat(i,0,o,l-a,o,l,s);return i}}class gR extends dR{InterpolantFactoryMethodLinear(e){return new mR(this.times,this.values,this.getValueSize(),e)}}gR.prototype.ValueTypeName="quaternion",gR.prototype.DefaultInterpolation=ES,gR.prototype.InterpolantFactoryMethodSmooth=void 0;class vR extends dR{}vR.prototype.ValueTypeName="string",vR.prototype.ValueBufferType=Array,vR.prototype.DefaultInterpolation=AS,vR.prototype.InterpolantFactoryMethodLinear=void 0,vR.prototype.InterpolantFactoryMethodSmooth=void 0;class yR extends dR{}yR.prototype.ValueTypeName="vector";class bR{constructor(e,t=-1,n,r=OS){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=_M(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let e=0,i=n.length;e!==i;++e)t.push(wR(n[e]).scale(r));const i=new this(e.name,e.duration,t,e.blendMode);return i.uuid=e.uuid,i}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,r=n.length;e!==r;++e)t.push(dR.toJSON(n[e]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const i=t.length,o=[];for(let e=0;e<i;e++){let a=[],s=[];a.push((e+i-1)%i,e,(e+1)%i),s.push(0,1,0);const l=rR(a);a=iR(a,1,l),s=iR(s,1,l),r||0!==a[0]||(a.push(i),s.push(s[0])),o.push(new pR(".morphTargetInfluences["+t[e].name+"]",a,s).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},i=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){const n=e[t],o=n.name.match(i);if(o&&o.length>1){const e=o[1];let t=r[e];t||(r[e]=t=[]),t.push(n)}}const o=[];for(const e in r)o.push(this.CreateFromMorphTargetSequence(e,r[e],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,r,i){if(0!==n.length){const o=[],a=[];oR(n,o,a,r),0!==o.length&&i.push(new e(t,o,a))}},r=[],i=e.name||"default",o=e.fps||30,a=e.blendMode;let s=e.length||-1;const l=e.hierarchy||[];for(let e=0;e<l.length;e++){const i=l[e].keys;if(i&&0!==i.length)if(i[0].morphTargets){const e={};let t;for(t=0;t<i.length;t++)if(i[t].morphTargets)for(let n=0;n<i[t].morphTargets.length;n++)e[i[t].morphTargets[n]]=-1;for(const n in e){const e=[],o=[];for(let r=0;r!==i[t].morphTargets.length;++r){const r=i[t];e.push(r.time),o.push(r.morphTarget===n?1:0)}r.push(new pR(".morphTargetInfluence["+n+"]",e,o))}s=e.length*o}else{const o=".bones["+t[e].name+"]";n(yR,o+".position",i,"pos",r),n(gR,o+".quaternion",i,"rot",r),n(yR,o+".scale",i,"scl",r)}}if(0===r.length)return null;return new this(i,s,r,a)}resetDuration(){let e=0;for(let t=0,n=this.tracks.length;t!==n;++t){const n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,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 wR(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return pR;case"vector":case"vector2":case"vector3":case"vector4":return yR;case"color":return hR;case"quaternion":return gR;case"bool":case"boolean":return fR;case"string":return vR}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],n=[];oR(e.keys,t,n,"value"),e.times=t,e.values=n}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const xR={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class SR{constructor(e,t,n){const r=this;let i,o=!1,a=0,s=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){s++,!1===o&&void 0!==r.onStart&&r.onStart(e,a,s),o=!0},this.itemEnd=function(e){a++,void 0!==r.onProgress&&r.onProgress(e,a,s),a===s&&(o=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return i?i(e):e},this.setURLModifier=function(e){return i=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){const t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=l.length;t<n;t+=2){const n=l[t],r=l[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}}const MR=new SR;class _R{constructor(e){this.manager=void 0!==e?e:MR,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise((function(r,i){n.load(e,r,t,i)}))}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}}const AR={};class ER extends Error{constructor(e,t){super(e),this.response=t}}class CR extends _R{constructor(e){super(e)}load(e,t,n,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=xR.get(e);if(void 0!==i)return this.manager.itemStart(e),setTimeout((()=>{t&&t(i),this.manager.itemEnd(e)}),0),i;if(void 0!==AR[e])return void AR[e].push({onLoad:t,onProgress:n,onError:r});AR[e]=[],AR[e].push({onLoad:t,onProgress:n,onError:r});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,s=this.responseType;fetch(o).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=AR[e],r=t.body.getReader(),i=t.headers.get("Content-Length"),o=i?parseInt(i):0,a=0!==o;let s=0;const l=new ReadableStream({start(e){!function t(){r.read().then((({done:r,value:i})=>{if(r)e.close();else{s+=i.byteLength;const r=new ProgressEvent("progress",{lengthComputable:a,loaded:s,total:o});for(let e=0,t=n.length;e<t;e++){const t=n[e];t.onProgress&&t.onProgress(r)}e.enqueue(i),t()}}))}()}});return new Response(l)}throw new ER(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(s){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,a)));case"json":return e.json();default:if(void 0===a)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(a),n=t&&t[1]?t[1].toLowerCase():void 0,r=new TextDecoder(n);return e.arrayBuffer().then((e=>r.decode(e)))}}})).then((t=>{xR.add(e,t);const n=AR[e];delete AR[e];for(let e=0,r=n.length;e<r;e++){const r=n[e];r.onLoad&&r.onLoad(t)}})).catch((t=>{const n=AR[e];if(void 0===n)throw this.manager.itemError(e),t;delete AR[e];for(let e=0,r=n.length;e<r;e++){const r=n[e];r.onError&&r.onError(t)}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 kR extends _R{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new CR(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e){const t=[];for(let n=0;n<e.length;n++){const r=bR.parse(e[n]);t.push(r)}return t}}class TR extends _R{constructor(e){super(e)}load(e,t,n,r){const i=this,o=[],a=new bI,s=new CR(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(i.withCredentials);let l=0;function c(c){s.load(e[c],(function(e){const n=i.parse(e,!0);o[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(a.minFilter=Sx),a.image=o,a.format=n.format,a.needsUpdate=!0,t&&t(a))}),n,r)}if(Array.isArray(e))for(let t=0,n=e.length;t<n;++t)c(t);else s.load(e,(function(e){const n=i.parse(e,!0);if(n.isCubemap){const e=n.mipmaps.length/n.mipmapCount;for(let t=0;t<e;t++){o[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)o[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),o[t].format=n.format,o[t].width=n.width,o[t].height=n.height}a.image=o}else a.image.width=n.width,a.image.height=n.height,a.mipmaps=n.mipmaps;1===n.mipmapCount&&(a.minFilter=Sx),a.format=n.format,a.needsUpdate=!0,t&&t(a)}),n,r);return a}}class IR extends _R{constructor(e){super(e)}load(e,t,n,r){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,o=xR.get(e);if(void 0!==o)return i.manager.itemStart(e),setTimeout((function(){t&&t(o),i.manager.itemEnd(e)}),0),o;const a=FM("img");function s(){c(),xR.add(e,this),t&&t(this),i.manager.itemEnd(e)}function l(t){c(),r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)}function c(){a.removeEventListener("load",s,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",s,!1),a.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),i.manager.itemStart(e),a.src=e,a}}class OR extends _R{constructor(e){super(e)}load(e,t,n,r){const i=new ME,o=new IR(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function s(n){o.load(e[n],(function(e){i.images[n]=e,a++,6===a&&(i.needsUpdate=!0,t&&t(i))}),void 0,r)}for(let t=0;t<e.length;++t)s(t);return i}}class RR extends _R{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new VT,a=new CR(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(i.withCredentials),a.load(e,(function(e){const n=i.parse(e);n&&(void 0!==n.image?o.image=n.image:void 0!==n.data&&(o.image.width=n.width,o.image.height=n.height,o.image.data=n.data),o.wrapS=void 0!==n.wrapS?n.wrapS:mx,o.wrapT=void 0!==n.wrapT?n.wrapT:mx,o.magFilter=void 0!==n.magFilter?n.magFilter:Sx,o.minFilter=void 0!==n.minFilter?n.minFilter:Sx,o.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.encoding&&(o.encoding=n.encoding),void 0!==n.flipY&&(o.flipY=n.flipY),void 0!==n.format&&(o.format=n.format),void 0!==n.type&&(o.type=n.type),void 0!==n.mipmaps&&(o.mipmaps=n.mipmaps,o.minFilter=Ax),1===n.mipmapCount&&(o.minFilter=Sx),void 0!==n.generateMipmaps&&(o.generateMipmaps=n.generateMipmaps),o.needsUpdate=!0,t&&t(o,n))}),n,r),o}}class PR extends _R{constructor(e){super(e)}load(e,t,n,r){const i=new n_,o=new IR(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,(function(e){i.image=e,i.needsUpdate=!0,void 0!==t&&t(i)}),n,r),i}}class NR extends hA{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new QM(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,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}class LR extends NR{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(hA.DefaultUp),this.updateMatrix(),this.groundColor=new QM(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const DR=new H_,BR=new d_,jR=new d_;class FR{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new NM(512,512),this.map=null,this.mapPass=null,this.matrix=new H_,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new OE,this._frameExtents=new NM(1,1),this._viewportCount=1,this._viewports=[new r_(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;BR.setFromMatrixPosition(e.matrixWorld),t.position.copy(BR),jR.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(jR),t.updateMatrixWorld(),DR.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(DR),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class UR extends FR{constructor(){super(new wE(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=2*MM*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,i=e.distance||t.far;n===t.fov&&r===t.aspect&&i===t.far||(t.fov=n,t.aspect=r,t.far=i,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class zR extends NR{constructor(e,t,n=0,r=Math.PI/3,i=0,o=1){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(hA.DefaultUp),this.updateMatrix(),this.target=new hA,this.distance=n,this.angle=r,this.penumbra=i,this.decay=o,this.map=null,this.shadow=new UR}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 HR=new H_,VR=new d_,WR=new d_;class GR extends FR{constructor(){super(new wE(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new NM(4,2),this._viewportCount=6,this._viewports=[new r_(2,1,1,1),new r_(0,1,1,1),new r_(3,1,1,1),new r_(1,1,1,1),new r_(3,0,1,1),new r_(1,0,1,1)],this._cubeDirections=[new d_(1,0,0),new d_(-1,0,0),new d_(0,0,1),new d_(0,0,-1),new d_(0,1,0),new d_(0,-1,0)],this._cubeUps=[new d_(0,1,0),new d_(0,1,0),new d_(0,1,0),new d_(0,1,0),new d_(0,0,1),new d_(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,i=e.distance||n.far;i!==n.far&&(n.far=i,n.updateProjectionMatrix()),VR.setFromMatrixPosition(e.matrixWorld),n.position.copy(VR),WR.copy(n.position),WR.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(WR),n.updateMatrixWorld(),r.makeTranslation(-VR.x,-VR.y,-VR.z),HR.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(HR)}}class qR extends NR{constructor(e,t,n=0,r=1){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new GR}get power(){return 4*this.intensity*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 KR extends FR{constructor(){super(new WE(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class YR extends NR{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(hA.DefaultUp),this.updateMatrix(),this.target=new hA,this.shadow=new KR}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class JR extends NR{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class QR extends NR{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class XR{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new d_)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,r=e.y,i=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*i),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],n*r*1.092548),t.addScaledVector(o[5],r*i*1.092548),t.addScaledVector(o[6],.315392*(3*i*i-1)),t.addScaledVector(o[7],n*i*1.092548),t.addScaledVector(o[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){const n=e.x,r=e.y,i=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],1.023328*r),t.addScaledVector(o[2],1.023328*i),t.addScaledVector(o[3],1.023328*n),t.addScaledVector(o[4],.858086*n*r),t.addScaledVector(o[5],.858086*r*i),t.addScaledVector(o[6],.743125*i*i-.247708),t.addScaledVector(o[7],.858086*n*i),t.addScaledVector(o[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+3*r);return this}toArray(e=[],t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+3*r);return e}static getBasisAt(e,t){const n=e.x,r=e.y,i=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*i,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*i,t[6]=.315392*(3*i*i-1),t[7]=1.092548*n*i,t[8]=.546274*(n*n-r*r)}}class ZR extends NR{constructor(e=new XR,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class $R extends _R{constructor(e){super(e),this.textures={}}load(e,t,n,r){const i=this,o=new CR(i.manager);o.setPath(i.path),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,(function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e){const t=this.textures;function n(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}const r=$R.createMaterialFromType(e.type);if(void 0!==e.uuid&&(r.uuid=e.uuid),void 0!==e.name&&(r.name=e.name),void 0!==e.color&&void 0!==r.color&&r.color.setHex(e.color),void 0!==e.roughness&&(r.roughness=e.roughness),void 0!==e.metalness&&(r.metalness=e.metalness),void 0!==e.sheen&&(r.sheen=e.sheen),void 0!==e.sheenColor&&(r.sheenColor=(new QM).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(r.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==r.emissive&&r.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==r.specular&&r.specular.setHex(e.specular),void 0!==e.specularIntensity&&(r.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==r.specularColor&&r.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(r.shininess=e.shininess),void 0!==e.clearcoat&&(r.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(r.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.iridescence&&(r.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(r.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(r.transmission=e.transmission),void 0!==e.thickness&&(r.thickness=e.thickness),void 0!==e.attenuationDistance&&(r.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==r.attenuationColor&&r.attenuationColor.setHex(e.attenuationColor),void 0!==e.fog&&(r.fog=e.fog),void 0!==e.flatShading&&(r.flatShading=e.flatShading),void 0!==e.blending&&(r.blending=e.blending),void 0!==e.combine&&(r.combine=e.combine),void 0!==e.side&&(r.side=e.side),void 0!==e.shadowSide&&(r.shadowSide=e.shadowSide),void 0!==e.opacity&&(r.opacity=e.opacity),void 0!==e.transparent&&(r.transparent=e.transparent),void 0!==e.alphaTest&&(r.alphaTest=e.alphaTest),void 0!==e.depthTest&&(r.depthTest=e.depthTest),void 0!==e.depthWrite&&(r.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(r.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(r.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(r.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(r.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(r.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(r.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(r.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(r.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(r.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(r.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(r.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(r.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(r.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(r.rotation=e.rotation),1!==e.linewidth&&(r.linewidth=e.linewidth),void 0!==e.dashSize&&(r.dashSize=e.dashSize),void 0!==e.gapSize&&(r.gapSize=e.gapSize),void 0!==e.scale&&(r.scale=e.scale),void 0!==e.polygonOffset&&(r.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(r.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(r.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(r.dithering=e.dithering),void 0!==e.alphaToCoverage&&(r.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(r.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.visible&&(r.visible=e.visible),void 0!==e.toneMapped&&(r.toneMapped=e.toneMapped),void 0!==e.userData&&(r.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const i=e.uniforms[t];switch(r.uniforms[t]={},i.type){case"t":r.uniforms[t].value=n(i.value);break;case"c":r.uniforms[t].value=(new QM).setHex(i.value);break;case"v2":r.uniforms[t].value=(new NM).fromArray(i.value);break;case"v3":r.uniforms[t].value=(new d_).fromArray(i.value);break;case"v4":r.uniforms[t].value=(new r_).fromArray(i.value);break;case"m3":r.uniforms[t].value=(new LM).fromArray(i.value);break;case"m4":r.uniforms[t].value=(new H_).fromArray(i.value);break;default:r.uniforms[t].value=i.value}}if(void 0!==e.defines&&(r.defines=e.defines),void 0!==e.vertexShader&&(r.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(r.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(r.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)r.extensions[t]=e.extensions[t];if(void 0!==e.size&&(r.size=e.size),void 0!==e.sizeAttenuation&&(r.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(r.map=n(e.map)),void 0!==e.matcap&&(r.matcap=n(e.matcap)),void 0!==e.alphaMap&&(r.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(r.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(r.bumpScale=e.bumpScale),void 0!==e.normalMap&&(r.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(r.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),r.normalScale=(new NM).fromArray(t)}return void 0!==e.displacementMap&&(r.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(r.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(r.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(r.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(r.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(r.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(r.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(r.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(r.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(r.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(r.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(r.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(r.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(r.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(r.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(r.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(r.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(r.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(r.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(r.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(r.clearcoatNormalScale=(new NM).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(r.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(r.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(r.thicknessMap=n(e.thicknessMap)),void 0!==e.sheenColorMap&&(r.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:WO,SpriteMaterial:vT,RawShaderMaterial:GO,ShaderMaterial:yE,PointsMaterial:uI,MeshPhysicalMaterial:KO,MeshStandardMaterial:qO,MeshPhongMaterial:YO,MeshToonMaterial:JO,MeshNormalMaterial:QO,MeshLambertMaterial:XO,MeshDepthMaterial:Jk,MeshDistanceMaterial:Qk,MeshBasicMaterial:CA,MeshMatcapMaterial:ZO,LineDashedMaterial:$O,LineBasicMaterial:$T,Material:EA}[e]}}class eP{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch(e){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===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 tP extends YA{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return(new this.constructor).copy(this)}toJSON(){const e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class nP extends _R{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new CR(i.manager);o.setPath(i.path),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,(function(n){try{t(i.parse(JSON.parse(n)))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e){const t={},n={};function r(e,r){if(void 0!==t[r])return t[r];const i=e.interleavedBuffers[r],o=function(e,t){if(void 0!==n[t])return n[t];const r=e.arrayBuffers,i=r[t],o=new Uint32Array(i).buffer;return n[t]=o,o}(e,i.buffer),a=jM(i.type,o),s=new pT(a,i.stride);return s.uuid=i.uuid,t[r]=s,s}const i=e.isInstancedBufferGeometry?new tP:new YA,o=e.data.index;if(void 0!==o){const e=jM(o.type,o.array);i.setIndex(new IA(e,1))}const a=e.data.attributes;for(const t in a){const n=a[t];let o;if(n.isInterleavedBufferAttribute){const t=r(e.data,n.data);o=new gT(t,n.itemSize,n.offset,n.normalized)}else{const e=jM(n.type,n.array);o=new(n.isInstancedBufferAttribute?KT:IA)(e,n.itemSize,n.normalized)}void 0!==n.name&&(o.name=n.name),void 0!==n.usage&&o.setUsage(n.usage),void 0!==n.updateRange&&(o.updateRange.offset=n.updateRange.offset,o.updateRange.count=n.updateRange.count),i.setAttribute(t,o)}const s=e.data.morphAttributes;if(s)for(const t in s){const n=s[t],o=[];for(let t=0,i=n.length;t<i;t++){const i=n[t];let a;if(i.isInterleavedBufferAttribute){const t=r(e.data,i.data);a=new gT(t,i.itemSize,i.offset,i.normalized)}else{const e=jM(i.type,i.array);a=new IA(e,i.itemSize,i.normalized)}void 0!==i.name&&(a.name=i.name),o.push(a)}i.morphAttributes[t]=o}e.data.morphTargetsRelative&&(i.morphTargetsRelative=!0);const l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(let e=0,t=l.length;e!==t;++e){const t=l[e];i.addGroup(t.start,t.count,t.materialIndex)}const c=e.data.boundingSphere;if(void 0!==c){const e=new d_;void 0!==c.center&&e.fromArray(c.center),i.boundingSphere=new P_(e,c.radius)}return e.name&&(i.name=e.name),e.userData&&(i.userData=e.userData),i}}class rP extends _R{constructor(e){super(e)}load(e,t,n,r){const i=this,o=""===this.path?eP.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const a=new CR(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){let o=null;try{o=JSON.parse(n)}catch(t){return void 0!==r&&r(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}const a=o.metadata;void 0!==a&&void 0!==a.type&&"geometry"!==a.type.toLowerCase()?i.parse(o,t):console.error("THREE.ObjectLoader: Can't load "+e)}),n,r)}async loadAsync(e,t){const n=""===this.path?eP.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;const r=new CR(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);const i=await r.loadAsync(e,t),o=JSON.parse(i),a=o.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+e);return await this.parseAsync(o)}parse(e,t){const n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,(function(){void 0!==t&&t(l)})),a=this.parseTextures(e.textures,o),s=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,i,s,a,n),c=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,c),void 0!==t){let e=!1;for(const t in o)if(o[t].data instanceof HTMLImageElement){e=!0;break}!1===e&&t(l)}return l}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),i=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,i),a=this.parseMaterials(e.materials,o),s=this.parseObject(e.object,r,a,o,t),l=this.parseSkeletons(e.skeletons,s);return this.bindSkeletons(s,l),s}parseShapes(e){const t={};if(void 0!==e)for(let n=0,r=e.length;n<r;n++){const r=(new tO).fromJSON(e[n]);t[r.uuid]=r}return t}parseSkeletons(e,t){const n={},r={};if(t.traverse((function(e){e.isBone&&(r[e.uuid]=e)})),void 0!==e)for(let t=0,i=e.length;t<i;t++){const i=(new qT).fromJSON(e[t],r);n[i.uuid]=i}return n}parseGeometries(e,t){const n={};if(void 0!==e){const r=new nP;for(let i=0,o=e.length;i<o;i++){let o;const a=e[i];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(a);break;default:a.type in VO?o=VO[a.type].fromJSON(a,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}o.uuid=a.uuid,void 0!==a.name&&(o.name=a.name),!0===o.isBufferGeometry&&void 0!==a.userData&&(o.userData=a.userData),n[a.uuid]=o}}return n}parseMaterials(e,t){const n={},r={};if(void 0!==e){const i=new $R;i.setTextures(t);for(let t=0,o=e.length;t<o;t++){const o=e[t];void 0===n[o.uuid]&&(n[o.uuid]=i.parse(o)),r[o.uuid]=n[o.uuid]}}return r}parseAnimations(e){const t={};if(void 0!==e)for(let n=0;n<e.length;n++){const r=e[n],i=bR.parse(r);t[i.uuid]=i}return t}parseImages(e,t){const n=this,r={};let i;function o(e){if("string"==typeof e){const t=e;return function(e){return n.manager.itemStart(e),i.load(e,(function(){n.manager.itemEnd(e)}),void 0,(function(){n.manager.itemError(e),n.manager.itemEnd(e)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t)?t:n.resourcePath+t)}return e.data?{data:jM(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){const n=new SR(t);i=new IR(n),i.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){const n=e[t],i=n.url;if(Array.isArray(i)){const e=[];for(let t=0,n=i.length;t<n;t++){const n=o(i[t]);null!==n&&(n instanceof HTMLImageElement?e.push(n):e.push(new VT(n.data,n.width,n.height)))}r[n.uuid]=new $M(e)}else{const e=o(n.url);r[n.uuid]=new $M(e)}}}return r}async parseImagesAsync(e){const t=this,n={};let r;async function i(e){if("string"==typeof e){const n=e,i=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:t.resourcePath+n;return await r.loadAsync(i)}return e.data?{data:jM(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){r=new IR(this.manager),r.setCrossOrigin(this.crossOrigin);for(let t=0,r=e.length;t<r;t++){const r=e[t],o=r.url;if(Array.isArray(o)){const e=[];for(let t=0,n=o.length;t<n;t++){const n=o[t],r=await i(n);null!==r&&(r instanceof HTMLImageElement?e.push(r):e.push(new VT(r.data,r.width,r.height)))}n[r.uuid]=new $M(e)}else{const e=await i(r.url);n[r.uuid]=new $M(e)}}}return n}parseTextures(e,t){function n(e,t){return"number"==typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}const r={};if(void 0!==e)for(let i=0,o=e.length;i<o;i++){const o=e[i];void 0===o.image&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),void 0===t[o.image]&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const a=t[o.image],s=a.data;let l;Array.isArray(s)?(l=new ME,6===s.length&&(l.needsUpdate=!0)):(l=s&&s.data?new VT:new n_,s&&(l.needsUpdate=!0)),l.source=a,l.uuid=o.uuid,void 0!==o.name&&(l.name=o.name),void 0!==o.mapping&&(l.mapping=n(o.mapping,iP)),void 0!==o.offset&&l.offset.fromArray(o.offset),void 0!==o.repeat&&l.repeat.fromArray(o.repeat),void 0!==o.center&&l.center.fromArray(o.center),void 0!==o.rotation&&(l.rotation=o.rotation),void 0!==o.wrap&&(l.wrapS=n(o.wrap[0],oP),l.wrapT=n(o.wrap[1],oP)),void 0!==o.format&&(l.format=o.format),void 0!==o.type&&(l.type=o.type),void 0!==o.encoding&&(l.encoding=o.encoding),void 0!==o.minFilter&&(l.minFilter=n(o.minFilter,aP)),void 0!==o.magFilter&&(l.magFilter=n(o.magFilter,aP)),void 0!==o.anisotropy&&(l.anisotropy=o.anisotropy),void 0!==o.flipY&&(l.flipY=o.flipY),void 0!==o.premultiplyAlpha&&(l.premultiplyAlpha=o.premultiplyAlpha),void 0!==o.unpackAlignment&&(l.unpackAlignment=o.unpackAlignment),void 0!==o.userData&&(l.userData=o.userData),r[o.uuid]=l}return r}parseObject(e,t,n,r,i){let o,a,s;function l(e){return void 0===t[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),t[e]}function c(e){if(void 0!==e){if(Array.isArray(e)){const t=[];for(let r=0,i=e.length;r<i;r++){const i=e[r];void 0===n[i]&&console.warn("THREE.ObjectLoader: Undefined material",i),t.push(n[i])}return t}return void 0===n[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),n[e]}}function u(e){return void 0===r[e]&&console.warn("THREE.ObjectLoader: Undefined texture",e),r[e]}switch(e.type){case"Scene":o=new hT,void 0!==e.background&&(Number.isInteger(e.background)?o.background=new QM(e.background):o.background=u(e.background)),void 0!==e.environment&&(o.environment=u(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?o.fog=new fT(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(o.fog=new dT(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":o=new wE(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(o.focus=e.focus),void 0!==e.zoom&&(o.zoom=e.zoom),void 0!==e.filmGauge&&(o.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(o.filmOffset=e.filmOffset),void 0!==e.view&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new WE(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(o.zoom=e.zoom),void 0!==e.view&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new JR(e.color,e.intensity);break;case"DirectionalLight":o=new YR(e.color,e.intensity);break;case"PointLight":o=new qR(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new QR(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new zR(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new LR(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=(new ZR).fromJSON(e);break;case"SkinnedMesh":a=l(e.geometry),s=c(e.material),o=new zT(a,s),void 0!==e.bindMode&&(o.bindMode=e.bindMode),void 0!==e.bindMatrix&&o.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(o.skeleton=e.skeleton);break;case"Mesh":a=l(e.geometry),s=c(e.material),o=new fE(a,s);break;case"InstancedMesh":a=l(e.geometry),s=c(e.material);const t=e.count,n=e.instanceMatrix,r=e.instanceColor;o=new ZT(a,s,t),o.instanceMatrix=new KT(new Float32Array(n.array),16),void 0!==r&&(o.instanceColor=new KT(new Float32Array(r.array),r.itemSize));break;case"LOD":o=new LT;break;case"Line":o=new oI(l(e.geometry),c(e.material));break;case"LineLoop":o=new cI(l(e.geometry),c(e.material));break;case"LineSegments":o=new lI(l(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new mI(l(e.geometry),c(e.material));break;case"Sprite":o=new OT(c(e.material));break;case"Group":o=new nT;break;case"Bone":o=new HT;break;default:o=new hA}if(o.uuid=e.uuid,void 0!==e.name&&(o.name=e.name),void 0!==e.matrix?(o.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(void 0!==e.position&&o.position.fromArray(e.position),void 0!==e.rotation&&o.rotation.fromArray(e.rotation),void 0!==e.quaternion&&o.quaternion.fromArray(e.quaternion),void 0!==e.scale&&o.scale.fromArray(e.scale)),void 0!==e.castShadow&&(o.castShadow=e.castShadow),void 0!==e.receiveShadow&&(o.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(o.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(o.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(o.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&o.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(o.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(o.visible=e.visible),void 0!==e.frustumCulled&&(o.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(o.renderOrder=e.renderOrder),void 0!==e.userData&&(o.userData=e.userData),void 0!==e.layers&&(o.layers.mask=e.layers),void 0!==e.children){const a=e.children;for(let e=0;e<a.length;e++)o.add(this.parseObject(a[e],t,n,r,i))}if(void 0!==e.animations){const t=e.animations;for(let e=0;e<t.length;e++){const n=t[e];o.animations.push(i[n])}}if("LOD"===e.type){void 0!==e.autoUpdate&&(o.autoUpdate=e.autoUpdate);const t=e.levels;for(let e=0;e<t.length;e++){const n=t[e],r=o.getObjectByProperty("uuid",n.object);void 0!==r&&o.addLevel(r,n.distance)}}return o}bindSkeletons(e,t){0!==Object.keys(t).length&&e.traverse((function(e){if(!0===e.isSkinnedMesh&&void 0!==e.skeleton){const n=t[e.skeleton];void 0===n?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(n,e.bindMatrix)}}))}}const iP={UVMapping:lx,CubeReflectionMapping:cx,CubeRefractionMapping:ux,EquirectangularReflectionMapping:dx,EquirectangularRefractionMapping:fx,CubeUVReflectionMapping:hx},oP={RepeatWrapping:px,ClampToEdgeWrapping:mx,MirroredRepeatWrapping:gx},aP={NearestFilter:vx,NearestMipmapNearestFilter:yx,NearestMipmapLinearFilter:wx,LinearFilter:Sx,LinearMipmapNearestFilter:Mx,LinearMipmapLinearFilter:Ax};class sP extends _R{constructor(e){super(e),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,o=xR.get(e);if(void 0!==o)return i.manager.itemStart(e),setTimeout((function(){t&&t(o),i.manager.itemEnd(e)}),0),o;const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(i.options,{colorSpaceConversion:"none"}))})).then((function(n){xR.add(e,n),t&&t(n),i.manager.itemEnd(e)})).catch((function(t){r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)})),i.manager.itemStart(e)}}let lP;const cP={getContext:function(){return void 0===lP&&(lP=new(window.AudioContext||window.webkitAudioContext)),lP},setContext:function(e){lP=e}};class uP extends _R{constructor(e){super(e)}load(e,t,n,r){const i=this,o=new CR(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(n){try{const e=n.slice(0);cP.getContext().decodeAudioData(e,(function(e){t(e)}))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}}class dP extends ZR{constructor(e,t,n=1){super(void 0,n),this.isHemisphereLightProbe=!0;const r=(new QM).set(e),i=(new QM).set(t),o=new d_(r.r,r.g,r.b),a=new d_(i.r,i.g,i.b),s=Math.sqrt(Math.PI),l=s*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(a).multiplyScalar(s),this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(l)}}class fP extends ZR{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const n=(new QM).set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const hP=new H_,pP=new H_,mP=new H_;class gP{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new wE,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new wE,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,mP.copy(e.projectionMatrix);const n=t.eyeSep/2,r=n*t.near/t.focus,i=t.near*Math.tan(SM*t.fov*.5)/t.zoom;let o,a;pP.elements[12]=-n,hP.elements[12]=n,o=-i*t.aspect+r,a=i*t.aspect+r,mP.elements[0]=2*t.near/(a-o),mP.elements[8]=(a+o)/(a-o),this.cameraL.projectionMatrix.copy(mP),o=-i*t.aspect-r,a=i*t.aspect-r,mP.elements[0]=2*t.near/(a-o),mP.elements[8]=(a+o)/(a-o),this.cameraR.projectionMatrix.copy(mP)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(pP),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(hP)}}class vP{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=yP(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=yP();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function yP(){return("undefined"==typeof performance?Date:performance).now()}const bP=new d_,wP=new u_,xP=new d_,SP=new d_;class MP extends hA{constructor(){super(),this.type="AudioListener",this.context=cP.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new vP}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(bP,wP,xP),SP.set(0,0,-1).applyQuaternion(wP),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(bP.x,e),t.positionY.linearRampToValueAtTime(bP.y,e),t.positionZ.linearRampToValueAtTime(bP.z,e),t.forwardX.linearRampToValueAtTime(SP.x,e),t.forwardY.linearRampToValueAtTime(SP.y,e),t.forwardZ.linearRampToValueAtTime(SP.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(bP.x,bP.y,bP.z),t.setOrientation(SP.x,SP.y,SP.z,n.x,n.y,n.z)}}class _P extends hA{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const AP=new d_,EP=new u_,CP=new d_,kP=new d_;class TP extends _P{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(AP,EP,CP),kP.set(0,0,1).applyQuaternion(EP);const t=this.panner;if(t.positionX){const e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(AP.x,e),t.positionY.linearRampToValueAtTime(AP.y,e),t.positionZ.linearRampToValueAtTime(AP.z,e),t.orientationX.linearRampToValueAtTime(kP.x,e),t.orientationY.linearRampToValueAtTime(kP.y,e),t.orientationZ.linearRampToValueAtTime(kP.z,e)}else t.setPosition(AP.x,AP.y,AP.z),t.setOrientation(kP.x,kP.y,kP.z)}}class IP{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class OP{constructor(e,t,n){let r,i,o;switch(this.binding=e,this.valueSize=n,t){case"quaternion":r=this._slerp,i=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":r=this._select,i=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:r=this._lerp,i=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=i,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,r=this.valueSize,i=e*r+r;let o=this.cumulativeWeight;if(0===o){for(let e=0;e!==r;++e)n[i+e]=n[e];o=t}else{o+=t;const e=t/o;this._mixBufferRegion(n,i,0,e,r)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,r=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,r=e*t+t,i=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,i<1){const e=t*this._origIndex;this._mixBufferRegion(n,r,e,1-i,t)}o>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let e=t,i=t+t;e!==i;++e)if(n[e]!==n[e+t]){a.setValue(n,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let e=n,i=r;e!==i;++e)t[e]=t[r+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;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,r,i){if(r>=.5)for(let r=0;r!==i;++r)e[t+r]=e[n+r]}_slerp(e,t,n,r){u_.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,i){const o=this._workIndex*i;u_.multiplyQuaternionsFlat(e,o,e,t,e,n),u_.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,n,r,i){const o=1-r;for(let a=0;a!==i;++a){const i=t+a;e[i]=e[i]*o+e[n+a]*r}}_lerpAdditive(e,t,n,r,i){for(let o=0;o!==i;++o){const i=t+o;e[i]=e[i]+e[n+o]*r}}}const RP="\\[\\]\\.:\\/",PP=new RegExp("["+RP+"]","g"),NP="[^"+RP+"]",LP="[^"+RP.replace("\\.","")+"]",DP=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",NP)+/(WCOD+)?/.source.replace("WCOD",LP)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",NP)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",NP)+"$"),BP=["material","materials","bones","map"];class jP{constructor(e,t,n){this.path=t,this.parsedPath=n||jP.parseTrackName(t),this.node=jP.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new jP.Composite(e,t,n):new jP(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(PP,"")}static parseTrackName(e){const t=DP.exec(e);if(null===t)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]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){const e=n.nodeName.substring(r+1);-1!==BP.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let r=0;r<e.length;r++){const i=e[r];if(i.name===t||i.uuid===t)return i;const o=n(i.children);if(o)return o}return null},r=n(e.children);if(r)return r}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 r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_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 r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=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,r=t.propertyName;let i=t.propertyIndex;if(e||(e=jP.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(n){let r=t.objectIndex;switch(n){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===r){r=t;break}break;case"map":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;default:if(void 0===e[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[n]}if(void 0!==r){if(void 0===e[r])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[r]}}const o=e[r];if(void 0===o){const n=t.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+n+"."+r+" but it wasn't found.",e)}let a=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let s=this.BindingType.Direct;if(void 0!==i){if("morphTargetInfluences"===r){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[i]&&(i=e.morphTargetDictionary[i])}s=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=i}else void 0!==o.fromArray&&void 0!==o.toArray?(s=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(s=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[s],this.setValue=this.SetterByBindingTypeAndVersioning[s][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}jP.Composite=class{constructor(e,t,n){const r=n||jP.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];void 0!==r&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].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()}},jP.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},jP.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},jP.prototype.GetterByBindingType=[jP.prototype._getValue_direct,jP.prototype._getValue_array,jP.prototype._getValue_arrayElement,jP.prototype._getValue_toArray],jP.prototype.SetterByBindingTypeAndVersioning=[[jP.prototype._setValue_direct,jP.prototype._setValue_direct_setNeedsUpdate,jP.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[jP.prototype._setValue_array,jP.prototype._setValue_array_setNeedsUpdate,jP.prototype._setValue_array_setMatrixWorldNeedsUpdate],[jP.prototype._setValue_arrayElement,jP.prototype._setValue_arrayElement_setNeedsUpdate,jP.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[jP.prototype._setValue_fromArray,jP.prototype._setValue_fromArray_setNeedsUpdate,jP.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class FP{constructor(){this.isAnimationObjectGroup=!0,this.uuid=_M(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let t=0,n=arguments.length;t!==n;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,r=this._parsedPaths,i=this._bindings,o=i.length;let a,s=e.length,l=this.nCachedObjects_;for(let c=0,u=arguments.length;c!==u;++c){const u=arguments[c],d=u.uuid;let f=t[d];if(void 0===f){f=s++,t[d]=f,e.push(u);for(let e=0,t=o;e!==t;++e)i[e].push(new jP(u,n[e],r[e]))}else if(f<l){a=e[f];const s=--l,c=e[s];t[c.uuid]=f,e[f]=c,t[d]=s,e[s]=u;for(let e=0,t=o;e!==t;++e){const t=i[e],o=t[s];let a=t[f];t[f]=o,void 0===a&&(a=new jP(u,n[e],r[e])),t[s]=a}}else e[f]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let i=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const a=arguments[o],s=a.uuid,l=t[s];if(void 0!==l&&l>=i){const o=i++,c=e[o];t[c.uuid]=l,e[l]=c,t[s]=o,e[o]=a;for(let e=0,t=r;e!==t;++e){const t=n[e],r=t[o],i=t[l];t[l]=r,t[o]=i}}}this.nCachedObjects_=i}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let i=this.nCachedObjects_,o=e.length;for(let a=0,s=arguments.length;a!==s;++a){const s=arguments[a].uuid,l=t[s];if(void 0!==l)if(delete t[s],l<i){const a=--i,s=e[a],c=--o,u=e[c];t[s.uuid]=l,e[l]=s,t[u.uuid]=a,e[a]=u,e.pop();for(let e=0,t=r;e!==t;++e){const t=n[e],r=t[a],i=t[c];t[l]=r,t[a]=i,t.pop()}}else{const i=--o,a=e[i];i>0&&(t[a.uuid]=l),e[l]=a,e.pop();for(let e=0,t=r;e!==t;++e){const t=n[e];t[l]=t[i],t.pop()}}}this.nCachedObjects_=i}subscribe_(e,t){const n=this._bindingsIndicesByPath;let r=n[e];const i=this._bindings;if(void 0!==r)return i[r];const o=this._paths,a=this._parsedPaths,s=this._objects,l=s.length,c=this.nCachedObjects_,u=new Array(l);r=i.length,n[e]=r,o.push(e),a.push(t),i.push(u);for(let n=c,r=s.length;n!==r;++n){const r=s[n];u[n]=new jP(r,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const r=this._paths,i=this._parsedPaths,o=this._bindings,a=o.length-1,s=o[a];t[e[a]]=n,o[n]=s,o.pop(),i[n]=i[a],i.pop(),r[n]=r[a],r.pop()}}}class UP{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const i=t.tracks,o=i.length,a=new Array(o),s={endingStart:kS,endingEnd:kS};for(let e=0;e!==o;++e){const t=i[e].createInterpolant(null);a[e]=t,t.settings=s}this._interpolantSettings=s,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=MS,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&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const n=this._clip.duration,r=e._clip.duration,i=r/n,o=n/r;e.warp(1,i,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return null!==e&&(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 r=this._mixer,i=r.time,o=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);const s=a.parameterPositions,l=a.sampleValues;return s[0]=i,s[1]=i+n,l[0]=e/o,l[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(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,r){if(!this.enabled)return void this._updateWeight(e);const i=this._startTime;if(null!==i){const r=(e-i)*n;r<0||0===n?t=0:(this._startTime=null,t=n*r)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===RS)for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(o),t[n].accumulateAdditive(a);else for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(o),t[n].accumulate(r,a)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let r=this.time+e,i=this._loopCount;const o=n===_S;if(0===e)return-1===i?r:o&&1==(1&i)?t-r:r;if(n===SS){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else{if(!(r<0)){this.time=r;break e}r=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===i&&(e>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),r>=t||r<0){const n=Math.floor(r/t);r-=t*n,i+=Math.abs(n);const a=this.repetitions-i;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===a){const t=e<0;this._setEndings(t,!t,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(o&&1==(1&i))return t-r}return r}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=TS,r.endingEnd=TS):(r.endingStart=e?this.zeroSlopeAtStart?TS:kS:IS,r.endingEnd=t?this.zeroSlopeAtEnd?TS:kS:IS)}_scheduleFading(e,t,n){const r=this._mixer,i=r.time;let o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=t,a[1]=i+e,s[1]=n,this}}const zP=new Float32Array(1);class HP extends bM{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,r=e._clip.tracks,i=r.length,o=e._propertyBindings,a=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName;let c=l[s];void 0===c&&(c={},l[s]=c);for(let e=0;e!==i;++e){const i=r[e],l=i.name;let u=c[l];if(void 0!==u)++u.referenceCount,o[e]=u;else{if(u=o[e],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,s,l));continue}const r=t&&t._propertyBindings[e].binding.parsedPath;u=new OP(jP.create(n,l,r),i.ValueTypeName,i.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,l),o[e]=u}a[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}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 null!==t&&t<this._nActiveActions}_addInactiveAction(e,t,n){const r=this._actions,i=this._actionsByClip;let o=i[t];if(void 0===o)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,i[t]=o;else{const t=o.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;const i=e._clip.uuid,o=this._actionsByClip,a=o[i],s=a.knownActions,l=s[s.length-1],c=e._byClipCacheIndex;l._byClipCacheIndex=c,s[c]=l,s.pop(),e._byClipCacheIndex=null;delete a.actionByRoot[(e._localRoot||this._root).uuid],0===s.length&&delete o[i],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.referenceCount&&this._removeInactiveBinding(n)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_addInactiveBinding(e,t,n){const r=this._bindingsByRootAndName,i=this._bindings;let o=r[t];void 0===o&&(o={},r[t]=o),o[n]=e,e._cacheIndex=i.length,i.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,r=n.rootNode.uuid,i=n.path,o=this._bindingsByRootAndName,a=o[r],s=t[t.length-1],l=e._cacheIndex;s._cacheIndex=l,t[l]=s,t.pop(),delete a[i],0===Object.keys(a).length&&delete o[r]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,i=t[r];e._cacheIndex=r,t[r]=e,i._cacheIndex=n,t[n]=i}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return void 0===n&&(n=new cR(new Float32Array(2),new Float32Array(2),1,zP),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,i=t[r];e.__cacheIndex=r,t[r]=e,i.__cacheIndex=n,t[n]=i}clipAction(e,t,n){const r=t||this._root,i=r.uuid;let o="string"==typeof e?bR.findByName(r,e):e;const a=null!==o?o.uuid:e,s=this._actionsByClip[a];let l=null;if(void 0===n&&(n=null!==o?o.blendMode:OS),void 0!==s){const e=s.actionByRoot[i];if(void 0!==e&&e.blendMode===n)return e;l=s.knownActions[0],null===o&&(o=l._clip)}if(null===o)return null;const c=new UP(this,o,t,n);return this._bindAction(c,l),this._addInactiveAction(c,a,i),c}existingAction(e,t){const n=t||this._root,r=n.uuid,i="string"==typeof e?bR.findByName(n,e):e,o=i?i.uuid:e,a=this._actionsByClip[o];return void 0!==a&&a.actionByRoot[r]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,r=this.time+=e,i=Math.sign(e),o=this._accuIndex^=1;for(let a=0;a!==n;++a){t[a]._update(r,e,i,o)}const a=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)a[e].apply(o);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,r=this._actionsByClip,i=r[n];if(void 0!==i){const e=i.knownActions;for(let n=0,r=e.length;n!==r;++n){const r=e[n];this._deactivateAction(r);const i=r._cacheIndex,o=t[t.length-1];r._cacheIndex=null,r._byClipCacheIndex=null,o._cacheIndex=i,t[i]=o,t.pop(),this._removeInactiveBindingsForAction(r)}delete r[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const e in n){const r=n[e].actionByRoot[t];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}const r=this._bindingsByRootAndName[t];if(void 0!==r)for(const e in r){const t=r[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){const n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class VP{constructor(e){this.value=e}clone(){return new VP(void 0===this.value.clone?this.value:this.value.clone())}}let WP=0;class GP extends bM{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:WP++}),this.name="",this.usage=sM,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let e=0,n=t.length;e<n;e++)this.uniforms.push(t[e].clone());return this}clone(){return(new this.constructor).copy(this)}}class qP extends pT{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class KP{constructor(e,t,n,r,i){this.isGLBufferAttribute=!0,this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=i,this.version=0}set needsUpdate(e){!0===e&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}class YP{constructor(e,t,n=0,r=1/0){this.ray=new z_(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new $_,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return QP(e,this,n,t),n.sort(JP),n}intersectObjects(e,t=!0,n=[]){for(let r=0,i=e.length;r<i;r++)QP(e[r],this,n,t);return n.sort(JP),n}}function JP(e,t){return e.distance-t.distance}function QP(e,t,n,r){if(e.layers.test(t.layers)&&e.raycast(t,n),!0===r){const r=e.children;for(let e=0,i=r.length;e<i;e++)QP(r[e],t,n,!0)}}class XP{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(AM(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class ZP{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return(new this.constructor).copy(this)}}const $P=new NM;class eN{constructor(e=new NM(1/0,1/0),t=new NM(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=$P.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return $P.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const tN=new d_,nN=new d_;class rN{constructor(e=new d_,t=new d_){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){tN.subVectors(e,this.start),nN.subVectors(this.end,this.start);const n=nN.dot(nN);let r=nN.dot(tN)/n;return t&&(r=AM(r,0,1)),r}closestPointToPoint(e,t,n){const r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const iN=new d_;class oN extends hA{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;const n=new YA,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1,n=32;e<n;e++,t++){const i=e/n*Math.PI*2,o=t/n*Math.PI*2;r.push(Math.cos(i),Math.sin(i),1,Math.cos(o),Math.sin(o),1)}n.setAttribute("position",new FA(r,3));const i=new $T({fog:!1,toneMapped:!1});this.cone=new lI(n,i),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),iN.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(iN),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const aN=new d_,sN=new H_,lN=new H_;class cN extends lI{constructor(e){const t=uN(e),n=new YA,r=[],i=[],o=new QM(0,0,1),a=new QM(0,1,0);for(let e=0;e<t.length;e++){const n=t[e];n.parent&&n.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),i.push(o.r,o.g,o.b),i.push(a.r,a.g,a.b))}n.setAttribute("position",new FA(r,3)),n.setAttribute("color",new FA(i,3));super(n,new $T({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),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,r=n.getAttribute("position");lN.copy(this.root.matrixWorld).invert();for(let e=0,n=0;e<t.length;e++){const i=t[e];i.parent&&i.parent.isBone&&(sN.multiplyMatrices(lN,i.matrixWorld),aN.setFromMatrixPosition(sN),r.setXYZ(n,aN.x,aN.y,aN.z),sN.multiplyMatrices(lN,i.parent.matrixWorld),aN.setFromMatrixPosition(sN),r.setXYZ(n+1,aN.x,aN.y,aN.z),n+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}function uN(e){const t=[];!0===e.isBone&&t.push(e);for(let n=0;n<e.children.length;n++)t.push.apply(t,uN(e.children[n]));return t}class dN extends fE{constructor(e,t,n){super(new DO(t,4,2),new CA({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.light.updateMatrixWorld(),this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const fN=new d_,hN=new QM,pN=new QM;class mN extends hA{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;const r=new PO(t);r.rotateY(.5*Math.PI),this.material=new CA({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const i=r.getAttribute("position"),o=new Float32Array(3*i.count);r.setAttribute("color",new IA(o,3)),this.add(new fE(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");hN.copy(this.light.color),pN.copy(this.light.groundColor);for(let e=0,n=t.count;e<n;e++){const r=e<n/2?hN:pN;t.setXYZ(e,r.r,r.g,r.b)}t.needsUpdate=!0}e.lookAt(fN.setFromMatrixPosition(this.light.matrixWorld).negate())}}class gN extends lI{constructor(e=10,t=10,n=4473924,r=8947848){n=new QM(n),r=new QM(r);const i=t/2,o=e/t,a=e/2,s=[],l=[];for(let e=0,c=0,u=-a;e<=t;e++,u+=o){s.push(-a,0,u,a,0,u),s.push(u,0,-a,u,0,a);const t=e===i?n:r;t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3}const c=new YA;c.setAttribute("position",new FA(s,3)),c.setAttribute("color",new FA(l,3));super(c,new $T({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}class vN extends lI{constructor(e=10,t=16,n=8,r=64,i=4473924,o=8947848){i=new QM(i),o=new QM(o);const a=[],s=[];if(t>1)for(let n=0;n<t;n++){const r=n/t*(2*Math.PI),l=Math.sin(r)*e,c=Math.cos(r)*e;a.push(0,0,0),a.push(l,0,c);const u=1&n?i:o;s.push(u.r,u.g,u.b),s.push(u.r,u.g,u.b)}for(let t=0;t<n;t++){const l=1&t?i:o,c=e-e/n*t;for(let e=0;e<r;e++){let t=e/r*(2*Math.PI),n=Math.sin(t)*c,i=Math.cos(t)*c;a.push(n,0,i),s.push(l.r,l.g,l.b),t=(e+1)/r*(2*Math.PI),n=Math.sin(t)*c,i=Math.cos(t)*c,a.push(n,0,i),s.push(l.r,l.g,l.b)}}const l=new YA;l.setAttribute("position",new FA(a,3)),l.setAttribute("color",new FA(s,3));super(l,new $T({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}}const yN=new d_,bN=new d_,wN=new d_;class xN extends hA{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,void 0===t&&(t=1);let r=new YA;r.setAttribute("position",new FA([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const i=new $T({fog:!1,toneMapped:!1});this.lightPlane=new oI(r,i),this.add(this.lightPlane),r=new YA,r.setAttribute("position",new FA([0,0,0,0,0,1],3)),this.targetLine=new oI(r,i),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){yN.setFromMatrixPosition(this.light.matrixWorld),bN.setFromMatrixPosition(this.light.target.matrixWorld),wN.subVectors(bN,yN),this.lightPlane.lookAt(bN),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(bN),this.targetLine.scale.z=wN.length()}}const SN=new d_,MN=new bE;class _N extends lI{constructor(e){const t=new YA,n=new $T({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],i=[],o={};function a(e,t){s(e),s(t)}function s(e){r.push(0,0,0),i.push(0,0,0),void 0===o[e]&&(o[e]=[]),o[e].push(r.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),t.setAttribute("position",new FA(r,3)),t.setAttribute("color",new FA(i,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const l=new QM(16755200),c=new QM(16711680),u=new QM(43775),d=new QM(16777215),f=new QM(3355443);this.setColors(l,c,u,d,f)}setColors(e,t,n,r,i){const o=this.geometry.getAttribute("color");o.setXYZ(0,e.r,e.g,e.b),o.setXYZ(1,e.r,e.g,e.b),o.setXYZ(2,e.r,e.g,e.b),o.setXYZ(3,e.r,e.g,e.b),o.setXYZ(4,e.r,e.g,e.b),o.setXYZ(5,e.r,e.g,e.b),o.setXYZ(6,e.r,e.g,e.b),o.setXYZ(7,e.r,e.g,e.b),o.setXYZ(8,e.r,e.g,e.b),o.setXYZ(9,e.r,e.g,e.b),o.setXYZ(10,e.r,e.g,e.b),o.setXYZ(11,e.r,e.g,e.b),o.setXYZ(12,e.r,e.g,e.b),o.setXYZ(13,e.r,e.g,e.b),o.setXYZ(14,e.r,e.g,e.b),o.setXYZ(15,e.r,e.g,e.b),o.setXYZ(16,e.r,e.g,e.b),o.setXYZ(17,e.r,e.g,e.b),o.setXYZ(18,e.r,e.g,e.b),o.setXYZ(19,e.r,e.g,e.b),o.setXYZ(20,e.r,e.g,e.b),o.setXYZ(21,e.r,e.g,e.b),o.setXYZ(22,e.r,e.g,e.b),o.setXYZ(23,e.r,e.g,e.b),o.setXYZ(24,t.r,t.g,t.b),o.setXYZ(25,t.r,t.g,t.b),o.setXYZ(26,t.r,t.g,t.b),o.setXYZ(27,t.r,t.g,t.b),o.setXYZ(28,t.r,t.g,t.b),o.setXYZ(29,t.r,t.g,t.b),o.setXYZ(30,t.r,t.g,t.b),o.setXYZ(31,t.r,t.g,t.b),o.setXYZ(32,n.r,n.g,n.b),o.setXYZ(33,n.r,n.g,n.b),o.setXYZ(34,n.r,n.g,n.b),o.setXYZ(35,n.r,n.g,n.b),o.setXYZ(36,n.r,n.g,n.b),o.setXYZ(37,n.r,n.g,n.b),o.setXYZ(38,r.r,r.g,r.b),o.setXYZ(39,r.r,r.g,r.b),o.setXYZ(40,i.r,i.g,i.b),o.setXYZ(41,i.r,i.g,i.b),o.setXYZ(42,i.r,i.g,i.b),o.setXYZ(43,i.r,i.g,i.b),o.setXYZ(44,i.r,i.g,i.b),o.setXYZ(45,i.r,i.g,i.b),o.setXYZ(46,i.r,i.g,i.b),o.setXYZ(47,i.r,i.g,i.b),o.setXYZ(48,i.r,i.g,i.b),o.setXYZ(49,i.r,i.g,i.b),o.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap;MN.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),AN("c",t,e,MN,0,0,-1),AN("t",t,e,MN,0,0,1),AN("n1",t,e,MN,-1,-1,-1),AN("n2",t,e,MN,1,-1,-1),AN("n3",t,e,MN,-1,1,-1),AN("n4",t,e,MN,1,1,-1),AN("f1",t,e,MN,-1,-1,1),AN("f2",t,e,MN,1,-1,1),AN("f3",t,e,MN,-1,1,1),AN("f4",t,e,MN,1,1,1),AN("u1",t,e,MN,.7,1.1,-1),AN("u2",t,e,MN,-.7,1.1,-1),AN("u3",t,e,MN,0,2,-1),AN("cf1",t,e,MN,-1,0,1),AN("cf2",t,e,MN,1,0,1),AN("cf3",t,e,MN,0,-1,1),AN("cf4",t,e,MN,0,1,1),AN("cn1",t,e,MN,-1,0,-1),AN("cn2",t,e,MN,1,0,-1),AN("cn3",t,e,MN,0,-1,-1),AN("cn4",t,e,MN,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function AN(e,t,n,r,i,o,a){SN.set(i,o,a).unproject(r);const s=t[e];if(void 0!==s){const e=n.getAttribute("position");for(let t=0,n=s.length;t<n;t++)e.setXYZ(s[t],SN.x,SN.y,SN.z)}}const EN=new p_;class CN extends lI{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),i=new YA;i.setIndex(new IA(n,1)),i.setAttribute("position",new IA(r,3)),super(i,new $T({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&EN.setFromObject(this.object),EN.isEmpty())return;const t=EN.min,n=EN.max,r=this.geometry.attributes.position,i=r.array;i[0]=n.x,i[1]=n.y,i[2]=n.z,i[3]=t.x,i[4]=n.y,i[5]=n.z,i[6]=t.x,i[7]=t.y,i[8]=n.z,i[9]=n.x,i[10]=t.y,i[11]=n.z,i[12]=n.x,i[13]=n.y,i[14]=t.z,i[15]=t.x,i[16]=n.y,i[17]=t.z,i[18]=t.x,i[19]=t.y,i[20]=t.z,i[21]=n.x,i[22]=t.y,i[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}}class kN extends lI{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new YA;r.setIndex(new IA(n,1)),r.setAttribute("position",new FA([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(r,new $T({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}}class TN extends oI{constructor(e,t=1,n=16776960){const r=n,i=new YA;i.setAttribute("position",new FA([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),i.computeBoundingSphere(),super(i,new $T({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=new YA;o.setAttribute("position",new FA([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),o.computeBoundingSphere(),this.add(new fE(o,new CA({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}}const IN=new d_;let ON,RN;class PN extends hA{constructor(e=new d_(0,0,1),t=new d_(0,0,0),n=1,r=16776960,i=.2*n,o=.2*i){super(),this.type="ArrowHelper",void 0===ON&&(ON=new YA,ON.setAttribute("position",new FA([0,0,0,0,1,0],3)),RN=new qI(0,.5,1,5,1),RN.translate(0,-.5,0)),this.position.copy(t),this.line=new oI(ON,new $T({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new fE(RN,new CA({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,i,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{IN.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(IN,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}}class NN extends lI{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new YA;n.setAttribute("position",new FA(t,3)),n.setAttribute("color",new FA([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(n,new $T({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){const r=new QM,i=this.geometry.attributes.color.array;return r.set(e),r.toArray(i,0),r.toArray(i,3),r.set(t),r.toArray(i,6),r.toArray(i,9),r.set(n),r.toArray(i,12),r.toArray(i,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class LN{constructor(){this.type="ShapePath",this.color=new QM,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new HI,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,i,o){return this.currentPath.bezierCurveTo(e,t,n,r,i,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const n=t.length;let r=!1;for(let i=n-1,o=0;o<n;i=o++){let n=t[i],a=t[o],s=a.x-n.x,l=a.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=t[o],s=-s,a=t[i],l=-l),e.y<n.y||e.y>a.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-s*(e.y-n.y);if(0===t)return!0;if(t<0)continue;r=!r}}else{if(e.y!==n.y)continue;if(a.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=a.x)return!0}}return r}const n=CO.isClockWise,r=this.subPaths;if(0===r.length)return[];let i,o,a;const s=[];if(1===r.length)return o=r[0],a=new tO,a.curves=o.curves,s.push(a),s;let l=!n(r[0].getPoints());l=e?!l:l;const c=[],u=[];let d,f,h=[],p=0;u[p]=void 0,h[p]=[];for(let t=0,a=r.length;t<a;t++)o=r[t],d=o.getPoints(),i=n(d),i=e?!i:i,i?(!l&&u[p]&&p++,u[p]={s:new tO,p:d},u[p].s.curves=o.curves,l&&p++,h[p]=[]):h[p].push({h:o,p:d[0]});if(!u[0])return function(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n],i=new tO;i.curves=r.curves,t.push(i)}return t}(r);if(u.length>1){let e=!1,n=0;for(let e=0,t=u.length;e<t;e++)c[e]=[];for(let r=0,i=u.length;r<i;r++){const i=h[r];for(let o=0;o<i.length;o++){const a=i[o];let s=!0;for(let i=0;i<u.length;i++)t(a.p,u[i].p)&&(r!==i&&n++,s?(s=!1,c[i].push(a)):e=!0);s&&c[r].push(a)}}n>0&&!1===e&&(h=c)}for(let e=0,t=u.length;e<t;e++){a=u[e].s,s.push(a),f=h[e];for(let e=0,t=f.length;e<t;e++)a.holes.push(f[e].h)}return s}}const DN=BN();function BN(){const e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(r[e]=0,r[256|e]=32768,i[e]=24,i[256|e]=24):t<-14?(r[e]=1024>>-t-14,r[256|e]=1024>>-t-14|32768,i[e]=-t-1,i[256|e]=-t-1):t<=15?(r[e]=t+15<<10,r[256|e]=t+15<<10|32768,i[e]=13,i[256|e]=13):t<128?(r[e]=31744,r[256|e]=64512,i[e]=24,i[256|e]=24):(r[e]=31744,r[256|e]=64512,i[e]=13,i[256|e]=13)}const o=new Uint32Array(2048),a=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;0==(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,o[e]=t|n}for(let e=1024;e<2048;++e)o[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)a[e]=e<<23;a[31]=1199570944,a[32]=2147483648;for(let e=33;e<63;++e)a[e]=2147483648+(e-32<<23);a[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:o,exponentTable:a,offsetTable:s}}var jN=Object.freeze({__proto__:null,toHalfFloat:function(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=AM(e,-65504,65504),DN.floatView[0]=e;const t=DN.uint32View[0],n=t>>23&511;return DN.baseTable[n]+((8388607&t)>>DN.shiftTable[n])},fromHalfFloat:function(e){const t=e>>10;return DN.uint32View[0]=DN.mantissaTable[DN.offsetTable[t]+(1023&e)]+DN.exponentTable[t],DN.floatView[0]}});function FN(){console.error("THREE.ImmediateRenderObject has been removed.")}class UN extends i_{constructor(e,t,n){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,n),this.samples=4}}class zN extends o_{constructor(e,t,n,r){console.warn("THREE.DataTexture2DArray has been renamed to DataArrayTexture."),super(e,t,n,r)}}class HN extends s_{constructor(e,t,n,r){console.warn("THREE.DataTexture3D has been renamed to Data3DTexture."),super(e,t,n,r)}}class VN extends pE{constructor(e,t,n,r,i,o){console.warn("THREE.BoxBufferGeometry has been renamed to THREE.BoxGeometry."),super(e,t,n,r,i,o)}}class WN extends WI{constructor(e,t,n,r){console.warn("THREE.CapsuleBufferGeometry has been renamed to THREE.CapsuleGeometry."),super(e,t,n,r)}}class GN extends GI{constructor(e,t,n,r){console.warn("THREE.CircleBufferGeometry has been renamed to THREE.CircleGeometry."),super(e,t,n,r)}}class qN extends KI{constructor(e,t,n,r,i,o,a){console.warn("THREE.ConeBufferGeometry has been renamed to THREE.ConeGeometry."),super(e,t,n,r,i,o,a)}}class KN extends qI{constructor(e,t,n,r,i,o,a,s){console.warn("THREE.CylinderBufferGeometry has been renamed to THREE.CylinderGeometry."),super(e,t,n,r,i,o,a,s)}}class YN extends JI{constructor(e,t){console.warn("THREE.DodecahedronBufferGeometry has been renamed to THREE.DodecahedronGeometry."),super(e,t)}}class JN extends IO{constructor(e,t){console.warn("THREE.ExtrudeBufferGeometry has been renamed to THREE.ExtrudeGeometry."),super(e,t)}}class QN extends RO{constructor(e,t){console.warn("THREE.IcosahedronBufferGeometry has been renamed to THREE.IcosahedronGeometry."),super(e,t)}}class XN extends VI{constructor(e,t,n,r){console.warn("THREE.LatheBufferGeometry has been renamed to THREE.LatheGeometry."),super(e,t,n,r)}}class ZN extends PO{constructor(e,t){console.warn("THREE.OctahedronBufferGeometry has been renamed to THREE.OctahedronGeometry."),super(e,t)}}class $N extends NE{constructor(e,t,n,r){console.warn("THREE.PlaneBufferGeometry has been renamed to THREE.PlaneGeometry."),super(e,t,n,r)}}class eL extends YI{constructor(e,t,n,r){console.warn("THREE.PolyhedronBufferGeometry has been renamed to THREE.PolyhedronGeometry."),super(e,t,n,r)}}class tL extends NO{constructor(e,t,n,r,i,o){console.warn("THREE.RingBufferGeometry has been renamed to THREE.RingGeometry."),super(e,t,n,r,i,o)}}class nL extends LO{constructor(e,t){console.warn("THREE.ShapeBufferGeometry has been renamed to THREE.ShapeGeometry."),super(e,t)}}class rL extends DO{constructor(e,t,n,r,i,o,a){console.warn("THREE.SphereBufferGeometry has been renamed to THREE.SphereGeometry."),super(e,t,n,r,i,o,a)}}class iL extends BO{constructor(e,t){console.warn("THREE.TetrahedronBufferGeometry has been renamed to THREE.TetrahedronGeometry."),super(e,t)}}class oL extends jO{constructor(e,t,n,r,i){console.warn("THREE.TorusBufferGeometry has been renamed to THREE.TorusGeometry."),super(e,t,n,r,i)}}class aL extends FO{constructor(e,t,n,r,i,o){console.warn("THREE.TorusKnotBufferGeometry has been renamed to THREE.TorusKnotGeometry."),super(e,t,n,r,i,o)}}class sL extends UO{constructor(e,t,n,r,i){console.warn("THREE.TubeBufferGeometry has been renamed to THREE.TubeGeometry."),super(e,t,n,r,i)}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:cw}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=cw);const lL=new WeakMap;class cL extends _R{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,r){const i=new CR(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(e=>{const n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,n).then(t).catch(r)}),n,r)}decodeDracoFile(e,t,n,r){const i={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,i).then(t)}decodeGeometry(e,t){for(const e in t.attributeTypes){const n=t.attributeTypes[e];void 0!==n.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=n.name)}const n=JSON.stringify(t);if(lL.has(e)){const t=lL.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const i=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(i,o).then((n=>(r=n,new Promise(((n,o)=>{r._callbacks[i]={resolve:n,reject:o},r.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return a.catch((()=>!0)).then((()=>{r&&i&&this._releaseTask(r,i)})),lL.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new YA;e.index&&t.setIndex(new IA(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n],i=r.name,o=r.array,a=r.itemSize;t.setAttribute(i,new IA(o,a))}return t}_loadLibrary(e,t){const n=new CR(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,r)=>{n.load(e,t,void 0,r)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,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((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const r=uL.toString(),i=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._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}}function uL(){let e,t;function n(e,t,n,r,i,o){const a=o.num_components(),s=n.num_points()*a,l=s*i.BYTES_PER_ELEMENT,c=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,i),u=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,o,c,l,u);const d=new i(e.HEAPF32.buffer,u,s).slice();return e._free(u),{name:r,array:d,itemSize:a}}onmessage=function(r){const i=r.data;switch(i.type){case"init":e=i.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=i.buffer,o=i.taskConfig;t.then((e=>{const t=e.draco,a=new t.Decoder,s=new t.DecoderBuffer;s.Init(new Int8Array(r),r.byteLength);try{const e=function(e,t,r,i){const o=i.attributeIDs,a=i.attributeTypes;let s,l;const c=t.GetEncodedGeometryType(r);if(c===e.TRIANGULAR_MESH)s=new e.Mesh,l=t.DecodeBufferToMesh(r,s);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");s=new e.PointCloud,l=t.DecodeBufferToPointCloud(r,s)}if(!l.ok()||0===s.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const u={index:null,attributes:[]};for(const r in o){const l=self[a[r]];let c,d;if(i.useUniqueIDs)d=o[r],c=t.GetAttributeByUniqueId(s,d);else{if(d=t.GetAttributeId(s,e[o[r]]),-1===d)continue;c=t.GetAttribute(s,d)}u.attributes.push(n(e,t,s,r,l,c))}c===e.TRIANGULAR_MESH&&(u.index=function(e,t,n){const r=n.num_faces(),i=3*r,o=4*i,a=e._malloc(o);t.GetTrianglesUInt32Array(n,o,a);const s=new Uint32Array(e.HEAPF32.buffer,a,i).slice();return e._free(a),{array:s,itemSize:1}}(e,t,s));return e.destroy(s),u}(t,a,s,o),r=e.attributes.map((e=>e.array.buffer));e.index&&r.push(e.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:e},r)}catch(e){console.error(e),self.postMessage({type:"error",id:i.id,error:e.message})}finally{t.destroy(s),t.destroy(a)}}))}}}class dL extends _R{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new vL(e)})),this.register((function(e){return new _L(e)})),this.register((function(e){return new AL(e)})),this.register((function(e){return new bL(e)})),this.register((function(e){return new wL(e)})),this.register((function(e){return new xL(e)})),this.register((function(e){return new SL(e)})),this.register((function(e){return new gL(e)})),this.register((function(e){return new ML(e)})),this.register((function(e){return new yL(e)})),this.register((function(e){return new pL(e)})),this.register((function(e){return new EL(e)}))}load(e,t,n,r){const i=this;let o;o=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:eP.extractUrlBase(e),this.manager.itemStart(e);const a=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new CR(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(n){try{i.parse(n,o,(function(n){t(n),i.manager.itemEnd(e)}),a)}catch(e){a(e)}}),n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i;const o={},a={};if("string"==typeof e)i=e;else{if(eP.decodeText(new Uint8Array(e,0,4))===CL){try{o[hL.KHR_BINARY_GLTF]=new IL(e)}catch(e){return void(r&&r(e))}i=o[hL.KHR_BINARY_GLTF].content}else i=eP.decodeText(new Uint8Array(e))}const s=JSON.parse(i);if(void 0===s.asset||s.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new lD(s,{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 e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);a[t.name]=t,o[t.name]=!0}if(s.extensionsUsed)for(let e=0;e<s.extensionsUsed.length;++e){const t=s.extensionsUsed[e],n=s.extensionsRequired||[];switch(t){case hL.KHR_MATERIALS_UNLIT:o[t]=new mL;break;case hL.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:o[t]=new NL;break;case hL.KHR_DRACO_MESH_COMPRESSION:o[t]=new OL(s,this.dracoLoader);break;case hL.KHR_TEXTURE_TRANSFORM:o[t]=new RL;break;case hL.KHR_MESH_QUANTIZATION:o[t]=new LL;break;default:n.indexOf(t)>=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,r)}parseAsync(e,t){const n=this;return new Promise((function(r,i){n.parse(e,t,r,i)}))}}function fL(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const hL={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_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",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_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_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class pL{constructor(e){this.parser=e,this.name=hL.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const i=t.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let a;const s=new QM(16777215);void 0!==o.color&&s.fromArray(o.color);const l=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new YR(s),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new qR(s),a.distance=l;break;case"spot":a=new zR(s),a.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),a.decay=2,void 0!==o.intensity&&(a.intensity=o.intensity),a.name=t.createUniqueName(o.name||"light_"+e),r=Promise.resolve(a),t.cache.add(n,r),r}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(e){return n._getNodeRef(t.cache,i,e)}))}}class mL{constructor(){this.name=hL.KHR_MATERIALS_UNLIT}getMaterialType(){return CA}extendParams(e,t,n){const r=[];e.color=new QM(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(e,"map",i.baseColorTexture,BS))}return Promise.all(r)}}class gL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name].emissiveStrength;return void 0!==r&&(t.emissiveIntensity=r),Promise.resolve()}}class vL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];if(void 0!==o.clearcoatFactor&&(t.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&i.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(i.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const e=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new NM(e,e)}return Promise.all(i)}}class yL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];return void 0!==o.iridescenceFactor&&(t.iridescence=o.iridescenceFactor),void 0!==o.iridescenceTexture&&i.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),void 0!==o.iridescenceIor&&(t.iridescenceIOR=o.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==o.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),void 0!==o.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),void 0!==o.iridescenceThicknessTexture&&i.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class bL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new QM(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=r.extensions[this.name];return void 0!==o.sheenColorFactor&&t.sheenColor.fromArray(o.sheenColorFactor),void 0!==o.sheenRoughnessFactor&&(t.sheenRoughness=o.sheenRoughnessFactor),void 0!==o.sheenColorTexture&&i.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,BS)),void 0!==o.sheenRoughnessTexture&&i.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class wL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];return void 0!==o.transmissionFactor&&(t.transmission=o.transmissionFactor),void 0!==o.transmissionTexture&&i.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class xL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];t.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&i.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new QM(a[0],a[1],a[2]),Promise.all(i)}}class SL{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class ML{constructor(e){this.parser=e,this.name=hL.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?KO:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];t.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&i.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new QM(a[0],a[1],a[2]),void 0!==o.specularColorTexture&&i.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,BS)),Promise.all(i)}}class _L{constructor(e){this.parser=e,this.name=hL.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const i=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){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,i.source,o)}}class AL{constructor(e){this.parser=e,this.name=hL.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],a=r.images[o.source];let s=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(s=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,o.source,s);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class EL{constructor(e){this.name=hL.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 e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.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(t){const n=e.byteOffset||0,r=e.byteLength||0,o=e.count,a=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(o,a,s,e.mode,e.filter).then((function(e){return e.buffer})):i.ready.then((function(){const t=new ArrayBuffer(o*a);return i.decodeGltfBuffer(new Uint8Array(t),o,a,s,e.mode,e.filter),t}))}))}return null}}const CL="glTF",kL=1313821514,TL=5130562;class IL{constructor(e){this.name=hL.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:eP.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==CL)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(e,12);let i=0;for(;i<n;){const t=r.getUint32(i,!0);i+=4;const n=r.getUint32(i,!0);if(i+=4,n===kL){const n=new Uint8Array(e,12+i,t);this.content=eP.decodeText(n)}else if(n===TL){const n=12+i;this.body=e.slice(n,n+t)}i+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class OL{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=hL.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},s={},l={};for(const e in o){const t=QL[e]||e.toLowerCase();a[t]=o[e]}for(const t in e.attributes){const r=QL[t]||t.toLowerCase();if(void 0!==o[t]){const i=n.accessors[e.attributes[t]],o=qL[i.componentType];l[r]=o.name,s[r]=!0===i.normalized}}return t.getDependency("bufferView",i).then((function(e){return new Promise((function(t){r.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],r=s[t];void 0!==r&&(n.normalized=r)}t(e)}),a,l)}))}))}}class RL{constructor(){this.name=hL.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class PL extends qO{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const t=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),n=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),r=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),i=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),o=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),a={specular:{value:(new QM).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(e){for(const t in a)e.uniforms[t]=a[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",r).replace("#include <metalnessmap_fragment>",i).replace("#include <lights_physical_fragment>",o)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(e){a.specular.value=e}},specularMap:{get:function(){return a.specularMap.value},set:function(e){a.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(e){a.glossiness.value=e}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(e){a.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class NL{constructor(){this.name=hL.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return PL}extendParams(e,t,n){const r=t.extensions[this.name];e.color=new QM(1,1,1),e.opacity=1;const i=[];if(Array.isArray(r.diffuseFactor)){const t=r.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==r.diffuseTexture&&i.push(n.assignTexture(e,"map",r.diffuseTexture,BS)),e.emissive=new QM(0,0,0),e.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,e.specular=new QM(1,1,1),Array.isArray(r.specularFactor)&&e.specular.fromArray(r.specularFactor),void 0!==r.specularGlossinessTexture){const t=r.specularGlossinessTexture;i.push(n.assignTexture(e,"glossinessMap",t)),i.push(n.assignTexture(e,"specularMap",t,BS))}return Promise.all(i)}createMaterial(e){const t=new PL(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=void 0===e.emissiveIntensity?1:e.emissiveIntensity,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=US,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}}class LL{constructor(){this.name=hL.KHR_MESH_QUANTIZATION}}class DL extends sR{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=2*a,l=3*a,c=r-t,u=(n-t)/c,d=u*u,f=d*u,h=e*l,p=h-l,m=-2*f+3*d,g=f-d,v=1-m,y=g-d+u;for(let e=0;e!==a;e++){const t=o[p+e+a],n=o[p+e+s]*c,r=o[h+e+a],l=o[h+e]*c;i[e]=v*t+y*n+m*r+g*l}return i}}const BL=new u_;class jL extends DL{interpolate_(e,t,n,r){const i=super.interpolate_(e,t,n,r);return BL.fromArray(i).normalize().toArray(i),i}}const FL=0,UL=1,zL=2,HL=3,VL=4,WL=5,GL=6,qL={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},KL={9728:vx,9729:Sx,9984:yx,9985:Mx,9986:wx,9987:Ax},YL={33071:mx,33648:gx,10497:px},JL={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},QL={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},XL={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ZL={CUBICSPLINE:void 0,LINEAR:ES,STEP:AS},$L="OPAQUE",eD="MASK",tD="BLEND";function nD(e,t,n){for(const r in n.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function rD(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function iD(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function oD(e){const t=e.extensions&&e.extensions[hL.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+aD(t.attributes):e.indices+":"+aD(e.attributes)+":"+e.mode,n}function aD(e){let t="";const n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+":"+e[n[r]]+";";return t}function sD(e){switch(e){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.")}}class lD{constructor(e={},t={}){var n,r;this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new fL,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};const i="undefined"!=typeof navigator&&!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),o="undefined"!=typeof navigator&&(null===(n=navigator.userAgent)||void 0===n?void 0:n.indexOf("Firefox"))>-1,a="undefined"!=typeof navigator&&o?null===(r=navigator.userAgent)||void 0===r?void 0:r.match(/Firefox\/([0-9]+)\./)[1]:-1;"undefined"==typeof createImageBitmap||i||o&&a<98?this.textureLoader=new PR(this.options.manager):this.textureLoader=new sP(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new CR(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const o={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};nD(i,o,r),rD(o,r),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(o)}))).then((function(){e(o)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){const r=e[t];void 0!==r.mesh&&(this._addNodeRef(this.meshCache,r.mesh),void 0!==r.skin&&(n[r.mesh].isSkinnedMesh=!0)),void 0!==r.camera&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),i=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this.loadNode(t);break;case"mesh":r=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":r=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":r=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map((function(t,r){return n.getDependency(e,r)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[hL.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(e,i){n.load(eP.resolveURL(t.uri,r.path),e,void 0,(function(){i(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(e){const n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)}))}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse)return Promise.resolve(null);const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then((function(e){const i=e[0],o=JL[r.type],a=qL[r.componentType],s=a.BYTES_PER_ELEMENT,l=s*o,c=r.byteOffset||0,u=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,d=!0===r.normalized;let f,h;if(u&&u!==l){const e=Math.floor(c/u),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let l=t.cache.get(n);l||(f=new a(i,e*u,r.count*u/s),l=new pT(f,u/s),t.cache.add(n,l)),h=new gT(l,o,c%u/s,d)}else f=null===i?new a(r.count*o):new a(i,c,r.count*o),h=new IA(f,o,d);if(void 0!==r.sparse){const t=JL.SCALAR,n=qL[r.sparse.indices.componentType],s=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,c=new n(e[1],s,r.sparse.count*t),u=new a(e[2],l,r.sparse.count*o);null!==i&&(h=new IA(h.array.slice(),h.itemSize,h.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(h.setX(t,u[e*o]),o>=2&&h.setY(t,u[e*o+1]),o>=3&&h.setZ(t,u[e*o+2]),o>=4&&h.setW(t,u[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return h}))}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r];let o=this.textureLoader;if(i.uri){const e=n.manager.getHandler(i.uri);null!==e&&(o=e)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){const r=this,i=this.json,o=i.textures[e],a=i.images[t],s=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[s])return this.textureCache[s];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,o.name&&(t.name=o.name);const n=(i.samplers||{})[o.sampler]||{};return t.magFilter=KL[n.magFilter]||Sx,t.minFilter=KL[n.minFilter]||Ax,t.wrapS=YL[n.wrapS]||px,t.wrapT=YL[n.wrapT]||px,r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[s]=l,l}loadImageSource(e,t){const n=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const i=n.images[e],o=self.URL||self.webkitURL;let a=i.uri||"",s=!1;if(void 0!==i.bufferView)a=this.getDependency("bufferView",i.bufferView).then((function(e){s=!0;const t=new Blob([e],{type:i.mimeType});return a=o.createObjectURL(t),a}));else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(a).then((function(e){return new Promise((function(n,i){let o=n;!0===t.isImageBitmapLoader&&(o=function(e){const t=new n_(e);t.needsUpdate=!0,n(t)}),t.load(eP.resolveURL(e,r.path),o,void 0,i)}))})).then((function(e){var t;return!0===s&&o.revokeObjectURL(a),e.userData.mimeType=i.mimeType||((t=i.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){const i=this;return this.getDependency("texture",n.index).then((function(o){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),i.extensions[hL.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[hL.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(o);o=i.extensions[hL.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),i.associations.set(o,t)}}return void 0!==r&&(o.encoding=r),e[t]=o,o}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new uI,EA.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new $T,EA.prototype.copy.call(t,n),t.color.copy(n.color),this.cache.add(e,t)),n=t}if(r||i||o){let e="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return qO}loadMaterial(e){const t=this,n=this.json,r=this.extensions,i=n.materials[e];let o;const a={},s=i.extensions||{},l=[];if(s[hL.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=r[hL.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];o=e.getMaterialType(),l.push(e.extendParams(a,i,t))}else if(s[hL.KHR_MATERIALS_UNLIT]){const e=r[hL.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),l.push(e.extendParams(a,i,t))}else{const n=i.pbrMetallicRoughness||{};if(a.color=new QM(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.fromArray(e),a.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(a,"map",n.baseColorTexture,BS)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),o=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===i.doubleSided&&(a.side=Sw);const c=i.alphaMode||$L;if(c===tD?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===eD&&(a.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&o!==CA&&(l.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new NM(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==i.occlusionTexture&&o!==CA&&(l.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(a.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&o!==CA&&(a.emissive=(new QM).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&o!==CA&&l.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,BS)),Promise.all(l).then((function(){let n;return n=o===PL?r[hL.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new o(a),i.name&&(n.name=i.name),rD(n,i),t.associations.set(n,{materials:e}),i.extensions&&nD(r,n,i),n}))}createUniqueName(e){const t=jP.sanitizeNodeName(e||"");let n=t;for(let e=1;this.nodeNamesUsed[n];++e)n=t+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[hL.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return uD(n,e,t)}))}const o=[];for(let n=0,a=e.length;n<a;n++){const a=e[n],s=oD(a),l=r[s];if(l)o.push(l.promise);else{let e;e=a.extensions&&a.extensions[hL.KHR_DRACO_MESH_COMPRESSION]?i(a):uD(new YA,a,t),r[s]={primitive:a,promise:e},o.push(e)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,r=this.extensions,i=n.meshes[e],o=i.primitives,a=[];for(let e=0,t=o.length;e<t;e++){const t=void 0===o[e].material?(void 0===(s=this.cache).DefaultMaterial&&(s.DefaultMaterial=new qO({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ww})),s.DefaultMaterial):this.getDependency("material",o[e].material);a.push(t)}var s;return a.push(t.loadGeometries(o)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),s=n[n.length-1],l=[];for(let n=0,c=s.length;n<c;n++){const c=s[n],u=o[n];let d;const f=a[n];if(u.mode===VL||u.mode===WL||u.mode===GL||void 0===u.mode)d=!0===i.isSkinnedMesh?new zT(c,f):new fE(c,f),!0!==d.isSkinnedMesh||d.geometry.attributes.skinWeight.normalized||d.normalizeSkinWeights(),u.mode===WL?d.geometry=dD(d.geometry,NS):u.mode===GL&&(d.geometry=dD(d.geometry,LS));else if(u.mode===UL)d=new lI(c,f);else if(u.mode===HL)d=new oI(c,f);else if(u.mode===zL)d=new cI(c,f);else{if(u.mode!==FL)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);d=new mI(c,f)}Object.keys(d.geometry.morphAttributes).length>0&&iD(d,i),d.name=t.createUniqueName(i.name||"mesh_"+e),rD(d,i),u.extensions&&nD(r,d,u),t.assignFinalMaterial(d),l.push(d)}for(let n=0,r=l.length;n<r;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return l[0];const c=new nT;t.associations.set(c,{meshes:e});for(let e=0,t=l.length;e<t;e++)c.add(l[e]);return c}))}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(r)return"perspective"===n.type?t=new wE(PM.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(t=new WE(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),rD(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(n):this.getDependency("accessor",t.inverseBindMatrices).then((function(e){return n.inverseBindMatrices=e,n}))}loadAnimation(e){const t=this.json.animations[e],n=[],r=[],i=[],o=[],a=[];for(let e=0,s=t.channels.length;e<s;e++){const s=t.channels[e],l=t.samplers[s.sampler],c=s.target,u=c.node,d=void 0!==t.parameters?t.parameters[l.input]:l.input,f=void 0!==t.parameters?t.parameters[l.output]:l.output;n.push(this.getDependency("node",u)),r.push(this.getDependency("accessor",d)),i.push(this.getDependency("accessor",f)),o.push(l),a.push(c)}return Promise.all([Promise.all(n),Promise.all(r),Promise.all(i),Promise.all(o),Promise.all(a)]).then((function(n){const r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=[];for(let e=0,t=r.length;e<t;e++){const t=r[e],n=i[e],c=o[e],u=a[e],d=s[e];if(void 0===t)continue;let f;switch(t.updateMatrix(),XL[d.path]){case XL.weights:f=pR;break;case XL.rotation:f=gR;break;default:f=yR}const h=t.name?t.name:t.uuid,p=void 0!==u.interpolation?ZL[u.interpolation]:ES,m=[];XL[d.path]===XL.weights?t.traverse((function(e){e.morphTargetInfluences&&m.push(e.name?e.name:e.uuid)})):m.push(h);let g=c.array;if(c.normalized){const e=sD(g.constructor),t=new Float32Array(g.length);for(let n=0,r=g.length;n<r;n++)t[n]=g[n]*e;g=t}for(let e=0,t=m.length;e<t;e++){const t=new f(m[e]+"."+XL[d.path],n.array,g,p);"CUBICSPLINE"===u.interpolation&&(t.createInterpolant=function(e){return new(this instanceof gR?jL:DL)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(t)}}const c=t.name?t.name:"animation_"+e;return new bR(c,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]})),t}))}loadNode(e){const t=this.json,n=this.extensions,r=this,i=t.nodes[e],o=i.name?r.createUniqueName(i.name):"";return function(){const t=[],n=r._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return n&&t.push(n),void 0!==i.camera&&t.push(r.getDependency("camera",i.camera).then((function(e){return r._getNodeRef(r.cameraCache,i.camera,e)}))),r._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let a;if(a=!0===i.isBone?new HT:t.length>1?new nT:1===t.length?t[0]:new hA,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(i.name&&(a.userData.name=i.name,a.name=o),rD(a,i),i.extensions&&nD(n,a,i),void 0!==i.matrix){const e=new H_;e.fromArray(i.matrix),a.applyMatrix4(e)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);return r.associations.has(a)||r.associations.set(a,{}),r.associations.get(a).nodes=e,a}))}loadScene(e){const t=this.json,n=this.extensions,r=this.json.scenes[e],i=this,o=new nT;r.name&&(o.name=i.createUniqueName(r.name)),rD(o,r),r.extensions&&nD(n,o,r);const a=r.nodes||[],s=[];for(let e=0,n=a.length;e<n;e++)s.push(cD(a[e],o,t,i));return Promise.all(s).then((function(){return i.associations=(e=>{const t=new Map;for(const[e,n]of i.associations)(e instanceof EA||e instanceof n_)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(o),o}))}}function cD(e,t,n,r){const i=n.nodes[e];return r.getDependency("node",e).then((function(e){if(void 0===i.skin)return e;let t;return r.getDependency("skin",i.skin).then((function(e){t=e;const n=[];for(let e=0,i=t.joints.length;e<i;e++)n.push(r.getDependency("node",t.joints[e]));return Promise.all(n)})).then((function(n){return e.traverse((function(e){if(!e.isMesh)return;const r=[],i=[];for(let e=0,o=n.length;e<o;e++){const o=n[e];if(o){r.push(o);const n=new H_;void 0!==t.inverseBindMatrices&&n.fromArray(t.inverseBindMatrices.array,16*e),i.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}e.bind(new qT(r,i),e.matrixWorld)})),e}))})).then((function(e){t.add(e);const o=[];if(i.children){const t=i.children;for(let i=0,a=t.length;i<a;i++){const a=t[i];o.push(cD(a,e,n,r))}}return Promise.all(o)}))}function uD(e,t,n){const r=t.attributes,i=[];function o(t,r){return n.getDependency("accessor",t).then((function(t){e.setAttribute(r,t)}))}for(const t in r){const n=QL[t]||t.toLowerCase();n in e.attributes||i.push(o(r[t],n))}if(void 0!==t.indices&&!e.index){const r=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));i.push(r)}return rD(e,t),function(e,t,n){const r=t.attributes,i=new p_;if(void 0===r.POSITION)return;{const e=n.json.accessors[r.POSITION],t=e.min,o=e.max;if(void 0===t||void 0===o)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new d_(t[0],t[1],t[2]),new d_(o[0],o[1],o[2])),e.normalized){const t=sD(qL[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}const o=t.targets;if(void 0!==o){const e=new d_,t=new d_;for(let r=0,i=o.length;r<i;r++){const i=o[r];if(void 0!==i.POSITION){const r=n.json.accessors[i.POSITION],o=r.min,a=r.max;if(void 0!==o&&void 0!==a){if(t.setX(Math.max(Math.abs(o[0]),Math.abs(a[0]))),t.setY(Math.max(Math.abs(o[1]),Math.abs(a[1]))),t.setZ(Math.max(Math.abs(o[2]),Math.abs(a[2]))),r.normalized){const e=sD(qL[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(e)}e.boundingBox=i;const a=new P_;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=a}(e,t,n),Promise.all(i).then((function(){return void 0!==t.targets?function(e,t,n){let r=!1,i=!1,o=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(r=!0),void 0!==n.NORMAL&&(i=!0),void 0!==n.COLOR_0&&(o=!0),r&&i&&o)break}if(!r&&!i&&!o)return Promise.resolve(e);const a=[],s=[],l=[];for(let c=0,u=t.length;c<u;c++){const u=t[c];if(r){const t=void 0!==u.POSITION?n.getDependency("accessor",u.POSITION):e.attributes.position;a.push(t)}if(i){const t=void 0!==u.NORMAL?n.getDependency("accessor",u.NORMAL):e.attributes.normal;s.push(t)}if(o){const t=void 0!==u.COLOR_0?n.getDependency("accessor",u.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(a),Promise.all(s),Promise.all(l)]).then((function(t){const n=t[0],a=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=a),o&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}function dD(e,t){let n=e.getIndex();if(null===n){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const r=n.count-2,i=[];if(t===LS)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=e.clone();return o.setIndex(i),o}let fD;const hD=()=>{if(fD)return fD;const e=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]),t=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]);if("object"!=typeof WebAssembly)return{supported:!1};let n,r="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB";WebAssembly.validate(e)&&(r="B9h9z9tFBBBFiI9gBB9gLaaaaaFa9gEaaaB9gFaFaEMcBBFBFFGGGEILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBOn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBNI9z9iqlBVc+N9IcIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMk8lLbaE97F9+FaL978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAeDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAeDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBReCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBH8ZCFD9tA8ZAPD9OD9hD9RH8ZDQBTFtGmEYIPLdKeOnHpAIAQJDBIBHyCFD9tAyAPD9OD9hD9RHyAIASJDBIBH8cCFD9tA8cAPD9OD9hD9RH8cDQBTFtGmEYIPLdKeOnH8dDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAeD9uHeDyBjGBAEAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeApA8dDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNiV8ZcpMyS8cQ8df8eb8fHdAyA8cDQNiV8ZcpMyS8cQ8df8eb8fH8ZDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/dLEK97FaF97GXGXAGCI9HQBAF9FQFCBRGEXABABDBBBHECiD+rFCiD+sFD/6FHIAECND+rFCiD+sFD/6FAID/gFAECTD+rFCiD+sFD/6FHLD/gFD/kFD/lFHKCBDtD+2FHOAICUUUU94DtHND9OD9RD/kFHI9DBB/+hDYAIAID/mFAKAKD/mFALAOALAND9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHLD/mF9DBBX9LDYHOD/kFCgFDtD9OAECUUU94DtD9OD9QAIALD/mFAOD/kFCND+rFCU/+EDtD9OD9QAKALD/mFAOD/kFCTD+rFCUU/8ODtD9OD9QDMBBABCTJRBAGCIJHGAF9JQBSGMMAF9FQBCBRGEXABCTJHVAVDBBBHECBDtHOCUU98D8cFCUU98D8cEHND9OABDBBBHKAEDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAKAEDQBFGENVcMTtmYi8ZpyHECTD+sFD/6FHID/gFAECTD+rFCTD+sFD/6FHLD/gFD/kFD/lFHE9DB/+g6DYALAEAOD+2FHOALCUUUU94DtHcD9OD9RD/kFHLALD/mFAEAED/mFAIAOAIAcD9OD9RD/kFHEAED/mFD/kFD/kFD/jFD/nFHID/mF9DBBX9LDYHOD/kFCTD+rFALAID/mFAOD/kFCggEDtD9OD9QHLAEAID/mFAOD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHEDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAKAND9OALAEDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM/hEIGaF97FaL978jUUUUBCTlREGXAF9FQBCBRIEXAEABDBBBHLABCTJHKDBBBHODQILKOSQfbPden8c8d8e8fHNCTD+sFHVCID+rFDMIBAB9DBBU8/DY9D/zI818/DYAVCEDtD9QD/6FD/nFHVALAODQBFGENVcMTtmYi8ZpyHLCTD+rFCTD+sFD/6FD/mFHOAOD/mFAVALCTD+sFD/6FD/mFHcAcD/mFAVANCTD+rFCTD+sFD/6FD/mFHNAND/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHVD/mF9DBBX9LDYHLD/kFCggEDtHMD9OAcAVD/mFALD/kFCTD+rFD9QHcANAVD/mFALD/kFCTD+rFAOAVD/mFALD/kFAMD9OD9QHVDQBFTtGEmYILPdKOenHLD8dBAEDBIBDyB+t+J83EBABCNJALD8dFAEDBIBDyF+t+J83EBAKAcAVDQNVi8ZcMpySQ8c8dfb8e8fHVD8dBAEDBIBDyG+t+J83EBABCiJAVD8dFAEDBIBDyE+t+J83EBABCAJRBAICIJHIAF9JQBMMM9jFF97GXAGCGrAF9sHG9FQBCBRFEXABABDBBBHECND+rFCND+sFD/6FAECiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBABCTJRBAFCIJHFAG9JQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB");const i=WebAssembly.instantiate(function(e){const n=new Uint8Array(e.length);for(let t=0;t<e.length;++t){const r=e.charCodeAt(t);n[t]=r>96?r-71:r>64?r-65:r>47?r+4:r>46?63:62}let r=0;for(let i=0;i<e.length;++i)n[r++]=n[i]<60?t[n[i]]:64*(n[i]-60)+n[++i];return n.buffer.slice(0,r)}(r),{}).then((e=>{n=e.instance,n.exports.__wasm_call_ctors()}));function o(e,t,r,i,o,a){const s=n.exports.sbrk,l=r+3&-4,c=s(l*i),u=s(o.length),d=new Uint8Array(n.exports.memory.buffer);d.set(o,u);const f=e(c,r,i,u,o.length);if(0===f&&a&&a(c,l,i),t.set(d.subarray(c,c+r*i)),s(c-s(0)),0!==f)throw new Error(`Malformed buffer data: ${f}`)}const a={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},s={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return fD={ready:i,supported:!0,decodeVertexBuffer(e,t,r,i,s){o(n.exports.meshopt_decodeVertexBuffer,e,t,r,i,n.exports[a[s]])},decodeIndexBuffer(e,t,r,i){o(n.exports.meshopt_decodeIndexBuffer,e,t,r,i)},decodeIndexSequence(e,t,r,i){o(n.exports.meshopt_decodeIndexSequence,e,t,r,i)},decodeGltfBuffer(e,t,r,i,l,c){o(n.exports[s[l]],e,t,r,i,n.exports[a[c]])}},fD};u=a("85Hg2");var pD={};Object.defineProperty(pD,"__esModule",{value:!0});u=a("85Hg2");function mD(e){var t,n=new Set,r=function(e,r){var i="function"==typeof e?e(t):e;if(i!==t){var o=t;t=r?i:Object.assign({},t,i),n.forEach((function(e){return e(t,o)}))}},i=function(){return t},o={setState:r,getState:i,subscribe:function(e,r,o){return r||o?function(e,r,o){void 0===r&&(r=i),void 0===o&&(o=Object.is),console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");var a=r(t);function s(){var n=r(t);if(!o(a,n)){var i=a;e(a=n,i)}}return n.add(s),function(){return n.delete(s)}}(e,r,o):(n.add(e),function(){return n.delete(e)})},destroy:function(){return n.clear()}};return t=e(r,i,o),o}var gD="undefined"==typeof window||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent)?u.useEffect:u.useLayoutEffect;pD.default=function(e){var t="function"==typeof e?mD(e):e,n=function(e,n){void 0===e&&(e=t.getState),void 0===n&&(n=Object.is);var r,i=u.useReducer((function(e){return e+1}),0)[1],o=t.getState(),a=u.useRef(o),s=u.useRef(e),l=u.useRef(n),c=u.useRef(!1),d=u.useRef();void 0===d.current&&(d.current=e(o));var f=!1;(a.current!==o||s.current!==e||l.current!==n||c.current)&&(r=e(o),f=!n(d.current,r)),gD((function(){f&&(d.current=r),a.current=o,s.current=e,l.current=n,c.current=!1}));var h=u.useRef(o);gD((function(){var e=function(){try{var e=t.getState(),n=s.current(e);l.current(d.current,n)||(a.current=e,d.current=n,i())}catch(e){c.current=!0,i()}},n=t.subscribe(e);return t.getState()!==h.current&&e(),n}),[]);var p=f?r:d.current;return u.useDebugValue(p),p};return Object.assign(n,t),n[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");var e=[n,t];return{next:function(){var t=e.length<=0;return{value:e.shift(),done:t}}}},n};var vD;vD=a("YtP34");var yD,bD=a("kMsGZ");yD=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(i=r;0!=i--;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(i=r;0!=i--;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;0!=i--;){var a=o[i];if(!e(t[a],n[a]))return!1}return!0}return t!=t&&n!=n};const wD=[];function xD(e,t,n,i=0,o=!1){for(const e of t)if(r(yD)(n,e.args)){if(o)return;if(e.error)throw e.error;if(e.response)return e.response;throw e.promise}const a={args:n,promise:e(...n).then((e=>a.response=null==e||e)).catch((e=>a.error=null!=e?e:"unknown error")).then((()=>{i>0&&setTimeout((()=>{const e=t.indexOf(a);-1!==e&&t.splice(e,1)}),i)}))};if(t.push(a),!o)throw a.promise}function SD(e,...t){if(void 0===t||0===t.length)e.splice(0,e.length);else{const n=e.find((e=>r(yD)(t,e.args)));if(n){const t=e.indexOf(n);-1!==t&&e.splice(t,1)}}}function MD(e,...t){return xD(e,wD,t,MD.lifespan)}MD.lifespan=0,MD.clear=(...e)=>SD(wD,...e),MD.preload=(e,...t)=>{xD(e,wD,t,MD.lifespan,!0)},MD.peek=(...e)=>{var t;return null==(t=wD.find((t=>r(yD)(e,t.args))))?void 0:t.response};var _D;u=a("85Hg2");function AD(e,t,n){var r,i,o,a,s;function l(){var c=Date.now()-a;c<t&&c>=0?r=setTimeout(l,t-c):(r=null,n||(s=e.apply(o,i),o=i=null))}null==t&&(t=100);var c=function(){o=this,i=arguments,a=Date.now();var c=n&&!r;return r||(r=setTimeout(l,t)),c&&(s=e.apply(o,i),o=i=null),s};return c.clear=function(){r&&(clearTimeout(r),r=null)},c.flush=function(){r&&(s=e.apply(o,i),o=i=null,clearTimeout(r),r=null)},c}function ED(e){let{debounce:t,scroll:n,polyfill:i,offsetSize:o}=void 0===e?{debounce:0,scroll:!1,offsetSize:!1}:e;const a=i||("undefined"==typeof window?class{}:window.ResizeObserver);if(!a)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,l]=(0,u.useState)({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),c=(0,u.useRef)({element:null,scrollContainers:null,resizeObserver:null,lastBounds:s}),d=t?"number"==typeof t?t:t.scroll:null,f=t?"number"==typeof t?t:t.resize:null,h=(0,u.useRef)(!1);(0,u.useEffect)((()=>(h.current=!0,()=>{h.current=!1})));const[p,m,g]=(0,u.useMemo)((()=>{const e=()=>{if(!c.current.element)return;const{left:e,top:t,width:n,height:r,bottom:i,right:a,x:s,y:u}=c.current.element.getBoundingClientRect(),d={left:e,top:t,width:n,height:r,bottom:i,right:a,x:s,y:u};c.current.element instanceof HTMLElement&&o&&(d.height=c.current.element.offsetHeight,d.width=c.current.element.offsetWidth),Object.freeze(d),h.current&&!TD(c.current.lastBounds,d)&&l(c.current.lastBounds=d)};return[e,f?r(_D)(e,f):e,d?r(_D)(e,d):e]}),[l,o,d,f]);function v(){c.current.scrollContainers&&(c.current.scrollContainers.forEach((e=>e.removeEventListener("scroll",g,!0))),c.current.scrollContainers=null),c.current.resizeObserver&&(c.current.resizeObserver.disconnect(),c.current.resizeObserver=null)}function y(){c.current.element&&(c.current.resizeObserver=new a(g),c.current.resizeObserver.observe(c.current.element),n&&c.current.scrollContainers&&c.current.scrollContainers.forEach((e=>e.addEventListener("scroll",g,{capture:!0,passive:!0}))))}var b,w,x;return b=g,w=Boolean(n),(0,u.useEffect)((()=>{if(w){const e=b;return window.addEventListener("scroll",e,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",e,!0)}}}),[b,w]),x=m,(0,u.useEffect)((()=>{const e=x;return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[x]),(0,u.useEffect)((()=>{v(),y()}),[n,g,m]),(0,u.useEffect)((()=>v),[]),[e=>{e&&e!==c.current.element&&(v(),c.current.element=e,c.current.scrollContainers=CD(e),y())},s,p]}function CD(e){const t=[];if(!e||e===document.body)return t;const{overflow:n,overflowX:r,overflowY:i}=window.getComputedStyle(e);return[n,r,i].some((e=>"auto"===e||"scroll"===e))&&t.push(e),[...t,...CD(e.parentElement)]}AD.debounce=AD,_D=AD;const kD=["x","y","top","bottom","left","right","width","height"],TD=(e,t)=>kD.every((n=>e[n]===t[n]));const ID={obj:e=>e===Object(e)&&!ID.arr(e)&&"function"!=typeof e,fun:e=>"function"==typeof e,str:e=>"string"==typeof e,num:e=>"number"==typeof e,und:e=>void 0===e,arr:e=>Array.isArray(e),equ(e,t){if(typeof e!=typeof t||!!e!=!!t)return!1;if(ID.str(e)||ID.num(e)||ID.obj(e))return e===t;if(ID.arr(e)&&e==t)return!0;let n;for(n in e)if(!(n in t))return!1;for(n in t)if(e[n]!==t[n])return!1;return!ID.und(n)||e===t}};function OD(e){return(e.eventObject||e.object).uuid+"/"+e.index+e.instanceId}function RD(e,t,n,r){const i=n.get(t);i&&(n.delete(t),0===n.size&&(e.delete(r),i.target.releasePointerCapture(r)))}function PD(e){const t=new lw.Vector3;function n(e){return e.filter((e=>["Move","Over","Enter","Out","Leave"].some((t=>{var n;return null==(n=e.__r3f)?void 0:n.handlers["onPointer"+t]}))))}function r(t){const{internal:n}=e.getState();Array.from(n.hovered.values()).forEach((e=>{if(!t.length||!t.find((t=>t.object===e.object&&t.index===e.index&&t.instanceId===e.instanceId))){const r=e.eventObject.__r3f,i=null==r?void 0:r.handlers;if(n.hovered.delete(OD(e)),null!=r&&r.eventCount){const n={...e,intersections:t||[]};null==i.onPointerOut||i.onPointerOut(n),null==i.onPointerLeave||i.onPointerLeave(n)}}}))}function i(e,t){t.forEach((t=>{var n;return null==(n=t.__r3f)||null==n.handlers.onPointerMissed?void 0:n.handlers.onPointerMissed(e)}))}return{handlePointer:o=>{switch(o){case"onPointerLeave":case"onPointerCancel":return()=>r([]);case"onLostPointerCapture":return t=>{const{internal:n}=e.getState();"pointerId"in t&&!n.capturedMap.has(t.pointerId)&&(n.capturedMap.delete(t.pointerId),r([]))}}return a=>{const{onPointerMissed:s,internal:l}=e.getState();!function(t){var n;const r=e.getState(),{raycaster:i,mouse:o,camera:a,size:s}=r,{offsetX:l,offsetY:c}=null!=(n=null==i.computeOffsets?void 0:i.computeOffsets(t,r))?n:t,{width:u,height:d}=s;o.set(l/u*2-1,-c/d*2+1),i.setFromCamera(o,a)}(a),l.lastEvent.current=a;const c="onPointerMove"===o,u="onClick"===o||"onContextMenu"===o||"onDoubleClick"===o,d=function(t,n){const{internal:r}=e.getState();if("pointerId"in n&&r.capturedMap.has(n.pointerId))for(let e of r.capturedMap.get(n.pointerId).values())t.push(e.intersection);return t}(function(t){const n=e.getState(),{raycaster:r,internal:i}=n;if(!r.enabled)return[];const o=new Set,a=[],s=t?t(i.interaction):i.interaction;let l=r.intersectObjects(s,!0).filter((e=>{const t=OD(e);return!o.has(t)&&(o.add(t),!0)}));r.filter&&(l=r.filter(l,n));for(const e of l){let t=e.object;for(;t;){var c;null!=(c=t.__r3f)&&c.eventCount&&a.push({...e,eventObject:t}),t=t.parent}}return a}(c?n:void 0),a),f=u?function(t){const{internal:n}=e.getState(),r=t.offsetX-n.initialClick[0],i=t.offsetY-n.initialClick[1];return Math.round(Math.sqrt(r*r+i*i))}(a):0;"onPointerDown"===o&&(l.initialClick=[a.offsetX,a.offsetY],l.initialHits=d.map((e=>e.eventObject))),u&&!d.length&&f<=2&&(i(a,l.interaction),s&&s(a)),c&&r(d),function(n,i,o,a){const{raycaster:s,mouse:l,camera:c,internal:u}=e.getState();if(n.length){const e=t.set(l.x,l.y,0).unproject(c),d={stopped:!1};for(const t of n){const f=e=>{var n,r;return null!=(n=null==(r=u.capturedMap.get(e))?void 0:r.has(t.eventObject))&&n},h=e=>{const n={intersection:t,target:i.target};u.capturedMap.has(e)?u.capturedMap.get(e).set(t.eventObject,n):u.capturedMap.set(e,new Map([[t.eventObject,n]])),i.target.setPointerCapture(e)},p=e=>{const n=u.capturedMap.get(e);n&&RD(u.capturedMap,t.eventObject,n,e)};let m={};for(let e in i){let t=i[e];"function"!=typeof t&&(m[e]=t)}let g={...t,...m,spaceX:l.x,spaceY:l.y,intersections:n,stopped:d.stopped,delta:o,unprojectedPoint:e,ray:s.ray,camera:c,stopPropagation:()=>{const e="pointerId"in i&&u.capturedMap.get(i.pointerId);(!e||e.has(t.eventObject))&&(g.stopped=d.stopped=!0,u.hovered.size&&Array.from(u.hovered.values()).find((e=>e.eventObject===t.eventObject)))&&r([...n.slice(0,n.indexOf(t)),t])},target:{hasPointerCapture:f,setPointerCapture:h,releasePointerCapture:p},currentTarget:{hasPointerCapture:f,setPointerCapture:h,releasePointerCapture:p},sourceEvent:i,nativeEvent:i};if(a(g),!0===d.stopped)break}}}(d,a,f,(e=>{const t=e.eventObject,n=t.__r3f,r=null==n?void 0:n.handlers;if(null!=n&&n.eventCount)if(c){if(r.onPointerOver||r.onPointerEnter||r.onPointerOut||r.onPointerLeave){const t=OD(e),n=l.hovered.get(t);n?n.stopped&&e.stopPropagation():(l.hovered.set(t,e),null==r.onPointerOver||r.onPointerOver(e),null==r.onPointerEnter||r.onPointerEnter(e))}null==r.onPointerMove||r.onPointerMove(e)}else{const n=r[o];n?u&&!l.initialHits.includes(t)||(i(a,l.interaction.filter((e=>!l.initialHits.includes(e)))),n(e)):u&&l.initialHits.includes(t)&&i(a,l.interaction.filter((e=>!l.initialHits.includes(e))))}}))}}}}const ND=e=>e&&!!e.getState,LD=(e,t)=>{var n,r;return{root:ND(e)?e:null!=(n=null==(r=e.__r3f)?void 0:r.root)?n:t.__r3f.root,container:ND(e)?e.getState().scene:e}},DD="__default",BD={};let jD={};function FD(e,t){const n=e;return(null!=t&&t.primitive||!n.__r3f)&&(n.__r3f={root:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...t}),e}const UD=e=>e&&e.isOrthographicCamera;function zD(e){return Array.isArray(e)?Math.min(Math.max(e[0],window.devicePixelRatio),e[1]):e}const HD=u.createContext(null);let VD,WD=[],GD=[],qD=[];function KD(e,t){for(VD=0;VD<e.length;VD++)e[VD](t)}function YD(e,t){let n=t.clock.getDelta();for("never"===t.frameloop&&"number"==typeof e&&(n=e-t.clock.elapsedTime,t.clock.oldTime=t.clock.elapsedTime,t.clock.elapsedTime=e),VD=0;VD<t.internal.subscribers.length;VD++)t.internal.subscribers[VD].ref.current(t,n);return!t.internal.priority&&t.gl.render&&t.gl.render(t.scene,t.camera),t.internal.frames=Math.max(0,t.internal.frames-1),"always"===t.frameloop?1:t.internal.frames}function JD(e){const{handlePointer:t}=PD(e),n={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};return{connected:!1,handlers:Object.keys(n).reduce(((e,n)=>({...e,[n]:t(n)})),{}),connect:t=>{var r;const{set:i,events:o}=e.getState();null==o.disconnect||o.disconnect(),i((e=>({events:{...e.events,connected:t}}))),Object.entries(null!=(r=null==o?void 0:o.handlers)?r:[]).forEach((([e,r])=>{const[i,o]=n[e];t.addEventListener(i,r,{passive:o})}))},disconnect:()=>{const{set:t,events:r}=e.getState();var i;r.connected&&(Object.entries(null!=(i=r.handlers)?i:[]).forEach((([e,t])=>{if(r&&r.connected instanceof HTMLElement){const[i]=n[e];r.connected.removeEventListener(i,t)}})),t((e=>({events:{...e.events,connected:!1}}))))}}}const QD="undefined"!=typeof window?u.useLayoutEffect:u.useEffect;function XD({set:e}){return QD((()=>(e(new Promise((()=>null))),()=>e(!1))),[]),null}class ZD extends u.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}ZD.getDerivedStateFromError=()=>({error:!0});const $D=u.forwardRef((function({children:e,fallback:t,tabIndex:n,resize:i,id:o,style:a,className:s,events:l,...c},d){const[f,{width:h,height:p}]=ED({scroll:!0,debounce:{scroll:50,resize:0},...i}),m=u.useRef(null),[g,v]=u.useState(!1),[y,b]=u.useState(!1);if(g)throw g;if(y)throw y;return QD((()=>{h>0&&p>0&&function(e,t,{gl:n,size:i,mode:o=lB[1],events:a,onCreated:s,...l}={}){var c,d,f,h,p;i||(i={width:null!=(d=null==(f=t.parentElement)?void 0:f.clientWidth)?d:0,height:null!=(h=null==(p=t.parentElement)?void 0:p.clientHeight)?h:0});let m=sB.get(t),g=null==m?void 0:m.fiber,v=null==m?void 0:m.store,y=null==(c=v)?void 0:c.getState();if(g&&y){void 0===l.dpr||ID.equ(y.viewport.dpr,zD(l.dpr))||y.setDpr(l.dpr),y.size.width===i.width&&y.size.height===i.height||y.setSize(i.width,i.height),y.frameloop!==l.frameloop&&y.setFrameloop(l.frameloop);l.linear!==y.internal.lastProps.linear&&(pB(t),g=void 0)}if(!g){const e=((e,t)=>{const n="function"==typeof e?e(t):e;if(r=n,null!=r&&r.render)return n;var r;const i=new lw.WebGLRenderer({powerPreference:"high-performance",canvas:t,antialias:!0,alpha:!0,...e});i.outputEncoding=lw.sRGBEncoding,i.toneMapping=lw.ACESFilmicToneMapping,e&&fB(i,e);return i})(n,t);l.vr&&(e.xr.enabled=!0,e.setAnimationLoop((e=>uB(e,!0)))),v=((e,t,n,i)=>{const{gl:o,size:a,shadows:s=!1,linear:l=!1,flat:c=!1,vr:d=!1,orthographic:f=!1,frameloop:h="always",dpr:p=1,performance:m,clock:g=new lw.Clock,raycaster:v,camera:y,onPointerMissed:b}=i;s&&(o.shadowMap.enabled=!0,"object"==typeof s?Object.assign(o.shadowMap,s):o.shadowMap.type=lw.PCFSoftShadowMap),l&&(o.outputEncoding=lw.LinearEncoding),c&&(o.toneMapping=lw.NoToneMapping),"never"===h&&(g.stop(),g.elapsedTime=0);const w=r(pD)(((r,a)=>{const s=new lw.Raycaster,{params:w,...x}=v||{};e(s,{enabled:!0,...x,params:{...s.params,...w}});const S=y instanceof lw.Camera,M=S?y:f?new lw.OrthographicCamera(0,0,0,0,.1,1e3):new lw.PerspectiveCamera(75,0,.1,1e3);S||(M.position.z=5,y&&e(M,y),null!=y&&y.rotation||M.lookAt(0,0,0));const _=zD(p),A=new lw.Vector3,E=new lw.Vector3,C=new lw.Vector3;function k(e=a().camera,t=E,n=a().size){const{width:r,height:i}=n,o=r/i;t instanceof lw.Vector3?C.copy(t):C.set(...t);const s=e.getWorldPosition(A).distanceTo(C);if(UD(e))return{width:r/e.zoom,height:i/e.zoom,factor:1,distance:s,aspect:o};{const t=e.fov*Math.PI/180,n=2*Math.tan(t/2)*s,a=n*(r/i);return{width:a,height:n,factor:r/a,distance:s,aspect:o}}}let T;const I=e=>r((t=>({performance:{...t.performance,current:e}})));return{gl:o,set:r,get:a,invalidate:()=>t(a()),advance:(e,t)=>n(e,t,a()),linear:l,flat:c,scene:FD(new lw.Scene),camera:M,controls:null,raycaster:s,clock:g,mouse:new lw.Vector2,vr:d,frameloop:h,onPointerMissed:b,performance:{current:1,min:.5,max:1,debounce:200,...m,regress:()=>{const e=a();T&&clearTimeout(T),e.performance.current!==e.performance.min&&I(e.performance.min),T=setTimeout((()=>I(a().performance.max)),e.performance.debounce)}},size:{width:0,height:0},viewport:{initialDpr:_,dpr:_,width:0,height:0,aspect:0,distance:0,factor:0,getCurrentViewport:k},setSize:(e,t)=>{const n={width:e,height:t};r((e=>({size:n,viewport:{...e.viewport,...k(M,E,n)}})))},setDpr:e=>r((t=>({viewport:{...t.viewport,dpr:zD(e)}}))),setFrameloop:(e="always")=>r((()=>({frameloop:e}))),events:{connected:!1},internal:{active:!1,priority:0,frames:0,lastProps:i,lastEvent:u.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(e,t=0)=>(r((({internal:n})=>({internal:{...n,priority:n.priority+(t>0?1:0),subscribers:[...n.subscribers,{ref:e,priority:t}].sort(((e,t)=>e.priority-t.priority))}}))),()=>{r((({internal:n})=>({internal:{...n,priority:n.priority-(t>0?1:0),subscribers:n.subscribers.filter((t=>t.ref!==e))}})))})}}})),x=w.getState();let S=x.size,M=x.viewport.dpr;return w.subscribe((()=>{const{camera:e,size:t,viewport:n,internal:r}=w.getState();t===S&&n.dpr===M||(e.manual||r.lastProps.camera instanceof lw.Camera||(UD(e)?(e.left=t.width/-2,e.right=t.width/2,e.top=t.height/2,e.bottom=t.height/-2):e.aspect=t.width/t.height,e.updateProjectionMatrix(),e.updateMatrixWorld()),o.setPixelRatio(n.dpr),o.setSize(t.width,t.height),S=t,M=n.dpr)})),a&&x.setSize(a.width,a.height),w.subscribe((e=>t(e))),w})(fB,cB,uB,{gl:e,size:i,...l});const s=v.getState();g=dB.createContainer(v,lB.indexOf(o),!1,null),sB.set(t,{fiber:g,store:v}),a&&s.set({events:a(v)})}if(v&&g)return dB.updateContainer(u.createElement(hB,{store:v,element:e,onCreated:s,target:t}),g,null,(()=>{})),v;throw"Error creating root!"}(u.createElement(ZD,{set:b},u.createElement(u.Suspense,{fallback:u.createElement(XD,{set:v})},e)),m.current,{...c,size:{width:h,height:p},events:l||JD})}),[h,p,e]),QD((()=>{const e=m.current;return()=>pB(e)}),[]),u.createElement("div",{ref:f,id:o,className:s,tabIndex:n,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",...a}},u.createElement("canvas",{ref:(w=[m,d],function(e){w.forEach((function(t){"function"==typeof t?t(e):null!=t&&(t.current=e)}))}),style:{display:"block"}},t));var w}));function eB(){const e=u.useContext(HD);if(!e)throw"R3F hooks can only be used within the Canvas component!";return e}function tB(e=(e=>e),t){return eB()(e,t)}function nB(e,t=0){const n=eB().getState().internal.subscribe,r=u.useRef(e);return u.useLayoutEffect((()=>{r.current=e}),[e]),u.useLayoutEffect((()=>n(r,t)),[t,n]),null}function rB(e){const t={nodes:{},materials:{}};return e&&e.traverse((e=>{e.name&&(t.nodes[e.name]=e),e.material&&!t.materials[e.material.name]&&(t.materials[e.material.name]=e.material)})),t}function iB(e){return u.useMemo((()=>rB(e)),[e])}function oB(e,t){return function(n,...r){const i=new n;return e&&e(i),Promise.all(r.map((e=>new Promise(((n,r)=>i.load(e,(e=>{e.scene&&Object.assign(e,rB(e.scene)),n(e)}),t,(t=>r(`Could not load ${e}: ${t.message}`))))))))}}function aB(e,t,n,r){const i=Array.isArray(t)?t:[t],o=MD(oB(n,r),e,...i);return Array.isArray(t)?o:o[0]}aB.preload=function(e,t,n){const r=Array.isArray(t)?t:[t];return MD.preload(oB(n),e,...r)},aB.clear=function(e,t){const n=Array.isArray(t)?t:[t];return MD.clear(e,...n)};const sB=new Map,lB=["legacy","blocking","concurrent"],{invalidate:cB,advance:uB}=function(e){let t,n=!1;function r(i){if(n=!0,t=0,KD(WD,i),e.forEach((e=>{const n=e.store.getState();n.internal.active&&("always"===n.frameloop||n.internal.frames>0)&&(t+=YD(i,n))})),KD(GD,i),t>0)return requestAnimationFrame(r);KD(qD,i),n=!1}return{loop:r,invalidate:function t(i){if(!i)return e.forEach((e=>t(e.store.getState())));!i.vr&&i.internal.active&&"never"!==i.frameloop&&(i.internal.frames=Math.min(60,i.internal.frames+1),n||(n=!0,requestAnimationFrame(r)))},advance:function(t,n=!0,r){n&&KD(WD,t),r?YD(t,r):e.forEach((e=>YD(t,e.store.getState()))),n&&KD(GD,t)}}}(sB),{reconciler:dB,applyProps:fB}=function(e){function t(e,{children:t,key:n,ref:r,...i},{children:o,key:a,ref:s,...l}={},c=!1){var u;const d=null!=(u=null==e?void 0:e.__r3f)?u:{},f=Object.entries(i),h=[];if(c){const e=Object.keys(l);for(let t=0;t<e.length;t++)i.hasOwnProperty(e[t])||f.unshift([e[t],DD+"remove"])}f.forEach((([t,n])=>{var r;if(null!=(r=e.__r3f)&&r.primitive&&"object"===t)return;if(function(e,t){return!(!ID.arr(e)||!ID.equ(e,t))||e===t}(n,l[t]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(t))return h.push([t,n,!0,[]]);let i=[];t.includes("-")&&(i=t.split("-")),h.push([t,n,!1,i])}));const p={...i};return d.memoizedProps&&d.memoizedProps.args&&(p.args=d.memoizedProps.args),d.memoizedProps&&d.memoizedProps.attach&&(p.attach=d.memoizedProps.attach),{accumulative:c,memoized:p,changes:h}}function n(e,n){var r,a,s;const l=null!=(r=null==e?void 0:e.__r3f)?r:{},c=l.root,u=null!=(a=null==c||null==c.getState?void 0:c.getState())?a:{},{memoized:d,changes:f}=(h=n)&&h.memoized&&h.changes?n:t(e,n);var h;const p=l.eventCount;if(e.__r3f&&(e.__r3f.memoizedProps=d),f.forEach((([t,n,r,o])=>{var a;let s=e,c=s[t];if(o.length&&(c=o.reduce(((e,t)=>e[t]),e),!c||!c.set)){const[n,...r]=o.reverse();s=r.reverse().reduce(((e,t)=>e[t]),e),t=n}if(n===DD+"remove")if(c&&c.constructor)n=new c.constructor(d.args);else if(s.constructor){const e=new s.constructor(s.__r3f.memoizedProps.args);n=e[c],e.dispose&&e.dispose()}else n=0;const f=(null==u||null==(a=u.gl)?void 0:a.outputEncoding)===lw.LinearEncoding;if(r)n?l.handlers[t]=n:delete l.handlers[t],l.eventCount=Object.keys(l.handlers).length;else if(c&&c.set&&(c.copy||c instanceof lw.Layers)){if(Array.isArray(n))c.fromArray?c.fromArray(n):c.set(...n);else if(c.copy&&n&&n.constructor&&c.constructor.name===n.constructor.name)c.copy(n);else if(void 0!==n){const e=c instanceof lw.Color;!e&&c.setScalar?c.setScalar(n):c instanceof lw.Layers&&n instanceof lw.Layers?c.mask=n.mask:c.set(n),!f&&e&&c.convertSRGBToLinear()}}else s[t]=n,!f&&s[t]instanceof lw.Texture&&(s[t].encoding=lw.sRGBEncoding);i(e)})),l.parent&&u.internal&&e.raycast&&p!==l.eventCount){const t=u.internal.interaction.indexOf(e);t>-1&&u.internal.interaction.splice(t,1),l.eventCount&&u.internal.interaction.push(e)}return f.length&&null!=(s=e.__r3f)&&s.parent&&o(e),e}function i(e){var t,n;const r=null==(t=e.__r3f)||null==(n=t.root)||null==n.getState?void 0:n.getState();r&&0===r.internal.frames&&r.invalidate()}function o(e){null==e.onUpdate||e.onUpdate(e)}function a(e,{args:t=[],...r},i,o,a){let s,l=`${e[0].toUpperCase()}${e.slice(1)}`;if(!ND(i)&&a){const e=t=>t.return?e(t.return):t.stateNode&&t.stateNode.containerInfo;i=e(a)}if(!i||!ND(i))throw`No valid root for ${l}!`;if("primitive"===e){if(void 0===r.object)throw"Primitives without 'object' are invalid!";s=FD(r.object,{root:i,primitive:!0})}else{const e=jD[l]||lw[l];if(!e)throw`${l} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`;if(!Array.isArray(t))throw"The args prop must be an array!";s=FD(new e(...t),{root:i,memoizedProps:{args:0===t.length?null:t}})}return"attachFns"in r||(l.endsWith("Geometry")?r={attach:"geometry",...r}:l.endsWith("Material")&&(r={attach:"material",...r})),n(s,r),s}function s(e,t){let n=!1;if(t){if(t.attachArray)ID.arr(e[t.attachArray])||(e[t.attachArray]=[]),e[t.attachArray].push(t);else if(t.attachObject)ID.obj(e[t.attachObject[0]])||(e[t.attachObject[0]]={}),e[t.attachObject[0]][t.attachObject[1]]=t;else if(t.attach&&!ID.fun(t.attach))e[t.attach]=t;else if(ID.arr(t.attachFns)){const[n]=t.attachFns;ID.str(n)&&ID.fun(e[n])?e[n](t):ID.fun(n)&&n(t,e)}else t.isObject3D&&e.isObject3D&&(e.add(t),n=!0);n||e.__r3f.objects.push(t),t.__r3f||FD(t,{}),t.__r3f.parent=e,o(t),i(t)}}function l(e,t,n){let r=!1;if(t){if(t.attachArray){const r=e[t.attachArray];ID.arr(r)||(e[t.attachArray]=[]),r.splice(r.indexOf(n),0,t)}else{if(t.attachObject||t.attach&&!ID.fun(t.attach))return s(e,t);if(t.isObject3D&&e.isObject3D){t.parent=e,t.dispatchEvent({type:"added"});const i=e.children.filter((e=>e!==t)),o=i.indexOf(n);e.children=[...i.slice(0,o),t,...i.slice(o)],r=!0}}r||e.__r3f.objects.push(t),t.__r3f||FD(t,{}),t.__r3f.parent=e,o(t),i(t)}}function c(e,t,n=!1){e&&[...e].forEach((e=>u(t,e,n)))}function u(e,t,n){if(t){var r,o;if(t.__r3f&&(t.__r3f.parent=null),null!=(r=e.__r3f)&&r.objects&&(e.__r3f.objects=e.__r3f.objects.filter((e=>e!==t))),t.attachArray)e[t.attachArray]=e[t.attachArray].filter((e=>e!==t));else if(t.attachObject)delete e[t.attachObject[0]][t.attachObject[1]];else if(t.attach&&!ID.fun(t.attach)&&e[t.attach]===t)e[t.attach]=null;else if(ID.arr(t.attachFns)){const[,n]=t.attachFns;ID.str(n)&&ID.fun(e[n])?e[n](t):ID.fun(n)&&n(t,e)}else if(t.isObject3D&&e.isObject3D){var a;e.remove(t),null!=(a=t.__r3f)&&a.root&&function(e,t){const{internal:n}=e.getState();n.interaction=n.interaction.filter((e=>e!==t)),n.initialHits=n.initialHits.filter((e=>e!==t)),n.hovered.forEach(((e,r)=>{e.eventObject!==t&&e.object!==t||n.hovered.delete(r)})),n.capturedMap.forEach(((e,r)=>{RD(n.capturedMap,t,e,r)}))}(t.__r3f.root,t)}const l=null==(o=t.__r3f)?void 0:o.primitive,u=void 0===n?null!==t.dispose&&!l:n;var s;if(!l)c(null==(s=t.__r3f)?void 0:s.objects,t,u),c(t.children,t,u);t.__r3f&&(delete t.__r3f.root,delete t.__r3f.objects,delete t.__r3f.handlers,delete t.__r3f.memoizedProps,l||delete t.__r3f),u&&t.dispose&&"Scene"!==t.type&&(0,bD.unstable_runWithPriority)(bD.unstable_IdlePriority,(()=>{try{t.dispose()}catch(e){}})),i(e)}}const d=r(vD)({now:bD.unstable_now,createInstance:a,removeChild:u,appendChild:s,appendInitialChild:s,insertBefore:l,warnsIfNotActing:!0,supportsMutation:!0,isPrimaryRenderer:!1,scheduleTimeout:ID.fun(setTimeout)?setTimeout:void 0,cancelTimeout:ID.fun(clearTimeout)?clearTimeout:void 0,setTimeout:ID.fun(setTimeout)?setTimeout:void 0,clearTimeout:ID.fun(clearTimeout)?clearTimeout:void 0,noTimeout:-1,appendChildToContainer:(e,t)=>{const{container:n,root:r}=LD(e,t);n.__r3f.root=r,s(n,t)},removeChildFromContainer:(e,t)=>u(LD(e,t).container,t),insertInContainerBefore:(e,t,n)=>l(LD(e,t).container,t,n),prepareUpdate(e,n,r,i){if(e.__r3f.primitive&&i.object&&i.object!==e)return[!0];{const{args:n=[],children:o,...a}=i,{args:l=[],children:c,...u}=r;if(!Array.isArray(n))throw"The args prop must be an array!";if(n.some(((e,t)=>e!==l[t])))return[!0];const d=t(e,a,u,!0);if(d.changes.length)return[!1,d];if(e.attach&&"function"!=typeof e.attach){const t=e.__r3f.parent;t&&t[e.attach]!==e&&s(t,e)}return null}},commitUpdate(e,[t,r],i,o,l,c){t?function(e,t,n,r){var i;const o=null==(i=e.__r3f)?void 0:i.parent;if(!o)return;const l=a(t,n,e.__r3f.root);"primitive"!==t&&e.children&&(e.children.forEach((e=>s(l,e))),e.children=[]),e.__r3f.objects.forEach((e=>s(l,e))),e.__r3f.objects=[],u(o,e),s(o,l),l.raycast&&l.__r3f.eventCount&&l.__r3f.root.getState().internal.interaction.push(l);[r,r.alternate].forEach((e=>{null!==e&&(e.stateNode=l,e.ref&&("function"==typeof e.ref?e.ref(l):e.ref.current=l))}))}(e,i,l,c):n(e,r)},hideInstance(e){e.isObject3D&&(e.visible=!1,i(e))},unhideInstance(e,t){(e.isObject3D&&null==t.visible||t.visible)&&(e.visible=!0,i(e))},hideTextInstance(){throw new Error("Text is not allowed in the R3F tree.")},getPublicInstance:e=>e,getRootHostContext:e=>BD,getChildHostContext:e=>e,createTextInstance(){},finalizeInitialChildren(e){var t;return!!(null!=(t=null==e?void 0:e.__r3f)?t:{}).handlers},commitMount(e){var t;const n=null!=(t=null==e?void 0:e.__r3f)?t:{};e.raycast&&n.handlers&&n.eventCount&&e.__r3f.root.getState().internal.interaction.push(e)},shouldDeprioritizeSubtree:()=>!1,prepareForCommit:()=>null,preparePortalMount(e){FD(e)},resetAfterCommit(){},shouldSetTextContent:()=>!1,clearContainer:()=>!1});return{reconciler:d,applyProps:n}}();function hB({store:e,element:t,onCreated:n,target:r}){return u.useEffect((()=>{const t=e.getState();t.set((e=>({internal:{...e.internal,active:!0}}))),null==t.events.connect||t.events.connect(r),n&&n(t)}),[]),u.createElement(HD.Provider,{value:e},t)}function pB(e,t){const n=sB.get(e),r=null==n?void 0:n.fiber;if(r){const i=null==n?void 0:n.store.getState();i&&(i.internal.active=!1),dB.updateContainer(null,r,null,(()=>{i&&setTimeout((()=>{var n,r,o;null==i.events.disconnect||i.events.disconnect(),null==(n=i.gl)||null==(r=n.renderLists)||null==r.dispose||r.dispose(),null==(o=i.gl)||null==o.forceContextLoss||o.forceContextLoss(),mB(i),sB.delete(e),t&&t(e)}),500)}))}}function mB(e){e.dispose&&"Scene"!==e.type&&e.dispose();for(const r in e){var t,n;null==(t=(n=r).dispose)||t.call(n),delete e[r]}}dB.act;function gB(e,t){return dB.createPortal(e,t,null,null)}dB.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:"17.0.2"});let vB=null;function yB(e,t,n){return r=>{n&&n(r),e&&(vB||(vB=new cL),vB.setDecoderPath("string"==typeof e?e:"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),r.setDRACOLoader(vB)),t&&r.setMeshoptDecoder(hD())}}function bB(e,t=!0,n=!0,r){return aB(dL,e,yB(t,n,r))}bB.preload=(e,t=!0,n=!0,r)=>aB.preload(dL,e,yB(t,n,r)),bB.clear=e=>aB.clear(dL,e);u=a("85Hg2");let wB,xB,SB=999,MB=0;const _B=()=>{SB=0,wB=setTimeout(_B,5e3*Math.random()+2e3)};function AB(e,t){(0,u.useEffect)((()=>{if(e)return xB=t.Wolf3D_Head||t.Wolf3D_Avatar,(null==xB?void 0:xB.morphTargetDictionary)&&(null==xB?void 0:xB.morphTargetInfluences)&&(MB=xB.morphTargetDictionary.eyesClosed),wB=setTimeout(_B,3e3),()=>{clearTimeout(wB)}}),[t,e]),nB(((t,n)=>{if(e)if(SB<2&&(null==xB?void 0:xB.morphTargetInfluences)){let e=Math.abs(Math.sin(SB*Math.PI/2));SB+=10*n,xB.morphTargetInfluences[MB]=e}else(null==xB?void 0:xB.morphTargetInfluences)&&(xB.morphTargetInfluences[MB]=0)}))}u=a("85Hg2");const EB=(e,t,n=.05)=>e*(1-n)+t*n,CB=(e,t,n,r,i)=>((e=((e,t,n)=>Math.min(Math.max(e,t),n))(e,t,n))-t)*(i-r)/(n-t)+r,kB=e=>{e.Wolf3D_Hands&&(e.Wolf3D_Hands.visible=!1),e.RightHand&&e.LeftHand&&(e.RightHand.position.set(0,-2,0),e.LeftHand.position.set(0,-2,0))},TB=e=>{Object.values(e).forEach((e=>{e.map&&(e.map.minFilter=Sx),e&&(e.depthWrite=!0)}))},IB=e=>"SkinnedMesh"===e.type,OB=Math.PI/180;let RB,PB=!1;const NB=new NM(0,0),LB=new NM(0,0),DB=()=>{RB=setTimeout((()=>{PB=!0}),1e3)},BB=()=>{clearTimeout(RB),PB=!1};function jB(e,t){const{gl:n}=tB();(0,u.useEffect)((()=>{if(e)return n.domElement.addEventListener("mouseleave",DB),n.domElement.addEventListener("mouseenter",BB),()=>{n.domElement.removeEventListener("mouseleave",DB),n.domElement.removeEventListener("mouseenter",BB)}}),[n.domElement,e]),nB((n=>{if(!e||!(null==t?void 0:t.Neck)||!(null==t?void 0:t.Head))return;const r=Math.abs(n.camera.rotation.z);!PB&&r<.2?(NB.x=CB(n.mouse.y,-1,1,5*OB,-5*OB),NB.y=CB(n.mouse.x,-1,1,-10*OB,10*OB)):NB.set(0,0),LB.x=EB(LB.x,NB.x),LB.y=EB(LB.y,NB.y),t.Neck.rotation.x=LB.x+.1,t.Neck.rotation.y=LB.y,t.Head.rotation.x=2*LB.x,t.Head.rotation.y=2*LB.y}))}u=a("85Hg2");let FB,UB,zB=999,HB=0,VB=0,WB=0,GB=0;const qB=()=>{zB=0,FB=setTimeout(qB,500*Math.random())};function KB(e,t){(0,u.useEffect)((()=>{if(e)return UB=t.Wolf3D_Head||t.Wolf3D_Avatar||t.Wolf3D_Avatar001,(null==UB?void 0:UB.morphTargetDictionary)&&(null==UB?void 0:UB.morphTargetInfluences)&&(HB=UB.morphTargetDictionary.mouthOpen,VB=UB.morphTargetDictionary.mouthSmile,WB=UB.morphTargetDictionary.mouthFunner,GB=UB.morphTargetDictionary.mouthPucker),FB=setTimeout(qB,200),()=>{clearTimeout(FB)}}),[t,e]),nB(((t,n)=>{if(e)if(zB<2&&(null==UB?void 0:UB.morphTargetInfluences)){let e=Math.abs(Math.sin(zB*Math.PI/2));zB+=10*n,UB.morphTargetInfluences[HB]=e/3,UB.morphTargetInfluences[VB]=e/10,UB.morphTargetInfluences[WB]=e/7,UB.morphTargetInfluences[GB]=e/5}else(null==UB?void 0:UB.morphTargetInfluences)&&(UB.morphTargetInfluences[HB]=0,UB.morphTargetInfluences[VB]=0,UB.morphTargetInfluences[WB]=0,UB.morphTargetInfluences[GB]=0);else(null==UB?void 0:UB.morphTargetInfluences)&&(UB.morphTargetInfluences[HB]=0,UB.morphTargetInfluences[VB]=0,UB.morphTargetInfluences[WB]=0,UB.morphTargetInfluences[GB]=0)}))}const YB=new d_(0,-.6,0);function JB({url:e,eyeBlink:t,headMovement:n,speaking:r,onLoaded:i}){const{scene:o}=bB(e),{nodes:a,materials:l}=iB(o);return AB(t,a),jB(n,a),KB(!!r,a),(0,u.useEffect)((()=>(kB(a),TB(l),i&&i(),()=>{Object.values(l).forEach(mB),Object.values(a).filter(IB).forEach(mB)})),[l,a,e,i]),(0,s.jsxs)("group",{position:YB,children:[(0,s.jsx)("primitive",{object:a.Hips},"armature"),Object.values(a).filter(IB).map((e=>(0,s.jsx)("primitive",{object:e,receiveShadow:!0,castShadow:!0},e.name)))]})}u=a("85Hg2"),u=a("85Hg2");function QB(e,t){const n=u.useRef(),[r]=u.useState((()=>t?t instanceof hA?{current:t}:t:n)),[i]=u.useState((()=>new HP(void 0))),o=u.useRef({}),[a]=u.useState((()=>{const t={};return e.forEach((e=>Object.defineProperty(t,e.name,{enumerable:!0,get(){if(r.current)return o.current[e.name]||(o.current[e.name]=i.clipAction(e,r.current))}}))),{ref:r,clips:e,actions:t,names:e.map((e=>e.name)),mixer:i}}));return nB(((e,t)=>i.update(t))),u.useEffect((()=>{const e=r.current;return()=>{o.current={},Object.values(a.actions).forEach((t=>{e&&i.uncacheAction(t,e)}))}}),[e]),a}u=a("85Hg2");let XB,ZB=0,$B=0;function ej(e,t){(0,u.useEffect)((()=>{e&&(XB=t.Wolf3D_Head||t.Wolf3D_Avatar||t.Wolf3D_Avatar001,(null==XB?void 0:XB.morphTargetDictionary)&&(null==XB?void 0:XB.morphTargetInfluences)&&(ZB=XB.morphTargetDictionary.mouthOpen,$B=XB.morphTargetDictionary.viseme_U))}),[t,e]),nB((()=>{e?(null==XB?void 0:XB.morphTargetInfluences)&&(XB.morphTargetInfluences[ZB]=.56,XB.morphTargetInfluences[$B]=.67):(null==XB?void 0:XB.morphTargetInfluences)&&(XB.morphTargetInfluences[ZB]=0,XB.morphTargetInfluences[$B]=0)}))}u=a("85Hg2");let tj,nj=0;function rj(e,t){(0,u.useEffect)((()=>{e&&(tj=t.Wolf3D_Head||t.Wolf3D_Avatar||t.Wolf3D_Avatar001,(null==tj?void 0:tj.morphTargetDictionary)&&(null==tj?void 0:tj.morphTargetInfluences)&&(nj=tj.morphTargetDictionary.mouthSmile))}),[t,e]),nB((()=>{e?(null==tj?void 0:tj.morphTargetInfluences)&&(tj.morphTargetInfluences[nj]=1/3):(null==tj?void 0:tj.morphTargetInfluences)&&(tj.morphTargetInfluences[nj]=0)}))}const ij=new d_(0,-1,0),oj=new Z_(.175,0,0);function aj({url:e,sex:t,eyeBlink:n,speaking:r,onLoaded:i,animation:o}){var a,l;const{scene:c}=bB(e),{animations:d}=bB("MALE"===t?"https://assets.memori.ai/api/v2/asset/b11eef07-c45b-4959-9d43-be8105365c1f.glb":"https://assets.memori.ai/api/v2/asset/24dc2bd7-d6b5-4492-ab29-791928b0a669.glb"),{animations:f}=bB("MALE"===t?"https://assets.memori.ai/api/v2/asset/2150d3d3-b77d-4489-8455-e6239334e8a7.glb":"https://assets.memori.ai/api/v2/asset/0a04e5b2-1a02-4964-9534-75c2a7574660.glb"),{nodes:h,materials:p}=iB(c),m=QB(d,c),g=QB(f.filter((e=>"Loading"===e.name)),c);AB(n,h),KB(!!r,h),ej("Loading"===o,h),rj(null==o?void 0:o.startsWith("Idle"),h),(0,u.useEffect)((()=>(TB(p),i&&i(),()=>{Object.values(p).forEach(mB),Object.values(h).filter(IB).forEach(mB)})),[p,h,e,i]);try{o&&o in m.actions?(Object.keys(m.actions).forEach((e=>{let t=m.actions[e];t&&(e===o&&"Loading"!==o?t.fadeIn(.3).play():t.fadeOut(.3).stop())})),"Loading"===o?null===(a=g.actions.Loading)||void 0===a||a.fadeIn(.3).play():null===(l=g.actions.Loading)||void 0===l||l.fadeOut(.3).stop()):Object.values(m.actions).forEach((e=>{e&&(null==e||e.fadeOut(.2).reset().stop())}))}catch(e){console.log(e)}return(0,s.jsx)("group",{position:ij,rotation:oj,children:(0,s.jsx)("primitive",{object:c})})}let sj=0;const lj=r(pD)((e=>(MR.onStart=(t,n,r)=>{e({active:!0,item:t,loaded:n,total:r,progress:(n-sj)/(r-sj)*100})},MR.onLoad=()=>{e({active:!1})},MR.onError=t=>e((e=>({errors:[...e.errors,t]}))),MR.onProgress=(t,n,r)=>{n===r&&(sj=r),e({active:!0,item:t,loaded:n,total:r,progress:(n-sj)/(r-sj)*100||100})},{errors:[],active:!1,progress:0,item:"",loaded:0,total:0})));function cj(){return cj=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},cj.apply(this,arguments)}u=a("85Hg2"),c=a("2BCLI");const uj=new d_,dj=new d_,fj=new d_;function hj(e,t,n){const r=uj.setFromMatrixPosition(e.matrixWorld);r.project(t);const i=n.width/2,o=n.height/2;return[r.x*i+i,-r.y*o+o]}const pj=e=>Math.abs(e)<1e-10?0:e;function mj(e,t,n=""){let r="matrix3d(";for(let n=0;16!==n;n++)r+=pj(t[n]*e.elements[n])+(15!==n?",":")");return n+r}const gj=(vj=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>mj(e,vj));var vj;const yj=(e,t)=>{return mj(e,[1/(n=t),1/n,1/n,1,-1/n,-1/n,-1/n,-1,1/n,1/n,1/n,1,1,1,1,1],"translate(-50%,-50%)");var n},bj=u.forwardRef((({children:e,eps:t=.001,style:n,className:r,prepend:i,center:o,fullscreen:a,portal:s,distanceFactor:l,sprite:d=!1,transform:f=!1,occlude:h,onOcclude:p,zIndexRange:m=[16777271,0],calculatePosition:g=hj,as:v="div",wrapperClass:y,pointerEvents:b="auto",...w},x)=>{var S;const M=tB((({gl:e})=>e)),_=tB((({camera:e})=>e)),A=tB((({scene:e})=>e)),E=tB((({size:e})=>e)),C=tB((({raycaster:e})=>e)),[k]=u.useState((()=>document.createElement(v))),T=u.useRef(null),I=u.useRef(0),O=u.useRef([0,0]),R=u.useRef(null),P=u.useRef(null),N=null!==(S=null==s?void 0:s.current)&&void 0!==S?S:M.domElement.parentNode;u.useEffect((()=>{if(T.current){if(A.updateMatrixWorld(),f)k.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const e=g(T.current,_,E);k.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return N&&(i?N.prepend(k):N.appendChild(k)),()=>{N&&N.removeChild(k),c.unmountComponentAtNode(k)}}}),[N,f]),u.useLayoutEffect((()=>{y&&(k.className=y)}),[y]);const L=u.useMemo((()=>f?{position:"absolute",top:0,left:0,width:E.width,height:E.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:o?"translate3d(-50%,-50%,0)":"none",...a&&{top:-E.height/2,left:-E.width/2,width:E.width,height:E.height},...n}),[n,o,a,E,f]),D=u.useMemo((()=>({position:"absolute",pointerEvents:b})),[b]);u.useLayoutEffect((()=>{f?c.render(u.createElement("div",{ref:R,style:L},u.createElement("div",{ref:P,style:D},u.createElement("div",{ref:x,className:r,style:n,children:e}))),k):c.render(u.createElement("div",{ref:x,style:L,className:r,children:e}),k)}));const B=u.useRef(!0);return nB((()=>{if(T.current){_.updateMatrixWorld(),T.current.updateWorldMatrix(!0,!1);const e=f?O.current:g(T.current,_,E);if(f||Math.abs(I.current-_.zoom)>t||Math.abs(O.current[0]-e[0])>t||Math.abs(O.current[1]-e[1])>t){const t=function(e,t){const n=uj.setFromMatrixPosition(e.matrixWorld),r=dj.setFromMatrixPosition(t.matrixWorld),i=n.sub(r),o=t.getWorldDirection(fj);return i.angleTo(o)>Math.PI/2}(T.current,_);let n=!1;"boolean"==typeof h?!0===h&&(n=[A]):Array.isArray(h)&&(n=h.map((e=>e.current)));const r=B.current;if(n){const e=function(e,t,n,r){const i=uj.setFromMatrixPosition(e.matrixWorld),o=i.clone();o.project(t),n.setFromCamera(o,t);const a=n.intersectObjects(r,!0);if(a.length){const e=a[0].distance;return i.distanceTo(n.ray.origin)<e}return!0}(T.current,_,C,n);B.current=e&&!t}else B.current=!t;if(r!==B.current&&(p?p(!B.current):k.style.display=B.current?"block":"none"),k.style.zIndex=`${function(e,t,n){if(t instanceof wE||t instanceof WE){const r=uj.setFromMatrixPosition(e.matrixWorld),i=dj.setFromMatrixPosition(t.matrixWorld),o=r.distanceTo(i),a=(n[1]-n[0])/(t.far-t.near),s=n[1]-a*t.far;return Math.round(a*o+s)}}(T.current,_,m)}`,f){const[e,t]=[E.width/2,E.height/2],n=_.projectionMatrix.elements[5]*t,{isOrthographicCamera:r,top:i,left:o,bottom:a,right:s}=_,c=gj(_.matrixWorldInverse),u=r?`scale(${n})translate(${pj(-(s+o)/2)}px,${pj((i+a)/2)}px)`:`translateZ(${n}px)`;let f=T.current.matrixWorld;d&&(f=_.matrixWorldInverse.clone().transpose().copyPosition(f).scale(T.current.scale),f.elements[3]=f.elements[7]=f.elements[11]=0,f.elements[15]=1),k.style.width=E.width+"px",k.style.height=E.height+"px",k.style.perspective=r?"":`${n}px`,R.current&&P.current&&(R.current.style.transform=`${u}${c}translate(${e}px,${t}px)`,P.current.style.transform=yj(f,1/((l||10)/400)))}else{const t=void 0===l?1:function(e,t){if(t instanceof WE)return t.zoom;if(t instanceof wE){const n=uj.setFromMatrixPosition(e.matrixWorld),r=dj.setFromMatrixPosition(t.matrixWorld),i=t.fov*Math.PI/180,o=n.distanceTo(r);return 1/(2*Math.tan(i/2)*o)}return 1}(T.current,_)*l;k.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}O.current=e,I.current=_.zoom}}})),u.createElement("group",cj({},w,{ref:T}))}));var wj=({fallbackImg:e})=>{const{progress:t}=lj();return(0,s.jsx)(bj,{center:!0,className:"avatar-loader",children:(0,s.jsx)(dp,{spinning:!0,children:e?(0,s.jsxs)("figure",{children:[(0,s.jsx)("img",{src:e,alt:`${Math.round(t)}% loaded`,title:`${Math.round(t)}% loaded`}),(0,s.jsx)("figcaption",{children:`${Math.round(t)}%`})]}):(0,s.jsxs)(s.Fragment,{children:[Math.round(t)," % loaded"]})})})};u=a("85Hg2");class xj extends yE{constructor(){super({uniforms:{depth:{value:null},opacity:{value:1},attenuation:{value:2.5},anglePower:{value:12},spotPosition:{value:new d_(0,0,0)},lightColor:{value:new QM("white")},cameraNear:{value:0},cameraFar:{value:1},resolution:{value:new NM(0,0)}},transparent:!0,depthWrite:!1,vertexShader:"\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n varying float vViewZ;\n varying float vIntensity;\n uniform vec3 spotPosition;\n uniform float attenuation; \n\n void main() {\n // compute intensity\n vNormal = normalize( normalMatrix * normal );\n vec4 worldPosition\t= modelMatrix * vec4( position, 1.0 );\n vWorldPosition = worldPosition.xyz;\n vec4 viewPosition = viewMatrix * worldPosition;\n vViewZ = viewPosition.z;\n float intensity\t= distance(worldPosition.xyz, spotPosition) / attenuation;\n intensity\t= 1.0 - clamp(intensity, 0.0, 1.0);\n vIntensity = intensity; \n // set gl_Position\n gl_Position\t= projectionMatrix * viewPosition;\n\n }",fragmentShader:"\n #include <packing>\n\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n uniform vec3 lightColor;\n uniform vec3 spotPosition;\n uniform float attenuation;\n uniform float anglePower;\n uniform sampler2D depth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n varying float vViewZ;\n varying float vIntensity;\n uniform float opacity;\n\n float readDepth( sampler2D depthSampler, vec2 coord ) {\n float fragCoordZ = texture2D( depthSampler, coord ).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZ;\n }\n\n void main() {\n float d = 1.0;\n bool isSoft = resolution[0] > 0.0 && resolution[1] > 0.0;\n if (isSoft) {\n vec2 sUv = gl_FragCoord.xy / resolution;\n d = readDepth(depth, sUv);\n }\n float intensity = vIntensity;\n vec3 normal\t= vec3(vNormal.x, vNormal.y, abs(vNormal.z));\n float angleIntensity\t= pow( dot(normal, vec3(0.0, 0.0, 1.0)), anglePower );\n intensity\t*= angleIntensity;\n // fades when z is close to sampled depth, meaning the cone is intersecting existing geometry\n if (isSoft) {\n intensity\t*= smoothstep(0., 1., vViewZ - d);\n }\n gl_FragColor = vec4(lightColor, intensity * opacity);\n\n #include <tonemapping_fragment>\n\t #include <encodings_fragment>\n }"})}}const Sj=new d_,Mj=u.forwardRef((({opacity:e=1,radiusTop:t,radiusBottom:n,depthBuffer:r,color:i="white",distance:o=5,angle:a=.15,attenuation:s=5,anglePower:l=5,...c},d)=>{const f=u.useRef(null),h=tB((e=>e.size)),p=tB((e=>e.camera)),m=tB((e=>e.viewport.dpr)),[g]=u.useState((()=>new xj));t=void 0===t?.1:t,n=void 0===n?7*a:n,nB((()=>{g.uniforms.spotPosition.value.copy(f.current.getWorldPosition(Sj)),f.current.lookAt(f.current.parent.target.getWorldPosition(Sj))}));const v=u.useMemo((()=>{const e=new qI(t,n,o,128,64,!0);return e.applyMatrix4((new H_).makeTranslation(0,-o/2,0)),e.applyMatrix4((new H_).makeRotationX(-Math.PI/2)),e}),[a,o,t,n]);return u.createElement("spotLight",cj({ref:d,angle:a,color:i,distance:o},c),u.createElement("mesh",{ref:f,geometry:v,raycast:()=>null},u.createElement("primitive",{object:g,attach:"material","uniforms-opacity-value":e,"uniforms-lightColor-value":i,"uniforms-attenuation-value":s,"uniforms-anglePower-value":l,"uniforms-depth-value":r,"uniforms-cameraNear-value":p.near,"uniforms-cameraFar-value":p.far,"uniforms-resolution-value":r?[h.width*m,h.height*m]:[0,0]})))}));u=a("85Hg2");class _j extends RR{constructor(e){super(e),this.type=Nx}parse(e){const t=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},n=function(e,t,n){t=t||1024;let r=e.pos,i=-1,o=0,a="",s=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));for(;0>(i=s.indexOf("\n"))&&o<t&&r<e.byteLength;)a+=s,o+=s.length,r+=128,s+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));return-1<i&&(!1!==n&&(e.pos+=o+i+1),a+s.slice(0,i))},r=function(e,t,n,r){const i=e[t+3],o=Math.pow(2,i-128)/255;n[r+0]=e[t+0]*o,n[r+1]=e[t+1]*o,n[r+2]=e[t+2]*o,n[r+3]=1},i=function(e,t,n,r){const i=e[t+3],o=Math.pow(2,i-128)/255;n[r+0]=jN.toHalfFloat(Math.min(e[t+0]*o,65504)),n[r+1]=jN.toHalfFloat(Math.min(e[t+1]*o,65504)),n[r+2]=jN.toHalfFloat(Math.min(e[t+2]*o,65504)),n[r+3]=jN.toHalfFloat(1)},o=new Uint8Array(e);o.pos=0;const a=function(e){const r=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,i=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*FORMAT=(\S+)\s*$/,a=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,s={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,c;if(e.pos>=e.byteLength||!(l=n(e)))return t(1,"no header found");if(!(c=l.match(/^#\?(\S+)/)))return t(3,"bad initial token");for(s.valid|=1,s.programtype=c[1],s.string+=l+"\n";l=n(e),!1!==l;)if(s.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(r))&&(s.gamma=parseFloat(c[1])),(c=l.match(i))&&(s.exposure=parseFloat(c[1])),(c=l.match(o))&&(s.valid|=2,s.format=c[1]),(c=l.match(a))&&(s.valid|=4,s.height=parseInt(c[1],10),s.width=parseInt(c[2],10)),2&s.valid&&4&s.valid)break}else s.comments+=l+"\n";return 2&s.valid?4&s.valid?s:t(3,"missing image size specifier"):t(3,"missing format specifier")}(o);if(-1!==a){const e=a.width,n=a.height,s=function(e,n,r){const i=n;if(i<8||i>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(i!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");const o=new Uint8Array(4*n*r);if(!o.length)return t(4,"unable to allocate buffer space");let a=0,s=0;const l=4*i,c=new Uint8Array(4),u=new Uint8Array(l);let d=r;for(;d>0&&s<e.byteLength;){if(s+4>e.byteLength)return t(1);if(c[0]=e[s++],c[1]=e[s++],c[2]=e[s++],c[3]=e[s++],2!=c[0]||2!=c[1]||(c[2]<<8|c[3])!=i)return t(3,"bad rgbe scanline format");let n,r=0;for(;r<l&&s<e.byteLength;){n=e[s++];const i=n>128;if(i&&(n-=128),0===n||r+n>l)return t(3,"bad scanline data");if(i){const t=e[s++];for(let e=0;e<n;e++)u[r++]=t}else u.set(e.subarray(s,s+n),r),r+=n,s+=n}const f=i;for(let e=0;e<f;e++){let t=0;o[a]=u[e+t],t+=i,o[a+1]=u[e+t],t+=i,o[a+2]=u[e+t],t+=i,o[a+3]=u[e+t],a+=4}d--}return o}(o.subarray(o.pos),e,n);if(-1!==s){let t,o,l;switch(this.type){case Px:l=s.length/4;const e=new Float32Array(4*l);for(let t=0;t<l;t++)r(s,4*t,e,4*t);t=e,o=Px;break;case Nx:l=s.length/4;const n=new Uint16Array(4*l);for(let e=0;e<l;e++)i(s,4*e,n,4*e);t=n,o=Nx;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:e,height:n,data:t,header:a.string,gamma:a.gamma,exposure:a.exposure,type:o}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,r){return super.load(e,(function(e,n){switch(e.type){case Px:case Nx:e.encoding=DS,e.minFilter=Sx,e.magFilter=Sx,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,r)}}const Aj={sunset:"venice/venice_sunset_1k.hdr",dawn:"kiara/kiara_1_dawn_1k.hdr",night:"dikhololo/dikhololo_night_1k.hdr",warehouse:"empty-wharehouse/empty_warehouse_01_1k.hdr",forest:"forrest-slope/forest_slope_1k.hdr",apartment:"lebombo/lebombo_1k.hdr",studio:"studio-small-3/studio_small_03_1k.hdr",city:"potsdamer-platz/potsdamer_platz_1k.hdr",park:"rooitou/rooitou_park_1k.hdr",lobby:"st-fagans/st_fagans_interior_1k.hdr"},Ej=e=>{return(t=e).current&&t.current.isScene?e.current:e;var t};function Cj(e){return e.map?u.createElement(kj,e):e.children?u.createElement(Tj,e):u.createElement(Ij,e)}function kj({scene:e,background:t=!1,map:n}){const r=tB((e=>e.scene));return u.useLayoutEffect((()=>{if(n){const i=Ej(e||r),o=i.background,a=i.environment;return"only"!==t&&(i.environment=n),t&&(i.background=n),()=>{"only"!==t&&(i.environment=a),t&&(i.background=o)}}}),[e,n]),null}function Tj({children:e,near:t=1,far:n=1e3,resolution:r=256,frames:i=1,background:o=!1,scene:a,files:s,path:l,preset:c,extensions:d}){const f=tB((e=>e.gl)),h=tB((e=>e.scene)),p=u.useRef(null),[m]=u.useState((()=>new hT)),g=u.useMemo((()=>{const e=new _E(r);return e.texture.type=Nx,e}),[r]);u.useLayoutEffect((()=>{1===i&&p.current.update(f,m);const e=Ej(a||h),t=e.background,n=e.environment;return"only"!==o&&(e.environment=g.texture),o&&(e.background=g.texture),()=>{"only"!==o&&(e.environment=n),o&&(e.background=t)}}),[e,a]);let v=1;return nB((()=>{(i===1/0||v<i)&&(p.current.update(f,m),v++)})),u.createElement(u.Fragment,null,gB(u.createElement(u.Fragment,null,e,u.createElement("cubeCamera",{ref:p,args:[t,n,g]}),(s||c)&&u.createElement(kj,{background:!0,files:s,preset:c,path:l,extensions:d,scene:m})),m))}function Ij({background:e=!1,files:t=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"],path:n="",preset:r,scene:i,extensions:o}){if(r){if(!(r in Aj))throw new Error("Preset must be one of: "+Object.keys(Aj).join(", "));t=Aj[r],n="https://market-assets.fra1.cdn.digitaloceanspaces.com/market-assets/hdris/"}const a=tB((e=>e.scene)),s=Array.isArray(t),l=aB(s?OR:_j,s?[t]:t,(e=>{e.setPath(n),null==e.setDataType||e.setDataType(Px),o&&o(e)})),c=s?l[0]:l;return c.mapping=s?cx:dx,u.useLayoutEffect((()=>{const t=Ej(i||a),n=t.background,r=t.environment;return"only"!==e&&(t.environment=c),e&&(t.background=c),()=>{"only"!==e&&(t.environment=r),e&&(t.background=n)}}),[c,e,i]),null}u=a("85Hg2");function Oj(e){return Oj="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Oj(e)}function Rj(e,t){if("object"!==Oj(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==Oj(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function Pj(e){var t=Rj(e,"string");return"symbol"===Oj(t)?t:String(t)}function Nj(e,t,n){return(t=Pj(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const Lj=(e,t)=>(e%t+t)%t;class Dj extends bM{constructor(e,t){super(),Nj(this,"object",void 0),Nj(this,"domElement",void 0),Nj(this,"enabled",!0),Nj(this,"target",new d_),Nj(this,"minDistance",0),Nj(this,"maxDistance",1/0),Nj(this,"minZoom",0),Nj(this,"maxZoom",1/0),Nj(this,"minPolarAngle",0),Nj(this,"maxPolarAngle",Math.PI),Nj(this,"minAzimuthAngle",-1/0),Nj(this,"maxAzimuthAngle",1/0),Nj(this,"enableDamping",!1),Nj(this,"dampingFactor",.05),Nj(this,"enableZoom",!0),Nj(this,"zoomSpeed",1),Nj(this,"enableRotate",!0),Nj(this,"rotateSpeed",1),Nj(this,"enablePan",!0),Nj(this,"panSpeed",1),Nj(this,"screenSpacePanning",!0),Nj(this,"keyPanSpeed",7),Nj(this,"autoRotate",!1),Nj(this,"autoRotateSpeed",2),Nj(this,"reverseOrbit",!1),Nj(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),Nj(this,"mouseButtons",{LEFT:uw.ROTATE,MIDDLE:uw.DOLLY,RIGHT:uw.PAN}),Nj(this,"touches",{ONE:dw.ROTATE,TWO:dw.DOLLY_PAN}),Nj(this,"target0",void 0),Nj(this,"position0",void 0),Nj(this,"zoom0",void 0),Nj(this,"_domElementKeyEvents",null),Nj(this,"getPolarAngle",void 0),Nj(this,"getAzimuthalAngle",void 0),Nj(this,"setPolarAngle",void 0),Nj(this,"setAzimuthalAngle",void 0),Nj(this,"getDistance",void 0),Nj(this,"listenToKeyEvents",void 0),Nj(this,"saveState",void 0),Nj(this,"reset",void 0),Nj(this,"update",void 0),Nj(this,"connect",void 0),Nj(this,"dispose",void 0),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object instanceof wE?this.object.zoom:1,this.getPolarAngle=()=>c.phi,this.getAzimuthalAngle=()=>c.theta,this.setPolarAngle=e=>{let t=Lj(e,2*Math.PI),r=c.phi;r<0&&(r+=2*Math.PI),t<0&&(t+=2*Math.PI);let i=Math.abs(t-r);2*Math.PI-i<i&&(t<r?t+=2*Math.PI:r+=2*Math.PI),u.phi=t-r,n.update()},this.setAzimuthalAngle=e=>{let t=Lj(e,2*Math.PI),r=c.theta;r<0&&(r+=2*Math.PI),t<0&&(t+=2*Math.PI);let i=Math.abs(t-r);2*Math.PI-i<i&&(t<r?t+=2*Math.PI:r+=2*Math.PI),u.theta=t-r,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=e=>{e.addEventListener("keydown",q),this._domElementKeyEvents=e},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object instanceof wE?n.object.zoom:1},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object instanceof wE&&(n.object.zoom=n.zoom0,n.object.updateProjectionMatrix()),n.dispatchEvent(r),n.update(),s=a.NONE},this.update=(()=>{const t=new d_,i=(new u_).setFromUnitVectors(e.up,new d_(0,1,0)),o=i.clone().invert(),p=new d_,m=new u_,g=2*Math.PI;return function(){const e=n.object.position;t.copy(e).sub(n.target),t.applyQuaternion(i),c.setFromVector3(t),n.autoRotate&&s===a.NONE&&E(2*Math.PI/60/60*n.autoRotateSpeed),n.enableDamping?(c.theta+=u.theta*n.dampingFactor,c.phi+=u.phi*n.dampingFactor):(c.theta+=u.theta,c.phi+=u.phi);let v=n.minAzimuthAngle,y=n.maxAzimuthAngle;return isFinite(v)&&isFinite(y)&&(v<-Math.PI?v+=g:v>Math.PI&&(v-=g),y<-Math.PI?y+=g:y>Math.PI&&(y-=g),c.theta=v<=y?Math.max(v,Math.min(y,c.theta)):c.theta>(v+y)/2?Math.max(v,c.theta):Math.min(y,c.theta)),c.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,c.phi)),c.makeSafe(),c.radius*=d,c.radius=Math.max(n.minDistance,Math.min(n.maxDistance,c.radius)),!0===n.enableDamping?n.target.addScaledVector(f,n.dampingFactor):n.target.add(f),t.setFromSpherical(c),t.applyQuaternion(o),e.copy(n.target).add(t),n.object.lookAt(n.target),!0===n.enableDamping?(u.theta*=1-n.dampingFactor,u.phi*=1-n.dampingFactor,f.multiplyScalar(1-n.dampingFactor)):(u.set(0,0,0),f.set(0,0,0)),d=1,!!(h||p.distanceToSquared(n.object.position)>l||8*(1-m.dot(n.object.quaternion))>l)&&(n.dispatchEvent(r),p.copy(n.object.position),m.copy(n.object.quaternion),h=!1,!0)}})(),this.connect=e=>{e===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),n.domElement=e,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",K),n.domElement.addEventListener("pointerdown",z),n.domElement.addEventListener("pointercancel",W),n.domElement.addEventListener("wheel",G)},this.dispose=()=>{var e,t,r,i,o,a;null===(e=n.domElement)||void 0===e||e.removeEventListener("contextmenu",K),null===(t=n.domElement)||void 0===t||t.removeEventListener("pointerdown",z),null===(r=n.domElement)||void 0===r||r.removeEventListener("pointercancel",W),null===(i=n.domElement)||void 0===i||i.removeEventListener("wheel",G),null===(o=n.domElement)||void 0===o||o.ownerDocument.removeEventListener("pointermove",H),null===(a=n.domElement)||void 0===a||a.ownerDocument.removeEventListener("pointerup",V),null!==n._domElementKeyEvents&&n._domElementKeyEvents.removeEventListener("keydown",q)};const n=this,r={type:"change"},i={type:"start"},o={type:"end"},a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=a.NONE;const l=1e-6,c=new XP,u=new XP;let d=1;const f=new d_;let h=!1;const p=new NM,m=new NM,g=new NM,v=new NM,y=new NM,b=new NM,w=new NM,x=new NM,S=new NM,M=[],_={};function A(){return Math.pow(.95,n.zoomSpeed)}function E(e){n.reverseOrbit?u.theta+=e:u.theta-=e}function C(e){n.reverseOrbit?u.phi+=e:u.phi-=e}const k=(()=>{const e=new d_;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),f.add(e)}})(),T=(()=>{const e=new d_;return function(t,r){!0===n.screenSpacePanning?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),f.add(e)}})(),I=(()=>{const e=new d_;return function(t,r){const i=n.domElement;if(i&&n.object instanceof wE&&n.object.isPerspectiveCamera){const o=n.object.position;e.copy(o).sub(n.target);let a=e.length();a*=Math.tan(n.object.fov/2*Math.PI/180),k(2*t*a/i.clientHeight,n.object.matrix),T(2*r*a/i.clientHeight,n.object.matrix)}else i&&n.object instanceof WE&&n.object.isOrthographicCamera?(k(t*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),T(r*(n.object.top-n.object.bottom)/n.object.zoom/i.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function O(e){n.object instanceof wE&&n.object.isPerspectiveCamera?d/=e:n.object instanceof WE&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*e)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function R(e){n.object instanceof wE&&n.object.isPerspectiveCamera?d*=e:n.object instanceof WE&&n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/e)),n.object.updateProjectionMatrix(),h=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function P(e){p.set(e.clientX,e.clientY)}function N(e){v.set(e.clientX,e.clientY)}function L(){if(1==M.length)p.set(M[0].pageX,M[0].pageY);else{const e=.5*(M[0].pageX+M[1].pageX),t=.5*(M[0].pageY+M[1].pageY);p.set(e,t)}}function D(){if(1==M.length)v.set(M[0].pageX,M[0].pageY);else{const e=.5*(M[0].pageX+M[1].pageX),t=.5*(M[0].pageY+M[1].pageY);v.set(e,t)}}function B(){const e=M[0].pageX-M[1].pageX,t=M[0].pageY-M[1].pageY,n=Math.sqrt(e*e+t*t);w.set(0,n)}function j(e){if(1==M.length)m.set(e.pageX,e.pageY);else{const t=Q(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);m.set(n,r)}g.subVectors(m,p).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(E(2*Math.PI*g.x/t.clientHeight),C(2*Math.PI*g.y/t.clientHeight)),p.copy(m)}function F(e){if(1==M.length)y.set(e.pageX,e.pageY);else{const t=Q(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);y.set(n,r)}b.subVectors(y,v).multiplyScalar(n.panSpeed),I(b.x,b.y),v.copy(y)}function U(e){const t=Q(e),r=e.pageX-t.x,i=e.pageY-t.y,o=Math.sqrt(r*r+i*i);x.set(0,o),S.set(0,Math.pow(x.y/w.y,n.zoomSpeed)),O(S.y),w.copy(x)}function z(e){if(!1!==n.enabled){var t,r;if(0===M.length)null===(t=n.domElement)||void 0===t||t.ownerDocument.addEventListener("pointermove",H),null===(r=n.domElement)||void 0===r||r.ownerDocument.addEventListener("pointerup",V);!function(e){M.push(e)}(e),"touch"===e.pointerType?function(e){switch(J(e),M.length){case 1:switch(n.touches.ONE){case dw.ROTATE:if(!1===n.enableRotate)return;L(),s=a.TOUCH_ROTATE;break;case dw.PAN:if(!1===n.enablePan)return;D(),s=a.TOUCH_PAN;break;default:s=a.NONE}break;case 2:switch(n.touches.TWO){case dw.DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&B(),n.enablePan&&D(),s=a.TOUCH_DOLLY_PAN;break;case dw.DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&B(),n.enableRotate&&L(),s=a.TOUCH_DOLLY_ROTATE;break;default:s=a.NONE}break;default:s=a.NONE}s!==a.NONE&&n.dispatchEvent(i)}(e):function(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case uw.DOLLY:if(!1===n.enableZoom)return;!function(e){w.set(e.clientX,e.clientY)}(e),s=a.DOLLY;break;case uw.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;N(e),s=a.PAN}else{if(!1===n.enableRotate)return;P(e),s=a.ROTATE}break;case uw.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;P(e),s=a.ROTATE}else{if(!1===n.enablePan)return;N(e),s=a.PAN}break;default:s=a.NONE}s!==a.NONE&&n.dispatchEvent(i)}(e)}}function H(e){!1!==n.enabled&&("touch"===e.pointerType?function(e){switch(J(e),s){case a.TOUCH_ROTATE:if(!1===n.enableRotate)return;j(e),n.update();break;case a.TOUCH_PAN:if(!1===n.enablePan)return;F(e),n.update();break;case a.TOUCH_DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(e){n.enableZoom&&U(e),n.enablePan&&F(e)}(e),n.update();break;case a.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(e){n.enableZoom&&U(e),n.enableRotate&&j(e)}(e),n.update();break;default:s=a.NONE}}(e):function(e){if(!1===n.enabled)return;switch(s){case a.ROTATE:if(!1===n.enableRotate)return;!function(e){m.set(e.clientX,e.clientY),g.subVectors(m,p).multiplyScalar(n.rotateSpeed);const t=n.domElement;t&&(E(2*Math.PI*g.x/t.clientHeight),C(2*Math.PI*g.y/t.clientHeight)),p.copy(m),n.update()}(e);break;case a.DOLLY:if(!1===n.enableZoom)return;!function(e){x.set(e.clientX,e.clientY),S.subVectors(x,w),S.y>0?O(A()):S.y<0&&R(A()),w.copy(x),n.update()}(e);break;case a.PAN:if(!1===n.enablePan)return;!function(e){y.set(e.clientX,e.clientY),b.subVectors(y,v).multiplyScalar(n.panSpeed),I(b.x,b.y),v.copy(y),n.update()}(e)}}(e))}function V(e){var t,r,i;(Y(e),0===M.length)&&(null===(t=n.domElement)||void 0===t||t.releasePointerCapture(e.pointerId),null===(r=n.domElement)||void 0===r||r.ownerDocument.removeEventListener("pointermove",H),null===(i=n.domElement)||void 0===i||i.ownerDocument.removeEventListener("pointerup",V));n.dispatchEvent(o),s=a.NONE}function W(e){Y(e)}function G(e){!1===n.enabled||!1===n.enableZoom||s!==a.NONE&&s!==a.ROTATE||(e.preventDefault(),n.dispatchEvent(i),function(e){e.deltaY<0?R(A()):e.deltaY>0&&O(A()),n.update()}(e),n.dispatchEvent(o))}function q(e){!1!==n.enabled&&!1!==n.enablePan&&function(e){let t=!1;switch(e.code){case n.keys.UP:I(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:I(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:I(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:I(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function K(e){!1!==n.enabled&&e.preventDefault()}function Y(e){delete _[e.pointerId];for(let t=0;t<M.length;t++)if(M[t].pointerId==e.pointerId)return void M.splice(t,1)}function J(e){let t=_[e.pointerId];void 0===t&&(t=new NM,_[e.pointerId]=t),t.set(e.pageX,e.pageY)}function Q(e){const t=e.pointerId===M[0].pointerId?M[1]:M[0];return _[t.pointerId]}void 0!==t&&this.connect(t),this.update()}}const Bj=u.forwardRef((({makeDefault:e,camera:t,regress:n,domElement:r,enableDamping:i=!0,onChange:o,onStart:a,onEnd:s,...l},c)=>{const d=tB((e=>e.invalidate)),f=tB((e=>e.camera)),h=tB((e=>e.gl)),p=tB((e=>e.events)),m=tB((e=>e.set)),g=tB((e=>e.get)),v=tB((e=>e.performance)),y=t||f,b=r||p.connected||h.domElement,w=u.useMemo((()=>new Dj(y)),[y]);return nB((()=>{w.enabled&&w.update()})),u.useEffect((()=>(w.connect(b),()=>{w.dispose()})),[b,n,w,d]),u.useEffect((()=>{const e=e=>{d(),n&&v.regress(),o&&o(e)};return w.addEventListener("change",e),a&&w.addEventListener("start",a),s&&w.addEventListener("end",s),()=>{a&&w.removeEventListener("start",a),s&&w.removeEventListener("end",s),w.removeEventListener("change",e)}}),[o,a,s]),u.useEffect((()=>{if(e){const e=g().controls;return m({controls:w}),()=>m({controls:e})}}),[e,w]),u.createElement("primitive",cj({ref:c,object:w,enableDamping:i},l))})),jj={width:"250px",height:"250px",backgroundColor:"white",borderRadius:"100%"},Fj={width:"500px",height:"500px",backgroundColor:"white"};function Uj({url:e,sex:t,fallbackImg:n,style:r,rotateAvatar:i,eyeBlink:o,headMovement:a,speaking:l,fallback:c,halfBody:d=!0,animation:f}){const h=d?jj:Fj;return(0,s.jsx)($D,{style:r||h,camera:d?{fov:40,position:[0,0,.6]}:{fov:40,position:[0,175e-7,3]},children:(0,s.jsxs)(u.Suspense,{fallback:c||(0,s.jsx)(wj,{fallbackImg:n}),children:["android"===((null===(p=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===p?void 0:p.platform)||(null===navigator||void 0===navigator?void 0:navigator.platform)||"unknown").toLowerCase()||navigator.userAgent.includes("Android")?(0,s.jsx)(Mj,{distance:100,position:[-.3,.2,1.25],angle:Math.PI/2,attenuation:5,anglePower:5}):(0,s.jsx)(Cj,{preset:"sunset"}),i&&d&&(0,s.jsx)(Bj,{enablePan:!1,enableZoom:!1}),d?(0,s.jsx)(JB,{url:e,eyeBlink:o,headMovement:a,speaking:l}):(0,s.jsx)(aj,{url:e,sex:t,eyeBlink:o,headMovement:a,speaking:l,animation:f})]})});var p}Jd=a("4IUwl");var zj=({avatar:e,speaking:t=!1})=>(0,s.jsxs)("div",{className:r(Jd)("memori-blob",{"memori-blob--speaking":t}),children:[e&&(0,s.jsx)("figure",{children:(0,s.jsx)("img",{src:e,alt:"",role:"presentation"})}),(0,s.jsx)("div",{className:"mainDiv"}),(0,s.jsx)("div",{className:"mainDiv"}),(0,s.jsx)("div",{className:"mainDiv"}),(0,s.jsx)("div",{className:"mainDiv"}),(0,s.jsx)("div",{className:"mainDiv"})]});var Hj=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 000 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z"})});var Vj=({className:e,title:t})=>(0,s.jsxs)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:[(0,s.jsx)("path",{d:"M942.2 486.2Q889.47 375.11 816.7 305l-50.88 50.88C807.31 395.53 843.45 447.4 874.7 512 791.5 684.2 673.4 766 512 766q-72.67 0-133.87-22.38L323 798.75Q408 838 512 838q288.3 0 430.2-300.3a60.29 60.29 0 000-51.5zm-63.57-320.64L836 122.88a8 8 0 00-11.32 0L715.31 232.2Q624.86 186 512 186q-288.3 0-430.2 300.3a60.3 60.3 0 000 51.5q56.69 119.4 136.5 191.41L112.48 835a8 8 0 000 11.31L155.17 889a8 8 0 0011.31 0l712.15-712.12a8 8 0 000-11.32zM149.3 512C232.6 339.8 350.7 258 512 258c54.54 0 104.13 9.36 149.12 28.39l-70.3 70.3a176 176 0 00-238.13 238.13l-83.42 83.42C223.1 637.49 183.3 582.28 149.3 512zm246.7 0a112.11 112.11 0 01146.2-106.69L401.31 546.2A112 112 0 01396 512z"}),(0,s.jsx)("path",{d:"M508 624c-3.46 0-6.87-.16-10.25-.47l-52.82 52.82a176.09 176.09 0 00227.42-227.42l-52.82 52.82c.31 3.38.47 6.79.47 10.25a111.94 111.94 0 01-112 112z"})]});var Wj=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"})});Jd=a("4IUwl");var Gj=(0,u.memo)((({memori:e,integration:t,integrationConfig:n,tenant:i,instruct:o=!1,avatar3dVisible:a=!1,setAvatar3dVisible:l,hasUserActivatedSpeak:c=!1,isPlayingAudio:d=!1,loading:f=!1,baseUrl:h,apiUrl:p})=>{const{t:m}=Te(),[g,v]=(0,u.useState)(!1);(0,u.useEffect)((()=>{v(!0)}),[]);const y=(0,u.useMemo)((()=>d?["Talk 1","Talk 2","Talk 3"][Math.round(2*Math.random())]:f?"Loading":["Idle","Idle 1","Idle 2","Idle 3"][Math.round(3*Math.random())]),[d,f]);return(0,s.jsxs)(s.Fragment,{children:["readyplayerme"!==(null==n?void 0:n.avatar)&&"readyplayerme-full"!==(null==n?void 0:n.avatar)&&"customglb"!==(null==n?void 0:n.avatar)||!(null==n?void 0:n.avatarURL)?(0,s.jsx)("div",{className:"memori--blob-container",children:g&&(0,s.jsx)(zj,{avatar:"userAvatar"===(null==n?void 0:n.avatar)&&e.avatarURL&&e.avatarURL.length>0?jm({type:"avatar",tenantID:null==i?void 0:i.id,resourceURI:e.avatarURL,baseURL:h,apiURL:p}):void 0})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:r(Jd)("memori--avatar-wrapper",{hidden:!a}),children:[g&&("readyplayerme"===n.avatar||"readyplayerme-full"===n.avatar)&&(0,s.jsx)(sw,{fallback:(0,s.jsx)("div",{className:"memori--blob-container",children:g&&(0,s.jsx)(zj,{speaking:d,avatar:"userAvatar"===(null==n?void 0:n.avatar)&&e.avatarURL&&e.avatarURL.length>0?jm({type:"avatar",tenantID:null==i?void 0:i.id,resourceURI:e.avatarURL,baseURL:h,apiURL:p}):void 0})}),children:(0,s.jsx)(Uj,{url:n.avatarURL,sex:"FEMALE"===e.voiceType?"FEMALE":"MALE",fallbackImg:jm({type:"avatar",tenantID:null==i?void 0:i.id,resourceURI:e.avatarURL,baseURL:h,apiURL:p}),headMovement:!0,eyeBlink:!0,halfBody:"readyplayerme"===n.avatar,animation:y,speaking:d,style:"readyplayerme"===n.avatar?{width:"300px",height:"300px",backgroundColor:"none",borderRadius:"100%",boxShadow:"none"}:{width:"600px",height:"600px",backgroundColor:"none"}})}),g&&"customglb"===n.avatar&&(0,s.jsx)(Cg,{poster:jm({type:"avatar",tenantID:null==i?void 0:i.id,resourceURI:e.avatarURL,baseURL:h,apiURL:p}),src:n.avatarURL,alt:""})]}),(0,s.jsx)("div",{className:"memori--avatar-toggle",children:(0,s.jsx)(Zd,{ghost:!0,onClick:()=>l(!a),icon:a?(0,s.jsx)(Vj,{}):(0,s.jsx)(Hj,{}),children:(0,s.jsx)("span",{className:"memori--avatar-toggle-text",children:m(a?"hide":"show")})})})]}),o&&!c&&e.isGiver&&(null==i?void 0:i.id)&&(0,s.jsx)("div",{className:"memori--avatar-link-to-integrations",children:(0,s.jsx)("a",{className:"memori-button memori-button--circle memori-button--outlined",href:`https://${i.id}/${"it-IT"===e.culture?"it":"en"}/${e.ownerUserName}/${e.name}/integrations${(null==t?void 0:t.integrationID)?`?integration=${t.integrationID}&openAvatarModal=true`:""}`,children:(0,s.jsx)(zm,{content:m("widgetgoToIntegrationsToCustomizeAvatar"),children:(0,s.jsx)("span",{className:"memori-button--icon",children:(0,s.jsx)(Wj,{})})})})})]})}),((e,t)=>JSON.stringify(e)===JSON.stringify(t)));var qj=({instruct:e,canInstruct:t,onChangeMode:n})=>{const{t:r}=Te();return t?(0,s.jsx)("div",{className:"memori--changeMode-instruct",children:(0,s.jsxs)(Sb,{name:"instruct",value:e?"instruct":"test",defaultValue:e?"instruct":"test",className:"memori--changeMode-instruct-radio",onChange:n,children:[(0,s.jsx)(Sb.Option,{value:"instruct",className:"memori--changeMode-instruct-radio-button",children:({checked:e})=>(0,s.jsx)(Zd,{primary:e,children:r("widget.instruct")||"Instruct"})}),(0,s.jsx)(Sb.Option,{value:"test",className:"memori--changeMode-instruct-radio-button",children:({checked:e})=>(0,s.jsx)(Zd,{primary:e,children:r("widget.test")||"Test"})})]})}):null};u=a("85Hg2"),Jd=a("4IUwl");var Kj=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",className:e,"aria-label":t,children:(0,s.jsx)("path",{fill:"currentColor",d:"M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z"})});var Yj=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",viewBox:"0 0 40 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M25.085.277c-.264 0-.531.071-.777.236L8.482 10.857H1.161a.716.716 0 00-.715.714V24.43c0 .392.322.714.715.714h7.321l15.826 10.344c.246.16.518.236.777.236.745 0 1.433-.593 1.433-1.433V1.71c0-.84-.688-1.433-1.433-1.433zM23.304 30.99l-13.063-8.54-.803-.522H3.66V14.07h5.777l.799-.522 13.067-8.54V30.99zM39.534 15.148L36.967 18l2.567 2.852a1.09 1.09 0 010 1.427l-1.283 1.426a.845.845 0 01-1.284 0L34.4 20.852l-2.567 2.852a.845.845 0 01-1.283 0l-1.284-1.426a1.09 1.09 0 010-1.426L31.833 18l-2.567-2.852a1.09 1.09 0 010-1.426l1.283-1.427a.845.845 0 011.284 0l2.567 2.853 2.567-2.853a.845.845 0 011.284 0l1.283 1.427a1.09 1.09 0 010 1.426z",fill:"currentColor"})});var Jj,Qj=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M625.9 115c-5.9 0-11.9 1.6-17.4 5.3L254 352H90c-8.8 0-16 7.2-16 16v288c0 8.8 7.2 16 16 16h164l354.5 231.7c5.5 3.6 11.6 5.3 17.4 5.3 16.7 0 32.1-13.3 32.1-32.1V147.1c0-18.8-15.4-32.1-32.1-32.1zM586 803L293.4 611.7l-18-11.7H146V424h129.4l17.9-11.7L586 221v582zm348-327H806c-8.8 0-16 7.2-16 16v40c0 8.8 7.2 16 16 16h128c8.8 0 16-7.2 16-16v-40c0-8.8-7.2-16-16-16zm-41.9 261.8l-110.3-63.7a15.9 15.9 0 00-21.7 5.9l-19.9 34.5c-4.4 7.6-1.8 17.4 5.8 21.8L856.3 800a15.9 15.9 0 0021.7-5.9l19.9-34.5c4.4-7.6 1.7-17.4-5.8-21.8zM760 344a15.9 15.9 0 0021.7 5.9L892 286.2c7.6-4.4 10.2-14.2 5.8-21.8L878 230a15.9 15.9 0 00-21.7-5.9L746 287.8a15.99 15.99 0 00-5.8 21.8L760 344z"})}),Xj=(u=a("85Hg2"),(Jj=Xj||{})[Jj.Open=0]="Open",Jj[Jj.Closed=1]="Closed",Jj),Zj=(e=>(e[e.TogglePopover=0]="TogglePopover",e[e.ClosePopover=1]="ClosePopover",e[e.SetButton=2]="SetButton",e[e.SetButtonId=3]="SetButtonId",e[e.SetPanel=4]="SetPanel",e[e.SetPanelId=5]="SetPanelId",e))(Zj||{});let $j={0:e=>({...e,popoverState:$d(e.popoverState,{0:1,1:0})}),1:e=>1===e.popoverState?e:{...e,popoverState:1},2:(e,t)=>e.button===t.button?e:{...e,button:t.button},3:(e,t)=>e.buttonId===t.buttonId?e:{...e,buttonId:t.buttonId},4:(e,t)=>e.panel===t.panel?e:{...e,panel:t.panel},5:(e,t)=>e.panelId===t.panelId?e:{...e,panelId:t.panelId}},eF=(0,u.createContext)(null);function tF(e){let t=(0,u.useContext)(eF);if(null===t){let t=new Error(`<${e} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,tF),t}return t}eF.displayName="PopoverContext";let nF=(0,u.createContext)(null);function rF(e){let t=(0,u.useContext)(nF);if(null===t){let t=new Error(`<${e} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,rF),t}return t}nF.displayName="PopoverAPIContext";let iF=(0,u.createContext)(null);function oF(){return(0,u.useContext)(iF)}iF.displayName="PopoverGroupContext";let aF=(0,u.createContext)(null);function sF(e,t){return $d(t.type,$j,e,t)}aF.displayName="PopoverPanelContext";let lF=lf((function(e,t){var n;let i=`headlessui-popover-button-${nh()}`,o=`headlessui-popover-panel-${nh()}`,a=(0,u.useRef)(null),s=_f(t,Mf((e=>{a.current=e}))),l=(0,u.useReducer)(sF,{popoverState:1,button:null,buttonId:i,panel:null,panelId:o,beforePanelSentinel:(0,u.createRef)(),afterPanelSentinel:(0,u.createRef)()}),[{popoverState:c,button:d,panel:f,beforePanelSentinel:h,afterPanelSentinel:p},m]=l,g=Mh(null!=(n=a.current)?n:d);(0,u.useEffect)((()=>m({type:3,buttonId:i})),[i,m]),(0,u.useEffect)((()=>m({type:5,panelId:o})),[o,m]);let v=(0,u.useMemo)((()=>{if(!d||!f)return!1;for(let e of document.querySelectorAll("body > *"))if(Number(null==e?void 0:e.contains(d))^Number(null==e?void 0:e.contains(f)))return!0;let e=dh(),t=e.indexOf(d),n=(t+e.length-1)%e.length,r=(t+1)%e.length,i=e[n],o=e[r];return!f.contains(i)&&!f.contains(o)}),[d,f]),y=(0,u.useMemo)((()=>({buttonId:i,panelId:o,close:()=>m({type:1})})),[i,o,m]),b=oF(),w=null==b?void 0:b.registerPopover,x=xf((()=>{var e;return null!=(e=null==b?void 0:b.isFocusWithinPopoverGroup())?e:(null==g?void 0:g.activeElement)&&((null==d?void 0:d.contains(g.activeElement))||(null==f?void 0:f.contains(g.activeElement)))}));(0,u.useEffect)((()=>null==w?void 0:w(y)),[w,y]),_h(null==g?void 0:g.defaultView,"focus",(e=>{var t,n,r,i;0===c&&(x()||!d||!f||null!=(n=null==(t=h.current)?void 0:t.contains)&&n.call(t,e.target)||null!=(i=null==(r=p.current)?void 0:r.contains)&&i.call(r,e.target)||m({type:1}))}),!0),Qh([d,f],((e,t)=>{m({type:1}),hh(t,fh.Loose)||(e.preventDefault(),null==d||d.focus())}),0===c);let S=xf((e=>{m({type:1});let t=e?e instanceof HTMLElement?e:"current"in e&&e.current instanceof HTMLElement?e.current:d:d;null==t||t.focus()})),M=(0,u.useMemo)((()=>({close:S,isPortalled:v})),[S,v]),_=(0,u.useMemo)((()=>({open:0===c,close:S})),[c,S]),A=e,E={ref:s};return r(u).createElement(eF.Provider,{value:l},r(u).createElement(nF.Provider,{value:M},r(u).createElement(pf,{value:$d(c,{0:ff.Open,1:ff.Closed})},of({ourProps:E,theirProps:A,slot:_,defaultTag:"div",name:"Popover"}))))})),cF=lf((function(e,t){let[n,i]=tF("Popover.Button"),{isPortalled:o}=rF("Popover.Button"),a=(0,u.useRef)(null),s=`headlessui-focus-sentinel-${nh()}`,l=oF(),c=null==l?void 0:l.closeOthers,d=(0,u.useContext)(aF),f=null!==d&&d===n.panelId,h=_f(a,t,f?null:e=>e&&i({type:2,button:e})),p=_f(a,t),m=Mh(a),g=xf((e=>{var t,r,o;if(f){if(1===n.popoverState)return;switch(e.key){case Xf.Space:case Xf.Enter:e.preventDefault(),null==(r=(t=e.target).click)||r.call(t),i({type:1}),null==(o=n.button)||o.focus()}}else switch(e.key){case Xf.Space:case Xf.Enter:e.preventDefault(),e.stopPropagation(),1===n.popoverState&&(null==c||c(n.buttonId)),i({type:0});break;case Xf.Escape:if(0!==n.popoverState)return null==c?void 0:c(n.buttonId);if(!a.current||(null==m?void 0:m.activeElement)&&!a.current.contains(m.activeElement))return;e.preventDefault(),e.stopPropagation(),i({type:1})}})),v=xf((e=>{f||e.key===Xf.Space&&e.preventDefault()})),y=xf((t=>{var r,o;Zf(t.currentTarget)||e.disabled||(f?(i({type:1}),null==(r=n.button)||r.focus()):(t.preventDefault(),t.stopPropagation(),1===n.popoverState&&(null==c||c(n.buttonId)),i({type:0}),null==(o=n.button)||o.focus()))})),b=xf((e=>{e.preventDefault(),e.stopPropagation()})),w=0===n.popoverState,x=(0,u.useMemo)((()=>({open:w})),[w]),S=qm(e,a),M=e,_=f?{ref:p,type:S,onKeyDown:g,onClick:y}:{ref:h,id:n.buttonId,type:S,"aria-expanded":e.disabled?void 0:0===n.popoverState,"aria-controls":n.panel?n.panelId:void 0,onKeyDown:g,onKeyUp:v,onClick:y,onMouseDown:b},A=Sh(),E=xf((()=>{let e=n.panel;e&&$d(A.current,{[xh.Forwards]:()=>bh(e,lh.First),[xh.Backwards]:()=>bh(e,lh.Last)})}));return r(u).createElement(r(u).Fragment,null,of({ourProps:_,theirProps:M,slot:x,defaultTag:"button",name:"Popover.Button"}),w&&!f&&o&&r(u).createElement(ih,{id:s,features:rh.Focusable,as:"button",type:"button",onFocus:E}))})),uF=nf.RenderStrategy|nf.Static,dF=lf((function(e,t){let[{popoverState:n},r]=tF("Popover.Overlay"),i=_f(t),o=`headlessui-popover-overlay-${nh()}`,a=hf(),s=null!==a?a===ff.Open:0===n;return of({ourProps:{ref:i,id:o,"aria-hidden":!0,onClick:xf((e=>{if(Zf(e.currentTarget))return e.preventDefault();r({type:1})}))},theirProps:e,slot:(0,u.useMemo)((()=>({open:0===n})),[n]),defaultTag:"div",features:uF,visible:s,name:"Popover.Overlay"})})),fF=nf.RenderStrategy|nf.Static,hF=lf((function(e,t){let{focus:n=!1,...i}=e,[o,a]=tF("Popover.Panel"),{close:s,isPortalled:l}=rF("Popover.Panel"),c=`headlessui-focus-sentinel-before-${nh()}`,d=`headlessui-focus-sentinel-after-${nh()}`,f=(0,u.useRef)(null),h=_f(f,t,(e=>{a({type:4,panel:e})})),p=Mh(f),m=hf(),g=null!==m?m===ff.Open:0===o.popoverState,v=xf((e=>{var t;if(e.key===Xf.Escape){if(0!==o.popoverState||!f.current||(null==p?void 0:p.activeElement)&&!f.current.contains(p.activeElement))return;e.preventDefault(),e.stopPropagation(),a({type:1}),null==(t=o.button)||t.focus()}}));(0,u.useEffect)((()=>{var t;e.static||1===o.popoverState&&(null==(t=e.unmount)||t)&&a({type:4,panel:null})}),[o.popoverState,e.unmount,e.static,a]),(0,u.useEffect)((()=>{if(!n||0!==o.popoverState||!f.current)return;let e=null==p?void 0:p.activeElement;f.current.contains(e)||bh(f.current,lh.First)}),[n,f,o.popoverState]);let y=(0,u.useMemo)((()=>({open:0===o.popoverState,close:s})),[o,s]),b={ref:h,id:o.panelId,onKeyDown:v,onBlur:n&&0===o.popoverState?e=>{var t,n,r,i,s;let l=e.relatedTarget;!l||!f.current||null!=(t=f.current)&&t.contains(l)||(a({type:1}),((null==(r=null==(n=o.beforePanelSentinel.current)?void 0:n.contains)?void 0:r.call(n,l))||(null==(s=null==(i=o.afterPanelSentinel.current)?void 0:i.contains)?void 0:s.call(i,l)))&&l.focus({preventScroll:!0}))}:void 0,tabIndex:-1},w=Sh(),x=xf((()=>{let e=f.current;e&&$d(w.current,{[xh.Forwards]:()=>{bh(e,lh.First)},[xh.Backwards]:()=>{var e;null==(e=o.button)||e.focus({preventScroll:!0})}})})),S=xf((()=>{let e=f.current;e&&$d(w.current,{[xh.Forwards]:()=>{var e,t,n;if(!o.button)return;let r=dh(),i=r.indexOf(o.button),a=r.slice(0,i+1),s=[...r.slice(i+1),...a];for(let r of s.slice())if((null==(t=null==(e=null==r?void 0:r.id)?void 0:e.startsWith)?void 0:t.call(e,"headlessui-focus-sentinel-"))||(null==(n=o.panel)?void 0:n.contains(r))){let e=s.indexOf(r);-1!==e&&s.splice(e,1)}bh(s,lh.First,!1)},[xh.Backwards]:()=>bh(e,lh.Last)})}));return r(u).createElement(aF.Provider,{value:o.panelId},g&&l&&r(u).createElement(ih,{id:c,ref:o.beforePanelSentinel,features:rh.Focusable,as:"button",type:"button",onFocus:x}),of({ourProps:b,theirProps:i,slot:y,defaultTag:"div",features:fF,visible:g,name:"Popover.Panel"}),g&&l&&r(u).createElement(ih,{id:d,ref:o.afterPanelSentinel,features:rh.Focusable,as:"button",type:"button",onFocus:S}))})),pF=lf((function(e,t){let n=(0,u.useRef)(null),i=_f(n,t),[o,a]=(0,u.useState)([]),s=xf((e=>{a((t=>{let n=t.indexOf(e);if(-1!==n){let e=t.slice();return e.splice(n,1),e}return t}))})),l=xf((e=>(a((t=>[...t,e])),()=>s(e)))),c=xf((()=>{var e;let t=oh(n);if(!t)return!1;let r=t.activeElement;return!(null==(e=n.current)||!e.contains(r))||o.some((e=>{var n,i;return(null==(n=t.getElementById(e.buttonId))?void 0:n.contains(r))||(null==(i=t.getElementById(e.panelId))?void 0:i.contains(r))}))})),d=xf((e=>{for(let t of o)t.buttonId!==e&&t.close()})),f=(0,u.useMemo)((()=>({registerPopover:l,unregisterPopover:s,isFocusWithinPopoverGroup:c,closeOthers:d})),[l,s,c,d]),h=(0,u.useMemo)((()=>({})),[]),p=e,m={ref:i};return r(u).createElement(iF.Provider,{value:f},of({ourProps:m,theirProps:p,slot:h,defaultTag:"div",name:"Popover.Group"}))})),mF=Object.assign(lF,{Button:cF,Overlay:dF,Panel:hF,Group:pF});var gF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M464 512a48 48 0 1096 0 48 48 0 10-96 0zm200 0a48 48 0 1096 0 48 48 0 10-96 0zm-400 0a48 48 0 1096 0 48 48 0 10-96 0zm661.2-173.6c-22.6-53.7-55-101.9-96.3-143.3a444.35 444.35 0 00-143.3-96.3C630.6 75.7 572.2 64 512 64h-2c-60.6.3-119.3 12.3-174.5 35.9a445.35 445.35 0 00-142 96.5c-40.9 41.3-73 89.3-95.2 142.8-23 55.4-34.6 114.3-34.3 174.9A449.4 449.4 0 00112 714v152a46 46 0 0046 46h152.1A449.4 449.4 0 00510 960h2.1c59.9 0 118-11.6 172.7-34.3a444.48 444.48 0 00142.8-95.2c41.3-40.9 73.8-88.7 96.5-142 23.6-55.2 35.6-113.9 35.9-174.5.3-60.9-11.5-120-34.8-175.6zm-151.1 438C704 845.8 611 884 512 884h-1.7c-60.3-.3-120.2-15.3-173.1-43.5l-8.4-4.5H188V695.2l-4.5-8.4C155.3 633.9 140.3 574 140 513.7c-.4-99.7 37.7-193.3 107.6-263.8 69.8-70.5 163.1-109.5 262.8-109.9h1.7c50 0 98.5 9.7 144.2 28.9 44.6 18.7 84.6 45.6 119 80 34.3 34.3 61.3 74.4 80 119 19.4 46.2 29.1 95.2 28.9 145.8-.6 99.6-39.7 192.9-110.1 262.7z"})});Jd=a("4IUwl");var vF=({history:e,memori:t,className:n,buttonClassName:i,icon:o,disabled:a=!1,align:l="right",filename:c})=>{const{t:u}=Te(),d=`${u("write_and_speak.conversationStartedLabel")} ${new Intl.DateTimeFormat("it",{dateStyle:"short",timeStyle:"short"}).format(new Date)}\n\n`.concat(e.map((e=>`${e.fromUser?"YOU":t.name}: ${e.text}`)).join("\n"));return(0,s.jsx)(mF,{title:u("write_and_speak.exportChatHistoryMessage"),className:r(Jd)("memori-export-history-button",n,{"memori-export-history-button--align-left":"left"===l}),children:({close:e})=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(mF.Button,{disabled:a,className:r(Jd)("memori-button","memori-button--circle","memori-button--icon-only",i,{"memori-button--disabled":a,"memori-button--primary":!a}),children:(0,s.jsx)("div",{className:"memori-button--icon",children:o||(0,s.jsx)(gF,{})})}),(0,s.jsxs)(mF.Panel,{className:"memori-export-history-button--panel",children:[(0,s.jsx)("p",{children:u("write_and_speak.exportChatHistory")}),(0,s.jsx)(Zd,{primary:!0,onClick:()=>((e,t="export-chat.txt")=>{const n=new Blob([e],{type:"text/plain"}),r=URL.createObjectURL(n),i=document.createElement("a");i.setAttribute("href",r),i.setAttribute("download",t),i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i)})(d,c||`${t.name.replace(/\W+/g,"-")}-export-chat.txt`),children:u("yes")||"Yes"}),(0,s.jsx)(Zd,{onClick:()=>e(),children:u("no")||"No"})]})]})})};var yF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M924.8 625.7l-65.5-56c3.1-19 4.7-38.4 4.7-57.8s-1.6-38.8-4.7-57.8l65.5-56a32.03 32.03 0 009.3-35.2l-.9-2.6a443.74 443.74 0 00-79.7-137.9l-1.8-2.1a32.12 32.12 0 00-35.1-9.5l-81.3 28.9c-30-24.6-63.5-44-99.7-57.6l-15.7-85a32.05 32.05 0 00-25.8-25.7l-2.7-.5c-52.1-9.4-106.9-9.4-159 0l-2.7.5a32.05 32.05 0 00-25.8 25.7l-15.8 85.4a351.86 351.86 0 00-99 57.4l-81.9-29.1a32 32 0 00-35.1 9.5l-1.8 2.1a446.02 446.02 0 00-79.7 137.9l-.9 2.6c-4.5 12.5-.8 26.5 9.3 35.2l66.3 56.6c-3.1 18.8-4.6 38-4.6 57.1 0 19.2 1.5 38.4 4.6 57.1L99 625.5a32.03 32.03 0 00-9.3 35.2l.9 2.6c18.1 50.4 44.9 96.9 79.7 137.9l1.8 2.1a32.12 32.12 0 0035.1 9.5l81.9-29.1c29.8 24.5 63.1 43.9 99 57.4l15.8 85.4a32.05 32.05 0 0025.8 25.7l2.7.5a449.4 449.4 0 00159 0l2.7-.5a32.05 32.05 0 0025.8-25.7l15.7-85a350 350 0 0099.7-57.6l81.3 28.9a32 32 0 0035.1-9.5l1.8-2.1c34.8-41.1 61.6-87.5 79.7-137.9l.9-2.6c4.5-12.3.8-26.3-9.3-35zM788.3 465.9c2.5 15.1 3.8 30.6 3.8 46.1s-1.3 31-3.8 46.1l-6.6 40.1 74.7 63.9a370.03 370.03 0 01-42.6 73.6L721 702.8l-31.4 25.8c-23.9 19.6-50.5 35-79.3 45.8l-38.1 14.3-17.9 97a377.5 377.5 0 01-85 0l-17.9-97.2-37.8-14.5c-28.5-10.8-55-26.2-78.7-45.7l-31.4-25.9-93.4 33.2c-17-22.9-31.2-47.6-42.6-73.6l75.5-64.5-6.5-40c-2.4-14.9-3.7-30.3-3.7-45.5 0-15.3 1.2-30.6 3.7-45.5l6.5-40-75.5-64.5c11.3-26.1 25.6-50.7 42.6-73.6l93.4 33.2 31.4-25.9c23.7-19.5 50.2-34.9 78.7-45.7l37.9-14.3 17.9-97.2c28.1-3.2 56.8-3.2 85 0l17.9 97 38.1 14.3c28.7 10.8 55.4 26.2 79.3 45.8l31.4 25.8 92.8-32.9c17 22.9 31.2 47.6 42.6 73.6L781.8 426l6.5 39.9zM512 326c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm79.2 255.2A111.6 111.6 0 01512 614c-29.9 0-58-11.7-79.2-32.8A111.6 111.6 0 01400 502c0-29.9 11.7-58 32.8-79.2C454 401.6 482.1 390 512 390c29.9 0 58 11.6 79.2 32.8A111.6 111.6 0 01624 502c0 29.9-11.7 58-32.8 79.2z"})});u=a("85Hg2");var bF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-32 736H663.9V602.2h104l15.6-120.7H663.9v-77.1c0-35 9.7-58.8 59.8-58.8h63.9v-108c-11.1-1.5-49-4.8-93.2-4.8-92.2 0-155.3 56.3-155.3 159.6v89H434.9v120.7h104.3V848H176V176h672v672z"})});var wF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M928 254.3c-30.6 13.2-63.9 22.7-98.2 26.4a170.1 170.1 0 0 0 75-94 336.64 336.64 0 0 1-108.2 41.2A170.1 170.1 0 0 0 672 174c-94.5 0-170.5 76.6-170.5 170.6 0 13.2 1.6 26.4 4.2 39.1-141.5-7.4-267.7-75-351.6-178.5a169.32 169.32 0 0 0-23.2 86.1c0 59.2 30.1 111.4 76 142.1a172 172 0 0 1-77.1-21.7v2.1c0 82.9 58.6 151.6 136.7 167.4a180.6 180.6 0 0 1-44.9 5.8c-11.1 0-21.6-1.1-32.2-2.6C211 652 273.9 701.1 348.8 702.7c-58.6 45.9-132 72.9-211.7 72.9-14.3 0-27.5-.5-41.2-2.1C171.5 822 261.2 850 357.8 850 671.4 850 843 590.2 843 364.7c0-7.4 0-14.8-.5-22.2 33.2-24.3 62.3-54.4 85.5-88.2z"})});var xF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M847.7 112H176.3c-35.5 0-64.3 28.8-64.3 64.3v671.4c0 35.5 28.8 64.3 64.3 64.3h671.4c35.5 0 64.3-28.8 64.3-64.3V176.3c0-35.5-28.8-64.3-64.3-64.3zm0 736c-447.8-.1-671.7-.2-671.7-.3.1-447.8.2-671.7.3-671.7 447.8.1 671.7.2 671.7.3-.1 447.8-.2 671.7-.3 671.7zM230.6 411.9h118.7v381.8H230.6zm59.4-52.2c37.9 0 68.8-30.8 68.8-68.8a68.8 68.8 0 1 0-137.6 0c-.1 38 30.7 68.8 68.8 68.8zm252.3 245.1c0-49.8 9.5-98 71.2-98 60.8 0 61.7 56.9 61.7 101.2v185.7h118.6V584.3c0-102.8-22.2-181.9-142.3-181.9-57.7 0-96.4 31.7-112.3 61.7h-1.6v-52.2H423.7v381.8h118.6V604.8z"})});var SF=({className:e,title:t})=>(0,s.jsxs)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:[(0,s.jsx)("path",{d:"M713.5 599.9c-10.9-5.6-65.2-32.2-75.3-35.8-10.1-3.8-17.5-5.6-24.8 5.6-7.4 11.1-28.4 35.8-35 43.3-6.4 7.4-12.9 8.3-23.8 2.8-64.8-32.4-107.3-57.8-150-131.1-11.3-19.5 11.3-18.1 32.4-60.2 3.6-7.4 1.8-13.7-1-19.3-2.8-5.6-24.8-59.8-34-81.9-8.9-21.5-18.1-18.5-24.8-18.9-6.4-.4-13.7-.4-21.1-.4-7.4 0-19.3 2.8-29.4 13.7-10.1 11.1-38.6 37.8-38.6 92s39.5 106.7 44.9 114.1c5.6 7.4 77.7 118.6 188.4 166.5 70 30.2 97.4 32.8 132.4 27.6 21.3-3.2 65.2-26.6 74.3-52.5 9.1-25.8 9.1-47.9 6.4-52.5-2.7-4.9-10.1-7.7-21-13z"}),(0,s.jsx)("path",{d:"M925.2 338.4c-22.6-53.7-55-101.9-96.3-143.3-41.3-41.3-89.5-73.8-143.3-96.3C630.6 75.7 572.2 64 512 64h-2c-60.6.3-119.3 12.3-174.5 35.9-53.3 22.8-101.1 55.2-142 96.5-40.9 41.3-73 89.3-95.2 142.8-23 55.4-34.6 114.3-34.3 174.9.3 69.4 16.9 138.3 48 199.9v152c0 25.4 20.6 46 46 46h152.1c61.6 31.1 130.5 47.7 199.9 48h2.1c59.9 0 118-11.6 172.7-34.3 53.5-22.3 101.6-54.3 142.8-95.2 41.3-40.9 73.8-88.7 96.5-142 23.6-55.2 35.6-113.9 35.9-174.5.3-60.9-11.5-120-34.8-175.6zm-151.1 438C704 845.8 611 884 512 884h-1.7c-60.3-.3-120.2-15.3-173.1-43.5l-8.4-4.5H188V695.2l-4.5-8.4C155.3 633.9 140.3 574 140 513.7c-.4-99.7 37.7-193.3 107.6-263.8 69.8-70.5 163.1-109.5 262.8-109.9h1.7c50 0 98.5 9.7 144.2 28.9 44.6 18.7 84.6 45.6 119 80 34.3 34.3 61.3 74.4 80 119 19.4 46.2 29.1 95.2 28.9 145.8-.6 99.6-39.7 192.9-110.1 262.7z"})]});var MF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zm-40 110.8V792H136V270.8l-27.6-21.5 39.3-50.5 42.8 33.3h643.1l42.8-33.3 39.3 50.5-27.7 21.5zM833.6 232L512 482 190.4 232l-42.8-33.3-39.3 50.5 27.6 21.5 341.6 265.6a55.99 55.99 0 0 0 68.7 0L888 270.8l27.6-21.5-39.3-50.5-42.7 33.2z"})});var _F=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M752 664c-28.5 0-54.8 10-75.4 26.7L469.4 540.8a160.68 160.68 0 0 0 0-57.6l207.2-149.9C697.2 350 723.5 360 752 360c66.2 0 120-53.8 120-120s-53.8-120-120-120-120 53.8-120 120c0 11.6 1.6 22.7 4.7 33.3L439.9 415.8C410.7 377.1 364.3 352 312 352c-88.4 0-160 71.6-160 160s71.6 160 160 160c52.3 0 98.7-25.1 127.9-63.8l196.8 142.5c-3.1 10.6-4.7 21.8-4.7 33.3 0 66.2 53.8 120 120 120s120-53.8 120-120-53.8-120-120-120zm0-476c28.7 0 52 23.3 52 52s-23.3 52-52 52-52-23.3-52-52 23.3-52 52-52zM312 600c-48.5 0-88-39.5-88-88s39.5-88 88-88 88 39.5 88 88-39.5 88-88 88zm440 236c-28.7 0-52-23.3-52-52s23.3-52 52-52 52 23.3 52 52-23.3 52-52 52z"})});var AF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M505.7 661a8 8 0 0012.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"})});var EF,CF=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},focusable:"false",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",className:e,"aria-label":t,children:(0,s.jsx)("path",{fill:"currentColor",d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm121.8 169.9l-40.7 191.8c-3 13.6-11.1 16.9-22.4 10.5l-62-45.7-29.9 28.8c-3.3 3.3-6.1 6.1-12.5 6.1l4.4-63.1 114.9-103.8c5-4.4-1.1-6.9-7.7-2.5l-142 89.4-61.2-19.1c-13.3-4.2-13.6-13.3 2.8-19.7l239.1-92.2c11.1-4 20.8 2.7 17.2 19.5z"})}),kF=(u=a("85Hg2"),Object.defineProperty),TF=Object.getOwnPropertySymbols,IF=Object.prototype.hasOwnProperty,OF=Object.prototype.propertyIsEnumerable,RF=(e,t,n)=>t in e?kF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,PF=(e,t)=>{for(var n in t||(t={}))IF.call(t,n)&&RF(e,n,t[n]);if(TF)for(var n of TF(t))OF.call(t,n)&&RF(e,n,t[n]);return e},NF=(e,t)=>{var n={};for(var r in e)IF.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&TF)for(var r of TF(e))t.indexOf(r)<0&&OF.call(e,r)&&(n[r]=e[r]);return n};(e=>{const t=class{constructor(e,n,r,i){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version value out of range");if(i<-1||i>7)throw new RangeError("Mask value out of range");this.size=4*e+17;let a=[];for(let e=0;e<this.size;e++)a.push(!1);for(let e=0;e<this.size;e++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();const s=this.addEccAndInterleave(r);if(this.drawCodewords(s),-1==i){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);const n=this.getPenaltyScore();n<e&&(i=t,e=n),this.applyMask(t)}}o(0<=i&&i<=7),this.mask=i,this.applyMask(i),this.drawFormatBits(i),this.isFunction=[]}static encodeText(n,r){const i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){const i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,n,i=1,a=40,l=-1,c=!0){if(!(t.MIN_VERSION<=i&&i<=a&&a<=t.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let u,d;for(u=i;;u++){const r=8*t.getNumDataCodewords(u,n),i=s.getTotalBits(e,u);if(i<=r){d=i;break}if(u>=a)throw new RangeError("Data too long")}for(const e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])c&&d<=8*t.getNumDataCodewords(u,e)&&(n=e);let f=[];for(const t of e){r(t.mode.modeBits,4,f),r(t.numChars,t.mode.numCharCountBits(u),f);for(const e of t.getData())f.push(e)}o(f.length==d);const h=8*t.getNumDataCodewords(u,n);o(f.length<=h),r(0,Math.min(4,h-f.length),f),r(0,(8-f.length%8)%8,f),o(f.length%8==0);for(let e=236;f.length<h;e^=253)r(e,8,f);let p=[];for(;8*p.length<f.length;)p.push(0);return f.forEach(((e,t)=>p[t>>>3]|=e<<7-(7&t))),new t(u,n,p,l)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)0==n&&0==r||0==n&&r==t-1||n==t-1&&0==r||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const t=this.errorCorrectionLevel.formatBits<<3|e;let n=t;for(let e=0;e<10;e++)n=n<<1^1335*(n>>>9);const r=21522^(t<<10|n);o(r>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,i(r,e));this.setFunctionModule(8,7,i(r,6)),this.setFunctionModule(8,8,i(r,7)),this.setFunctionModule(7,8,i(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,i(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,i(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,i(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^7973*(e>>>11);const t=this.version<<12|e;o(t>>>18==0);for(let e=0;e<18;e++){const n=i(t,e),r=this.size-11+e%3,o=Math.floor(e/3);this.setFunctionModule(r,o,n),this.setFunctionModule(o,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){const i=Math.max(Math.abs(r),Math.abs(n)),o=e+r,a=t+n;0<=o&&o<this.size&&0<=a&&a<this.size&&this.setFunctionModule(o,a,2!=i&&4!=i)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,1!=Math.max(Math.abs(r),Math.abs(n)))}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){const n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw new RangeError("Invalid argument");const i=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],a=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),l=i-s%i,c=Math.floor(s/i);let u=[];const d=t.reedSolomonComputeDivisor(a);for(let n=0,r=0;n<i;n++){let i=e.slice(r,r+c-a+(n<l?0:1));r+=i.length;const o=t.reedSolomonComputeRemainder(i,d);n<l&&i.push(0),u.push(i.concat(o))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach(((t,n)=>{(e!=c-a||n>=l)&&f.push(t[e])}));return o(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let t=this.size-1;t>=1;t-=2){6==t&&(t=5);for(let r=0;r<this.size;r++)for(let o=0;o<2;o++){const a=t-o,s=0==(t+1&2)?this.size-1-r:r;!this.isFunction[s][a]&&n<8*e.length&&(this.modules[s][a]=i(e[n>>>3],7-(7&n)),n++)}}o(n==8*e.length)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,o=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[n][a]==r?(i++,5==i?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,o),r||(e+=this.finderPenaltyCountPatterns(o)*t.PENALTY_N3),r=this.modules[n][a],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,o)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,o=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][n]==r?(i++,5==i?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,o),r||(e+=this.finderPenaltyCountPatterns(o)*t.PENALTY_N3),r=this.modules[a][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,o)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){const i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(const e of this.modules)n=e.reduce(((e,t)=>e+(t?1:0)),n);const r=this.size*this.size,i=Math.ceil(Math.abs(20*n-10*r)/r)-1;return o(0<=i&&i<=9),e+=i*t.PENALTY_N4,o(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(1==this.version)return[];{const e=Math.floor(this.version/7)+2,t=32==this.version?26:2*Math.ceil((4*this.version+4)/(2*e-2));let n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return o(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map((e=>0));for(const i of e){const e=i^r.shift();r.push(0),n.forEach(((n,i)=>r[i]^=t.reedSolomonMultiply(n,e)))}return r}static reedSolomonMultiply(e,t){if(e>>>8!=0||t>>>8!=0)throw new RangeError("Byte out of range");let n=0;for(let r=7;r>=0;r--)n=n<<1^285*(n>>>7),n^=(t>>>r&1)*e;return o(n>>>8==0),n}finderPenaltyCountPatterns(e){const t=e[1];o(t<=3*this.size);const n=t>0&&e[2]==t&&e[3]==3*t&&e[4]==t&&e[5]==t;return(n&&e[0]>=4*t&&e[6]>=t?1:0)+(n&&e[6]>=4*t&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){0==t[0]&&(e+=this.size),t.pop(),t.unshift(e)}};let n=t;function r(e,t,n){if(t<0||t>31||e>>>t!=0)throw new RangeError("Value out of range");for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function i(e,t){return 0!=(e>>>t&1)}function o(e){if(!e)throw new Error("Assertion error")}n.MIN_VERSION=1,n.MAX_VERSION=40,n.PENALTY_N1=3,n.PENALTY_N2=3,n.PENALTY_N3=40,n.PENALTY_N4=10,n.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],n.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=n;const a=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw new RangeError("Invalid argument");this.bitData=n.slice()}static makeBytes(e){let t=[];for(const n of e)r(n,8,t);return new a(a.Mode.BYTE,e.length,t)}static makeNumeric(e){if(!a.isNumeric(e))throw new RangeError("String contains non-numeric characters");let t=[];for(let n=0;n<e.length;){const i=Math.min(e.length-n,3);r(parseInt(e.substr(n,i),10),3*i+1,t),n+=i}return new a(a.Mode.NUMERIC,e.length,t)}static makeAlphanumeric(e){if(!a.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let t,n=[];for(t=0;t+2<=e.length;t+=2){let i=45*a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t));i+=a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),r(i,11,n)}return t<e.length&&r(a.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,n),new a(a.Mode.ALPHANUMERIC,e.length,n)}static makeSegments(e){return""==e?[]:a.isNumeric(e)?[a.makeNumeric(e)]:a.isAlphanumeric(e)?[a.makeAlphanumeric(e)]:[a.makeBytes(a.toUtf8ByteArray(e))]}static makeEci(e){let t=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)r(e,8,t);else if(e<16384)r(2,2,t),r(e,14,t);else{if(!(e<1e6))throw new RangeError("ECI assignment value out of range");r(6,3,t),r(e,21,t)}return new a(a.Mode.ECI,0,t)}static isNumeric(e){return a.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return a.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(const r of e){const e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)"%"!=e.charAt(n)?t.push(e.charCodeAt(n)):(t.push(parseInt(e.substr(n+1,2),16)),n+=2);return t}};let s=a;s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",e.QrSegment=s})(EF||(EF={})),(e=>{let t;(e=>{const t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};let n=t;n.LOW=new t(0,1),n.MEDIUM=new t(1,0),n.QUARTILE=new t(2,3),n.HIGH=new t(3,2),e.Ecc=n})(t=e.QrCode||(e.QrCode={}))})(EF||(EF={})),(e=>{let t;(e=>{const t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};let n=t;n.NUMERIC=new t(1,[10,12,14]),n.ALPHANUMERIC=new t(2,[9,11,13]),n.BYTE=new t(4,[8,16,16]),n.KANJI=new t(8,[8,10,12]),n.ECI=new t(7,[0,0,0]),e.Mode=n})(t=e.QrSegment||(e.QrSegment={}))})(EF||(EF={}));var LF=EF,DF={L:LF.QrCode.Ecc.LOW,M:LF.QrCode.Ecc.MEDIUM,Q:LF.QrCode.Ecc.QUARTILE,H:LF.QrCode.Ecc.HIGH},BF=128,jF="L",FF="#FFFFFF",UF="#000000",zF=!1;
|
|
104
104
|
/**
|
|
105
105
|
* @license qrcode.react
|
|
106
106
|
* Copyright (c) Paul O'Shannessy
|
|
@@ -119,4 +119,4 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
119
119
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
120
120
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
121
121
|
PERFORMANCE OF THIS SOFTWARE.
|
|
122
|
-
***************************************************************************** */function ZK(e,t){function n(){this.constructor=e}XK(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var $K=function(){return $K=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},$K.apply(this,arguments)};Object.create;Object.create;var eY;u=a("85Hg2");function tY(e,t,n,r,i,o){void 0===o&&(o=0);var a=fY(e,t,o),s=a.width,l=a.height,c=Math.min(s,n),u=Math.min(l,r);return c>u*i?{width:u*i,height:u}:{width:c,height:c/i}}function nY(e,t,n,r,i){void 0===i&&(i=0);var o=fY(t.width,t.height,i),a=o.width,s=o.height;return{x:rY(e.x,a,n.width,r),y:rY(e.y,s,n.height,r)}}function rY(e,t,n,r){var i=t*r/2-n/2;return hY(e,-i,i)}function iY(e,t){return Math.sqrt(Math.pow(e.y-t.y,2)+Math.pow(e.x-t.x,2))}function oY(e,t){return 180*Math.atan2(t.y-e.y,t.x-e.x)/Math.PI}function aY(e,t,n,r,i,o,a){void 0===o&&(o=0),void 0===a&&(a=!0);var s=a?sY:lY,l=fY(t.width,t.height,o),c=fY(t.naturalWidth,t.naturalHeight,o),u={x:s(100,((l.width-n.width/i)/2-e.x/i)/l.width*100),y:s(100,((l.height-n.height/i)/2-e.y/i)/l.height*100),width:s(100,n.width/l.width*100/i),height:s(100,n.height/l.height*100/i)},d=Math.round(s(c.width,u.width*c.width/100)),f=Math.round(s(c.height,u.height*c.height/100)),h=c.width>=c.height*r?{width:Math.round(f*r),height:f}:{width:d,height:Math.round(d/r)};return{croppedAreaPercentages:u,croppedAreaPixels:$K($K({},h),{x:Math.round(s(c.width-h.width,u.x*c.width/100)),y:Math.round(s(c.height-h.height,u.y*c.height/100))})}}function sY(e,t){return Math.min(e,Math.max(0,t))}function lY(e,t){return t}function cY(e,t,n,r,i,o){var a=fY(t.width,t.height,n),s=hY(r.width/a.width*(100/e.width),i,o);return{crop:{x:s*a.width/2-r.width/2-a.width*s*(e.x/100),y:s*a.height/2-r.height/2-a.height*s*(e.y/100)},zoom:s}}function uY(e,t,n,r,i,o){void 0===n&&(n=0);var a=fY(t.naturalWidth,t.naturalHeight,n),s=hY(function(e,t,n){var r=function(e){return e.width>e.height?e.width/e.naturalWidth:e.height/e.naturalHeight}(t);return n.height>n.width?n.height/(e.height*r):n.width/(e.width*r)}(e,t,r),i,o),l=r.height>r.width?r.height/e.height:r.width/e.width;return{crop:{x:((a.width-e.width)/2-e.x)*l,y:((a.height-e.height)/2-e.y)*l},zoom:s}}function dY(e,t){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function fY(e,t,n){var r=n*Math.PI/180;return{width:Math.abs(Math.cos(r)*e)+Math.abs(Math.sin(r)*t),height:Math.abs(Math.sin(r)*e)+Math.abs(Math.cos(r)*t)}}function hY(e,t,n){return Math.min(Math.max(e,t),n)}function pY(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.filter((function(e){return"string"==typeof e&&e.length>0})).join(" ").trim()}eY=a("lmpx0");var mY=function(e){function t(){var n=null!==e&&e.apply(this,arguments)||this;return n.imageRef=r(u).createRef(),n.videoRef=r(u).createRef(),n.containerRef=null,n.styleRef=null,n.containerRect=null,n.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},n.dragStartPosition={x:0,y:0},n.dragStartCrop={x:0,y:0},n.gestureZoomStart=0,n.gestureRotationStart=0,n.isTouching=!1,n.lastPinchDistance=0,n.lastPinchRotation=0,n.rafDragTimeout=null,n.rafPinchTimeout=null,n.wheelTimer=null,n.currentDoc="undefined"!=typeof document?document:null,n.currentWindow="undefined"!=typeof window?window:null,n.resizeObserver=null,n.state={cropSize:null,hasWheelJustStarted:!1},n.initResizeObserver=function(){if(void 0!==window.ResizeObserver&&n.containerRef){var e=!0;n.resizeObserver=new window.ResizeObserver((function(t){e?e=!1:n.computeSizes()})),n.resizeObserver.observe(n.containerRef)}},n.preventZoomSafari=function(e){return e.preventDefault()},n.cleanEvents=function(){n.currentDoc&&(n.currentDoc.removeEventListener("mousemove",n.onMouseMove),n.currentDoc.removeEventListener("mouseup",n.onDragStopped),n.currentDoc.removeEventListener("touchmove",n.onTouchMove),n.currentDoc.removeEventListener("touchend",n.onDragStopped),n.currentDoc.removeEventListener("gesturemove",n.onGestureMove),n.currentDoc.removeEventListener("gestureend",n.onGestureEnd))},n.clearScrollEvent=function(){n.containerRef&&n.containerRef.removeEventListener("wheel",n.onWheel),n.wheelTimer&&clearTimeout(n.wheelTimer)},n.onMediaLoad=function(){var e=n.computeSizes();e&&(n.emitCropData(),n.setInitialCrop(e)),n.props.onMediaLoaded&&n.props.onMediaLoaded(n.mediaSize)},n.setInitialCrop=function(e){if(n.props.initialCroppedAreaPercentages){var t=cY(n.props.initialCroppedAreaPercentages,n.mediaSize,n.props.rotation,e,n.props.minZoom,n.props.maxZoom),r=t.crop,i=t.zoom;n.props.onCropChange(r),n.props.onZoomChange&&n.props.onZoomChange(i)}else if(n.props.initialCroppedAreaPixels){var o=uY(n.props.initialCroppedAreaPixels,n.mediaSize,n.props.rotation,e,n.props.minZoom,n.props.maxZoom);r=o.crop,i=o.zoom;n.props.onCropChange(r),n.props.onZoomChange&&n.props.onZoomChange(i)}},n.computeSizes=function(){var e,t,r,i,o,a,s=n.imageRef.current||n.videoRef.current;if(s&&n.containerRef){n.containerRect=n.containerRef.getBoundingClientRect();var l=n.containerRect.width/n.containerRect.height,c=(null===(e=n.imageRef.current)||void 0===e?void 0:e.naturalWidth)||(null===(t=n.videoRef.current)||void 0===t?void 0:t.videoWidth)||0,u=(null===(r=n.imageRef.current)||void 0===r?void 0:r.naturalHeight)||(null===(i=n.videoRef.current)||void 0===i?void 0:i.videoHeight)||0,d=c/u,f=void 0;if(s.offsetWidth<c||s.offsetHeight<u)switch(n.props.objectFit){default:case"contain":f=l>d?{width:n.containerRect.height*d,height:n.containerRect.height}:{width:n.containerRect.width,height:n.containerRect.width/d};break;case"horizontal-cover":f={width:n.containerRect.width,height:n.containerRect.width/d};break;case"vertical-cover":f={width:n.containerRect.height*d,height:n.containerRect.height};break;case"auto-cover":f=c>u?{width:n.containerRect.width,height:n.containerRect.width/d}:{width:n.containerRect.height*d,height:n.containerRect.height}}else f={width:s.offsetWidth,height:s.offsetHeight};n.mediaSize=$K($K({},f),{naturalWidth:c,naturalHeight:u}),n.props.setMediaSize&&n.props.setMediaSize(n.mediaSize);var h=n.props.cropSize?n.props.cropSize:tY(n.mediaSize.width,n.mediaSize.height,n.containerRect.width,n.containerRect.height,n.props.aspect,n.props.rotation);return(null===(o=n.state.cropSize)||void 0===o?void 0:o.height)===h.height&&(null===(a=n.state.cropSize)||void 0===a?void 0:a.width)===h.width||n.props.onCropSizeChange&&n.props.onCropSizeChange(h),n.setState({cropSize:h},n.recomputeCropPosition),n.props.setCropSize&&n.props.setCropSize(h),h}},n.onMouseDown=function(e){n.currentDoc&&(e.preventDefault(),n.currentDoc.addEventListener("mousemove",n.onMouseMove),n.currentDoc.addEventListener("mouseup",n.onDragStopped),n.onDragStart(t.getMousePoint(e)))},n.onMouseMove=function(e){return n.onDrag(t.getMousePoint(e))},n.onTouchStart=function(e){n.currentDoc&&(n.isTouching=!0,n.props.onTouchRequest&&!n.props.onTouchRequest(e)||(n.currentDoc.addEventListener("touchmove",n.onTouchMove,{passive:!1}),n.currentDoc.addEventListener("touchend",n.onDragStopped),2===e.touches.length?n.onPinchStart(e):1===e.touches.length&&n.onDragStart(t.getTouchPoint(e.touches[0]))))},n.onTouchMove=function(e){e.preventDefault(),2===e.touches.length?n.onPinchMove(e):1===e.touches.length&&n.onDrag(t.getTouchPoint(e.touches[0]))},n.onGestureStart=function(e){n.currentDoc&&(e.preventDefault(),n.currentDoc.addEventListener("gesturechange",n.onGestureMove),n.currentDoc.addEventListener("gestureend",n.onGestureEnd),n.gestureZoomStart=n.props.zoom,n.gestureRotationStart=n.props.rotation)},n.onGestureMove=function(e){if(e.preventDefault(),!n.isTouching){var r=t.getMousePoint(e),i=n.gestureZoomStart-1+e.scale;if(n.setNewZoom(i,r,{shouldUpdatePosition:!0}),n.props.onRotationChange){var o=n.gestureRotationStart+e.rotation;n.props.onRotationChange(o)}}},n.onGestureEnd=function(e){n.cleanEvents()},n.onDragStart=function(e){var t,r,i=e.x,o=e.y;n.dragStartPosition={x:i,y:o},n.dragStartCrop=$K({},n.props.crop),null===(r=(t=n.props).onInteractionStart)||void 0===r||r.call(t)},n.onDrag=function(e){var t=e.x,r=e.y;n.currentWindow&&(n.rafDragTimeout&&n.currentWindow.cancelAnimationFrame(n.rafDragTimeout),n.rafDragTimeout=n.currentWindow.requestAnimationFrame((function(){if(n.state.cropSize&&void 0!==t&&void 0!==r){var e=t-n.dragStartPosition.x,i=r-n.dragStartPosition.y,o={x:n.dragStartCrop.x+e,y:n.dragStartCrop.y+i},a=n.props.restrictPosition?nY(o,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):o;n.props.onCropChange(a)}})))},n.onDragStopped=function(){var e,t;n.isTouching=!1,n.cleanEvents(),n.emitCropData(),null===(t=(e=n.props).onInteractionEnd)||void 0===t||t.call(e)},n.onWheel=function(e){if(n.currentWindow&&(!n.props.onWheelRequest||n.props.onWheelRequest(e))){e.preventDefault();var i=t.getMousePoint(e),o=r(eY)(e).pixelY,a=n.props.zoom-o*n.props.zoomSpeed/200;n.setNewZoom(a,i,{shouldUpdatePosition:!0}),n.state.hasWheelJustStarted||n.setState({hasWheelJustStarted:!0},(function(){var e,t;return null===(t=(e=n.props).onInteractionStart)||void 0===t?void 0:t.call(e)})),n.wheelTimer&&clearTimeout(n.wheelTimer),n.wheelTimer=n.currentWindow.setTimeout((function(){return n.setState({hasWheelJustStarted:!1},(function(){var e,t;return null===(t=(e=n.props).onInteractionEnd)||void 0===t?void 0:t.call(e)}))}),250)}},n.getPointOnContainer=function(e){var t=e.x,r=e.y;if(!n.containerRect)throw new Error("The Cropper is not mounted");return{x:n.containerRect.width/2-(t-n.containerRect.left),y:n.containerRect.height/2-(r-n.containerRect.top)}},n.getPointOnMedia=function(e){var t=e.x,r=e.y,i=n.props,o=i.crop,a=i.zoom;return{x:(t+o.x)/a,y:(r+o.y)/a}},n.setNewZoom=function(e,t,r){var i=(void 0===r?{}:r).shouldUpdatePosition,o=void 0===i||i;if(n.state.cropSize&&n.props.onZoomChange){var a=hY(e,n.props.minZoom,n.props.maxZoom);if(o){var s=n.getPointOnContainer(t),l=n.getPointOnMedia(s),c={x:l.x*a-s.x,y:l.y*a-s.y},u=n.props.restrictPosition?nY(c,n.mediaSize,n.state.cropSize,a,n.props.rotation):c;n.props.onCropChange(u)}n.props.onZoomChange(a)}},n.getCropData=function(){return n.state.cropSize?aY(n.props.restrictPosition?nY(n.props.crop,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):n.props.crop,n.mediaSize,n.state.cropSize,n.getAspect(),n.props.zoom,n.props.rotation,n.props.restrictPosition):null},n.emitCropData=function(){var e=n.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;n.props.onCropComplete&&n.props.onCropComplete(t,r),n.props.onCropAreaChange&&n.props.onCropAreaChange(t,r)}},n.emitCropAreaChange=function(){var e=n.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;n.props.onCropAreaChange&&n.props.onCropAreaChange(t,r)}},n.recomputeCropPosition=function(){if(n.state.cropSize){var e=n.props.restrictPosition?nY(n.props.crop,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):n.props.crop;n.props.onCropChange(e),n.emitCropData()}},n}return ZK(t,e),t.prototype.componentDidMount=function(){this.currentDoc&&this.currentWindow&&(this.containerRef&&(this.containerRef.ownerDocument&&(this.currentDoc=this.containerRef.ownerDocument),this.currentDoc.defaultView&&(this.currentWindow=this.currentDoc.defaultView),this.initResizeObserver(),void 0===window.ResizeObserver&&this.currentWindow.addEventListener("resize",this.computeSizes),this.props.zoomWithScroll&&this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}),this.containerRef.addEventListener("gesturestart",this.onGestureStart)),this.props.disableAutomaticStylesInjection||(this.styleRef=this.currentDoc.createElement("style"),this.styleRef.setAttribute("type","text/css"),this.props.nonce&&this.styleRef.setAttribute("nonce",this.props.nonce),this.styleRef.innerHTML=".reactEasyCrop_Container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n user-select: none;\n touch-action: none;\n cursor: move;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.reactEasyCrop_Image,\n.reactEasyCrop_Video {\n will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */\n}\n\n.reactEasyCrop_Contain {\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n}\n.reactEasyCrop_Cover_Horizontal {\n width: 100%;\n height: auto;\n}\n.reactEasyCrop_Cover_Vertical {\n width: auto;\n height: 100%;\n}\n\n.reactEasyCrop_CropArea {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n border: 1px solid rgba(255, 255, 255, 0.5);\n box-sizing: border-box;\n box-shadow: 0 0 0 9999em;\n color: rgba(0, 0, 0, 0.5);\n overflow: hidden;\n}\n\n.reactEasyCrop_CropAreaRound {\n border-radius: 50%;\n}\n\n.reactEasyCrop_CropAreaGrid::before {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 0;\n bottom: 0;\n left: 33.33%;\n right: 33.33%;\n border-top: 0;\n border-bottom: 0;\n}\n\n.reactEasyCrop_CropAreaGrid::after {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 33.33%;\n bottom: 33.33%;\n left: 0;\n right: 0;\n border-left: 0;\n border-right: 0;\n}\n",this.currentDoc.head.appendChild(this.styleRef)),this.imageRef.current&&this.imageRef.current.complete&&this.onMediaLoad(),this.props.setImageRef&&this.props.setImageRef(this.imageRef),this.props.setVideoRef&&this.props.setVideoRef(this.videoRef))},t.prototype.componentWillUnmount=function(){var e,t;this.currentDoc&&this.currentWindow&&(void 0===window.ResizeObserver&&this.currentWindow.removeEventListener("resize",this.computeSizes),null===(e=this.resizeObserver)||void 0===e||e.disconnect(),this.containerRef&&this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.styleRef&&(null===(t=this.styleRef.parentNode)||void 0===t||t.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},t.prototype.componentDidUpdate=function(e){var t,n,r,i,o,a,s,l,c;e.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):e.aspect!==this.props.aspect?this.computeSizes():e.zoom!==this.props.zoom?this.recomputeCropPosition():(null===(t=e.cropSize)||void 0===t?void 0:t.height)!==(null===(n=this.props.cropSize)||void 0===n?void 0:n.height)||(null===(r=e.cropSize)||void 0===r?void 0:r.width)!==(null===(i=this.props.cropSize)||void 0===i?void 0:i.width)?this.computeSizes():(null===(o=e.crop)||void 0===o?void 0:o.x)===(null===(a=this.props.crop)||void 0===a?void 0:a.x)&&(null===(s=e.crop)||void 0===s?void 0:s.y)===(null===(l=this.props.crop)||void 0===l?void 0:l.y)||this.emitCropAreaChange(),e.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),e.video!==this.props.video&&(null===(c=this.videoRef.current)||void 0===c||c.load())},t.prototype.getAspect=function(){var e=this.props,t=e.cropSize,n=e.aspect;return t?t.width/t.height:n},t.prototype.onPinchStart=function(e){var n=t.getTouchPoint(e.touches[0]),r=t.getTouchPoint(e.touches[1]);this.lastPinchDistance=iY(n,r),this.lastPinchRotation=oY(n,r),this.onDragStart(dY(n,r))},t.prototype.onPinchMove=function(e){var n=this;if(this.currentDoc&&this.currentWindow){var r=t.getTouchPoint(e.touches[0]),i=t.getTouchPoint(e.touches[1]),o=dY(r,i);this.onDrag(o),this.rafPinchTimeout&&this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=this.currentWindow.requestAnimationFrame((function(){var e=iY(r,i),t=n.props.zoom*(e/n.lastPinchDistance);n.setNewZoom(t,o,{shouldUpdatePosition:!1}),n.lastPinchDistance=e;var a=oY(r,i),s=n.props.rotation+(a-n.lastPinchRotation);n.props.onRotationChange&&n.props.onRotationChange(s),n.lastPinchRotation=a}))}},t.prototype.render=function(){var e=this,t=this.props,n=t.image,i=t.video,o=t.mediaProps,a=t.transform,s=t.crop,l=s.x,c=s.y,d=t.rotation,f=t.zoom,h=t.cropShape,p=t.showGrid,m=t.style,g=m.containerStyle,v=m.cropAreaStyle,y=m.mediaStyle,b=t.classes,w=b.containerClassName,x=b.cropAreaClassName,S=b.mediaClassName,M=t.objectFit;return r(u).createElement("div",{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:function(t){return e.containerRef=t},"data-testid":"container",style:g,className:pY("reactEasyCrop_Container",w)},n?r(u).createElement("img",$K({alt:"",className:pY("reactEasyCrop_Image","contain"===M&&"reactEasyCrop_Contain","horizontal-cover"===M&&"reactEasyCrop_Cover_Horizontal","vertical-cover"===M&&"reactEasyCrop_Cover_Vertical","auto-cover"===M&&(this.mediaSize.naturalWidth>this.mediaSize.naturalHeight?"reactEasyCrop_Cover_Horizontal":"reactEasyCrop_Cover_Vertical"),S)},o,{src:n,ref:this.imageRef,style:$K($K({},y),{transform:a||"translate(".concat(l,"px, ").concat(c,"px) rotate(").concat(d,"deg) scale(").concat(f,")")}),onLoad:this.onMediaLoad})):i&&r(u).createElement("video",$K({autoPlay:!0,loop:!0,muted:!0,className:pY("reactEasyCrop_Video","contain"===M&&"reactEasyCrop_Contain","horizontal-cover"===M&&"reactEasyCrop_Cover_Horizontal","vertical-cover"===M&&"reactEasyCrop_Cover_Vertical","auto-cover"===M&&(this.mediaSize.naturalWidth>this.mediaSize.naturalHeight?"reactEasyCrop_Cover_Horizontal":"reactEasyCrop_Cover_Vertical"),S)},o,{ref:this.videoRef,onLoadedMetadata:this.onMediaLoad,style:$K($K({},y),{transform:a||"translate(".concat(l,"px, ").concat(c,"px) rotate(").concat(d,"deg) scale(").concat(f,")")}),controls:!1}),(Array.isArray(i)?i:[{src:i}]).map((function(e){return r(u).createElement("source",$K({key:e.src},e))}))),this.state.cropSize&&r(u).createElement("div",{style:$K($K({},v),{width:this.state.cropSize.width,height:this.state.cropSize.height}),"data-testid":"cropper",className:pY("reactEasyCrop_CropArea","round"===h&&"reactEasyCrop_CropAreaRound",p&&"reactEasyCrop_CropAreaGrid",x)}))},t.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:3,minZoom:1,cropShape:"rect",objectFit:"contain",showGrid:!0,style:{},classes:{},mediaProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0},t.getMousePoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t.getTouchPoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t}(r(u).Component);var gY=function(){return gY=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},gY.apply(this,arguments)};function vY(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}function yY(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var bY="img-crop",wY=.1,xY=(0,u.forwardRef)((function(e,t){var n=e.cropperRef,i=e.image,o=e.aspect,a=e.shape,s=e.grid,l=e.zoom,c=e.rotate,d=e.minZoom,f=e.maxZoom,h=e.cropperProps,p=(0,u.useState)({x:0,y:0}),m=p[0],g=p[1],v=(0,u.useState)({width:0,height:0}),y=v[0],b=v[1],w=(0,u.useState)(1),x=w[0],S=w[1],M=(0,u.useState)(0),_=M[0],A=M[1],E=(0,u.useRef)({width:0,height:0,x:0,y:0}),C=(0,u.useCallback)((function(e){var t=e.width,n=e.height,r=n*o;b(t>r?{width:r,height:n}:{width:t,height:t/o})}),[o]),k=(0,u.useCallback)((function(e,t){E.current=t}),[]);return(0,u.useImperativeHandle)(t,(function(){return{rotateVal:_,setZoomVal:S,setRotateVal:A,cropPixelsRef:E}}),[_]),r(u).createElement(r(u).Fragment,null,r(u).createElement(mY,gY({},h,{ref:n,image:i,crop:m,cropSize:y,onCropChange:g,aspect:o,cropShape:a,showGrid:s,zoomWithScroll:l,zoom:x,rotation:_,onZoomChange:S,onRotationChange:A,minZoom:d,maxZoom:f,onMediaLoaded:C,onCropComplete:k,classes:{containerClassName:"".concat(bY,"-container"),mediaClassName:"".concat(bY,"-media")}})),l&&r(u).createElement("section",{className:"".concat(bY,"-control ").concat(bY,"-control-zoom")},r(u).createElement("button",{onClick:function(){return S(x-wY)},disabled:x-wY<d},"-"),r(u).createElement(Xq.default,{min:d,max:f,step:wY,value:x,onChange:S}),r(u).createElement("button",{onClick:function(){return S(x+wY)},disabled:x+wY>f},"+")),c&&r(u).createElement("section",{className:"".concat(bY,"-control ").concat(bY,"-control-rotate")},r(u).createElement("button",{onClick:function(){return A(_-1)},disabled:-180===_},"↺"),r(u).createElement(Xq.default,{min:-180,max:180,step:1,value:_,onChange:A}),r(u).createElement("button",{onClick:function(){return A(_+1)},disabled:180===_},"↻")))})),SY=(0,u.memo)(xY);!function(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");t.setAttribute("media","screen"),t.innerHTML=e,document.head.appendChild(t)}}(".img-crop-modal .img-crop-container {\n position: relative;\n width: 100%;\n height: 40vh;\n}\n.img-crop-modal .img-crop-control {\n display: flex;\n align-items: center;\n width: 60%;\n margin-left: auto;\n margin-right: auto;\n}\n.img-crop-modal .img-crop-control:first-of-type {\n margin-top: 16px;\n}\n.img-crop-modal .img-crop-control:last-of-type {\n margin-bottom: -8px;\n}\n.img-crop-modal .img-crop-control button {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 34px;\n height: 34px;\n padding: 0;\n font-style: normal;\n background: transparent;\n border: 0;\n outline: 0;\n cursor: pointer;\n}\n.img-crop-modal .img-crop-control button[disabled] {\n cursor: default;\n}\n.img-crop-modal .img-crop-control button + div:only-of-type {\n flex: 1;\n margin: 0 8px;\n}\n.img-crop-modal .img-crop-control-zoom button {\n font-size: 18px;\n}\n.img-crop-modal .img-crop-control-rotate button {\n font-size: 16px;\n}\n.img-crop-modal .img-crop-control-rotate button:first-of-type {\n transform: rotate(-20deg);\n}\n.img-crop-modal .img-crop-control-rotate button:last-of-type {\n transform: rotate(20deg);\n}\n");var MY=(0,u.forwardRef)((function(e,t){var n=e.aspect,i=void 0===n?1:n,o=e.shape,a=void 0===o?"rect":o,s=e.grid,l=void 0!==s&&s,c=e.quality,d=void 0===c?.4:c,f=e.fillColor,h=void 0===f?"white":f,p=e.zoom,m=void 0===p||p,g=e.rotate,v=void 0!==g&&g,y=e.minZoom,b=void 0===y?1:y,w=e.maxZoom,x=void 0===w?3:w,S=e.modalTitle,M=e.modalWidth,_=e.modalOk,A=e.modalCancel,E=e.modalMaskTransitionName,C=e.modalTransitionName,k=e.onModalOk,T=e.onModalCancel,I=e.beforeCrop,O=e.onUploadFail,R=e.cropperProps,P=e.children,N=(0,u.useRef)({});N.current.onModalOk=k,N.current.onModalCancel=T,N.current.beforeCrop=I,N.current.onUploadFail=O;var L=(0,u.useState)(""),D=L[0],B=L[1],j=(0,u.useRef)(),F=(0,u.useRef)(),U=(0,u.useRef)(),z=(0,u.useRef)(),H=(0,u.useMemo)((function(){var e=Array.isArray(P)?P[0]:P,t=e.props,n=t.beforeUpload,r=t.accept,i=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(t,["beforeUpload","accept"]);return F.current=n,gY(gY({},e),{props:gY(gY({},i),{accept:r||"image/*",beforeUpload:function(e,t){return new Promise((function(n,r){return vY(void 0,void 0,void 0,(function(){var i;return yY(this,(function(o){switch(o.label){case 0:return N.current.beforeCrop?[4,N.current.beforeCrop(e,t)]:[3,2];case 1:if(!o.sent())return[2,r()];o.label=2;case 2:return j.current=e,U.current=function(e){var t,r;null===(r=(t=N.current).onModalOk)||void 0===r||r.call(t,e),n(e)},z.current=function(e){var t,n;null===(n=(t=N.current).onUploadFail)||void 0===n||n.call(t,e),r()},(i=new FileReader).addEventListener("load",(function(){"string"==typeof i.result&&B(i.result)})),i.readAsDataURL(e),[2]}}))}))}))}})})}),[P]),V=(0,u.useRef)({}),W=(0,u.useMemo)((function(){var e={width:M,okText:_,cancelText:A,maskTransitionName:E,transitionName:C};return Object.keys(e).forEach((function(t){e[t]||delete e[t]})),e}),[A,E,_,C,M]),G=function(){B(""),V.current.setZoomVal(1),V.current.setRotateVal(0)},q=(0,u.useCallback)((function(){var e,t;null===(t=(e=N.current).onModalCancel)||void 0===t||t.call(e),G()}),[]),K=(0,u.useCallback)((function(){return vY(void 0,void 0,void 0,(function(){var e,t,n,r,i,o,a,s,l,c,u,f,p,m,g,y,b,w,x,S,M,_,A,E;return yY(this,(function(C){return G(),e=document.createElement("canvas"),t=e.getContext("2d"),n=document.querySelector(".".concat(bY,"-media")),r=V.current.cropPixelsRef.current,i=r.width,o=r.height,a=r.x,s=r.y,v&&0!==V.current.rotateVal?(l=n.naturalWidth,c=n.naturalHeight,u=V.current.rotateVal*(Math.PI/180),f=Math.abs(Math.sin(u)),p=Math.abs(Math.cos(u)),m=l*p+c*f,g=c*p+l*f,e.width=m,e.height=g,t.fillStyle=h,t.fillRect(0,0,m,g),y=m/2,b=g/2,t.translate(y,b),t.rotate(u),t.translate(-y,-b),w=(m-l)/2,x=(g-c)/2,t.drawImage(n,0,0,l,c,w,x,l,c),S=t.getImageData(0,0,m,g),e.width=i,e.height=o,t.putImageData(S,-a,-s)):(e.width=i,e.height=o,t.fillStyle=h,t.fillRect(0,0,i,o),t.drawImage(n,a,s,i,o,0,0,i,o)),M=j.current,_=M.type,A=M.name,E=M.uid,e.toBlob((function(e){return vY(void 0,void 0,void 0,(function(){var t,n;return yY(this,(function(r){switch(r.label){case 0:return t=Object.assign(new File([e],A,{type:_}),{uid:E}),F.current?[4,F.current(t,[t])]:[2,U.current(t)];case 1:return!0===(n=r.sent())?[2,U.current(t)]:!1===n?[2,z.current(new Error("beforeUpload return false"))]:(delete t[Qq.LIST_IGNORE],n===Qq.LIST_IGNORE?(Object.defineProperty(t,Qq.LIST_IGNORE,{value:!0,configurable:!0}),[2,z.current(new Error("beforeUpload return LIST_IGNORE"))]):"object"==typeof n&&null!==n?[2,U.current(n)]:[2])}}))}))}),_,d),[2]}))}))}),[h,d,v]),Y=function(e){return r(u).createElement(r(u).Fragment,null,H,D&&r(u).createElement(SG,gY({visible:!0,wrapClassName:"".concat(bY,"-modal"),title:e,onOk:K,onCancel:q,maskClosable:!1,destroyOnClose:!0},W),r(u).createElement(SY,{ref:V,cropperRef:t,image:D,aspect:i,shape:a,grid:l,zoom:m,rotate:v,minZoom:b,maxZoom:x,cropperProps:R})))};return S?Y(S):r(u).createElement(sH,null,(function(e,t){return Y("zh-cn"===t?"编辑图片":"Edit image")}))}));var _Y=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"})});const AY=["image/jpeg","image/png","image/jpg","image/gif"],EY=({originNode:e,file:t,tenantID:n,apiUrl:r,actions:i,resourceType:o})=>{var a,l,c,u;const{t:d}=Te();return(0,s.jsxs)("div",{className:"memori--list-item-wrapper"+("uploading"===t.status?" listItemUploading":""),children:[(0,s.jsx)(dp,{spinning:"uploading"===t.status,children:"error"===t.status?(0,s.jsx)(zm,{content:d("media.uploadError"),children:e.props.children}):(0,s.jsx)(Xy,{item:{mediumID:t.uid,mimeType:"uploading"===t.status?"image/png":(null===(a=t.name)||void 0===a?void 0:a.endsWith(".glb"))?"model/gltf-binary":t.type||"image/png",title:null!==(l=t.name)&&void 0!==l?l:"",url:"uploading"===t.status?"":(null===(u=null===(c=t.response)||void 0===c?void 0:c.asset)||void 0===u?void 0:u.assetURL)?t.response.asset.assetURL:jm({type:o,resourceURI:t.thumbUrl,tenantID:n,apiURL:r}),content:`${jm({resourceURI:t.thumbUrl,type:o,apiURL:r})}`},preview:!1})}),("success"===t.status||"done"===t.status)&&(0,s.jsxs)("div",{className:"list-item-actions",children:[(0,s.jsx)(Zd,{outlined:!0,shape:"circle",icon:(0,s.jsx)(Wj,{}),className:"action-button",title:d("edit")||"Edit",onClick:()=>null==i?void 0:i.download(t)}),(0,s.jsx)(Zd,{outlined:!0,shape:"circle",icon:(0,s.jsx)(_Y,{}),className:"action-button",title:d("delete")||"Delete",onClick:()=>null==i?void 0:i.remove(t)})]})]})};var CY=({uploadMultipleImages:e,maxNumberOfVisualizedUploads:t,uploadUrl:n,apiUrl:i,tenantID:o,fileList:a,maxFileSizeInMB:l=2,fileResolution:c,useImageCrop:d,uploadMessage:f,imageProportions:h=1,imageProportionsHelper:p,allowedMimeTypes:m,onRemove:g,onFileChanged:v,onUploadFinished:y,onFileNotValid:b,disabled:w,showHelper:x,additionalHelper:S,resourceType:M})=>{var _;const{t:A}=Te(),[E,C]=(0,u.useState)(null!=a?a:[]),[k,T]=(0,u.useState)(),I=(0,s.jsx)(r($F),{className:"memori--upload",disabled:null!=w&&w,accept:(null===(_=null!=m?m:AY)||void 0===_?void 0:_.join(","))+";capture=camera,camcorder",action:n,listType:"picture-card",showUploadList:{showPreviewIcon:!0,showRemoveIcon:!0,showDownloadIcon:!0,downloadIcon:(0,s.jsx)(Wj,{title:A("edit")||"Edit"})},beforeUpload:e=>{if(!(null!=m?m:AY).find((t=>t===e.type))&&e.type)return console.debug("File not allowed",e,null!=m?m:AY),Qd.error(A("media.uploadMimeTypeNotAllowed")),b&&b(),Promise.reject(A("media.uploadMimeTypeNotAllowed"));if(!(e.size/1024/1024<(null!=l?l:2)))return Qd.error(A("media.uploadSizeLimitMessage",{size:l})),b&&b(),Promise.reject(A("media.uploadSizeLimitMessage",{size:l}));if(c&&c.length){const t=new FileReader;return t.readAsDataURL(e),new Promise(((n,r)=>{t.addEventListener("load",(t=>{var i,o,a,s=new Image;s.style.padding="0px",s.style.margin="0px",s.onload=()=>{s.width===c[0]&&s.height===c[1]?n(e):(Qd.error(A("media.uploadWrongResolutionMessage",{width:c[0],height:c[1]})),r(),b&&b())},s.src=null!==(a=null===(o=null===(i=t.target)||void 0===i?void 0:i.result)||void 0===o?void 0:o.toString())&&void 0!==a?a:""}))}))}return Promise.resolve(e)},supportServerRender:!0,fileList:E,multiple:e,maxCount:t||(e?100:1),onChange:e=>{C(e.fileList.map((e=>{var t;return{...e,status:null!==(t=e.status)&&void 0!==t?t:"error"}}))),"done"===e.file.status&&y&&y(e.file)},onRemove:g,onDownload:e=>{var t,n;let r=null===(t=e.response)||void 0===t?void 0:t.asset;if(r){let t=r.originalFileName&&e.name.includes(r.originalFileName)?r.originalFileName:e.name;T({...r,title:null!=t?t:r.title})}else T({assetID:e.uid,title:null!==(n=e.name)&&void 0!==n?n:e.fileName})},itemRender:(e,t,n,r)=>(0,s.jsx)(EY,{resourceType:M,originNode:e,file:t,fileList:E||n,actions:r,tenantID:o,apiUrl:i}),children:f});return(0,s.jsxs)("div",{"aria-live":"polite",children:[d?(0,s.jsx)(MY,{rotate:!0,aspect:h,fillColor:"transparent",modalCancel:A("cancel")||"Cancel",modalMaskTransitionName:"none",modalTransitionName:"none",children:I}):I,(0,s.jsxs)(hp,{open:!!k,title:A("media.editAttributes"),onClose:()=>{T(void 0)},footer:(0,s.jsx)(s.Fragment,{}),width:"100%",children:[(0,s.jsx)("label",{htmlFor:"media-title-input",className:"media-title-label",children:A("media.title")}),(0,s.jsx)("input",{id:"media-title-input",className:"media-title-input",type:"text",name:"title",defaultValue:(null==k?void 0:k.title)||"",onChange:e=>{T({...k,title:e.target.value})}}),(0,s.jsxs)("div",{className:"memori-modal--footer",children:[(0,s.jsx)(Zd,{onClick:()=>{T(void 0)},children:A("cancel")}),(0,s.jsx)(Zd,{primary:!0,onClick:()=>{v&&(null==k?void 0:k.assetID)&&v(k.assetID,{...k}),C((e=>e.map((e=>{var t,n;return e.uid===(null==k?void 0:k.assetID)||(null===(n=null===(t=e.response)||void 0===t?void 0:t.asset)||void 0===n?void 0:n.assetID)===(null==k?void 0:k.assetID)?{...e,title:null==k?void 0:k.title,name:null==k?void 0:k.title}:e})))),T(void 0)},children:A("confirm")})]})]}),x&&(0,s.jsxs)("legend",{className:"helper",children:[(0,s.jsx)("p",{children:A(m?"media.uploadHelper":"media.uploadHelperImages").replace("@size@",(null!=l?l:2).toString())}),p&&d&&(0,s.jsxs)("p",{children:[A("media.scaleRatio"),": ",p]}),S&&(0,s.jsx)("p",{children:S})]})]})};var kY=({visible:e,authToken:t,sessionID:n,tenantID:r,uploadAssetURL:i,deleteAsset:o,onCancel:a,onOk:l,apiURL:c})=>{const{t:d}=Te(),[f,h]=(0,u.useState)();return(0,s.jsx)(hp,{open:e,title:d("media.addMediaLabel"),className:"attachment-media-modal",closable:!0,width:"100%",widthMd:"100%",onClose:()=>{a&&a()},footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Zd,{onClick:a,children:d("cancel")}),(0,s.jsx)(Zd,{primary:!0,onClick:()=>{f&&l(f),h(void 0)},disabled:!f,children:d("confirm")})]}),children:(0,s.jsx)(CY,{tenantID:r,apiUrl:c,uploadMultipleImages:!1,maxNumberOfVisualizedUploads:1,maxFileSizeInMB:100,uploadUrl:i,useImageCrop:!1,allowedMimeTypes:_g,fileList:f?[{uid:"-1",name:f.assetID,status:"done",thumbUrl:jm({resourceURI:f.assetURL,tenantID:r,apiURL:c,sessionID:n})}]:[],uploadMessage:d("media.mediaUploadMessage"),imageProportions:1,onUploadFinished:e=>{let t=e.response.asset,n=e.response;0===n.resultCode?h(t):(console.error(n,e),Qd.error(d(ZF(n.resultCode))))},onFileChanged:(e,t)=>{h((e=>({...e||{},...t})))},onRemove:async e=>{const n=await o(t,e.thumbUrl);return 0===n.resultCode?h(void 0):(console.error(n,e),Qd.error(d(ZF(n.resultCode)))),0===n.resultCode}})})};u=a("85Hg2");var TY=({visible:e,onCancel:t,onOk:n})=>{var r,i,o;const{t:a}=Te(),[l,c]=(0,u.useState)({url:"",title:""}),d=e=>{if("Enter"===e.key){if(0===(null==l?void 0:l.url.length)||0===(null==l?void 0:l.title.length))return;let e=document.getElementById("save-link-button");e&&e.click()}};return(0,s.jsx)(hp,{open:e,title:a("media.addLinkLabel"),className:"attachment-link-modal",closable:!0,width:"100%",widthMd:"80%",onClose:()=>{t&&t()},footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Zd,{onClick:t,children:a("cancel")}),(0,s.jsx)(Zd,{id:"save-link-button",primary:!0,onClick:()=>{0!==(null==l?void 0:l.url.length)&&0!==(null==l?void 0:l.title.length)&&(n(l),c({url:"",title:""}))},disabled:0===(null==l?void 0:l.url.length)||0===(null==l?void 0:l.title.length),children:a("confirm")})]}),children:(0,s.jsxs)("div",{className:"attachment-link-modal--row",children:[(0,s.jsxs)("div",{className:"attachment-link-modal--column",children:[(0,s.jsxs)("label",{htmlFor:"new-link-url",className:"attachment-link-modal--label",children:[a("media.linkKey"),":"]}),(0,s.jsx)("input",{type:"url",className:"attachment-link-modal--input ",onChange:e=>{let t=e.target.value.startsWith("http")||0===e.target.value.length?e.target.value:`https://${e.target.value}`;c((e=>{var n;return{title:null!==(n=null==e?void 0:e.title)&&void 0!==n?n:"",url:t}}))},placeholder:"https://memori.ai/...",value:null==l?void 0:l.url,name:"url",onKeyDown:d}),(0,s.jsxs)("label",{htmlFor:"new-link-title",className:"attachment-link-modal--label",children:[a("media.linkValue"),":"]}),(0,s.jsx)("input",{type:"text",className:"attachment-link-modal--input ",onChange:e=>c((t=>{var n;return{url:null!==(n=null==t?void 0:t.url)&&void 0!==n?n:"",title:e.target.value}})),value:null==l?void 0:l.title,name:"title",onKeyDown:d})]}),(0,s.jsx)("div",{className:"attachment-link-modal--column",children:(0,s.jsx)("div",{className:"attachment-link-modal--centered",children:(0,s.jsx)(bg,{item:{title:null!==(r=null==l?void 0:l.title)&&void 0!==r?r:"",url:null!==(i=null==l?void 0:l.url)&&void 0!==i?i:"",mediumID:"",mimeType:"text/html"},onLinkPreviewInfo:e=>{var t;(null===(t=null==l?void 0:l.title)||void 0===t?void 0:t.length)||c((t=>{var n;return{...t,title:null!==(n=null==e?void 0:e.title)&&void 0!==n?n:""}}))}},null!==(o=null==l?void 0:l.url)&&void 0!==o?o:"")})})]})})};var IY=({tenant:e,userLang:t="en"})=>{const n="memorytwin"===(null==e?void 0:e.theme)?"memorytwin":"twincreator";return(0,s.jsxs)("div",{className:"memori--powered-by",children:[(0,s.jsx)("img",{src:`https://app.twincreator.com/images/${n}/logo.png`,alt:""}),(0,s.jsxs)("p",{children:["Powered by"," ",(0,s.jsx)("a",{href:`https://app.${n}.com/${t?t.toLowerCase():""}`,target:"_blank",rel:"noopener noreferrer",children:"memorytwin"===n?"MemoryTwin":"TwinCreator"})]})]})};var OY=({header:e,avatar:t,chat:n,startPanel:r,integrationStyle:i,integrationBackground:o,changeMode:a,sessionId:l,hasUserActivatedSpeak:c,showInstruct:u=!1,loading:d=!1,poweredBy:f})=>(0,s.jsxs)(s.Fragment,{children:[i,o,(0,s.jsxs)(dp,{spinning:d,children:[u&&a,e,(0,s.jsxs)("div",{className:"memori--grid",children:[(0,s.jsx)("div",{className:"memori--grid-column memori--grid-column-left",children:t}),(0,s.jsx)("div",{className:"memori--grid-column memori--grid-column-right",children:l&&c?n:r}),f]})]})]});var RY=({header:e,avatar:t,chat:n,startPanel:r,integrationStyle:i,integrationBackground:o,changeMode:a,sessionId:l,hasUserActivatedSpeak:c,showInstruct:u=!1,loading:d=!1,poweredBy:f})=>(0,s.jsxs)(s.Fragment,{children:[i,o,(0,s.jsxs)(dp,{spinning:d,className:"memori-totem-layout",children:[f,u&&a,(0,s.jsx)("div",{className:"memori-totem-layout--header",children:e}),(0,s.jsx)("div",{className:"memori-totem-layout--avatar",children:t}),(0,s.jsx)("div",{className:"memori-totem-layout--controls",children:l&&c?n:r})]})]});const PY={muteSpeaker:"@memori:muteSpeaker",continuousSpeech:"@memori:continuousSpeech",continuousSpeechTimeout:"@memori:continuousSpeechTimeout",sendOnEnter:"@memori:sendOnEnter",birthDate:"@memori:birthDate",controlsPosition:"@memori:controlsPosition"},NY=(e,t)=>{var n;const r=window.localStorage.getItem(null!==(n=PY[e])&&void 0!==n?n:e);if(!r)return t;try{return JSON.parse(r)}catch(e){return r}},LY=(e,t)=>{var n;window.localStorage.setItem(null!==(n=PY[e])&&void 0!==n?n:e,t.toString())},{deleteSession:DY,getStatistics:BY,initSession:jY}=W(),FY=new Map([[0,"🆕"],[10,"🐹"],[20,"🐇"],[30,"🐰"],[40,"💡"],[50,"🏆"],[60,"🏅"],[70,"🥉"],[80,"🥈"],[90,"🥇"],[100,"🔥"],[110,"🎓"],[120,"🤖"],[130,"👾"],[150,"🌍"],[180,"💜"],[200,"💙"],[250,"🧡"],[300,"💚"],[350,"💛"],[400,"💖"],[450,"💝"],[500,"🖤"],[550,"❤️"],[600,"🧠"]]),UY=e=>{const t=Array.from(FY.keys()).filter((t=>t<=e));if(t.length>0){const e=t[t.length-1];return FY.get(e)}return""},zY=e=>{if("🆕"===e)return{points:10,badge:"🐹"};let t,n,r=!1;for(const[i,o]of FY){if(r){t=i,n=o;break}o===e&&(r=!0)}return n&&t?{points:t,badge:n}:void 0},HY=e=>{let t=0;for(const[n,r]of FY)if(r===e){t=n;break}return t},VY=e=>{const t=Math.round(e),n=UY(t);return{points:t,badge:n,pointsForCurrentBadge:HY(n),nextBadge:zY(n)}};var WY=a("agy8n");u=a("85Hg2"),WY=a("agy8n");const GY={en:["January","February","March","April","May","June","July","August","September","October","November","December"],it:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"]},qY=(0,u.memo)((({defaultDate:e,onChange:t,disabled:n=!1})=>{const{t:i,i18n:o}=Te(),[a,l]=(0,u.useState)(r(WY)(e||Date.now()));return(0,u.useEffect)((()=>{t(a)}),[a,t]),r(WY).locale(o.language),(0,s.jsxs)("div",{className:"memori--date-selector",children:[(0,s.jsx)("div",{className:"memori--date-selector__select",children:(0,s.jsxs)(Xb,{value:a,onChange:e=>{l(e)},disabled:n,name:"day",children:[(0,s.jsxs)(Xb.Label,{className:"memori--date-selector__select-label",children:[i("day"),":"]}),(0,s.jsxs)(Xb.Button,{"aria-label":i("day"),className:"memori--date-selector__select-button",children:[(0,s.jsx)("span",{className:"memori--date-selector__select--value",children:a.date()}),(0,s.jsx)("span",{className:"memori--date-selector__select--icon",children:(0,s.jsx)(Zb,{})})]}),(0,s.jsx)(Jf,{as:u.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,s.jsx)(Xb.Options,{className:"memori--date-selector__select-options",children:[...Array(31).keys()].map((e=>(0,s.jsx)(Xb.Option,{value:a.clone().date(e+1),className:"memori--date-selector__select-option",children:e+1},e)))})})]})}),(0,s.jsx)("div",{className:"memori--date-selector__select",children:(0,s.jsxs)(Xb,{value:a,onChange:e=>{l(e)},disabled:n,name:"month",children:[(0,s.jsxs)(Xb.Label,{className:"memori--date-selector__select-label",children:[i("month"),":"]}),(0,s.jsxs)(Xb.Button,{"aria-label":i("month"),className:"memori--date-selector__select-button",children:[(0,s.jsx)("span",{className:"memori--date-selector__select--value",children:GY["it"===o.language?"it":"en"][a.month()]}),(0,s.jsx)("span",{className:"memori--date-selector__select--icon",children:(0,s.jsx)(Zb,{})})]}),(0,s.jsx)(Jf,{as:u.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,s.jsx)(Xb.Options,{className:"memori--date-selector__select-options",children:GY["it"===o.language?"it":"en"].map((e=>(0,s.jsx)(Xb.Option,{className:"memori--date-selector__select-option",value:a.clone().month(GY["it"===o.language?"it":"en"].findIndex((t=>t===e))),children:e},e)))})})]})}),(0,s.jsx)("div",{className:"memori--date-selector__select",children:(0,s.jsxs)(Xb,{value:a,onChange:e=>{l(e)},disabled:n,name:"year",children:[(0,s.jsxs)(Xb.Label,{className:"memori--date-selector__select-label",children:[i("year"),":"]}),(0,s.jsxs)(Xb.Button,{"aria-label":i("year"),className:"memori--date-selector__select-button",children:[(0,s.jsx)("span",{className:"memori--date-selector__select--value",children:a.year()}),(0,s.jsx)("span",{className:"memori--date-selector__select--icon",children:(0,s.jsx)(Zb,{})})]}),(0,s.jsx)(Jf,{as:u.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,s.jsx)(Xb.Options,{className:"memori--date-selector__select-options",children:[...Array(r(WY)().year()-1899).keys()].sort(((e,t)=>t-e)).map((e=>(0,s.jsx)(Xb.Option,{value:a.clone().year(e+1900),className:"memori--date-selector__select-option",children:e+1900},e)))})})]})})]})}));qY.displayName="DateSelector";var KY=qY;u=a("85Hg2");var YY=({visible:e=!1,onClose:t,minAge:n})=>{const{t:i}=Te(),[o,a]=(0,u.useState)(),[l,c]=(0,u.useState)(),d=(0,u.useCallback)((()=>{if(!o)return Qd.error(i("requiredField")),void c(i("requiredField")||"Required field");if(r(WY)().diff(o,"years")<n)return Qd.error(i("underageTwinSession",{age:n})),void c(i("underageTwinSession",{age:n})||`You must be at least ${n} years old to interact with this Twin`);t(o.toISOString())}),[o,n,t,i]);return(0,s.jsxs)(hp,{open:e,title:i("ageVerification"),className:"age-verification-modal",closable:!0,onClose:()=>t(),children:[(0,s.jsx)("p",{children:i("ageVerificationText",{minAge:n})}),(0,s.jsxs)("form",{className:"age-verification-form",onSubmit:e=>{e.preventDefault(),d()},children:[(0,s.jsx)("div",{className:"form-item",children:(0,s.jsxs)("fieldset",{name:"birthDate",children:[(0,s.jsx)("legend",{className:"sr-only",children:i("birthDate")}),(0,s.jsx)(KY,{defaultDate:new Date(Date.now()),onChange:e=>{a(e)}}),(0,s.jsx)("p",{className:"form-item-help",children:i("birthDateHelper")}),l&&(0,s.jsx)("p",{className:"form-item-error",children:l})]})}),(0,s.jsx)("div",{className:"form-item form-submit",children:(0,s.jsx)(Zd,{primary:!0,htmlType:"submit",className:"age-verification-submit",disabled:!o,children:i("confirm")})})]})]})};u=a("85Hg2"),Jd=a("4IUwl");var JY=({open:e=!1,onClose:t,className:n,title:i,description:o,children:a,footer:l,loading:c=!1,side:d="right",closable:f=!0,width:h="100%",widthMd:p="80%",widthLg:m="60%"})=>(0,s.jsx)(Jf,{appear:!0,show:e,as:r(u).Fragment,children:(0,s.jsxs)(up,{open:e,onClose:t,className:r(Jd)("memori-drawer",n),children:[(0,s.jsx)(Jf.Child,{as:r(u).Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,s.jsx)("div",{className:"memori-drawer--backdrop"})}),(0,s.jsx)("div",{className:"memori-drawer--container",children:(0,s.jsx)("div",{className:"memori-drawer--container-scrollable",children:(0,s.jsx)(Jf.Child,{as:r(u).Fragment,enter:"ease-out duration-300",enterFrom:"max-w-0 opacity-0",enterTo:"max-w-100 opacity-100",leave:"ease-in duration-200",leaveFrom:"max-w-100 opacity-100",leaveTo:"max-w-0 opacity-0",children:(0,s.jsxs)(up.Panel,{className:r(Jd)("memori-drawer--panel",{"memori-drawer--panel-left":"left"===d,"memori-drawer--with-footer":!!l}),children:[(0,s.jsx)("style",{dangerouslySetInnerHTML:{__html:`\n .memori-drawer--panel {\n --memori-drawer--width: ${h};\n --memori-drawer--width-lg: ${m};\n --memori-drawer--width-md: ${p};\n }\n `}}),f&&(0,s.jsx)("div",{className:"memori-drawer--close",children:(0,s.jsx)(Zd,{shape:"circle",outlined:!0,icon:(0,s.jsx)(fp,{}),onClick:()=>t(!1)})}),(0,s.jsxs)(dp,{spinning:c,children:[i&&(0,s.jsx)(up.Title,{className:"memori-drawer--title",children:i}),o&&(0,s.jsx)(up.Description,{className:"memori-drawer--description",children:o}),a,l&&(0,s.jsx)("div",{className:"memori-drawer--footer",children:l})]})]})})})})]})});Jd=a("4IUwl");var QY=({label:e,className:t,disabled:n=!1,checked:i,children:o,onChange:a,name:l,...c})=>(0,s.jsxs)("label",{className:r(Jd)("memori-checkbox",t,{"memori-checkbox--disabled":n}),children:[(0,s.jsxs)("span",{className:"memori-checkbox--input-wrapper",children:[(0,s.jsx)("input",{type:"checkbox",...c,name:l,disabled:n,defaultChecked:i,className:"memori-checkbox--input",onChange:a}),(0,s.jsx)("span",{className:"memori-checkbox--inner"})]}),(0,s.jsx)("span",{className:"memori-checkbox--text",children:e})]});const XY=[2,3,5,10,15,20,30,60];var ZY=({open:e,layout:t="DEFAULT",onClose:n,continuousSpeech:r,continuousSpeechTimeout:i,setContinuousSpeech:o,setContinuousSpeechTimeout:a,controlsPosition:l,setControlsPosition:c})=>{const{t:u}=Te();return(0,s.jsxs)(JY,{className:"memori-settings-drawer",open:e,onClose:n,title:u("widget.settings")||"Settings",description:u("write_and_speak.settingsHeaderLabel"),children:[(0,s.jsx)("div",{className:"memori-settings-drawer--field",children:(0,s.jsx)(QY,{label:u("write_and_speak.continuousSpeechLabel"),checked:r,onChange:e=>{o(e.target.checked),LY("continuousSpeech",e.target.checked),e.target.checked||"hidden"!==l||(c("bottom"),LY("controlsPosition","bottom"))}})}),(0,s.jsx)("div",{className:"memori-settings-drawer--field",children:(0,s.jsx)($b,{label:u("write_and_speak.secondsLabel")||"Seconds",placeholder:u("write_and_speak.secondsLabel")||"Seconds",options:XY.map((e=>({value:e,label:e}))),value:i,onChange:e=>{a(e),LY("continuousSpeechTimeout",e)}})}),"TOTEM"===t&&(0,s.jsxs)("div",{className:"memori-settings-drawer--field controls",children:[(0,s.jsxs)("label",{htmlFor:"#controlsPosition",children:[u("write_and_speak.controlsPosition")||"Controls",":"]}),(0,s.jsxs)(Sb,{id:"controlsPosition",name:"controlsPosition",value:l,defaultValue:l,className:"memori-settings-drawer--controlsposition-radio",onChange:e=>{c(e),LY("controlsPosition",e)},children:[(0,s.jsx)(Sb.Option,{value:"center",className:"memori-settings-drawer--controlsposition-radio-button",children:({checked:e})=>(0,s.jsx)(Zd,{primary:e,children:u("center")||"Center"})}),(0,s.jsx)(Sb.Option,{value:"bottom",className:"memori-settings-drawer--controlsposition-radio-button",children:({checked:e})=>(0,s.jsx)(Zd,{primary:e,children:u("bottom")||"Bottom"})}),!!r&&(0,s.jsx)(Sb.Option,{value:"hidden",className:"memori-settings-drawer--controlsposition-radio-button",children:({checked:e})=>(0,s.jsx)(Zd,{primary:e,children:u("hidden")||"Hidden"})})]})]})]})};let $Y,eJ,tJ,nJ,rJ;window.getMemoriState=e=>{var t,n,r,i,o;let a=e?document.querySelector(`.memori-widget[data-memori-integration="${e}"]`)||(null===(n=null===(t=document.querySelector("memori-client"))||void 0===t?void 0:t.shadowRoot)||void 0===n?void 0:n.querySelector(".memori-widget[data-memori-integration]")):document.querySelector(".memori-widget")||(null===(i=null===(r=document.querySelector("memori-client"))||void 0===r?void 0:r.shadowRoot)||void 0===i?void 0:i.querySelector(".memori-widget"));if(!a)return null;let s=null===(o=a.dataset)||void 0===o?void 0:o.memoriEngineState;return s?JSON.parse(s):null},window.typeMessage=e=>{var t,n;let r=document.querySelector("fieldset#chat-fieldset textarea")||(null===(n=null===(t=document.querySelector("memori-client"))||void 0===t?void 0:t.shadowRoot)||void 0===n?void 0:n.querySelector("fieldset#chat-fieldset textarea"));r&&(!function(e,t){var n,r,i,o;const a=null===(r=null===(n=null==Object?void 0:Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,"value"))||void 0===r?void 0:r.set,s=Object.getPrototypeOf(e),l=null===(o=null===(i=null==Object?void 0:Object.getOwnPropertyDescriptor)||void 0===i?void 0:i.call(Object,s,"value"))||void 0===o?void 0:o.set;l&&a&&a!==l?l.call(e,t):a&&a.call(e,t)}(r,e),r.dispatchEvent(new Event("input",{bubbles:!0})),setTimeout((()=>{var e,t;let n=document.querySelector("button.memori-chat-inputs--send")||(null===(t=null===(e=document.querySelector("memori-client"))||void 0===e?void 0:e.shadowRoot)||void 0===t?void 0:t.querySelector("button.memori-chat-inputs--send"));n&&n.click()}),100))};var iJ=({memori:e,memoriConfigs:t,memoriLang:n,integration:i,layout:o="DEFAULT",showInstruct:a=!1,showShare:l=!0,preview:c=!1,embed:d=!1,showInputs:f=!0,showDates:h=!1,showContextPerLine:p=!1,showSettings:m=!0,height:g="100vh",secret:v,baseUrl:y="https://app.twincreator.com",apiUrl:b="https://backend.memori.ai",initialContextVars:w,initialQuestion:x,ogImage:S,sessionID:M,tenant:_,personification:A,authToken:E,AZURE_COGNITIVE_SERVICES_TTS_KEY:C,onStateChange:k})=>{var T,I,O,R,P,N,L,D,B,j,F,U,z,H,V,G,q,K;const{t:Y,i18n:J}=Te(),[Q,X]=(0,u.useState)(!1);(0,u.useEffect)((()=>{X(!0)}),[]);const Z=W(b),{initSession:$,postTextEnteredEvent:ee,postPlaceChangedEvent:te,postTimeoutEvent:ne,postTagChangedEvent:re,getSession:ie,getContentQualityIndexes:oe}=Z,[ae,se]=(0,u.useState)(!1),[le,ce]=(0,u.useState)(!1),[ue,de]=(0,u.useState)(!1),fe=null===(R=null===(O=null===(I=null===(T=null==t?void 0:t.find((t=>t.memoriConfigID===e.memoriConfigurationID)))||void 0===T?void 0:T.culture)||void 0===I?void 0:I.split("-"))||void 0===O?void 0:O[0])||void 0===R?void 0:R.toUpperCase(),[he,pe]=(0,u.useState)(null!==(B=null!==(D=null!==(L=null!=n?n:null===(N=null===(P=null==e?void 0:e.culture)||void 0===P?void 0:P.split("-"))||void 0===N?void 0:N[0])&&void 0!==L?L:fe)&&void 0!==D?D:J.language)&&void 0!==B?B:"IT"),me=(null==i?void 0:i.customData)?JSON.parse(i.customData):null,ge=!!(null==me?void 0:me.multilanguage),[ve,ye]=(0,u.useState)(!1),[be,we]=(0,u.useState)(!1),xe=o||(null==me?void 0:me.layout)||"DEFAULT",[Se,Me]=(0,u.useState)(!1),[_e,Ae]=(0,u.useState)(!1),[Ee,Ce]=(0,u.useState)(!1),[ke,Ie]=(0,u.useState)(!1),[Oe,Re]=(0,u.useState)(!1),[Pe,Ne]=(0,u.useState)(!0),[Le,De]=(0,u.useState)(2),[Be,je]=(0,u.useState)(!1),[Fe,Ue]=(0,u.useState)("center");(0,u.useEffect)((()=>{je(!!tJ)}),[tJ]),(0,u.useEffect)((()=>{Re(NY("muteSpeaker",!1)),Ne(NY("continuousSpeech",!0)),De(NY("continuousSpeechTimeout",2)),Ue(NY("controlsPosition","center"))}),[]);const[ze,He]=(0,u.useState)(v),[Ve,We]=(0,u.useState)(),[Ge,qe]=(0,u.useState)(null),[Ke,Ye]=(0,u.useState)(),Je=async(e,t)=>{var n;const r=null!=t?t:ut;if(e&&r){const{currentState:t,...i}=await te({sessionId:r,placeName:e.placeName,latitude:e.latitude,longitude:e.longitude,uncertaintyKm:null!==(n=e.uncertainty)&&void 0!==n?n:0});t&&0===i.resultCode&&pt({...ft,...t})}},[Qe,Xe]=(0,u.useState)(""),[Ze,$e]=(0,u.useState)(!1),[et,tt]=(0,u.useState)([]),nt=e=>{tt((t=>[...t,{...e}]))},rt=async(t,n,r,i=!0,o)=>{var a,s,l,c,u;if(!ut||!(null==t?void 0:t.length))return;nt({text:t,translatedText:o,fromUser:!0,media:null!=n?n:[],initial:!!r}),we(!0);const d=null!==(c=null!==(l=null===(s=null===(a=e.culture)||void 0===a?void 0:a.split("-"))||void 0===s?void 0:s[0])&&void 0!==l?l:J.language)&&void 0!==c?c:"IT";let f=t;if(i&&!ae&&ge&&he.toUpperCase()!==d.toUpperCase()){f=(await Sg(t,d,he,y)).text}const{currentState:h,...p}=await ee({sessionId:null!=r?r:ut,text:f});if(0===p.resultCode&&h){const t=null!==(u=h.emission)&&void 0!==u?u:null==ft?void 0:ft.emission;if("X4"===h.state&&e.giverTag){const{currentState:t,...n}=await re(ut,e.giverTag);0===n.resultCode?(pt(t),t.emission&&(nt({text:t.emission,media:t.media,fromUser:!1}),Tt(t.emission))):(console.error(p,n),Qd.error(Y(ZF(n.resultCode))))}else if("X2d"===h.state&&e.giverTag){const{currentState:t,...n}=await ee({sessionId:null!=r?r:ut,text:Math.random().toString().substring(2,8)});if(0===n.resultCode){const{currentState:t,...n}=await re(ut,e.giverTag);0===n.resultCode?(pt(t),t.emission&&(nt({text:t.emission,media:t.media,fromUser:!1}),Tt(t.emission))):(console.error(p,n),Qd.error(Y(ZF(n.resultCode))))}else console.error(p,n),Qd.error(Y(ZF(n.resultCode)))}else he.toLowerCase()!==d.toLowerCase()&&t&&!ae&&ge?it(h,he).then((e=>{e.emission&&Tt(e.emission)})):(pt({...h,emission:t}),t&&(nt({text:t,media:h.media,fromUser:!1,generatedByAI:!!h.completion}),Tt(t)))}else 404===p.resultCode&&(tt((e=>[...e.slice(0,e.length-1)])),gt(!1,ze||e.secretToken,Ve,ae&&e.giverTag?e.giverTag:void 0,ae&&e.giverPIN?e.giverPIN:void 0,w,x).then((e=>{console.info("session timeout"),(null==e?void 0:e.sessionID)&&setTimeout((()=>{rt(t,n,null==e?void 0:e.sessionID)}),500)})));we(!1)},it=async(t,n)=>{var r,i,o,a,s,l,c;const u=null!==(a=null!==(o=null===(i=null===(r=e.culture)||void 0===r?void 0:r.split("-"))||void 0===i?void 0:i[0])&&void 0!==o?o:J.language)&&void 0!==a?a:"IT",d=null!==(s=t.emission)&&void 0!==s?s:null==ft?void 0:ft.emission;let f={...t},h=null;if(d&&!ae&&u.toUpperCase()!==n.toUpperCase()&&ge){const e=await Sg(d,n,u,y);if(t.hints&&t.hints.length>0){const r=await Promise.all((null!==(l=t.hints)&&void 0!==l?l:[]).map((async e=>{var t;const r=await Sg(e,n,u,y);return{text:null!==(t=null==r?void 0:r.text)&&void 0!==t?t:e,originalText:e}})));f={...t,emission:e.text,translatedHints:r}}else f={...t,emission:e.text,hints:null!==(c=t.hints)&&void 0!==c?c:"G1"===t.state?null==ft?void 0:ft.hints:[]};e.text.length>0&&(h={text:e.text,media:t.media,fromUser:!1,generatedByAI:!!t.completion})}else f={...t,emission:d},d&&(h={text:d,media:t.media,fromUser:!1});return pt(f),h&&nt(h),f},ot=e.ageRestriction?e.ageRestriction:e.nsfw?18:e.enableCompletions?14:0,[at,st]=(0,u.useState)(),[lt,ct]=(0,u.useState)(!1),[ut,dt]=(0,u.useState)(M),[ft,ht]=(0,u.useState)(),pt=e=>{ht(e),k&&k(e)},mt=async t=>{var n;if("PUBLIC"!==e.privacyType&&!e.secretToken&&!ze&&!Ve)return void qe("password");let r=NY("birthDate",void 0);if(at||r||!ot){ye(!0);try{if(!e.giverTag&&(null===(n=e.receivedInvitations)||void 0===n?void 0:n.length)){let t=e.receivedInvitations.find((e=>"GIVER"===e.type&&"ACCEPTED"===e.state));t&&(e.giverTag=t.tag,e.giverPIN=t.pin)}const r=await $(t);if((null==r?void 0:r.sessionID)&&(null==r?void 0:r.currentState)&&0===r.resultCode)return dt(r.sessionID),Ke&&Je(Ke,r.sessionID),ye(!1),{dialogState:r.currentState,sessionID:r.sessionID};(null==r?void 0:r.resultMessage.startsWith("This Memori is aged restricted"))?(console.error(r),Qd.error(Y("underageTwinSession",{age:ot})),de(!0)):(console.error(r),Qd.error(Y(ZF(null==r?void 0:r.resultCode))),de(!0))}catch(e){console.error(e),new Error("Error fetching session")}}else ct(!0)},gt=async(t=!1,n,r,i,o,a,s,l)=>{var c;ye(!0);try{let u=NY("birthDate",void 0);const{sessionID:d,currentState:f,...h}=await $({memoriID:null!==(c=e.engineMemoriID)&&void 0!==c?c:"",password:n,recoveryTokens:r,tag:i,pin:o,initialContextVars:a,initialQuestion:s,birthDate:l||u||void 0});if(d&&f&&0===h.resultCode)return dt(d),t&&(pt(f),f.emission&&(et.length<=1?tt([{text:f.emission,media:f.media,fromUser:!1}]):nt({text:f.emission,media:f.media,fromUser:!1}))),Ke&&Je(Ke,d),ye(!1),{dialogState:f,sessionID:d};(null==h?void 0:h.resultMessage.startsWith("This Memori is aged restricted"))?(console.error(h),Qd.error(Y("underageTwinSession",{age:ot})),de(!0)):(console.error(h),Qd.error(Y(ZF(h.resultCode))),de(!0))}catch(e){console.error(e)}return ye(!1),null},vt=async(t,n,r,i)=>{var o;if(!t||!n)return console.error("CHANGETAG/Session not found"),Promise.reject("Session not found");try{const{currentState:t,resultCode:a}=await re(n,null!=r?r:Ag);if(0===a){let s=0;if(r!==Ag&&i&&("X1a"===t.state||"X1b"===t.state)){const{resultCode:e}=await ee({sessionId:n,text:null!=i?i:""});s=e}if(0===s){const{currentState:e,...t}=await ie(n);if(0===t.resultCode&&e)return{currentState:e,sessionId:n,...t}}else if([400,401,403,404,500].includes(a)){console.warn("[APPCONTEXT/CHANGETAG]",a);let t=NY("birthDate",void 0);mt({memoriID:null!==(o=e.engineMemoriID)&&void 0!==o?o:"",password:v||e.secretToken,tag:e.giverTag,pin:e.giverPIN,initialContextVars:w,initialQuestion:x,birthDate:at||t||void 0})}else if(t)return{currentState:t,sessionId:n,resultCode:a}}}catch(e){let t=e;return console.error("[APPCONTEXT/CHANGETAG]",t),Promise.reject(t)}return null};(0,u.useEffect)((()=>()=>{ft&&(null==ft?void 0:ft.currentTag)===e.giverTag||(async()=>{ut&&e.giverTag&&e.giverPIN&&(tt([]),await vt(e.engineMemoriID,ut,e.giverTag,e.giverPIN))})()}),[]);const[yt,bt]=(0,u.useState)(),wt=(0,u.useRef)(),xt=()=>{yt&&(clearTimeout(yt),bt(void 0)),(null==wt?void 0:wt.current)&&(clearTimeout(wt.current),wt.current=void 0)},St=()=>{xt(),!(null==ft?void 0:ft.acceptsTimeout)||tJ||Be||Qe.length||Ze||_t()},Mt=async()=>{var e;if(tJ||Be||Qe.length||Ze)St();else if(ut&&Se&&(null==ft?void 0:ft.acceptsTimeout)){const{currentState:t,...n}=await ne(ut);if(0===n.resultCode&&t){const n=t.emission;!ae&&ge&&he!==(null==J?void 0:J.language)&&n&&n.length>0?it({...t,emission:n},he).then((e=>{e.emission&&Tt(e.emission)})):n&&n.length>0&&(nt({text:n,media:t.media,fromUser:!1,generatedByAI:!!t.completion}),Tt(n),pt({...t,hints:null!==(e=t.hints)&&void 0!==e?e:"G1"===t.state?null==ft?void 0:ft.hints:[]}))}}},_t=()=>{let e=null==ft?void 0:ft.timeout;if(!e){let t=40,n=25;if(e=Math.floor(Math.random()*(t-n))+n,null==ft?void 0:ft.emission){e+=ft.emission.length/26.5}}let t=setTimeout(Mt,1e3*e);bt(t),wt.current=t};(0,u.useEffect)((()=>{(Qe.length||Be)&&xt(),ut&&!Qe.length&&St()}),[null==ft?void 0:ft.acceptsTimeout,null==ft?void 0:ft.timeout,null==ft?void 0:ft.state,Be,ut,et,Qe]),(0,u.useEffect)((()=>()=>{Me(!1),ce(!1),xt(),wt.current=void 0}),[]);const At=(0,u.useCallback)((t=>{var n,r,i,o;let a="";switch((null!==(o=null!==(i=null!=t?t:null===(r=null===(n=e.culture)||void 0===n?void 0:n.split("-"))||void 0===r?void 0:r[0])&&void 0!==i?i:J.language)&&void 0!==o?o:"IT").toUpperCase()){case"IT":a=""+("MALE"===e.voiceType?"it-IT-DiegoNeural":"it-IT-ElsaNeural");break;case"DE":a=""+("MALE"===e.voiceType?"de-DE-ConradNeural":"de-DE-KatjaNeural");break;case"EN":a=""+("MALE"===e.voiceType?"en-GB-RyanNeural":"en-GB-SoniaNeural");break;case"ES":a=""+("MALE"===e.voiceType?"es-ES-AlvaroNeural":"es-ES-ElviraNeural");break;case"FR":a=""+("MALE"===e.voiceType?"fr-FR-HenriNeural":"fr-FR-DeniseNeural");break;case"PT":a=""+("MALE"===e.voiceType?"pt-PT-DuarteNeural":"pt-PT-RaquelNeural");break;case"UK":a=""+("MALE"===e.voiceType?"uk-UA-OstapNeural":"uk-UA-PolinaNeural");break;case"RU":a=""+("MALE"===e.voiceType?"ru-RU-DmitryNeural":"ru-RU-SvetlanaNeural");break;default:a=""+("MALE"===e.voiceType?"it-IT-DiegoNeural":"it-IT-IsabellaNeural")}return a}),[e.voiceType,J.language,e.culture]),Et=t=>{var n,r;let i="";switch((t||(null===(r=null===(n=e.culture)||void 0===n?void 0:n.split("-"))||void 0===r?void 0:r[0])||J.language||"IT").toUpperCase()){case"IT":default:i="it-IT";break;case"DE":i="de-DE";break;case"EN":i="en-GB";break;case"ES":i="es-ES";break;case"FR":i="fr-FR";break;case"PT":i="pt-PT";break;case"UK":i="uk-UK";break;case"RU":i="ru-RU"}return i},[Ct,kt]=(0,u.useState)();(0,u.useEffect)((()=>{(async()=>{try{const e=await fetch(`${y||"https://app.twincreator.com"}/api/lexiconmap`);return await e.json()}catch(e){console.error(e)}})().then((e=>{kt(e)}))}),[]);const Tt=e=>{if(!C)return;if(Ft(),c)return;if(Oe)return void(Pe&&Dt());nJ&&nJ.pause();let t=window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome"),n=/iPad|iPhone|iPod/.test(navigator.userAgent);if("interrupted"===rJ.state)return void rJ.resume().then((()=>Tt(e)));if(n&&t&&(rJ.suspend(),Be))try{tJ&&(tJ.close(),tJ=null),nJ&&(nJ.pause(),nJ.close()),rJ&&rJ.destination.disconnect()}catch(e){console.error("stopAudio error: ",e)}if("closed"===rJ.state){rJ=new ra;let e=rJ.createBuffer(1,1e4,22050),t=rJ.createBufferSource();t.buffer=e,t.connect(rJ.destination)}else if("suspended"===rJ.state){It(),rJ=new ra;let e=rJ.createBuffer(1,1e4,22050),t=rJ.createBufferSource();t.buffer=e,t.connect(rJ.destination)}if(!tJ){nJ=new _d.SpeakerAudioDestination;let e=Id.fromSpeakerOutput(nJ);tJ=new Vd.SpeechSynthesizer(eJ,e)}const r=rJ.createBufferSource();nJ.onAudioEnd=()=>{je(!1),r.disconnect(),Vt()},je(!0),tJ.speakSsmlAsync(`<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xmlns:emo="http://www.w3.org/2009/10/emotionml" xml:lang="${Et(he)}"><voice name="${At(he)}"><s>${((e,t)=>{var n;if(!Ct)return e;const r={...null!==(n=Ct.common)&&void 0!==n?n:{},...(null==_?void 0:_.id)&&Ct[_.id]?Ct[_.id]:{}},i=Object.keys(r).map((e=>{var n;return{word:e,phoneme:null!==(n=r[e][t])&&void 0!==n?n:r[e].default}}));return i.reduce(((e,{word:t,phoneme:n})=>e.replace(new RegExp(t,"gi"),`<phoneme alphabet="ipa" ph="${n}">${t}</phoneme>`)),e)})(e,he.toLowerCase())}</s></voice></speak>`,(i=>{if(i)try{rJ.decodeAudioData(i.audioData,(function(e){r.buffer=e,r.connect(rJ.destination),(et.length<1||t&&n)&&r.start(0)})),rJ.onstatechange=()=>{"suspended"===rJ.state||"closed"===rJ.state?r.disconnect():"interrupted"===rJ.state&&rJ.resume()},rJ.resume(),tJ&&(tJ.close(),tJ=null)}catch(t){console.error("speak error: ",t),window.speechSynthesis.speak(new SpeechSynthesisUtterance(e)),je(!1),tJ&&(tJ.close(),tJ=null)}else rJ.resume(),je(!1)}),(t=>{console.error("speak:",t),window.speechSynthesis.speak(new SpeechSynthesisUtterance(e)),je(!1)})),we(!1)},It=()=>{je(!1);try{tJ&&(tJ.close(),tJ=null),rJ&&rJ.close(),nJ&&(nJ.pause(),nJ.close())}catch(e){console.error("stopAudio error: ",e)}};(0,u.useEffect)((()=>{let e=document.querySelector("#chat-fieldset textarea");e&&e.focus()}),[null==ft?void 0:ft.emission]);const[Ot,Rt]=(0,u.useState)(""),Pt=()=>Rt(""),[Nt,Lt]=(0,u.useState)(null),Dt=()=>{let e=setTimeout((async()=>{Ut();const e=Bm(Ot);e.length>0?(rt(e),Pt(),Xe("")):Ze&&St()}),1e3*Le);Lt(e)},Bt=()=>{Nt&&(clearTimeout(Nt),Lt(null))};(0,u.useEffect)((()=>{Bt(),Pe&&Dt(),St()}),[Ot]);const jt=()=>{if(C){Ut(),Rt("");try{navigator.mediaDevices.getUserMedia({audio:!0}).then((function(e){Ae(!0),eJ||(eJ=Cc.fromSubscription(C,"eastus"),eJ.speechRecognitionLanguage=Et(he),eJ.speechSynthesisLanguage=Et(he),eJ.speechSynthesisVoiceName=At(he));const t=Id.fromDefaultMicrophoneInput();$Y=new Pd.SpeechRecognizer(eJ,t),$e(!0),$Y.recognized=(e,t)=>{if(t.result.text)if(t.result.reason===Pl.RecognizedSpeech){let e=t.result.text;if(Rt(e||""),(null==e?void 0:e.length)>0){const t=Bm(e);t.length>0&&Xe(t)}}else t.result.reason===Pl.NoMatch&&console.debug("NOMATCH: Speech could not be recognized.")},$Y.canceled=(e,t)=>{t.reason===ol.Error&&(console.debug(`"CANCELED: ErrorCode=${t.errorCode}`),console.debug(`"CANCELED: ErrorDetails=${t.errorDetails}`),console.debug("CANCELED: Did you set the speech resource key and region values?")),Ft()},$Y.sessionStopped=(e,t)=>{Ft()},$Y.startContinuousRecognitionAsync()})).catch(console.error)}catch(e){console.error(e)}}},Ft=()=>{$Y&&($Y.stopContinuousRecognitionAsync(),$Y.close(),$Y=null),$e(!1)},Ut=()=>{Ae(!1),Ft(),Bt()};(0,u.useEffect)((()=>()=>Ut()),[]),(0,u.useEffect)((()=>{"Z0"===(null==ft?void 0:ft.state)&&Ut()}),[null==ft?void 0:ft.state]);const[zt,Ht]=(0,u.useState)(!1),Vt=(0,u.useCallback)((e=>{Be&&tJ&&(tJ.close(),tJ=null),!Pe||!_e&&zt||(Ht(!0),jt())}),[Pe,_e]);(0,u.useEffect)((()=>{et.length>1&&!Be&&Pe&&(_e||!zt)?jt():Be&&Ze&&Ft()}),[Be]),(0,u.useEffect)((()=>(document.addEventListener("endSpeakStartListen",Vt),()=>{document.removeEventListener("endSpeakStartListen",Vt)})),[Vt]),(0,u.useEffect)((()=>{Ze&&(Ut(),Pt(),Xe(""),jt())}),[fe]);const[Wt,Gt]=(0,u.useState)("keypress");(0,u.useEffect)((()=>{const e=NY("sendOnEnter","keypress");Gt(e)}),[]),(0,u.useEffect)((()=>{LY("sendOnEnter",Wt)}),[Wt]);const[qt,Kt]=(0,u.useState)(),Yt=null==me?void 0:me.globalBackground,Jt=Yt?`url(${Yt})`:null,Qt=i?{"--memori-chat-bubble-bg":"#fff",...me&&!a?{"--memori-text-color":null!==(j=me.textColor)&&void 0!==j?j:"#000"}:{},...(null==me?void 0:me.buttonBgColor)?{"--memori-button-bg":me.buttonBgColor,"--memori-primary":me.buttonBgColor}:{},...(null==me?void 0:me.buttonTextColor)?{"--memori-button-text":me.buttonTextColor}:{},...(null==me?void 0:me.blurBackground)?{"--memori-blur-background":"5px"}:{"--memori-blur-background":"0px"},...(null==me?void 0:me.innerBgColor)?{"--memori-inner-bg":`rgba(${"dark"===me.innerBgColor?"0, 0, 0":"255, 255, 255"}, ${null!==(F=me.innerBgAlpha)&&void 0!==F?F:.4})`,"--memori-inner-content-pad":"1.5rem","--memori-nav-bg-image":"none","--memori-nav-bg":`rgba(${"dark"===me.innerBgColor?"0, 0, 0":"255, 255, 255"}, ${null!==(U=null==me?void 0:me.innerBgAlpha)&&void 0!==U?U:.4})`}:{"--memori-inner-content-pad":"0px"}}:{},Xt=`\n ${c?"#preview":":root"}, .memori-widget {\n ${Object.entries(Qt).map((([e,t])=>`${e}: ${t};`)).join("\n")}\n }\n `,Zt=void 0===(null==me?void 0:me.showAIicon)||(null==me?void 0:me.showAIicon),[$t,en]=(0,u.useState)(!1);(0,u.useEffect)((()=>{(window.innerWidth>=768&&"FULLPAGE"===xe||"FULLPAGE"!==xe)&&en(!0)}),[]);const[tn,nn]=(0,u.useState)();(0,u.useEffect)((()=>{e.engineMemoriID&&(async e=>{let t,n;try{const{contentQualityIndex:r,answerQualityIndex:i,unansweredQuestions:o,...a}=await oe(e);0===a.resultCode&&(t=r,n=o)}catch(e){let t=e;console.error("[APPCONTEXT/QUERYGAMIFICATIONPOINTS]",t)}return{points:null!=t?t:0,unansweredQuestions:null!=n?n:0}})(e.engineMemoriID).then((e=>{nn(VY(e.points))})).catch(console.error)}),[e.engineMemoriID]),(0,u.useEffect)((()=>{if(null==me?void 0:me.seoTitle){let e=document.createElement("meta");e.setAttribute("property","og:title"),e.setAttribute("content",me.seoTitle),document.head.append(e)}if(null==me?void 0:me.seoDescription){let e=document.createElement("meta");e.setAttribute("property","og:description"),e.setAttribute("content",me.seoDescription),document.head.append(e)}if(null==me?void 0:me.seoUrl){let e=document.createElement("meta");e.setAttribute("property","og:url"),e.setAttribute("content",me.seoUrl),document.head.append(e)}let t=S||e.avatarURL;if((null==me?void 0:me.seoImageShowAvatar)&&t){let e=document.createElement("meta");e.setAttribute("property","og:image"),e.setAttribute("content",t),document.head.append(e)}}),[me,e.avatarURL,S]);const rn=async t=>{const n=(null==t?void 0:t.sessionID)||ut,r=(null==t?void 0:t.dialogState)||ft;ce(!0);let i=document.getElementById("memori-audio"),o=window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome");i&&o&&(i.muted=!1,i.play().catch((e=>{console.error("error playing intro audio",e)})));let a=NY("birthDate",void 0),s=at||a||void 0;if(!n&&"PUBLIC"!==e.privacyType&&!e.secretToken&&!ze&&!Ve||!n&&ue)return qe("password"),void ce(!1);if(n||!ot||s){if(!n){ce(!1),de(!1);const t=await mt({memoriID:e.engineMemoriID,password:v||e.secretToken,tag:null==A?void 0:A.tag,pin:null==A?void 0:A.pin,initialContextVars:w,initialQuestion:x,birthDate:s});return void((null==t?void 0:t.dialogState)?(tt([]),it(t.dialogState,he).then((e=>{e.emission&&Tt(e.emission)})).finally((()=>{Me(!0)}))):await rn(t||void 0))}if(M){const{currentState:t,...r}=await ie(n);if(0!==r.resultCode||!t)return console.debug("session expired, opening new session"),de(!0),dt(void 0),ce(!1),void await rn();if(tt([]),ae&&e.giverTag&&(null==ft?void 0:ft.currentTag)!==e.giverTag)try{console.debug("change tag #0"),await vt(e.engineMemoriID,n,"-");const t=await vt(e.engineMemoriID,n,e.giverTag,e.giverPIN);if(!t||0!==t.resultCode)throw console.error("session #1",t),new Error("No session");it(t.currentState,he).then((e=>{e.emission&&Tt(e.emission)})).finally((()=>{Me(!0)}))}catch(t){console.error("session #2",t),gt(!0,null==e?void 0:e.secretToken,void 0,null==e?void 0:e.giverTag,null==e?void 0:e.giverPIN,w,x,s).then((()=>{Me(!0)}))}else if(!ae&&A&&(null==ft?void 0:ft.currentTag)!==A.tag)try{console.debug("change tag #3"),await vt(e.engineMemoriID,n,"-");const t=await vt(e.engineMemoriID,n,A.tag,A.pin);if(!t||0!==t.resultCode)throw console.error("session #4",t),new Error("No session");it(t.currentState,he).then((e=>{e.emission&&Tt(e.emission)})).finally((()=>{Me(!0)}))}catch(t){console.error("session #5",t),gt(!0,null==e?void 0:e.secretToken,void 0,A.tag,A.pin,w,x,s).then((()=>{Me(!0)}))}else if(ae||A||(null==ft?void 0:ft.currentTag)===Ag)it(t,he).then((e=>{e.emission&&Tt(e.emission)})).finally((()=>{Me(!0)}));else try{console.debug("change tag #6"),await vt(e.engineMemoriID,n,"-");const t=await vt(e.engineMemoriID,n,Ag);if(!t||0!==t.resultCode)throw console.error("session #7",t),new Error("No session");it(t.currentState,he).then((e=>{e.emission&&Tt(e.emission)})).finally((()=>{Me(!0)}))}catch(t){console.error("session #8",t),gt(!0,null==e?void 0:e.secretToken,void 0,void 0,void 0,w,x,s).then((()=>{Me(!0)}))}}else tt([]),it(r,he).then((e=>{e.emission&&Tt(e.emission)})).finally((()=>{Me(!0)}))}else ct(!0),ce(!1)},[on,an]=(0,u.useState)(E);(0,u.useEffect)((()=>{const t=document.querySelector(`memori-client[memoriname="${e.name}"]`)||document.querySelector(`memori-client[memoriid="${e.memoriID}"]`)||document.querySelector("memori-client");if(!t)return;const n=new MutationObserver(((e,t)=>{var n,r,i;for(const t of e)"attributes"===t.type&&"authtoken"===(null===(n=t.attributeName)||void 0===n?void 0:n.toLowerCase())&&("MEMORI-CLIENT"===t.target.nodeName?an(t.target.getAttribute("authtoken")||void 0):an((null===(i=null===(r=t.target)||void 0===r?void 0:r.parentElement)||void 0===i?void 0:i.getAttribute("authtoken"))||void 0))}));return n.observe(t,{attributes:!0,childList:!1,subtree:!1}),()=>{n.disconnect()}}),[]);const sn=(0,s.jsx)(QF,{memori:e,history:et,showShare:l,position:Ke,setShowPositionDrawer:Ce,setShowSettingsDrawer:Ie,showSpeaker:!!C,speakerMuted:Oe,setSpeakerMuted:e=>{if(Re(e),e)It();else{rJ=new ra;let e=rJ.createBuffer(1,1e4,22050),t=rJ.createBufferSource();t.buffer=e,t.connect(rJ.destination)}},showSettings:m,hasUserActivatedSpeak:Se,showReload:"TOTEM"===xe}),ln=(0,s.jsx)(Gj,{memori:e,integration:i,integrationConfig:me,tenant:_,instruct:ae,avatar3dVisible:$t,setAvatar3dVisible:en,hasUserActivatedSpeak:Se,isPlayingAudio:Be,loading:be,baseUrl:y,apiUrl:b}),cn=(0,s.jsx)(ew,{memori:e,tenant:_,gamificationLevel:tn,language:fe,userLang:he,setUserLang:pe,baseUrl:y,apiUrl:b,position:Ke,openPositionDrawer:()=>Ce(!0),integrationConfig:me,instruct:ae,sessionId:ut,clickedStart:le,onClickStart:rn,initializeTTS:()=>{if(!C)return;eJ=Cc.fromSubscription(C,"eastus"),eJ.speechSynthesisLanguage=Et(he),eJ.speechSynthesisVoiceName=At(he),eJ.speechRecognitionLanguage=Et(he),Dm()&&(eJ.speechSynthesisOutputFormat=hc.Audio16Khz32KBitRateMonoMp3),rJ=new ra;let e=rJ.createBuffer(1,1e4,22050),t=rJ.createBufferSource();t.buffer=e,t.connect(rJ.destination),nJ=new _d.SpeakerAudioDestination;let n=Id.fromSpeakerOutput(nJ);tJ=new Vd.SpeechSynthesizer(eJ,n)}}),un=ut?(0,s.jsx)(Ib,{memori:e,sessionID:ut,tenant:_,translateTo:ge&&he.toUpperCase()!==(null===(q=null!==(G=null!==(V=null===(H=null===(z=e.culture)||void 0===z?void 0:z.split("-"))||void 0===H?void 0:H[0])&&void 0!==V?V:J.language)&&void 0!==G?G:"IT")||void 0===q?void 0:q.toUpperCase())?he:void 0,baseUrl:y,apiUrl:b,memoriTyping:be,history:"TOTEM"===o?et.slice(-2):et,authToken:on,dialogState:ft,setDialogState:pt,pushMessage:nt,simulateUserPrompt:(e,t)=>{Ft(),It(),rt(e,void 0,void 0,!1,t)},showDates:h,showContextPerLine:p,showAIicon:Zt,client:Z,selectReceiverTag:async t=>{var n;if(ut)try{const{currentState:r,...i}=await re(ut,t);if(0===i.resultCode)if(nt({text:t,fromUser:!0}),"X4"===r.state&&e.giverTag){const{currentState:t,...n}=await Z.postTagChangedEvent(ut,e.giverTag);0===n.resultCode?(pt(t),t.emission&&nt({text:t.emission,media:t.media,fromUser:!1})):(console.error(n),Qd.error(Y(ZF(n.resultCode))))}else pt(r),r.emission&&nt({text:r.emission,media:r.media,fromUser:!1});else console.error(i,t,null===(n=null==ft?void 0:ft.knownTags)||void 0===n?void 0:n[t]),Qd.error(Y(ZF(i.resultCode)))}catch(e){let t=e;console.error(t),Qd.error(t.message)}},preview:c,sendOnEnter:Wt,setSendOnEnter:Gt,attachmentsMenuOpen:qt,setAttachmentsMenuOpen:Kt,instruct:ae,showInputs:f,showMicrophone:!!C,userMessage:Qe,onChangeUserMessage:e=>{if(!e||"\n"===e||""===e.trim())return Xe(""),void St();Xe(e),xt()},sendMessage:e=>{It(),Ft(),rt(e),Xe(""),Pt()},stopListening:Ut,startListening:jt,stopAudio:It,resetTranscript:Pt,listening:Ze,isPlayingAudio:Be}):null,dn=i&&Jt?(0,s.jsx)("div",{className:"memori--global-background",children:(0,s.jsx)("div",{className:"memori--global-background-image",style:{backgroundImage:Jt}})}):(0,s.jsx)("div",{className:"memori--global-background no-background-image"}),fn=i?(0,s.jsx)("style",{dangerouslySetInnerHTML:{__html:Xt}}):null,hn=(0,s.jsx)(qj,{canInstruct:!!e.giverTag,instruct:ae,onChangeMode:e=>{se("instruct"===e),Me(!1),ce(!1)}}),pn=(0,s.jsx)(IY,{tenant:_,userLang:he}),mn="TOTEM"===xe?RY:OY;return(0,s.jsxs)("div",{className:r(Jd)("memori","memori-widget",`memori-layout-${o.toLowerCase()}`,`memori-controls-${Fe.toLowerCase()}`,{"memori--preview":c,"memori--embed":d,"memori--with-integration":i,"memori--with-speechkey":!!C,"memori--active":Se}),"data-memori-name":null==e?void 0:e.name,"data-memori-id":null==e?void 0:e.engineMemoriID,"data-memori-secondary-id":null==e?void 0:e.memoriID,"data-memori-session-id":ut,"data-memori-integration":null==i?void 0:i.integrationID,"data-memori-engine-state":JSON.stringify({...ft,sessionID:ut}),style:{height:g},children:[(0,s.jsx)(mn,{header:sn,avatar:ln,chat:un,startPanel:cn,integrationStyle:fn,integrationBackground:dn,changeMode:hn,poweredBy:pn,sessionId:ut,hasUserActivatedSpeak:Se,showInstruct:a,loading:ve}),(0,s.jsx)("audio",{id:"memori-audio",style:{display:"none"},src:"https://app.twincreator.com/intro.mp3"}),Q&&(0,s.jsx)(Lm,{withModal:!0,pwdOrTokens:Ge,openModal:!!Ge,setPwdOrTokens:qe,showTokens:"SECRET"===e.privacyType,onFinish:async t=>{t.password&&He(t.password),t.tokens&&We(t.tokens),gt(!ut,t.password,t.tokens,ae?e.giverTag:void 0,ae?e.giverPIN:void 0,w,x,at).then((e=>{qe(null),rn(e||void 0)})).catch((()=>{qe(null),de(!0)}))},minimumNumberOfRecoveryTokens:null!==(K=null==e?void 0:e.minimumNumberOfRecoveryTokens)&&void 0!==K?K:1}),Q&&(0,s.jsx)(YY,{visible:lt,minAge:ot,onClose:t=>{t?(st(t),LY("birthDate",t),gt(!ut,null==e?void 0:e.secretToken,void 0,ae?e.giverTag:void 0,ae?e.giverPIN:void 0,w,x,t).then((e=>{ct(!1),rn(e||void 0)})).catch((()=>{ct(!1),de(!0)}))):(ct(!1),ce(!1))}}),ke&&(0,s.jsx)(ZY,{layout:xe,open:!!ke,onClose:()=>Ie(!1),continuousSpeech:Pe,continuousSpeechTimeout:Le,setContinuousSpeech:Ne,setContinuousSpeechTimeout:De,controlsPosition:Fe,setControlsPosition:Ue}),ut&&(0,s.jsx)(TY,{apiURL:b,visible:"link"===qt,onCancel:()=>Kt(void 0),onOk:async e=>{if(!ut)return;let t={mediumID:"",mimeType:"text/html",url:e.url,title:e.title};nt({text:Y("media.insertThisLink",{url:t.url,title:t.title}),fromUser:!0,media:[t]});try{const{currentState:e,...n}=await Z.postMediumSelectedEvent(ut,t);e&&0===n.resultCode?(pt(e),e.emission&&(nt({text:e.emission,media:e.media,fromUser:!1}),Tt(e.emission))):(console.error(n,e,t),Qd.error(Y(ZF(n.resultCode),{ns:"common"})))}catch(e){let t=e;console.error(t),Qd.error(t.message)}Kt(void 0)}}),on&&ut&&(null==_?void 0:_.id)&&(0,s.jsx)(kY,{apiURL:b,visible:"media"===qt,authToken:on,tenantID:null==_?void 0:_.id,sessionID:ut,uploadAssetURL:Z.backend.getUploadAssetURL(on,e.memoriID),deleteAsset:Z.backend.deleteAsset,onCancel:()=>Kt(void 0),onOk:async e=>{if(!ut)return;let t={mediumID:"",mimeType:e.mimeType,url:e.assetURL,title:e.title||e.assetID};nt({text:Y("media.insertThisMediaMsg"),fromUser:!0,media:[t]});try{const{currentState:e,...n}=await Z.postMediumSelectedEvent(ut,t);e&&0===n.resultCode?(pt(e),e.emission&&(nt({text:e.emission,media:e.media,fromUser:!1}),Tt(e.emission))):(console.error(n,e,t),Qd.error(Y(ZF(n.resultCode),{ns:"common"})))}catch(e){let t=e;console.error(t),Qd.error(t.message)}Kt(void 0)}})]})};function oJ(e){return oJ="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},oJ(e)}function aJ(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function sJ(e,t){if("object"!==oJ(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==oJ(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function lJ(e){var t=sJ(e,"string");return"symbol"===oJ(t)?t:String(t)}function cJ(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,lJ(r.key),r)}}function uJ(e,t,n){return t&&cJ(e.prototype,t),n&&cJ(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function dJ(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function fJ(e,t){return fJ=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},fJ(e,t)}function hJ(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&fJ(e,t)}function pJ(e,t){if(t&&("object"===oJ(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return dJ(e)}function mJ(e){return mJ=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},mJ(e)}function gJ(e,t,n){return(t=lJ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vJ(e){if(Array.isArray(e))return e}function yJ(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function bJ(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function wJ(e,t){if(e){if("string"==typeof e)return bJ(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bJ(e,t):void 0}}function xJ(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function SJ(e){return vJ(e)||yJ(e)||wJ(e)||xJ()}function MJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _J(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?MJ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):MJ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var AJ={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},EJ=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};aJ(this,e),this.init(t,n)}return uJ(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||AJ,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,n,r){return r&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(n).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,_J(_J({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}(),CJ=new EJ,kJ=function(){function e(){aJ(this,e),this.observers={}}return uJ(e,[{key:"on",value:function(e,t){var n=this;return e.split(" ").forEach((function(e){n.observers[e]=n.observers[e]||[],n.observers[e].push(t)})),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter((function(e){return e!==t})):delete this.observers[e])}},{key:"emit",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(this.observers[e]){var i=[].concat(this.observers[e]);i.forEach((function(e){e.apply(void 0,n)}))}if(this.observers["*"]){var o=[].concat(this.observers["*"]);o.forEach((function(t){t.apply(t,[e].concat(n))}))}}}]),e}();function TJ(){var e,t,n=new Promise((function(n,r){e=n,t=r}));return n.resolve=e,n.reject=t,n}function IJ(e){return null==e?"":""+e}function OJ(e,t,n){e.forEach((function(e){t[e]&&(n[e]=t[e])}))}function RJ(e,t,n){function r(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function i(){return!e||"string"==typeof e}for(var o="string"!=typeof t?[].concat(t):t.split(".");o.length>1;){if(i())return{};var a=r(o.shift());!e[a]&&n&&(e[a]=new n),e=Object.prototype.hasOwnProperty.call(e,a)?e[a]:{}}return i()?{}:{obj:e,k:r(o.shift())}}function PJ(e,t,n){var r=RJ(e,t,Object);r.obj[r.k]=n}function NJ(e,t){var n=RJ(e,t),r=n.obj,i=n.k;if(r)return r[i]}function LJ(e,t,n){var r=NJ(e,n);return void 0!==r?r:NJ(t,n)}function DJ(e,t,n){for(var r in t)"__proto__"!==r&&"constructor"!==r&&(r in e?"string"==typeof e[r]||e[r]instanceof String||"string"==typeof t[r]||t[r]instanceof String?n&&(e[r]=t[r]):DJ(e[r],t[r],n):e[r]=t[r]);return e}function BJ(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var jJ={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function FJ(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return jJ[e]})):e}var UJ="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,zJ=[" ",",","?","!",";"];function HJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function VJ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?HJ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):HJ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function WJ(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mJ(e);if(t){var i=mJ(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return pJ(this,n)}}function GJ(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var r=t.split(n),i=e,o=0;o<r.length;++o){if(!i)return;if("string"==typeof i[r[o]]&&o+1<r.length)return;if(void 0===i[r[o]]){for(var a=2,s=r.slice(o,o+a).join(n),l=i[s];void 0===l&&r.length>o+a;)a++,l=i[s=r.slice(o,o+a).join(n)];if(void 0===l)return;if(null===l)return null;if(t.endsWith(s)){if("string"==typeof l)return l;if(s&&"string"==typeof l[s])return l[s]}var c=r.slice(o+a).join(n);return c?GJ(l,c,n):void 0}i=i[r[o]]}return i}}var qJ=function(e){hJ(n,e);var t=WJ(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return aJ(this,n),r=t.call(this),UJ&&kJ.call(dJ(r)),r.data=e||{},r.options=i,void 0===r.options.keySeparator&&(r.options.keySeparator="."),void 0===r.options.ignoreJSONStructure&&(r.options.ignoreJSONStructure=!0),r}return uJ(n,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,o=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure,a=[e,t];n&&"string"!=typeof n&&(a=a.concat(n)),n&&"string"==typeof n&&(a=a.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(a=e.split("."));var s=NJ(this.data,a);return s||!o||"string"!=typeof n?s:GJ(this.data&&this.data[e]&&this.data[e][t],n,i)}},{key:"addResource",value:function(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},o=this.options.keySeparator;void 0===o&&(o=".");var a=[e,t];n&&(a=a.concat(o?n.split(o):n)),e.indexOf(".")>-1&&(r=t,t=(a=e.split("."))[1]),this.addNamespaces(t),PJ(this.data,a,r),i.silent||this.emit("added",e,t,n,r)}},{key:"addResources",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var i in n)"string"!=typeof n[i]&&"[object Array]"!==Object.prototype.toString.apply(n[i])||this.addResource(e,t,i,n[i],{silent:!0});r.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},a=[e,t];e.indexOf(".")>-1&&(r=n,n=t,t=(a=e.split("."))[1]),this.addNamespaces(t);var s=NJ(this.data,a)||{};r?DJ(s,n,i):s=VJ(VJ({},s),n),PJ(this.data,a,s),o.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?VJ(VJ({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((function(e){return t[e]&&Object.keys(t[e]).length>0}))}},{key:"toJSON",value:function(){return this.data}}]),n}(kJ),KJ={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,r,i){var o=this;return e.forEach((function(e){o.processors[e]&&(t=o.processors[e].process(t,n,r,i))})),t}};function YJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function JJ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?YJ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YJ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function QJ(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mJ(e);if(t){var i=mJ(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return pJ(this,n)}}var XJ={},ZJ=function(e){hJ(n,e);var t=QJ(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return aJ(this,n),r=t.call(this),UJ&&kJ.call(dJ(r)),OJ(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,dJ(r)),r.options=i,void 0===r.options.keySeparator&&(r.options.keySeparator="."),r.logger=CJ.create("translator"),r}return uJ(n,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");var r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=t.ns||this.options.defaultNS||[],o=n&&e.indexOf(n)>-1,a=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||function(e,t,n){t=t||"",n=n||"";var r=zJ.filter((function(e){return t.indexOf(e)<0&&n.indexOf(e)<0}));if(0===r.length)return!0;var i=new RegExp("(".concat(r.map((function(e){return"?"===e?"\\?":e})).join("|"),")")),o=!i.test(e);if(!o){var a=e.indexOf(n);a>0&&!i.test(e.substring(0,a))&&(o=!0)}return o}(e,n,r));if(o&&!a){var s=e.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:e,namespaces:i};var l=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(l[0])>-1)&&(i=l.shift()),e=l.join(r)}return"string"==typeof i&&(i=[i]),{key:e,namespaces:i}}},{key:"translate",value:function(e,t,r){var i=this;if("object"!==oJ(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var o=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,a=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,s=this.extractFromKey(e[e.length-1],t),l=s.key,c=s.namespaces,u=c[c.length-1],d=t.lng||this.language,f=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&"cimode"===d.toLowerCase()){if(f){var h=t.nsSeparator||this.options.nsSeparator;return o?(p.res="".concat(u).concat(h).concat(l),p):"".concat(u).concat(h).concat(l)}return o?(p.res=l,p):l}var p=this.resolve(e,t),m=p&&p.res,g=p&&p.usedKey||l,v=p&&p.exactUsedKey||l,y=Object.prototype.toString.apply(m),b=["[object Number]","[object Function]","[object RegExp]"],w=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,x=!this.i18nFormat||this.i18nFormat.handleAsObject,S="string"!=typeof m&&"boolean"!=typeof m&&"number"!=typeof m;if(x&&m&&S&&b.indexOf(y)<0&&("string"!=typeof w||"[object Array]"!==y)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var M=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,m,JJ(JJ({},t),{},{ns:c})):"key '".concat(l," (").concat(this.language,")' returned an object instead of string.");return o?(p.res=M,p):M}if(a){var _="[object Array]"===y,A=_?[]:{},E=_?v:g;for(var C in m)if(Object.prototype.hasOwnProperty.call(m,C)){var k="".concat(E).concat(a).concat(C);A[C]=this.translate(k,JJ(JJ({},t),{joinArrays:!1,ns:c})),A[C]===k&&(A[C]=m[C])}m=A}}else if(x&&"string"==typeof w&&"[object Array]"===y)(m=m.join(w))&&(m=this.extendTranslation(m,e,t,r));else{var T=!1,I=!1,O=void 0!==t.count&&"string"!=typeof t.count,R=n.hasDefaultValue(t),P=O?this.pluralResolver.getSuffix(d,t.count,t):"",N=t["defaultValue".concat(P)]||t.defaultValue;!this.isValidLookup(m)&&R&&(T=!0,m=N),this.isValidLookup(m)||(I=!0,m=l);var L=t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey,D=L&&I?void 0:m,B=R&&N!==m&&this.options.updateMissing;if(I||T||B){if(this.logger.log(B?"updateKey":"missingKey",d,u,l,B?N:m),a){var j=this.resolve(l,JJ(JJ({},t),{},{keySeparator:!1}));j&&j.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var F=[],U=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&U&&U[0])for(var z=0;z<U.length;z++)F.push(U[z]);else"all"===this.options.saveMissingTo?F=this.languageUtils.toResolveHierarchy(t.lng||this.language):F.push(t.lng||this.language);var H=function(e,n,r){var o=R&&r!==m?r:D;i.options.missingKeyHandler?i.options.missingKeyHandler(e,u,n,o,B,t):i.backendConnector&&i.backendConnector.saveMissing&&i.backendConnector.saveMissing(e,u,n,o,B,t),i.emit("missingKey",e,u,n,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&O?F.forEach((function(e){i.pluralResolver.getSuffixes(e,t).forEach((function(n){H([e],l+n,t["defaultValue".concat(n)]||N)}))})):H(F,l,N))}m=this.extendTranslation(m,e,t,p,r),I&&m===l&&this.options.appendNamespaceToMissingKey&&(m="".concat(u,":").concat(l)),(I||T)&&this.options.parseMissingKeyHandler&&(m="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(u,":").concat(l):l,T?m:void 0):this.options.parseMissingKeyHandler(m))}return o?(p.res=m,p):m}},{key:"extendTranslation",value:function(e,t,n,r,i){var o=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,JJ(JJ({},this.options.interpolation.defaultVariables),n),r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(JJ(JJ({},n),{interpolation:JJ(JJ({},this.options.interpolation),n.interpolation)}));var a,s="string"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(s){var l=e.match(this.interpolator.nestingRegexp);a=l&&l.length}var c=n.replace&&"string"!=typeof n.replace?n.replace:n;if(this.options.interpolation.defaultVariables&&(c=JJ(JJ({},this.options.interpolation.defaultVariables),c)),e=this.interpolator.interpolate(e,c,n.lng||this.language,n),s){var u=e.match(this.interpolator.nestingRegexp);a<(u&&u.length)&&(n.nest=!1)}!1!==n.nest&&(e=this.interpolator.nest(e,(function(){for(var e=arguments.length,r=new Array(e),a=0;a<e;a++)r[a]=arguments[a];return i&&i[0]===r[0]&&!n.context?(o.logger.warn("It seems you are nesting recursively key: ".concat(r[0]," in key: ").concat(t[0])),null):o.translate.apply(o,r.concat([t]))}),n)),n.interpolation&&this.interpolator.reset()}var d=n.postProcess||this.options.postProcess,f="string"==typeof d?[d]:d;return null!=e&&f&&f.length&&!1!==n.applyPostProcessor&&(e=KJ.handle(f,e,t,this.options&&this.options.postProcessPassResolved?JJ({i18nResolved:r},n):n,this)),e}},{key:"resolve",value:function(e){var t,n,r,i,o,a=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!a.isValidLookup(t)){var l=a.extractFromKey(e,s),c=l.key;n=c;var u=l.namespaces;a.options.fallbackNS&&(u=u.concat(a.options.fallbackNS));var d=void 0!==s.count&&"string"!=typeof s.count,f=d&&!s.ordinal&&0===s.count&&a.pluralResolver.shouldUseIntlApi(),h=void 0!==s.context&&("string"==typeof s.context||"number"==typeof s.context)&&""!==s.context,p=s.lngs?s.lngs:a.languageUtils.toResolveHierarchy(s.lng||a.language,s.fallbackLng);u.forEach((function(e){a.isValidLookup(t)||(o=e,!XJ["".concat(p[0],"-").concat(e)]&&a.utils&&a.utils.hasLoadedNamespace&&!a.utils.hasLoadedNamespace(o)&&(XJ["".concat(p[0],"-").concat(e)]=!0,a.logger.warn('key "'.concat(n,'" for languages "').concat(p.join(", "),'" won\'t get resolved as namespace "').concat(o,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),p.forEach((function(n){if(!a.isValidLookup(t)){i=n;var o,l=[c];if(a.i18nFormat&&a.i18nFormat.addLookupKeys)a.i18nFormat.addLookupKeys(l,c,n,e,s);else{var u;d&&(u=a.pluralResolver.getSuffix(n,s.count,s));var p="".concat(a.options.pluralSeparator,"zero");if(d&&(l.push(c+u),f&&l.push(c+p)),h){var m="".concat(c).concat(a.options.contextSeparator).concat(s.context);l.push(m),d&&(l.push(m+u),f&&l.push(m+p))}}for(;o=l.pop();)a.isValidLookup(t)||(r=o,t=a.getResource(n,e,o,s))}})))}))}})),{res:t,usedKey:n,exactUsedKey:r,usedLng:i,usedNS:o}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,t.length)&&void 0!==e[n])return!0;return!1}}]),n}(kJ);function $J(e){return e.charAt(0).toUpperCase()+e.slice(1)}var eQ=function(){function e(t){aJ(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=CJ.create("languageUtils")}return uJ(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map((function(e){return e.toLowerCase()})):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=$J(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=$J(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=$J(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,n=this;return e?(e.forEach((function(e){if(!t){var r=n.formatLanguageCode(e);n.options.supportedLngs&&!n.isSupportedCode(r)||(t=r)}})),!t&&this.options.supportedLngs&&e.forEach((function(e){if(!t){var r=n.getLanguagePartFromCode(e);if(n.isSupportedCode(r))return t=r;t=n.options.supportedLngs.find((function(e){if(0===e.indexOf(r))return e}))}})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,r=this.getFallbackCodes(t||this.options.fallbackLng||[],e),i=[],o=function(e){e&&(n.isSupportedCode(e)?i.push(e):n.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):"string"==typeof e&&o(this.formatLanguageCode(e)),r.forEach((function(e){i.indexOf(e)<0&&o(n.formatLanguageCode(e))})),i}}]),e}(),tQ=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],nQ={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},rQ=["v1","v2","v3"],iQ={zero:0,one:1,two:2,few:3,many:4,other:5};function oQ(){var e={};return tQ.forEach((function(t){t.lngs.forEach((function(n){e[n]={numbers:t.nr,plurals:nQ[t.fc]}}))})),e}var aQ=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};aJ(this,e),this.languageUtils=t,this.options=n,this.logger=CJ.create("pluralResolver"),this.options.compatibilityJSON&&"v4"!==this.options.compatibilityJSON||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=oQ()}return uJ(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map((function(e){return"".concat(t).concat(e)}))}},{key:"getSuffixes",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.getRule(e,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort((function(e,t){return iQ[e]-iQ[t]})).map((function(e){return"".concat(t.options.prepend).concat(e)})):r.numbers.map((function(r){return t.getSuffix(e,r,n)})):[]}},{key:"getSuffix",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.getRule(e,n);return r?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(r.select(t)):this.getSuffixRetroCompatible(r,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var n=this,r=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),i=e.numbers[r];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===i?i="plural":1===i&&(i=""));var o=function(){return n.options.prepend&&i.toString()?n.options.prepend+i.toString():i.toString()};return"v1"===this.options.compatibilityJSON?1===i?"":"number"==typeof i?"_plural_".concat(i.toString()):o():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?o():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}},{key:"shouldUseIntlApi",value:function(){return!rQ.includes(this.options.compatibilityJSON)}}]),e}();function sQ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function lQ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?sQ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sQ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var cQ=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};aJ(this,e),this.logger=CJ.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return uJ(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:FJ,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?BJ(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?BJ(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?BJ(t.nestingPrefix):t.nestingPrefixEscaped||BJ("$t("),this.nestingSuffix=t.nestingSuffix?BJ(t.nestingSuffix):t.nestingSuffixEscaped||BJ(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,r){var i,o,a,s=this,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function c(e){return e.replace(/\$/g,"$$$$")}var u=function(e){if(e.indexOf(s.formatSeparator)<0){var i=LJ(t,l,e);return s.alwaysFormat?s.format(i,void 0,n,lQ(lQ(lQ({},r),t),{},{interpolationkey:e})):i}var o=e.split(s.formatSeparator),a=o.shift().trim(),c=o.join(s.formatSeparator).trim();return s.format(LJ(t,l,a),c,n,lQ(lQ(lQ({},r),t),{},{interpolationkey:a}))};this.resetRegExp();var d=r&&r.missingInterpolationHandler||this.options.missingInterpolationHandler,f=r&&r.interpolation&&void 0!==r.interpolation.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return c(e)}},{regex:this.regexp,safeValue:function(e){return s.escapeValue?c(s.escape(e)):c(e)}}].forEach((function(t){for(a=0;i=t.regex.exec(e);){var n=i[1].trim();if(void 0===(o=u(n)))if("function"==typeof d){var l=d(e,i,r);o="string"==typeof l?l:""}else if(r&&r.hasOwnProperty(n))o="";else{if(f){o=i[0];continue}s.logger.warn("missed to pass in variable ".concat(n," for interpolating ").concat(e)),o=""}else"string"==typeof o||s.useRawValueToEscape||(o=IJ(o));var c=t.safeValue(o);if(e=e.replace(i[0],c),f?(t.regex.lastIndex+=o.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,++a>=s.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var n,r,i=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=lQ({},o);function s(e,t){var n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;var r=e.split(new RegExp("".concat(n,"[ ]*{"))),i="{".concat(r[1]);e=r[0];var o=(i=this.interpolate(i,a)).match(/'/g),s=i.match(/"/g);(o&&o.length%2==0&&!s||s.length%2!=0)&&(i=i.replace(/'/g,'"'));try{a=JSON.parse(i),t&&(a=lQ(lQ({},t),a))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(n).concat(i)}return delete a.defaultValue,e}for(a.applyPostProcessor=!1,delete a.defaultValue;n=this.nestingRegexp.exec(e);){var l=[],c=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){var u=n[1].split(this.formatSeparator).map((function(e){return e.trim()}));n[1]=u.shift(),l=u,c=!0}if((r=t(s.call(this,n[1].trim(),a),a))&&n[0]===e&&"string"!=typeof r)return r;"string"!=typeof r&&(r=IJ(r)),r||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),r=""),c&&(r=l.reduce((function(e,t){return i.format(e,t,o.lng,lQ(lQ({},o),{},{interpolationkey:n[1].trim()}))}),r.trim())),e=e.replace(n[0],r),this.regexp.lastIndex=0}return e}}]),e}();function uQ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function dQ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?uQ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):uQ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function fQ(e){var t={};return function(n,r,i){var o=r+JSON.stringify(i),a=t[o];return a||(a=e(r,i),t[o]=a),a(n)}}var hQ=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};aJ(this,e),this.logger=CJ.create("formatter"),this.options=t,this.formats={number:fQ((function(e,t){var n=new Intl.NumberFormat(e,t);return function(e){return n.format(e)}})),currency:fQ((function(e,t){var n=new Intl.NumberFormat(e,dQ(dQ({},t),{},{style:"currency"}));return function(e){return n.format(e)}})),datetime:fQ((function(e,t){var n=new Intl.DateTimeFormat(e,dQ({},t));return function(e){return n.format(e)}})),relativetime:fQ((function(e,t){var n=new Intl.RelativeTimeFormat(e,dQ({},t));return function(e){return n.format(e,t.range||"day")}})),list:fQ((function(e,t){var n=new Intl.ListFormat(e,dQ({},t));return function(e){return n.format(e)}}))},this.init(t)}return uJ(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}},n=t.interpolation;this.formatSeparator=n.formatSeparator?n.formatSeparator:n.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=fQ(t)}},{key:"format",value:function(e,t,n,r){var i=this,o=t.split(this.formatSeparator).reduce((function(e,t){var o=function(e){var t=e.toLowerCase().trim(),n={};if(e.indexOf("(")>-1){var r=e.split("(");t=r[0].toLowerCase().trim();var i=r[1].substring(0,r[1].length-1);"currency"===t&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):"relativetime"===t&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach((function(e){if(e){var t=SJ(e.split(":")),r=t[0],i=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");n[r.trim()]||(n[r.trim()]=i),"false"===i&&(n[r.trim()]=!1),"true"===i&&(n[r.trim()]=!0),isNaN(i)||(n[r.trim()]=parseInt(i,10))}}))}return{formatName:t,formatOptions:n}}(t),a=o.formatName,s=o.formatOptions;if(i.formats[a]){var l=e;try{var c=r&&r.formatParams&&r.formatParams[r.interpolationkey]||{},u=c.locale||c.lng||r.locale||r.lng||n;l=i.formats[a](e,u,dQ(dQ(dQ({},s),r),c))}catch(e){i.logger.warn(e)}return l}return i.logger.warn("there was no format function for ".concat(a)),e}),e);return o}}]),e}();function pQ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function mQ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pQ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pQ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function gQ(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mJ(e);if(t){var i=mJ(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return pJ(this,n)}}var vQ=function(e){hJ(n,e);var t=gQ(n);function n(e,r,i){var o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return aJ(this,n),o=t.call(this),UJ&&kJ.call(dJ(o)),o.backend=e,o.store=r,o.services=i,o.languageUtils=i.languageUtils,o.options=a,o.logger=CJ.create("backendConnector"),o.waitingReads=[],o.maxParallelReads=a.maxParallelReads||10,o.readingCalls=0,o.maxRetries=a.maxRetries>=0?a.maxRetries:5,o.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,o.state={},o.queue=[],o.backend&&o.backend.init&&o.backend.init(i,a.backend,a),o}return uJ(n,[{key:"queueLoad",value:function(e,t,n,r){var i=this,o={},a={},s={},l={};return e.forEach((function(e){var r=!0;t.forEach((function(t){var s="".concat(e,"|").concat(t);!n.reload&&i.store.hasResourceBundle(e,t)?i.state[s]=2:i.state[s]<0||(1===i.state[s]?void 0===a[s]&&(a[s]=!0):(i.state[s]=1,r=!1,void 0===a[s]&&(a[s]=!0),void 0===o[s]&&(o[s]=!0),void 0===l[t]&&(l[t]=!0)))})),r||(s[e]=!0)})),(Object.keys(o).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(o),pending:Object.keys(a),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(l)}}},{key:"loaded",value:function(e,t,n){var r=e.split("|"),i=r[0],o=r[1];t&&this.emit("failedLoading",i,o,t),n&&this.store.addResourceBundle(i,o,n),this.state[e]=t?-1:2;var a={};this.queue.forEach((function(n){var r,s,l,c,u,d;r=n.loaded,s=o,c=RJ(r,[i],Object),u=c.obj,d=c.k,u[d]=u[d]||[],l&&(u[d]=u[d].concat(s)),l||u[d].push(s),function(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}(n,e),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach((function(e){a[e]||(a[e]={});var t=n.loaded[e];t.length&&t.forEach((function(t){void 0===a[e][t]&&(a[e][t]=!0)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",a),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:i,wait:o,callback:a}):(this.readingCalls++,this.backend[n](e,t,(function(s,l){if(r.readingCalls--,r.waitingReads.length>0){var c=r.waitingReads.shift();r.read(c.lng,c.ns,c.fcName,c.tried,c.wait,c.callback)}s&&l&&i<r.maxRetries?setTimeout((function(){r.read.call(r,e,t,n,i+1,2*o,a)}),o):a(s,l)}))):a(null,{})}},{key:"prepareLoading",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var o=this.queueLoad(e,t,r,i);if(!o.toLoad.length)return o.pending.length||i(),null;o.toLoad.forEach((function(e){n.loadOne(e)}))}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split("|"),i=r[0],o=r[1];this.read(i,o,"read",void 0,void 0,(function(r,a){r&&t.logger.warn("".concat(n,"loading namespace ").concat(o," for language ").concat(i," failed"),r),!r&&a&&t.logger.log("".concat(n,"loaded namespace ").concat(o," for language ").concat(i),a),t.loaded(e,r,a)}))}},{key:"saveMissing",value:function(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null!=n&&""!==n&&(this.backend&&this.backend.create&&this.backend.create(e,t,n,r,null,mQ(mQ({},o),{},{isUpdate:i})),e&&e[0]&&this.store.addResource(e[0],t,n,r))}}]),n}(kJ);function yQ(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===oJ(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===oJ(e[2])||"object"===oJ(e[3])){var n=e[3]||e[2];Object.keys(n).forEach((function(e){t[e]=n[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,n,r){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function bQ(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function wQ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function xQ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wQ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wQ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function SQ(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mJ(e);if(t){var i=mJ(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return pJ(this,n)}}function MQ(){}function _Q(e){Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((function(t){"function"==typeof e[t]&&(e[t]=e[t].bind(e))}))}var AQ=function(e){hJ(n,e);var t=SQ(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;if(aJ(this,n),e=t.call(this),UJ&&kJ.call(dJ(e)),e.options=bQ(r),e.services={},e.logger=CJ,e.modules={external:[]},_Q(dJ(e)),i&&!e.isInitialized&&!r.isClone){if(!e.options.initImmediate)return e.init(r,i),pJ(e,dJ(e));setTimeout((function(){e.init(r,i)}),0)}return e}return uJ(n,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var r=yQ();function i(e){return e?"function"==typeof e?new e:e:null}if(this.options=xQ(xQ(xQ({},r),this.options),bQ(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=xQ(xQ({},r.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){var o;this.modules.logger?CJ.init(i(this.modules.logger),this.options):CJ.init(null,this.options),this.modules.formatter?o=this.modules.formatter:"undefined"!=typeof Intl&&(o=hQ);var a=new eQ(this.options);this.store=new qJ(this.options.resources,this.options);var s=this.services;s.logger=CJ,s.resourceStore=this.store,s.languageUtils=a,s.pluralResolver=new aQ(a,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!o||this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format||(s.formatter=i(o),s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new cQ(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new vQ(i(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];e.emit.apply(e,[t].concat(r))})),this.modules.languageDetector&&(s.languageDetector=i(this.modules.languageDetector),s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=i(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new ZJ(this.services,this.options),this.translator.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];e.emit.apply(e,[t].concat(r))})),this.modules.external.forEach((function(t){t.init&&t.init(e)}))}if(this.format=this.options.interpolation.format,n||(n=MQ),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&"dev"!==l[0]&&(this.options.lng=l[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");var c=["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"];c.forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}}));var u=["addResource","addResources","addResourceBundle","removeResourceBundle"];u.forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments),e}}));var d=TJ(),f=function(){var t=function(t,r){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),d.resolve(r),n(t,r)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?f():setTimeout(f,0),d}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:MQ,r=n,i="string"==typeof e?e:this.language;if("function"==typeof e&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i&&"cimode"===i.toLowerCase())return r();var o=[],a=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach((function(e){o.indexOf(e)<0&&o.push(e)}))};if(i)a(i);else{var s=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);s.forEach((function(e){return a(e)}))}this.options.preload&&this.options.preload.forEach((function(e){return a(e)})),this.services.backendConnector.load(o,this.options.ns,(function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),r(e)}))}else r(null)}},{key:"reloadResources",value:function(e,t,n){var r=TJ();return e||(e=this.languages),t||(t=this.options.ns),n||(n=MQ),this.services.backendConnector.reload(e,t,(function(e){r.resolve(),n(e)})),r}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&KJ.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var n=this.languages[t];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var r=TJ();this.emit("languageChanging",e);var i=function(e){n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.resolvedLanguage=void 0,n.setResolvedLanguage(e)},o=function(o){e||o||!n.services.languageDetector||(o=[]);var a="string"==typeof o?o:n.services.languageUtils.getBestMatchFromCodes(o);a&&(n.language||i(a),n.translator.language||n.translator.changeLanguage(a),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage(a)),n.loadResources(a,(function(e){!function(e,o){o?(i(o),n.translator.changeLanguage(o),n.isLanguageChangingTo=void 0,n.emit("languageChanged",o),n.logger.log("languageChanged",o)):n.isLanguageChangingTo=void 0,r.resolve((function(){return n.t.apply(n,arguments)})),t&&t(e,(function(){return n.t.apply(n,arguments)}))}(e,a)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(o):o(e):o(this.services.languageDetector.detect()),r}},{key:"getFixedT",value:function(e,t,n){var r=this,i=function e(t,i){var o;if("object"!==oJ(i)){for(var a=arguments.length,s=new Array(a>2?a-2:0),l=2;l<a;l++)s[l-2]=arguments[l];o=r.options.overloadTranslationOptionHandler([t,i].concat(s))}else o=xQ({},i);o.lng=o.lng||e.lng,o.lngs=o.lngs||e.lngs,o.ns=o.ns||e.ns,o.keyPrefix=o.keyPrefix||n||e.keyPrefix;var c=r.options.keySeparator||".",u=o.keyPrefix?"".concat(o.keyPrefix).concat(c).concat(t):t;return r.t(u,o)};return"string"==typeof e?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=n,i}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var r=this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===r.toLowerCase())return!0;var a=function(e,n){var r=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===r||2===r};if(n.precheck){var s=n.precheck(this,a);if(void 0!==s)return s}return!!this.hasResourceBundle(r,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!a(r,e)||i&&!a(o,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,r=TJ();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){n.options.ns.indexOf(e)<0&&n.options.ns.push(e)})),this.loadResources((function(e){r.resolve(),t&&t(e)})),r):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=TJ();"string"==typeof e&&(e=[e]);var r=this.options.preload||[],i=e.filter((function(e){return r.indexOf(e)<0}));return i.length?(this.options.preload=r.concat(i),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:MQ,i=xQ(xQ(xQ({},this.options),t),{isClone:!0}),o=new n(i);void 0===t.debug&&void 0===t.prefix||(o.logger=o.logger.clone(t));var a=["store","services","language"];return a.forEach((function(t){o[t]=e[t]})),o.services=xQ({},this.services),o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o.translator=new ZJ(o.services,o.options),o.translator.on("*",(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];o.emit.apply(o,[e].concat(n))})),o.init(i,r),o.translator.options=o.options,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),n}(kJ);gJ(AQ,"createInstance",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return new AQ(e,t)}));var EQ=AQ.createInstance();EQ.createInstance=AQ.createInstance;EQ.createInstance,EQ.init,EQ.loadResources,EQ.reloadResources,EQ.use,EQ.changeLanguage,EQ.getFixedT,EQ.t,EQ.exists,EQ.setDefaultNamespace,EQ.hasLoadedNamespace,EQ.loadNamespaces,EQ.loadLanguages;var CQ,kQ=EQ;CQ=JSON.parse('{"yes":"Si","no":"No","confirm":"Conferma","apply":"Applica","cancel":"Annulla","show":"Mostra","hide":"Nascondi","send":"Invia","close":"Chiudi","edit":"Modifica","delete":"Elimina","loading":"Caricamento","expand":"Espandi","fullscreenEnter":"Passa a schermo intero","fullscreenExit":"Esci da schermo intero","center":"Centro","bottom":"In basso","hidden":"Nascosto","day":"Giorno","month":"Mese","year":"Anno","copy":"Copia","copyToClipboard":"Copia negli appunti","showOriginalText":"Mostra originale","showTranslatedText":"Mostra traduzione","memoriBlockedTitle":"Bloccato","memoriBlockedUntil":"Memori bloccato fino al {{date}}","memoriBlockedAnon":"Attualmente \\"{{name}}\\" non può rispondere, torna qui il {{date}}","memoriBlockedReasonExceedChats":"perchè ha superato la soglia mensile di chat ammesse.","memoriBlockedGiverHelper":"Puoi sempre gestirlo in qualità di amministratore, ma altri utenti non potranno interrogarlo.","generatedByAI":"Risposta generata da IA, può talvolta generare informazioni non corrette","completionsEnabled":"IA evoluta, può rispondere con risposte generate automaticamente che talvolta potrebbero contenere informazioni non corrette","birthDate":"Data di nascita","birthDateHelper":"Ti chiediamo la data di nascita esclusivamente per abilitare o disabilitare le funzionalità che hanno restrizioni in base all\'età","underage":"Devi avere almeno {{age}} anni per registrarti.","underageTwinSession":"Devi avere almeno {{age}} anni per interagire con questo Twin.","ageVerification":"Verifica dell\'età","ageVerificationText":"Per interagire con questo Twin, devi aver almeno {{minAge}} anni.","nsfw":"NSFW: Questo Twin contiene contenuti per adulti","auth":{"useRecoveryTokens":"Utilizza i token di recupero","tokens":"Token","addToken":"Aggiungi token","usePassword":"Utilizza la password","atLeast":"Almeno"},"widget":{"instruct":"Istruisci","test":"Prova","sound":"Audio","position":"Posizione","settings":"Impostazioni","share":"Condividi","sendOnKeypress":"Premi Invio per inviare","sendOnClick":"Clicca sul bottone di invio","goToIntegrationsToCustomizeAvatar":"Per personalizzare l\'avatar, vai a Condividimi e configura la pagina pubblica"},"write_and_speak":{"micButtonPopover":"Premi il pulsante per parlare","micButtonPopoverListening":"Premi il pulsante per smettere di parlare","pageInstructExplanation":"Per insegnarmi nuove cose clicca sul pulsante ISTRUISCIMI per cominciare","pageTryMeExplanation":"Per parlare con me clicca sul pulsante INIZIAMO per cominciare","instructButton":"ISTRUISCIMI","tryMeButton":"INIZIAMO","chatHistory":"Cronologia chat","exportChatHistory":"Esporta la cronologia chat","exportChatHistoryMessage":"Vuoi esportare la cronologia chat?","chatBotButtonText":"CLICCA QUI PER APRIRE LA CHAT","conversationStartedLabel":"Conversazione avvenuta il","settingsHeaderLabel":"Configura qui il memori se vuoi impostare una conversazione continua. Setta i secondi di silenzio prima dell\'invio.","continuousSpeechLabel":"Conversazione continua","secondsLabel":"Secondi","controlsPosition":"Posizione dei controlli","tryMeHeaderLabel":"PROVA","unknownPosition":"Posizione sconosciuta","fieldPlace":"Indica la posizione (es \'Milano\')","showMapLinkFor":"Visualizza sulla mappa la posizione","useMyPosition":"Usa la mia posizione","myPosition":"Posizione corrente","updatingPosition":"Aggiorno la posizione...","placeNotFound":"Luogo sconosciuto!","requirePosition":"Inserisci la posizione prima di iniziare","attachmentsLabel":"Arricchisci il tuo messaggio","iWantToTalkToIn":"Voglio parlare con {{name}} in"},"media":{"title":"Titolo","editAttributes":"Modifica attributi media","uploadMimeTypeNotAllowed":"Il tipo di file non è permesso","uploadSizeLimitMessage":"Il file caricato è troppo grande (max {{size}}MB)","uploadWrongResolutionMessage":"La risoluzione deve essere {{width}}x{{height}} pixel","memoriNameAlreadyUsed":"Hai già un Twin con questo nome","uploadHelperImages":"Caricare un file con estensione png, jpg, jpeg o gif e con dimensione massima di {{size}}MB","uploadHelper":"Caricare un file di dimensione massima di {{size}}MB","uploadError":"Errore nel caricamento","square":"quadrato","scaleRatio":"Proporzioni","addMediaLabel":"Aggiungi media","insertThisMediaMsg":"Inserisci questi media","mediaUploadMessage":"Clicca per caricare un nuovo media","addLinkLabel":"Aggiungi un link","linkKey":"URL","linkValue":"Titolo link","insertThisLink":"Inserisci un link a {{url}} con titolo {{title}}"},"gamification":{"level":"Livello","points":"punti","memoriReachedLevel":"è diventato più evoluto ed ha raggiunto il livello","levelGoToStatistics":"{{memori}} è al livello {{level}} con {{points}} punti. Clicca per andare alle statistiche.","congratulationsNewLevel":"Congratulazioni, hai raggiunto un nuovo livello!","congratulationsNewLevelDescription":"Il tuo Memori è diventato più evoluto con {{points}} punti, guarda le","statistics":"statistiche"},"success":"Operazione andata a buon fine","Error":"Errore","internal server error":"Ops, scusa... qualcosa è andato storto nel server","error":"Errore","error.loading":"Errore durante il caricamento dei contenuti.","error.notFound":"Ops, non abbiamo trovato ciò che cercavi.","error.generic":"Ops, qualcosa è andato storto.","error.serverNotResponding":"Stiamo facendo manutenzione o rilasciando aggiornamenti. Riprova più tardi.","error.unprocessableEntity":"Errore durante il salvataggio dei dati. Ricontrolla i dati inseriti.","error.goBackTo":"Prova a tornare alla","error.reloadPage":"Ricarica la pagina","error.tryAgain":"Riprova","error.unauthorized":"Non sei autorizzato a visualizzare questo contenuto.","errors":{"TENANT_NOT_FOUND":"Tenant non trovato","TENANT_REGISTRATION_DISABLED":"La registrazione su questa piattaforma è disabilitata","TENANT_MISSING_NAME":"Tenant: nome mancante","TENANT_MAX_USERS_REACHED":"Numero massimo di utenti raggiunto","TENANT_MAX_ADMINS_REACHED":"Numero massimo di utenti amministratori raggiunto","USER_NOT_CONFIRMED":"Utente ancora non confermato","USER_NOT_FOUND":"Utente non trovato","USER_OR_PASSWORD_INVALID":"Utente o password non validi","USER_MUST_CHANGE_PASSWORD":"Devi cambiare la password","USER_MUST_ENTER_VERIFICATION_CODE":"Devi inserire il codice di verifica","USER_MISSING_TENANT":"Utente: tenant mancante","USER_MISSING_NAME":"Utente: nome mancante","USER_MISSING_PASSWORD":"Utente: password mancante","USER_MISSING_EMAIL":"Utente: email mancante","USER_MISSING_VERIFICATION_CODE":"Utente: codice di verifica mancante","USER_NAME_ALREADY_USED":"Nome utente già in uso","USER_PASSWORD_NOT_CONFORMING_TO_POLICY":"La password non rispetta le regole di sicurezza","USER_EMAIL_ALREADY_USED":"Email già in uso","USER_EMAIL_INVALID":"Email non valida","USER_VERIFICATION_CODE_INVALID":"Codice di verifica non valido","USER_MISSING_NAME_OR_EMAIL":"Nome utente o email mancante","USER_NAME_INVALID":"Nome utente non valido","USER_HAS_ONE_OR_MORE_MEMORI":"L\'utente ha uno o più memori","USER_MISSING_NEW_PASSWORD":"Utente: nuova password mancante","USER_NOTHING_TO_DO":"Niente da fare","USER_CANT_CREATE_MEMORI":"Utente non abilitato a creare Memori","USER_MAX_MEMORI_REACHED":"Massimo numero di Memori raggiunto","USER_CANT_EDIT_INTEGRATIONS":"Utente non abilitato a gestire integrazioni","MEMORI_NOT_FOUND":"Memori non trovato","MEMORI_NOT_ACCESSIBLE":"Memori non accessibile","MEMORI_ONLY_OWNER_CAN_CHANGE_GIVER_TAG_AND_PIN":"Solo il proprietario può cambiare il tag e il pin","SESSION_NOT_FOUND":"Sessione non trovata","SESSION_IS_NOT_ADMINISTRATIVE":"Sessione non amministrativa","MEMORI_MISSING_CONFIGURATION":"Memori: configurazione mancante","MEMORI_CONFIGURATION_NOT_FOUND":"Memori: configurazione non trovata","MEMORI_INVALID_PRIVACY_TYPE":"Memori: tipo di privacy non valido","MEMORI_MISSING_PASSWORD":"Memori: password mancante","MEMORI_INVALID_TOTAL_NUMBER_OF_RECOVERY_TOKENS":"Memori: numero totale di token di recupero non valido","MEMORI_INVALID_MINIMUM_NUMBER_OF_RECOVERY_TOKENS":"Memori: numero minimo di token di recupero non valido","MEMORI_INVALID_VOICE_TYPE":"Memori: tipo di voce non valido","MEMORI_MISSING_NAME":"Memori: nome mancante","MEMORI_MISSING_PASSWORD_OR_RECOVERY_TOKENS":"Memori: password o token di recupero mancanti","MEMORI_INVALID_ID":"Memori: ID non valido","MEMORI_NAME_ALREADY_USED":"Nome memori già in uso","MEMORI_INVALID_PIN":"Memori: PIN non valido","MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION":"Memori: cambio TAG e PIN richiedono operazioni separate","MEMORI_NO_PASSWORD_WHEN_PUBLIC":"Memori: password non richiesta su Memori pubblico","MEMORI_TRANSFER_MISSING_DESTINATION_USER":"Trasferimento: utente di destinazione mancante","MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID":"Trasferimento: ID utente di destinazione non valido","MEMORI_TRANSFER_DESTINATION_USER_DATA_INCONSISTENT":"Trasferimento: dati utente di destinazione non validi","MEMORI_TRANSFER_NOTHING_TO_DO":"Trasferimento: alcuna operazione da fare","MEMORI_CONFIGURATION_CANT_BE_CHANGED":"Memori: la configurazione non può essere modificata","MEMORI_MISSING_NEW_PASSWORD":"Memori: nuova password mancante","INTEGRATION_NOT_FOUND":"Integrazione non trovata","MEMORI_SESSIONS_INVALID_DATE_FROM_FORMAT":"Formato non valido data a partire da","MEMORI_SESSIONS_INVALID_DATE_TO_FORMAT":"Formato non valido data fino a","INTEGRATION_INVALID_TYPE":"Tipo integrazione non valido","INTEGRATION_ALREADY_EXISTS":"Integrazione già esistente","INTEGRATION_MEMORI_IS_NOT_PUBLIC":"Memori non pubblici non possono essere integrati","INTEGRATION_MISSING_INVOCATION_TEXT":"Integrazione: testo di invocazione mancante","INTEGRATION_MISSING_DEVICE_EMAILS":"Integrazione: email del dispositivo mancante","INTEGRATION_MEMORI_IS_EMPTY":"Memori vuoti non possono essere integrati","INTEGRATION_MISSING_PRIVACY_POLICY":"Integrazione: privacy policy mancante","INTEGRATION_MISSING_CATEGORY":"Categoria integrazione mancante","INTEGRATION_MISSING_DESCRIPTION":"Descrizione integrazione mancante","INTEGRATION_INVALID_INVOCATION_TEXT":"Testo di invocazione non valido","INTEGRATION_GOOGLE_NO_MORE_AVAILABLE":"Google Home non più disponibile","UPLOAD_REQUIRES_MULTIPART_ENCODING":"L\'upload richiede l\'encoding multipart","UPLOAD_MISSING_CONTENT_TYPE_BOUNDARY":"Upload: manca il content type boundary","UPLOAD_MAX_LENGTH_EXCEEDED":"Upload: dimensione massima superata","UPLOAD_FILE_IS_EMPTY":"Upload: file vuoto","UPLOAD_INVALID_FILE_TYPE_OR_SIGNATURE":"Upload: tipo di file o firma non validi","UPLOAD_MISSING_FILE_NAME":"Upload: nome file mancante","UPLOAD_INVALID_MEMORY_ID":"Upload: ID contenuto non valido","UPLOAD_MISSING_FILE_CONTENT":"Upload: contenuto file mancante","ASSET_NOT_FOUND":"Asset non trovato","ASSET_NOT_ACCESSIBLE":"Asset non accessibile","ASSET_MISSING_SESSION_ID":"Asset: ID sessione mancante","ASSET_INVALID_FILE_NAME":"Asset: nome file non valido","INVITATION_NOT_FOUND":"Invito non trovato","INVITATION_NOT_ACCESSIBLE":"Invito non accessibile","INVITATION_ALREADY_ACCEPTED":"Invito già accettato","INVITATION_ALREADY_REJECTED":"Invito già rifiutato","INVITATION_MISSING_DESTINATION_EMAIL":"Invito: email di destinazione mancante","INVITATION_DESTINATION_EMAIL_INVALID":"Invito: email di destinazione non valida","INVITATION_MISSING_TAG":"Invito: tag mancante","INVITATION_MISSING_PIN":"Invito: PIN mancante","INVITATION_INVALID_PIN":"Invito: PIN non valido","INVITATION_INVALID_TYPE":"Invito: tipo non valido","INVITATION_MISSING_DESTINATION_NAME":"Invito: nome destinatario mancante","INVITATION_TAG_PIN_CANT_BE_CHANGED":"Invito: tag e pin non possono essere cambiati","INVITATION_CANT_BE_CHANGED":"Invito: non può essere modificato","ACTIONLOG_INVALID_USER_ID":"ID utente non valido","ACTIONLOG_INVALID_DATE_FROM_FORMAT":"Data a partire da: formato non valido","ACTIONLOG_INVALID_DATE_TO_FORMAT":"Data fino a: formato non valido","ACTIONLOG_INVALID_MEMORI_ID":"ID Memori non valido","CONSUMPTIONLOG_INVALID_TYPE":"Tipo di log non valido","CONSUMPTIONLOG_INVALID_DATE_FROM_FORMAT":"Data a partire da: formato non valido","CONSUMPTIONLOG_INVALID_DATE_TO_FORMAT":"Data fino a: formato non valido","CONSUMPTIONLOG_INVALID_USER_ID":"ID utente non valido","CONSUMPTIONLOG_INVALID_MEMORI_ID":"Memori ID non valido"}}');const TQ={en:{translation:r(JSON.parse('{"yes":"Yes","no":"No","confirm":"Confirm","apply":"Apply","cancel":"Cancel","show":"Show","hide":"Hide","send":"Send","close":"Close","edit":"Edit","delete":"Delete","loading":"Loading","expand":"Expand","fullscreenEnter":"Enter fullscreen","fullscreenExit":"Exit fullscreen","center":"Center","bottom":"Bottom","hidden":"Hidden","day":"Day","month":"Month","year":"Year","copy":"Copy","copyToClipboard":"Copy to clipboard","showOriginalText":"Show original","showTranslatedText":"Show translation","memoriBlockedTitle":"Blocked","memoriBlockedUntil":"Memori blocked until {{date}}","memoriBlockedAnon":"Currently \\"{{name}}\\" can\'t answer, come back here on {{date}}","memoriBlockedReasonExceedChats":"because it has exceeded the monthly threshold of allowed chats.","memoriBlockedGiverHelper":"You can still manage it as administrator, but other users will not be able to interact with it.","generatedByAI":"Answer generated by AI, may occasionally generate incorrect informations","completionsEnabled":"Advanced AI, can respond with automatically generated answers that may sometimes contain incorrect information","birthDate":"Birth date","birthDateHelper":"We ask for your birth date only to enable or disable functionalities that have age restrictions","underage":"You must be at least {{age}} years old to sign up.","underageTwinSession":"You must be at least {{age}} years old to interact with this Twin.","ageVerification":"Age verification","ageVerificationText":"To interact with this Twin, you must be at least {{minAge}} years old.","nsfw":"NSFW: This Twin contains adult contents","auth":{"useRecoveryTokens":"Use recovery tokens","tokens":"Tokens","addToken":"Add token","usePassword":"Use password","atLeast":"At least"},"widget":{"instruct":"Instruct","test":"Test","sound":"Sound","position":"Position","settings":"Settings","share":"Share","sendOnKeypress":"Hit Enter to send","sendOnClick":"Click on Submit","goToIntegrationsToCustomizeAvatar":"To customize the avatar, go to Share and customize the public page"},"write_and_speak":{"micButtonPopover":"Click the button to speak","micButtonPopoverListening":"Click the button to stop speak","pageInstructExplanation":"To teach me new things click on the INSTRUCT ME button to get started","pageTryMeExplanation":"To talk to me click on the START button to get started","instructButton":"INSTRUCT ME","tryMeButton":"START","chatHistory":"Chat history","exportChatHistory":"Export chat history","exportChatHistoryMessage":"Do you want to export chat history?","chatBotButtonText":"CLICK HERE TO OPEN CHATBOT","conversationStartedLabel":"Conversation started on","settingsHeaderLabel":"Setup here if you want to set the memori as continuous speech, and change the silence seconds if you want to customize them.","continuousSpeechLabel":"Continuous speech","secondsLabel":"Set seconds","controlsPosition":"Controls position","tryMeHeaderLabel":"TRY","unknownPosition":"Unknown position","fieldPlace":"Write the place (eg \'Milano\')","showMapLinkFor":"Show the position on the map","useMyPosition":"Use my position","myPosition":"Your position","updatingPosition":"Updating position...","placeNotFound":"Place not found!","requirePosition":"Insert your position before start","attachmentsLabel":"Enrich your message","iWantToTalkToIn":"I want to talk to {{name}} in"},"media":{"title":"Title","editAttributes":"Edit media attributes","uploadMimeTypeNotAllowed":"The file type is not allowed","uploadSizeLimitMessage":"The uploaded size is too big (max {{size}}MB)","uploadWrongResolutionMessage":"The resolution must be {{width}}x{{height}} pixel","memoriNameAlreadyUsed":"You already have a Twin with this name","uploadHelperImages":"Upload a file with extension png, jpg, jpeg or gif, and having at maximum a size of {{size}}MB","uploadHelper":"Upload a file having at maximum a size of {{size}}MB","uploadError":"Upload failed","square":"square","scaleRatio":"Scale ratio","addMediaLabel":"Add a media","insertThisMediaMsg":"Insert these media","mediaUploadMessage":"Click to load a new media","addLinkLabel":"Add a link","linkKey":"URL","linkValue":"Link title","insertThisLink":"Insert a link to {{url}} with title {{title}}"},"gamification":{"level":"Level","points":"points","memoriReachedLevel":"became more evolved and reached level","levelGoToStatistics":"{{memori}} is at level {{level}} with {{points}} points. Click to go to statistics.","congratulationsNewLevel":"Congratulations, you have reached a new level!","congratulationsNewLevelDescription":"Your Memori became more evolved with {{points}} points, look at the","statistics":"statistics"},"success":"Success","Error":"Error","internal server error":"Oupsie, sorry... Something went wrong on the server","error":"Error","error.loading":"Error while loading content.","error.generic":"Oupsie, sorry... something went wrong.","error.serverNotResponding":"We are doing maintenance or releasing updates. Please try again later.","error.notFound":"Oupsie, we didn\'t find the page you were looking for.","error.goBackTo":"You can try to go back to the","error.reloadPage":"Reload the page","error.tryAgain":"Try again","error.unauthorized":"You are unauthorized to view this content.","error.unprocessableEntity":"Error while processing the request. Check the data you entered.","errors":{"TENANT_NOT_FOUND":"Tenant not found","TENANT_REGISTRATION_DISABLED":"Registration on this platform is disabled","TENANT_MISSING_NAME":"Tenant: name missing","TENANT_MAX_USERS_REACHED":"Maximum number of users reached","TENANT_MAX_ADMINS_REACHED":"Maximum number of admin users reached","USER_NOT_CONFIRMED":"User still not confirmed","USER_NOT_FOUND":"User not found","USER_OR_PASSWORD_INVALID":"Invalid user or password","USER_MUST_CHANGE_PASSWORD":"You must change your password","USER_MUST_ENTER_VERIFICATION_CODE":"You must enter the verification code","USER_MISSING_TENANT":"User: missing tenant","USER_MISSING_NAME":"User: name is missing","USER_MISSING_PASSWORD":"User: password missing","USER_MISSING_EMAIL":"User: Missing email","USER_MISSING_VERIFICATION_CODE":"User: Missing verification code","USER_NAME_ALREADY_USED":"User name already in use","USER_PASSWORD_NOT_CONFORMING_TO_POLICY":"The password does not meet the security rules","USER_EMAIL_ALREADY_USED":"Email already in use","USER_EMAIL_INVALID":"Invalid email","USER_VERIFICATION_CODE_INVALID":"Invalid verification code","USER_MISSING_NAME_OR_EMAIL":"Missing username or email","USER_NAME_INVALID":"Invalid user name","USER_HAS_ONE_OR_MORE_MEMORI":"The user has one or more memories","USER_MISSING_NEW_PASSWORD":"User: new password missing","USER_NOTHING_TO_DO":"Nothing to do","USER_CANT_CREATE_MEMORI":"User not allowed to create Memori","USER_MAX_MEMORI_REACHED":"Maximum number of Memori reached","USER_CANT_EDIT_INTEGRATIONS":"User not allowed to manage integrations","MEMORI_NOT_FOUND":"Memori not found","MEMORI_NOT_ACCESSIBLE":"Memori not accessible","MEMORI_ONLY_OWNER_CAN_CHANGE_GIVER_TAG_AND_PIN":"Only owner can change tag or pin","SESSION_NOT_FOUND":"Session not found","SESSION_IS_NOT_ADMINISTRATIVE":"Non-administrative session","MEMORI_MISSING_CONFIGURATION":"Memori: missing configuration","MEMORI_CONFIGURATION_NOT_FOUND":"Memories: configuration not found","MEMORI_INVALID_PRIVACY_TYPE":"Memories: invalid privacy type","MEMORI_MISSING_PASSWORD":"Memori: missing password","MEMORI_INVALID_TOTAL_NUMBER_OF_RECOVERY_TOKENS":"Memories: total number of invalid recovery tokens","MEMORI_INVALID_MINIMUM_NUMBER_OF_RECOVERY_TOKENS":"Memories: minimum number of invalid recovery tokens","MEMORI_INVALID_VOICE_TYPE":"Memories: invalid voice type","MEMORI_MISSING_NAME":"Memories: missing name","MEMORI_MISSING_PASSWORD_OR_RECOVERY_TOKENS":"Memories: missing password or recovery token","MEMORI_INVALID_ID":"Memories: invalid ID","MEMORI_NAME_ALREADY_USED":"Memory name already in use","MEMORI_INVALID_PIN":"Memories: Invalid PIN","MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION":"Memories: TAG and PIN change require separate operations","MEMORI_NO_PASSWORD_WHEN_PUBLIC":"Memories: no password required when public","MEMORI_TRANSFER_MISSING_DESTINATION_USER":"Transfer: missing destination user","MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID":"Transfer: invalid destination user ID","MEMORI_TRANSFER_DESTINATION_USER_DATA_INCONSISTENT":"Transfer: invalid destination user data","MEMORI_TRANSFER_NOTHING_TO_DO":"Transfer: nothing to do","MEMORI_CONFIGURATION_CANT_BE_CHANGED":"Memories: configuration cannot be changed","MEMORI_MISSING_NEW_PASSWORD":"Memories: new password missing","INTEGRATION_NOT_FOUND":"Integration not found","MEMORI_SESSIONS_INVALID_DATE_FROM_FORMAT":"Invalid date from format","MEMORI_SESSIONS_INVALID_DATE_TO_FORMAT":"Invalid date to format","INTEGRATION_INVALID_TYPE":"Invalid integration type","INTEGRATION_ALREADY_EXISTS":"Integration already exists","INTEGRATION_MEMORI_IS_NOT_PUBLIC":"Non-public memories cannot be integrated","INTEGRATION_MISSING_INVOCATION_TEXT":"Integration: missing invocation text","INTEGRATION_MISSING_DEVICE_EMAILS":"Integration: missing device email","INTEGRATION_MEMORI_IS_EMPTY":"Empty memories cannot be integrated","INTEGRATION_MISSING_PRIVACY_POLICY":"Integration: privacy policy missing","INTEGRATION_MISSING_CATEGORY":"Integration category missing","INTEGRATION_MISSING_DESCRIPTION":"Missing integration description","INTEGRATION_INVALID_INVOCATION_TEXT":"Invalid invocation text","INTEGRATION_GOOGLE_NO_MORE_AVAILABLE":"Google Home no more available","UPLOAD_REQUIRES_MULTIPART_ENCODING":"Upload requires multipart encoding","UPLOAD_MISSING_CONTENT_TYPE_BOUNDARY":"Upload: missing content type boundary","UPLOAD_MAX_LENGTH_EXCEEDED":"Upload: maximum size exceeded","UPLOAD_FILE_IS_EMPTY":"Upload: empty file","UPLOAD_INVALID_FILE_TYPE_OR_SIGNATURE":"Upload: invalid file type or signature","UPLOAD_MISSING_FILE_NAME":"Upload: missing file name","UPLOAD_INVALID_MEMORY_ID":"Upload: Invalid content ID","UPLOAD_MISSING_FILE_CONTENT":"Upload: Missing file content","ASSET_NOT_FOUND":"Asset not found","ASSET_NOT_ACCESSIBLE":"Asset not accessible","ASSET_MISSING_SESSION_ID":"Asset: missing session ID","ASSET_INVALID_FILE_NAME":"Asset: invalid file name","INVITATION_NOT_FOUND":"Invitation not found","INVITATION_NOT_ACCESSIBLE":"Invitation not accessible","INVITATION_ALREADY_ACCEPTED":"Invitation already accepted","INVITATION_ALREADY_REJECTED":"Invitation already rejected","INVITATION_MISSING_DESTINATION_EMAIL":"Invitation: missing destination email","INVITATION_DESTINATION_EMAIL_INVALID":"Invitation: destination email invalid","INVITATION_MISSING_TAG":"Invitation: missing tag","INVITATION_MISSING_PIN":"Invitation: PIN missing","INVITATION_INVALID_PIN":"Invitation: invalid PIN","INVITATION_INVALID_TYPE":"Invitation: invalid type","INVITATION_MISSING_DESTINATION_NAME":"Invitation: destination name missing","INVITATION_TAG_PIN_CANT_BE_CHANGED":"Invitation: tag and pin can\'t be changed","INVITATION_CANT_BE_CHANGED":"Intation: can\'t be changed","ACTIONLOG_INVALID_USER_ID":"Invalid user ID","ACTIONLOG_INVALID_DATE_FROM_FORMAT":"Date from: invalid format","ACTIONLOG_INVALID_DATE_TO_FORMAT":"Date to: invalid format","ACTIONLOG_INVALID_MEMORI_ID":"Invalid Memori ID","CONSUMPTIONLOG_INVALID_TYPE":"Invalid log type","CONSUMPTIONLOG_INVALID_DATE_FROM_FORMAT":"Date from: invalid format","CONSUMPTIONLOG_INVALID_DATE_TO_FORMAT":"Date to: invalid format","CONSUMPTIONLOG_INVALID_USER_ID":"Invalid user ID","CONSUMPTIONLOG_INVALID_MEMORI_ID":"Invalid Memori ID"}}'))},it:{translation:r(CQ)}};kQ.use(ye).init({resources:TQ,lng:"en",fallbackLng:"it",supportedLngs:["en","it"],nonExplicitSupportedLngs:!0,interpolation:{escapeValue:!1}});var IQ=kQ;const OQ=({ownerUserName:e,ownerUserID:t,memoriName:n,memoriID:r,integrationID:i,tenantID:o,secretToken:a,sessionID:l,layout:c="DEFAULT",showShare:d=!0,showSettings:f=!0,showInstruct:h=!1,height:p="100%",baseURL:m,apiURL:g="https://backend.memori.ai",tag:v,pin:y,context:b,initialQuestion:w,uiLang:x,spokenLang:S,authToken:M,AZURE_COGNITIVE_SERVICES_TTS_KEY:_,onStateChange:A})=>{var E,C,k;const[T,I]=(0,u.useState)(),{t:O}=Te();if(!(r&&t||n&&e))throw new Error("Identifier pair required: please provide either memoriID and ownerUserID or memoriName and ownerUserName");const R=W(g),P=(0,u.useCallback)((async()=>{if(r&&t){const{memori:e,...n}=await R.backend.getMemoriByUserAndId(o,t,r);0===n.resultCode&&e?I(e):console.error("[MEMORI]",n,e)}else if(n&&e){const{memori:t,...r}=await R.backend.getMemori(o,e,n);0===r.resultCode&&t?I(t):console.error("[MEMORI]",r,t)}}),[r,t,n,e,o]);return(0,u.useEffect)((()=>{P()}),[P,o]),(0,u.useEffect)((()=>{if(x)IQ.changeLanguage(x.toLowerCase());else{const{lng:e,fallbackLng:t}=(()=>{const e=navigator.language;if(e){let t=e.split("-")[0];if(["en","it"].includes(t))return{lng:t,fallbackLng:"en"===t?"it":"en"}}return{lng:"en",fallbackLng:"it"}})();IQ.changeLanguage(e).catch((()=>{IQ.changeLanguage(t)}))}}),[x]),T?(0,s.jsx)(iJ,{layout:c,height:p,baseUrl:m||(o.startsWith("https://")?o:`https://${o}`),apiUrl:g,memori:{...T,secretToken:a},memoriLang:null!=S?S:null===(C=null===(E=T.culture)||void 0===E?void 0:E.split("-"))||void 0===C?void 0:C[0],tenant:{id:o,theme:"twincreator",config:{name:o,showNewUser:!1,requirePosition:!!T.needsPosition}},secret:a,sessionID:l,showShare:d,showSettings:f,showInstruct:h,integration:null===(k=null==T?void 0:T.integrations)||void 0===k?void 0:k.find((e=>i?e.integrationID===i:!!e.publish&&"LANDING_EXPERIENCE"===e.type)),initialContextVars:b,initialQuestion:w,authToken:M,AZURE_COGNITIVE_SERVICES_TTS_KEY:_,onStateChange:A,...v&&y?{personification:{tag:v,pin:y}}:{}}):(0,s.jsx)("div",{children:(0,s.jsxs)("p",{style:{textAlign:"center",margin:"2rem auto"},children:[O("loading"),"..."]})})};OQ.propTypes={memoriName:r(l).string,memoriID:r(l).string,ownerUserName:r(l).string,ownerUserID:r(l).string,integrationID:r(l).string,tenantID:r(l).string.isRequired,secretToken:r(l).string,sessionID:r(l).string,showShare:r(l).bool,showSettings:r(l).bool,showInstruct:r(l).bool,layout:r(l).oneOf(["DEFAULT","FULLPAGE","TOTEM"]),height:r(l).oneOfType([r(l).string,r(l).number]),baseURL:r(l).string,apiURL:r(l).string,tag:r(l).string,pin:r(l).string,context:r(l).objectOf(r(l).any),initialQuestion:r(l).string,uiLang:r(l).oneOf(["en","it"]),spokenLang:r(l).string,authToken:r(l).string,AZURE_COGNITIVE_SERVICES_TTS_KEY:r(l).string,onStateChange:r(l).func};var RQ=OQ;class PQ extends HTMLElement{connectedCallback(){const e=document.createElement("div"),t=document.createElement("div");t.setAttribute("id","memori-root"),e.appendChild(t),this.appendChild(e);const n=Object.keys(RQ.propTypes).reduce(((e,t)=>(this.hasAttribute(t)&&(e[t]=this.getAttribute(t)),e)),{}),i=this.getAttribute("tenantId"),o=this.getAttribute("context")?.split(",")?.reduce(((e,t)=>{const[n,r]=t.split(":").map((e=>e.trim()));return{...e,[n]:r}}),{});i?r(c).render((0,s.jsx)(RQ,{...n,context:o,tenantID:i}),t):console.error("No tenantId attribute found")}}customElements.define("memori-client",PQ)})();
|
|
122
|
+
***************************************************************************** */function ZK(e,t){function n(){this.constructor=e}XK(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var $K=function(){return $K=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},$K.apply(this,arguments)};Object.create;Object.create;var eY;u=a("85Hg2");function tY(e,t,n,r,i,o){void 0===o&&(o=0);var a=fY(e,t,o),s=a.width,l=a.height,c=Math.min(s,n),u=Math.min(l,r);return c>u*i?{width:u*i,height:u}:{width:c,height:c/i}}function nY(e,t,n,r,i){void 0===i&&(i=0);var o=fY(t.width,t.height,i),a=o.width,s=o.height;return{x:rY(e.x,a,n.width,r),y:rY(e.y,s,n.height,r)}}function rY(e,t,n,r){var i=t*r/2-n/2;return hY(e,-i,i)}function iY(e,t){return Math.sqrt(Math.pow(e.y-t.y,2)+Math.pow(e.x-t.x,2))}function oY(e,t){return 180*Math.atan2(t.y-e.y,t.x-e.x)/Math.PI}function aY(e,t,n,r,i,o,a){void 0===o&&(o=0),void 0===a&&(a=!0);var s=a?sY:lY,l=fY(t.width,t.height,o),c=fY(t.naturalWidth,t.naturalHeight,o),u={x:s(100,((l.width-n.width/i)/2-e.x/i)/l.width*100),y:s(100,((l.height-n.height/i)/2-e.y/i)/l.height*100),width:s(100,n.width/l.width*100/i),height:s(100,n.height/l.height*100/i)},d=Math.round(s(c.width,u.width*c.width/100)),f=Math.round(s(c.height,u.height*c.height/100)),h=c.width>=c.height*r?{width:Math.round(f*r),height:f}:{width:d,height:Math.round(d/r)};return{croppedAreaPercentages:u,croppedAreaPixels:$K($K({},h),{x:Math.round(s(c.width-h.width,u.x*c.width/100)),y:Math.round(s(c.height-h.height,u.y*c.height/100))})}}function sY(e,t){return Math.min(e,Math.max(0,t))}function lY(e,t){return t}function cY(e,t,n,r,i,o){var a=fY(t.width,t.height,n),s=hY(r.width/a.width*(100/e.width),i,o);return{crop:{x:s*a.width/2-r.width/2-a.width*s*(e.x/100),y:s*a.height/2-r.height/2-a.height*s*(e.y/100)},zoom:s}}function uY(e,t,n,r,i,o){void 0===n&&(n=0);var a=fY(t.naturalWidth,t.naturalHeight,n),s=hY(function(e,t,n){var r=function(e){return e.width>e.height?e.width/e.naturalWidth:e.height/e.naturalHeight}(t);return n.height>n.width?n.height/(e.height*r):n.width/(e.width*r)}(e,t,r),i,o),l=r.height>r.width?r.height/e.height:r.width/e.width;return{crop:{x:((a.width-e.width)/2-e.x)*l,y:((a.height-e.height)/2-e.y)*l},zoom:s}}function dY(e,t){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function fY(e,t,n){var r=n*Math.PI/180;return{width:Math.abs(Math.cos(r)*e)+Math.abs(Math.sin(r)*t),height:Math.abs(Math.sin(r)*e)+Math.abs(Math.cos(r)*t)}}function hY(e,t,n){return Math.min(Math.max(e,t),n)}function pY(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.filter((function(e){return"string"==typeof e&&e.length>0})).join(" ").trim()}eY=a("lmpx0");var mY=function(e){function t(){var n=null!==e&&e.apply(this,arguments)||this;return n.imageRef=r(u).createRef(),n.videoRef=r(u).createRef(),n.containerRef=null,n.styleRef=null,n.containerRect=null,n.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},n.dragStartPosition={x:0,y:0},n.dragStartCrop={x:0,y:0},n.gestureZoomStart=0,n.gestureRotationStart=0,n.isTouching=!1,n.lastPinchDistance=0,n.lastPinchRotation=0,n.rafDragTimeout=null,n.rafPinchTimeout=null,n.wheelTimer=null,n.currentDoc="undefined"!=typeof document?document:null,n.currentWindow="undefined"!=typeof window?window:null,n.resizeObserver=null,n.state={cropSize:null,hasWheelJustStarted:!1},n.initResizeObserver=function(){if(void 0!==window.ResizeObserver&&n.containerRef){var e=!0;n.resizeObserver=new window.ResizeObserver((function(t){e?e=!1:n.computeSizes()})),n.resizeObserver.observe(n.containerRef)}},n.preventZoomSafari=function(e){return e.preventDefault()},n.cleanEvents=function(){n.currentDoc&&(n.currentDoc.removeEventListener("mousemove",n.onMouseMove),n.currentDoc.removeEventListener("mouseup",n.onDragStopped),n.currentDoc.removeEventListener("touchmove",n.onTouchMove),n.currentDoc.removeEventListener("touchend",n.onDragStopped),n.currentDoc.removeEventListener("gesturemove",n.onGestureMove),n.currentDoc.removeEventListener("gestureend",n.onGestureEnd))},n.clearScrollEvent=function(){n.containerRef&&n.containerRef.removeEventListener("wheel",n.onWheel),n.wheelTimer&&clearTimeout(n.wheelTimer)},n.onMediaLoad=function(){var e=n.computeSizes();e&&(n.emitCropData(),n.setInitialCrop(e)),n.props.onMediaLoaded&&n.props.onMediaLoaded(n.mediaSize)},n.setInitialCrop=function(e){if(n.props.initialCroppedAreaPercentages){var t=cY(n.props.initialCroppedAreaPercentages,n.mediaSize,n.props.rotation,e,n.props.minZoom,n.props.maxZoom),r=t.crop,i=t.zoom;n.props.onCropChange(r),n.props.onZoomChange&&n.props.onZoomChange(i)}else if(n.props.initialCroppedAreaPixels){var o=uY(n.props.initialCroppedAreaPixels,n.mediaSize,n.props.rotation,e,n.props.minZoom,n.props.maxZoom);r=o.crop,i=o.zoom;n.props.onCropChange(r),n.props.onZoomChange&&n.props.onZoomChange(i)}},n.computeSizes=function(){var e,t,r,i,o,a,s=n.imageRef.current||n.videoRef.current;if(s&&n.containerRef){n.containerRect=n.containerRef.getBoundingClientRect();var l=n.containerRect.width/n.containerRect.height,c=(null===(e=n.imageRef.current)||void 0===e?void 0:e.naturalWidth)||(null===(t=n.videoRef.current)||void 0===t?void 0:t.videoWidth)||0,u=(null===(r=n.imageRef.current)||void 0===r?void 0:r.naturalHeight)||(null===(i=n.videoRef.current)||void 0===i?void 0:i.videoHeight)||0,d=c/u,f=void 0;if(s.offsetWidth<c||s.offsetHeight<u)switch(n.props.objectFit){default:case"contain":f=l>d?{width:n.containerRect.height*d,height:n.containerRect.height}:{width:n.containerRect.width,height:n.containerRect.width/d};break;case"horizontal-cover":f={width:n.containerRect.width,height:n.containerRect.width/d};break;case"vertical-cover":f={width:n.containerRect.height*d,height:n.containerRect.height};break;case"auto-cover":f=c>u?{width:n.containerRect.width,height:n.containerRect.width/d}:{width:n.containerRect.height*d,height:n.containerRect.height}}else f={width:s.offsetWidth,height:s.offsetHeight};n.mediaSize=$K($K({},f),{naturalWidth:c,naturalHeight:u}),n.props.setMediaSize&&n.props.setMediaSize(n.mediaSize);var h=n.props.cropSize?n.props.cropSize:tY(n.mediaSize.width,n.mediaSize.height,n.containerRect.width,n.containerRect.height,n.props.aspect,n.props.rotation);return(null===(o=n.state.cropSize)||void 0===o?void 0:o.height)===h.height&&(null===(a=n.state.cropSize)||void 0===a?void 0:a.width)===h.width||n.props.onCropSizeChange&&n.props.onCropSizeChange(h),n.setState({cropSize:h},n.recomputeCropPosition),n.props.setCropSize&&n.props.setCropSize(h),h}},n.onMouseDown=function(e){n.currentDoc&&(e.preventDefault(),n.currentDoc.addEventListener("mousemove",n.onMouseMove),n.currentDoc.addEventListener("mouseup",n.onDragStopped),n.onDragStart(t.getMousePoint(e)))},n.onMouseMove=function(e){return n.onDrag(t.getMousePoint(e))},n.onTouchStart=function(e){n.currentDoc&&(n.isTouching=!0,n.props.onTouchRequest&&!n.props.onTouchRequest(e)||(n.currentDoc.addEventListener("touchmove",n.onTouchMove,{passive:!1}),n.currentDoc.addEventListener("touchend",n.onDragStopped),2===e.touches.length?n.onPinchStart(e):1===e.touches.length&&n.onDragStart(t.getTouchPoint(e.touches[0]))))},n.onTouchMove=function(e){e.preventDefault(),2===e.touches.length?n.onPinchMove(e):1===e.touches.length&&n.onDrag(t.getTouchPoint(e.touches[0]))},n.onGestureStart=function(e){n.currentDoc&&(e.preventDefault(),n.currentDoc.addEventListener("gesturechange",n.onGestureMove),n.currentDoc.addEventListener("gestureend",n.onGestureEnd),n.gestureZoomStart=n.props.zoom,n.gestureRotationStart=n.props.rotation)},n.onGestureMove=function(e){if(e.preventDefault(),!n.isTouching){var r=t.getMousePoint(e),i=n.gestureZoomStart-1+e.scale;if(n.setNewZoom(i,r,{shouldUpdatePosition:!0}),n.props.onRotationChange){var o=n.gestureRotationStart+e.rotation;n.props.onRotationChange(o)}}},n.onGestureEnd=function(e){n.cleanEvents()},n.onDragStart=function(e){var t,r,i=e.x,o=e.y;n.dragStartPosition={x:i,y:o},n.dragStartCrop=$K({},n.props.crop),null===(r=(t=n.props).onInteractionStart)||void 0===r||r.call(t)},n.onDrag=function(e){var t=e.x,r=e.y;n.currentWindow&&(n.rafDragTimeout&&n.currentWindow.cancelAnimationFrame(n.rafDragTimeout),n.rafDragTimeout=n.currentWindow.requestAnimationFrame((function(){if(n.state.cropSize&&void 0!==t&&void 0!==r){var e=t-n.dragStartPosition.x,i=r-n.dragStartPosition.y,o={x:n.dragStartCrop.x+e,y:n.dragStartCrop.y+i},a=n.props.restrictPosition?nY(o,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):o;n.props.onCropChange(a)}})))},n.onDragStopped=function(){var e,t;n.isTouching=!1,n.cleanEvents(),n.emitCropData(),null===(t=(e=n.props).onInteractionEnd)||void 0===t||t.call(e)},n.onWheel=function(e){if(n.currentWindow&&(!n.props.onWheelRequest||n.props.onWheelRequest(e))){e.preventDefault();var i=t.getMousePoint(e),o=r(eY)(e).pixelY,a=n.props.zoom-o*n.props.zoomSpeed/200;n.setNewZoom(a,i,{shouldUpdatePosition:!0}),n.state.hasWheelJustStarted||n.setState({hasWheelJustStarted:!0},(function(){var e,t;return null===(t=(e=n.props).onInteractionStart)||void 0===t?void 0:t.call(e)})),n.wheelTimer&&clearTimeout(n.wheelTimer),n.wheelTimer=n.currentWindow.setTimeout((function(){return n.setState({hasWheelJustStarted:!1},(function(){var e,t;return null===(t=(e=n.props).onInteractionEnd)||void 0===t?void 0:t.call(e)}))}),250)}},n.getPointOnContainer=function(e){var t=e.x,r=e.y;if(!n.containerRect)throw new Error("The Cropper is not mounted");return{x:n.containerRect.width/2-(t-n.containerRect.left),y:n.containerRect.height/2-(r-n.containerRect.top)}},n.getPointOnMedia=function(e){var t=e.x,r=e.y,i=n.props,o=i.crop,a=i.zoom;return{x:(t+o.x)/a,y:(r+o.y)/a}},n.setNewZoom=function(e,t,r){var i=(void 0===r?{}:r).shouldUpdatePosition,o=void 0===i||i;if(n.state.cropSize&&n.props.onZoomChange){var a=hY(e,n.props.minZoom,n.props.maxZoom);if(o){var s=n.getPointOnContainer(t),l=n.getPointOnMedia(s),c={x:l.x*a-s.x,y:l.y*a-s.y},u=n.props.restrictPosition?nY(c,n.mediaSize,n.state.cropSize,a,n.props.rotation):c;n.props.onCropChange(u)}n.props.onZoomChange(a)}},n.getCropData=function(){return n.state.cropSize?aY(n.props.restrictPosition?nY(n.props.crop,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):n.props.crop,n.mediaSize,n.state.cropSize,n.getAspect(),n.props.zoom,n.props.rotation,n.props.restrictPosition):null},n.emitCropData=function(){var e=n.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;n.props.onCropComplete&&n.props.onCropComplete(t,r),n.props.onCropAreaChange&&n.props.onCropAreaChange(t,r)}},n.emitCropAreaChange=function(){var e=n.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;n.props.onCropAreaChange&&n.props.onCropAreaChange(t,r)}},n.recomputeCropPosition=function(){if(n.state.cropSize){var e=n.props.restrictPosition?nY(n.props.crop,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):n.props.crop;n.props.onCropChange(e),n.emitCropData()}},n}return ZK(t,e),t.prototype.componentDidMount=function(){this.currentDoc&&this.currentWindow&&(this.containerRef&&(this.containerRef.ownerDocument&&(this.currentDoc=this.containerRef.ownerDocument),this.currentDoc.defaultView&&(this.currentWindow=this.currentDoc.defaultView),this.initResizeObserver(),void 0===window.ResizeObserver&&this.currentWindow.addEventListener("resize",this.computeSizes),this.props.zoomWithScroll&&this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}),this.containerRef.addEventListener("gesturestart",this.onGestureStart)),this.props.disableAutomaticStylesInjection||(this.styleRef=this.currentDoc.createElement("style"),this.styleRef.setAttribute("type","text/css"),this.props.nonce&&this.styleRef.setAttribute("nonce",this.props.nonce),this.styleRef.innerHTML=".reactEasyCrop_Container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n user-select: none;\n touch-action: none;\n cursor: move;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.reactEasyCrop_Image,\n.reactEasyCrop_Video {\n will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */\n}\n\n.reactEasyCrop_Contain {\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n}\n.reactEasyCrop_Cover_Horizontal {\n width: 100%;\n height: auto;\n}\n.reactEasyCrop_Cover_Vertical {\n width: auto;\n height: 100%;\n}\n\n.reactEasyCrop_CropArea {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n border: 1px solid rgba(255, 255, 255, 0.5);\n box-sizing: border-box;\n box-shadow: 0 0 0 9999em;\n color: rgba(0, 0, 0, 0.5);\n overflow: hidden;\n}\n\n.reactEasyCrop_CropAreaRound {\n border-radius: 50%;\n}\n\n.reactEasyCrop_CropAreaGrid::before {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 0;\n bottom: 0;\n left: 33.33%;\n right: 33.33%;\n border-top: 0;\n border-bottom: 0;\n}\n\n.reactEasyCrop_CropAreaGrid::after {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 33.33%;\n bottom: 33.33%;\n left: 0;\n right: 0;\n border-left: 0;\n border-right: 0;\n}\n",this.currentDoc.head.appendChild(this.styleRef)),this.imageRef.current&&this.imageRef.current.complete&&this.onMediaLoad(),this.props.setImageRef&&this.props.setImageRef(this.imageRef),this.props.setVideoRef&&this.props.setVideoRef(this.videoRef))},t.prototype.componentWillUnmount=function(){var e,t;this.currentDoc&&this.currentWindow&&(void 0===window.ResizeObserver&&this.currentWindow.removeEventListener("resize",this.computeSizes),null===(e=this.resizeObserver)||void 0===e||e.disconnect(),this.containerRef&&this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.styleRef&&(null===(t=this.styleRef.parentNode)||void 0===t||t.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},t.prototype.componentDidUpdate=function(e){var t,n,r,i,o,a,s,l,c;e.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):e.aspect!==this.props.aspect?this.computeSizes():e.zoom!==this.props.zoom?this.recomputeCropPosition():(null===(t=e.cropSize)||void 0===t?void 0:t.height)!==(null===(n=this.props.cropSize)||void 0===n?void 0:n.height)||(null===(r=e.cropSize)||void 0===r?void 0:r.width)!==(null===(i=this.props.cropSize)||void 0===i?void 0:i.width)?this.computeSizes():(null===(o=e.crop)||void 0===o?void 0:o.x)===(null===(a=this.props.crop)||void 0===a?void 0:a.x)&&(null===(s=e.crop)||void 0===s?void 0:s.y)===(null===(l=this.props.crop)||void 0===l?void 0:l.y)||this.emitCropAreaChange(),e.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),e.video!==this.props.video&&(null===(c=this.videoRef.current)||void 0===c||c.load())},t.prototype.getAspect=function(){var e=this.props,t=e.cropSize,n=e.aspect;return t?t.width/t.height:n},t.prototype.onPinchStart=function(e){var n=t.getTouchPoint(e.touches[0]),r=t.getTouchPoint(e.touches[1]);this.lastPinchDistance=iY(n,r),this.lastPinchRotation=oY(n,r),this.onDragStart(dY(n,r))},t.prototype.onPinchMove=function(e){var n=this;if(this.currentDoc&&this.currentWindow){var r=t.getTouchPoint(e.touches[0]),i=t.getTouchPoint(e.touches[1]),o=dY(r,i);this.onDrag(o),this.rafPinchTimeout&&this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=this.currentWindow.requestAnimationFrame((function(){var e=iY(r,i),t=n.props.zoom*(e/n.lastPinchDistance);n.setNewZoom(t,o,{shouldUpdatePosition:!1}),n.lastPinchDistance=e;var a=oY(r,i),s=n.props.rotation+(a-n.lastPinchRotation);n.props.onRotationChange&&n.props.onRotationChange(s),n.lastPinchRotation=a}))}},t.prototype.render=function(){var e=this,t=this.props,n=t.image,i=t.video,o=t.mediaProps,a=t.transform,s=t.crop,l=s.x,c=s.y,d=t.rotation,f=t.zoom,h=t.cropShape,p=t.showGrid,m=t.style,g=m.containerStyle,v=m.cropAreaStyle,y=m.mediaStyle,b=t.classes,w=b.containerClassName,x=b.cropAreaClassName,S=b.mediaClassName,M=t.objectFit;return r(u).createElement("div",{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:function(t){return e.containerRef=t},"data-testid":"container",style:g,className:pY("reactEasyCrop_Container",w)},n?r(u).createElement("img",$K({alt:"",className:pY("reactEasyCrop_Image","contain"===M&&"reactEasyCrop_Contain","horizontal-cover"===M&&"reactEasyCrop_Cover_Horizontal","vertical-cover"===M&&"reactEasyCrop_Cover_Vertical","auto-cover"===M&&(this.mediaSize.naturalWidth>this.mediaSize.naturalHeight?"reactEasyCrop_Cover_Horizontal":"reactEasyCrop_Cover_Vertical"),S)},o,{src:n,ref:this.imageRef,style:$K($K({},y),{transform:a||"translate(".concat(l,"px, ").concat(c,"px) rotate(").concat(d,"deg) scale(").concat(f,")")}),onLoad:this.onMediaLoad})):i&&r(u).createElement("video",$K({autoPlay:!0,loop:!0,muted:!0,className:pY("reactEasyCrop_Video","contain"===M&&"reactEasyCrop_Contain","horizontal-cover"===M&&"reactEasyCrop_Cover_Horizontal","vertical-cover"===M&&"reactEasyCrop_Cover_Vertical","auto-cover"===M&&(this.mediaSize.naturalWidth>this.mediaSize.naturalHeight?"reactEasyCrop_Cover_Horizontal":"reactEasyCrop_Cover_Vertical"),S)},o,{ref:this.videoRef,onLoadedMetadata:this.onMediaLoad,style:$K($K({},y),{transform:a||"translate(".concat(l,"px, ").concat(c,"px) rotate(").concat(d,"deg) scale(").concat(f,")")}),controls:!1}),(Array.isArray(i)?i:[{src:i}]).map((function(e){return r(u).createElement("source",$K({key:e.src},e))}))),this.state.cropSize&&r(u).createElement("div",{style:$K($K({},v),{width:this.state.cropSize.width,height:this.state.cropSize.height}),"data-testid":"cropper",className:pY("reactEasyCrop_CropArea","round"===h&&"reactEasyCrop_CropAreaRound",p&&"reactEasyCrop_CropAreaGrid",x)}))},t.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:3,minZoom:1,cropShape:"rect",objectFit:"contain",showGrid:!0,style:{},classes:{},mediaProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0},t.getMousePoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t.getTouchPoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t}(r(u).Component);var gY=function(){return gY=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},gY.apply(this,arguments)};function vY(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}function yY(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var bY="img-crop",wY=.1,xY=(0,u.forwardRef)((function(e,t){var n=e.cropperRef,i=e.image,o=e.aspect,a=e.shape,s=e.grid,l=e.zoom,c=e.rotate,d=e.minZoom,f=e.maxZoom,h=e.cropperProps,p=(0,u.useState)({x:0,y:0}),m=p[0],g=p[1],v=(0,u.useState)({width:0,height:0}),y=v[0],b=v[1],w=(0,u.useState)(1),x=w[0],S=w[1],M=(0,u.useState)(0),_=M[0],A=M[1],E=(0,u.useRef)({width:0,height:0,x:0,y:0}),C=(0,u.useCallback)((function(e){var t=e.width,n=e.height,r=n*o;b(t>r?{width:r,height:n}:{width:t,height:t/o})}),[o]),k=(0,u.useCallback)((function(e,t){E.current=t}),[]);return(0,u.useImperativeHandle)(t,(function(){return{rotateVal:_,setZoomVal:S,setRotateVal:A,cropPixelsRef:E}}),[_]),r(u).createElement(r(u).Fragment,null,r(u).createElement(mY,gY({},h,{ref:n,image:i,crop:m,cropSize:y,onCropChange:g,aspect:o,cropShape:a,showGrid:s,zoomWithScroll:l,zoom:x,rotation:_,onZoomChange:S,onRotationChange:A,minZoom:d,maxZoom:f,onMediaLoaded:C,onCropComplete:k,classes:{containerClassName:"".concat(bY,"-container"),mediaClassName:"".concat(bY,"-media")}})),l&&r(u).createElement("section",{className:"".concat(bY,"-control ").concat(bY,"-control-zoom")},r(u).createElement("button",{onClick:function(){return S(x-wY)},disabled:x-wY<d},"-"),r(u).createElement(Xq.default,{min:d,max:f,step:wY,value:x,onChange:S}),r(u).createElement("button",{onClick:function(){return S(x+wY)},disabled:x+wY>f},"+")),c&&r(u).createElement("section",{className:"".concat(bY,"-control ").concat(bY,"-control-rotate")},r(u).createElement("button",{onClick:function(){return A(_-1)},disabled:-180===_},"↺"),r(u).createElement(Xq.default,{min:-180,max:180,step:1,value:_,onChange:A}),r(u).createElement("button",{onClick:function(){return A(_+1)},disabled:180===_},"↻")))})),SY=(0,u.memo)(xY);!function(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");t.setAttribute("media","screen"),t.innerHTML=e,document.head.appendChild(t)}}(".img-crop-modal .img-crop-container {\n position: relative;\n width: 100%;\n height: 40vh;\n}\n.img-crop-modal .img-crop-control {\n display: flex;\n align-items: center;\n width: 60%;\n margin-left: auto;\n margin-right: auto;\n}\n.img-crop-modal .img-crop-control:first-of-type {\n margin-top: 16px;\n}\n.img-crop-modal .img-crop-control:last-of-type {\n margin-bottom: -8px;\n}\n.img-crop-modal .img-crop-control button {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 34px;\n height: 34px;\n padding: 0;\n font-style: normal;\n background: transparent;\n border: 0;\n outline: 0;\n cursor: pointer;\n}\n.img-crop-modal .img-crop-control button[disabled] {\n cursor: default;\n}\n.img-crop-modal .img-crop-control button + div:only-of-type {\n flex: 1;\n margin: 0 8px;\n}\n.img-crop-modal .img-crop-control-zoom button {\n font-size: 18px;\n}\n.img-crop-modal .img-crop-control-rotate button {\n font-size: 16px;\n}\n.img-crop-modal .img-crop-control-rotate button:first-of-type {\n transform: rotate(-20deg);\n}\n.img-crop-modal .img-crop-control-rotate button:last-of-type {\n transform: rotate(20deg);\n}\n");var MY=(0,u.forwardRef)((function(e,t){var n=e.aspect,i=void 0===n?1:n,o=e.shape,a=void 0===o?"rect":o,s=e.grid,l=void 0!==s&&s,c=e.quality,d=void 0===c?.4:c,f=e.fillColor,h=void 0===f?"white":f,p=e.zoom,m=void 0===p||p,g=e.rotate,v=void 0!==g&&g,y=e.minZoom,b=void 0===y?1:y,w=e.maxZoom,x=void 0===w?3:w,S=e.modalTitle,M=e.modalWidth,_=e.modalOk,A=e.modalCancel,E=e.modalMaskTransitionName,C=e.modalTransitionName,k=e.onModalOk,T=e.onModalCancel,I=e.beforeCrop,O=e.onUploadFail,R=e.cropperProps,P=e.children,N=(0,u.useRef)({});N.current.onModalOk=k,N.current.onModalCancel=T,N.current.beforeCrop=I,N.current.onUploadFail=O;var L=(0,u.useState)(""),D=L[0],B=L[1],j=(0,u.useRef)(),F=(0,u.useRef)(),U=(0,u.useRef)(),z=(0,u.useRef)(),H=(0,u.useMemo)((function(){var e=Array.isArray(P)?P[0]:P,t=e.props,n=t.beforeUpload,r=t.accept,i=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(t,["beforeUpload","accept"]);return F.current=n,gY(gY({},e),{props:gY(gY({},i),{accept:r||"image/*",beforeUpload:function(e,t){return new Promise((function(n,r){return vY(void 0,void 0,void 0,(function(){var i;return yY(this,(function(o){switch(o.label){case 0:return N.current.beforeCrop?[4,N.current.beforeCrop(e,t)]:[3,2];case 1:if(!o.sent())return[2,r()];o.label=2;case 2:return j.current=e,U.current=function(e){var t,r;null===(r=(t=N.current).onModalOk)||void 0===r||r.call(t,e),n(e)},z.current=function(e){var t,n;null===(n=(t=N.current).onUploadFail)||void 0===n||n.call(t,e),r()},(i=new FileReader).addEventListener("load",(function(){"string"==typeof i.result&&B(i.result)})),i.readAsDataURL(e),[2]}}))}))}))}})})}),[P]),V=(0,u.useRef)({}),W=(0,u.useMemo)((function(){var e={width:M,okText:_,cancelText:A,maskTransitionName:E,transitionName:C};return Object.keys(e).forEach((function(t){e[t]||delete e[t]})),e}),[A,E,_,C,M]),G=function(){B(""),V.current.setZoomVal(1),V.current.setRotateVal(0)},q=(0,u.useCallback)((function(){var e,t;null===(t=(e=N.current).onModalCancel)||void 0===t||t.call(e),G()}),[]),K=(0,u.useCallback)((function(){return vY(void 0,void 0,void 0,(function(){var e,t,n,r,i,o,a,s,l,c,u,f,p,m,g,y,b,w,x,S,M,_,A,E;return yY(this,(function(C){return G(),e=document.createElement("canvas"),t=e.getContext("2d"),n=document.querySelector(".".concat(bY,"-media")),r=V.current.cropPixelsRef.current,i=r.width,o=r.height,a=r.x,s=r.y,v&&0!==V.current.rotateVal?(l=n.naturalWidth,c=n.naturalHeight,u=V.current.rotateVal*(Math.PI/180),f=Math.abs(Math.sin(u)),p=Math.abs(Math.cos(u)),m=l*p+c*f,g=c*p+l*f,e.width=m,e.height=g,t.fillStyle=h,t.fillRect(0,0,m,g),y=m/2,b=g/2,t.translate(y,b),t.rotate(u),t.translate(-y,-b),w=(m-l)/2,x=(g-c)/2,t.drawImage(n,0,0,l,c,w,x,l,c),S=t.getImageData(0,0,m,g),e.width=i,e.height=o,t.putImageData(S,-a,-s)):(e.width=i,e.height=o,t.fillStyle=h,t.fillRect(0,0,i,o),t.drawImage(n,a,s,i,o,0,0,i,o)),M=j.current,_=M.type,A=M.name,E=M.uid,e.toBlob((function(e){return vY(void 0,void 0,void 0,(function(){var t,n;return yY(this,(function(r){switch(r.label){case 0:return t=Object.assign(new File([e],A,{type:_}),{uid:E}),F.current?[4,F.current(t,[t])]:[2,U.current(t)];case 1:return!0===(n=r.sent())?[2,U.current(t)]:!1===n?[2,z.current(new Error("beforeUpload return false"))]:(delete t[Qq.LIST_IGNORE],n===Qq.LIST_IGNORE?(Object.defineProperty(t,Qq.LIST_IGNORE,{value:!0,configurable:!0}),[2,z.current(new Error("beforeUpload return LIST_IGNORE"))]):"object"==typeof n&&null!==n?[2,U.current(n)]:[2])}}))}))}),_,d),[2]}))}))}),[h,d,v]),Y=function(e){return r(u).createElement(r(u).Fragment,null,H,D&&r(u).createElement(SG,gY({visible:!0,wrapClassName:"".concat(bY,"-modal"),title:e,onOk:K,onCancel:q,maskClosable:!1,destroyOnClose:!0},W),r(u).createElement(SY,{ref:V,cropperRef:t,image:D,aspect:i,shape:a,grid:l,zoom:m,rotate:v,minZoom:b,maxZoom:x,cropperProps:R})))};return S?Y(S):r(u).createElement(sH,null,(function(e,t){return Y("zh-cn"===t?"编辑图片":"Edit image")}))}));var _Y=({className:e,title:t})=>(0,s.jsx)("svg",{...t?{}:{"aria-hidden":"true"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",focusable:"false",role:"img",className:e,"aria-label":t,children:(0,s.jsx)("path",{d:"M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"})});const AY=["image/jpeg","image/png","image/jpg","image/gif"],EY=({originNode:e,file:t,tenantID:n,apiUrl:r,actions:i,resourceType:o})=>{var a,l,c,u;const{t:d}=Te();return(0,s.jsxs)("div",{className:"memori--list-item-wrapper"+("uploading"===t.status?" listItemUploading":""),children:[(0,s.jsx)(dp,{spinning:"uploading"===t.status,children:"error"===t.status?(0,s.jsx)(zm,{content:d("media.uploadError"),children:e.props.children}):(0,s.jsx)(Xy,{item:{mediumID:t.uid,mimeType:"uploading"===t.status?"image/png":(null===(a=t.name)||void 0===a?void 0:a.endsWith(".glb"))?"model/gltf-binary":t.type||"image/png",title:null!==(l=t.name)&&void 0!==l?l:"",url:"uploading"===t.status?"":(null===(u=null===(c=t.response)||void 0===c?void 0:c.asset)||void 0===u?void 0:u.assetURL)?t.response.asset.assetURL:jm({type:o,resourceURI:t.thumbUrl,tenantID:n,apiURL:r}),content:`${jm({resourceURI:t.thumbUrl,type:o,apiURL:r})}`},preview:!1})}),("success"===t.status||"done"===t.status)&&(0,s.jsxs)("div",{className:"list-item-actions",children:[(0,s.jsx)(Zd,{outlined:!0,shape:"circle",icon:(0,s.jsx)(Wj,{}),className:"action-button",title:d("edit")||"Edit",onClick:()=>null==i?void 0:i.download(t)}),(0,s.jsx)(Zd,{outlined:!0,shape:"circle",icon:(0,s.jsx)(_Y,{}),className:"action-button",title:d("delete")||"Delete",onClick:()=>null==i?void 0:i.remove(t)})]})]})};var CY=({uploadMultipleImages:e,maxNumberOfVisualizedUploads:t,uploadUrl:n,apiUrl:i,tenantID:o,fileList:a,maxFileSizeInMB:l=2,fileResolution:c,useImageCrop:d,uploadMessage:f,imageProportions:h=1,imageProportionsHelper:p,allowedMimeTypes:m,onRemove:g,onFileChanged:v,onUploadFinished:y,onFileNotValid:b,disabled:w,showHelper:x,additionalHelper:S,resourceType:M})=>{var _;const{t:A}=Te(),[E,C]=(0,u.useState)(null!=a?a:[]),[k,T]=(0,u.useState)(),I=(0,s.jsx)(r($F),{className:"memori--upload",disabled:null!=w&&w,accept:(null===(_=null!=m?m:AY)||void 0===_?void 0:_.join(","))+";capture=camera,camcorder",action:n,listType:"picture-card",showUploadList:{showPreviewIcon:!0,showRemoveIcon:!0,showDownloadIcon:!0,downloadIcon:(0,s.jsx)(Wj,{title:A("edit")||"Edit"})},beforeUpload:e=>{if(!(null!=m?m:AY).find((t=>t===e.type))&&e.type)return console.debug("File not allowed",e,null!=m?m:AY),Qd.error(A("media.uploadMimeTypeNotAllowed")),b&&b(),Promise.reject(A("media.uploadMimeTypeNotAllowed"));if(!(e.size/1024/1024<(null!=l?l:2)))return Qd.error(A("media.uploadSizeLimitMessage",{size:l})),b&&b(),Promise.reject(A("media.uploadSizeLimitMessage",{size:l}));if(c&&c.length){const t=new FileReader;return t.readAsDataURL(e),new Promise(((n,r)=>{t.addEventListener("load",(t=>{var i,o,a,s=new Image;s.style.padding="0px",s.style.margin="0px",s.onload=()=>{s.width===c[0]&&s.height===c[1]?n(e):(Qd.error(A("media.uploadWrongResolutionMessage",{width:c[0],height:c[1]})),r(),b&&b())},s.src=null!==(a=null===(o=null===(i=t.target)||void 0===i?void 0:i.result)||void 0===o?void 0:o.toString())&&void 0!==a?a:""}))}))}return Promise.resolve(e)},supportServerRender:!0,fileList:E,multiple:e,maxCount:t||(e?100:1),onChange:e=>{C(e.fileList.map((e=>{var t;return{...e,status:null!==(t=e.status)&&void 0!==t?t:"error"}}))),"done"===e.file.status&&y&&y(e.file)},onRemove:g,onDownload:e=>{var t,n;let r=null===(t=e.response)||void 0===t?void 0:t.asset;if(r){let t=r.originalFileName&&e.name.includes(r.originalFileName)?r.originalFileName:e.name;T({...r,title:null!=t?t:r.title})}else T({assetID:e.uid,title:null!==(n=e.name)&&void 0!==n?n:e.fileName})},itemRender:(e,t,n,r)=>(0,s.jsx)(EY,{resourceType:M,originNode:e,file:t,fileList:E||n,actions:r,tenantID:o,apiUrl:i}),children:f});return(0,s.jsxs)("div",{"aria-live":"polite",children:[d?(0,s.jsx)(MY,{rotate:!0,aspect:h,fillColor:"transparent",modalCancel:A("cancel")||"Cancel",modalMaskTransitionName:"none",modalTransitionName:"none",children:I}):I,(0,s.jsxs)(hp,{open:!!k,title:A("media.editAttributes"),onClose:()=>{T(void 0)},footer:(0,s.jsx)(s.Fragment,{}),width:"100%",children:[(0,s.jsx)("label",{htmlFor:"media-title-input",className:"media-title-label",children:A("media.title")}),(0,s.jsx)("input",{id:"media-title-input",className:"media-title-input",type:"text",name:"title",defaultValue:(null==k?void 0:k.title)||"",onChange:e=>{T({...k,title:e.target.value})}}),(0,s.jsxs)("div",{className:"memori-modal--footer",children:[(0,s.jsx)(Zd,{onClick:()=>{T(void 0)},children:A("cancel")}),(0,s.jsx)(Zd,{primary:!0,onClick:()=>{v&&(null==k?void 0:k.assetID)&&v(k.assetID,{...k}),C((e=>e.map((e=>{var t,n;return e.uid===(null==k?void 0:k.assetID)||(null===(n=null===(t=e.response)||void 0===t?void 0:t.asset)||void 0===n?void 0:n.assetID)===(null==k?void 0:k.assetID)?{...e,title:null==k?void 0:k.title,name:null==k?void 0:k.title}:e})))),T(void 0)},children:A("confirm")})]})]}),x&&(0,s.jsxs)("legend",{className:"helper",children:[(0,s.jsx)("p",{children:A(m?"media.uploadHelper":"media.uploadHelperImages").replace("@size@",(null!=l?l:2).toString())}),p&&d&&(0,s.jsxs)("p",{children:[A("media.scaleRatio"),": ",p]}),S&&(0,s.jsx)("p",{children:S})]})]})};var kY=({visible:e,authToken:t,sessionID:n,tenantID:r,uploadAssetURL:i,deleteAsset:o,onCancel:a,onOk:l,apiURL:c})=>{const{t:d}=Te(),[f,h]=(0,u.useState)();return(0,s.jsx)(hp,{open:e,title:d("media.addMediaLabel"),className:"attachment-media-modal",closable:!0,width:"100%",widthMd:"100%",onClose:()=>{a&&a()},footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Zd,{onClick:a,children:d("cancel")}),(0,s.jsx)(Zd,{primary:!0,onClick:()=>{f&&l(f),h(void 0)},disabled:!f,children:d("confirm")})]}),children:(0,s.jsx)(CY,{tenantID:r,apiUrl:c,uploadMultipleImages:!1,maxNumberOfVisualizedUploads:1,maxFileSizeInMB:100,uploadUrl:i,useImageCrop:!1,allowedMimeTypes:_g,fileList:f?[{uid:"-1",name:f.assetID,status:"done",thumbUrl:jm({resourceURI:f.assetURL,tenantID:r,apiURL:c,sessionID:n})}]:[],uploadMessage:d("media.mediaUploadMessage"),imageProportions:1,onUploadFinished:e=>{let t=e.response.asset,n=e.response;0===n.resultCode?h(t):(console.error(n,e),Qd.error(d(ZF(n.resultCode))))},onFileChanged:(e,t)=>{h((e=>({...e||{},...t})))},onRemove:async e=>{const n=await o(t,e.thumbUrl);return 0===n.resultCode?h(void 0):(console.error(n,e),Qd.error(d(ZF(n.resultCode)))),0===n.resultCode}})})};u=a("85Hg2");var TY=({visible:e,onCancel:t,onOk:n})=>{var r,i,o;const{t:a}=Te(),[l,c]=(0,u.useState)({url:"",title:""}),d=e=>{if("Enter"===e.key){if(0===(null==l?void 0:l.url.length)||0===(null==l?void 0:l.title.length))return;let e=document.getElementById("save-link-button");e&&e.click()}};return(0,s.jsx)(hp,{open:e,title:a("media.addLinkLabel"),className:"attachment-link-modal",closable:!0,width:"100%",widthMd:"80%",onClose:()=>{t&&t()},footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Zd,{onClick:t,children:a("cancel")}),(0,s.jsx)(Zd,{id:"save-link-button",primary:!0,onClick:()=>{0!==(null==l?void 0:l.url.length)&&0!==(null==l?void 0:l.title.length)&&(n(l),c({url:"",title:""}))},disabled:0===(null==l?void 0:l.url.length)||0===(null==l?void 0:l.title.length),children:a("confirm")})]}),children:(0,s.jsxs)("div",{className:"attachment-link-modal--row",children:[(0,s.jsxs)("div",{className:"attachment-link-modal--column",children:[(0,s.jsxs)("label",{htmlFor:"new-link-url",className:"attachment-link-modal--label",children:[a("media.linkKey"),":"]}),(0,s.jsx)("input",{type:"url",className:"attachment-link-modal--input ",onChange:e=>{let t=e.target.value.startsWith("http")||0===e.target.value.length?e.target.value:`https://${e.target.value}`;c((e=>{var n;return{title:null!==(n=null==e?void 0:e.title)&&void 0!==n?n:"",url:t}}))},placeholder:"https://memori.ai/...",value:null==l?void 0:l.url,name:"url",onKeyDown:d}),(0,s.jsxs)("label",{htmlFor:"new-link-title",className:"attachment-link-modal--label",children:[a("media.linkValue"),":"]}),(0,s.jsx)("input",{type:"text",className:"attachment-link-modal--input ",onChange:e=>c((t=>{var n;return{url:null!==(n=null==t?void 0:t.url)&&void 0!==n?n:"",title:e.target.value}})),value:null==l?void 0:l.title,name:"title",onKeyDown:d})]}),(0,s.jsx)("div",{className:"attachment-link-modal--column",children:(0,s.jsx)("div",{className:"attachment-link-modal--centered",children:(0,s.jsx)(bg,{item:{title:null!==(r=null==l?void 0:l.title)&&void 0!==r?r:"",url:null!==(i=null==l?void 0:l.url)&&void 0!==i?i:"",mediumID:"",mimeType:"text/html"},onLinkPreviewInfo:e=>{var t;(null===(t=null==l?void 0:l.title)||void 0===t?void 0:t.length)||c((t=>{var n;return{...t,title:null!==(n=null==e?void 0:e.title)&&void 0!==n?n:""}}))}},null!==(o=null==l?void 0:l.url)&&void 0!==o?o:"")})})]})})};var IY=({tenant:e,userLang:t="en"})=>{const n="memorytwin"===(null==e?void 0:e.theme)?"memorytwin":"twincreator";return(0,s.jsxs)("div",{className:"memori--powered-by",children:[(0,s.jsx)("img",{src:`https://app.twincreator.com/images/${n}/logo.png`,alt:""}),(0,s.jsxs)("p",{children:["Powered by"," ",(0,s.jsx)("a",{href:`https://app.${n}.com/${t?t.toLowerCase():""}`,target:"_blank",rel:"noopener noreferrer",children:"memorytwin"===n?"MemoryTwin":"TwinCreator"})]})]})};var OY=({header:e,avatar:t,chat:n,startPanel:r,integrationStyle:i,integrationBackground:o,changeMode:a,sessionId:l,hasUserActivatedSpeak:c,showInstruct:u=!1,loading:d=!1,poweredBy:f})=>(0,s.jsxs)(s.Fragment,{children:[i,o,(0,s.jsxs)(dp,{spinning:d,children:[u&&a,e,(0,s.jsxs)("div",{className:"memori--grid",children:[(0,s.jsx)("div",{className:"memori--grid-column memori--grid-column-left",children:t}),(0,s.jsx)("div",{className:"memori--grid-column memori--grid-column-right",children:l&&c?n:r}),f]})]})]});var RY=({header:e,avatar:t,chat:n,startPanel:r,integrationStyle:i,integrationBackground:o,changeMode:a,sessionId:l,hasUserActivatedSpeak:c,showInstruct:u=!1,loading:d=!1,poweredBy:f})=>(0,s.jsxs)(s.Fragment,{children:[i,o,(0,s.jsxs)(dp,{spinning:d,className:"memori-totem-layout",children:[f,u&&a,(0,s.jsx)("div",{className:"memori-totem-layout--header",children:e}),(0,s.jsx)("div",{className:"memori-totem-layout--avatar",children:t}),(0,s.jsx)("div",{className:"memori-totem-layout--controls",children:l&&c?n:r})]})]});const PY={muteSpeaker:"@memori:muteSpeaker",continuousSpeech:"@memori:continuousSpeech",continuousSpeechTimeout:"@memori:continuousSpeechTimeout",sendOnEnter:"@memori:sendOnEnter",birthDate:"@memori:birthDate",controlsPosition:"@memori:controlsPosition"},NY=(e,t)=>{var n;const r=window.localStorage.getItem(null!==(n=PY[e])&&void 0!==n?n:e);if(!r)return t;try{return JSON.parse(r)}catch(e){return r}},LY=(e,t)=>{var n;window.localStorage.setItem(null!==(n=PY[e])&&void 0!==n?n:e,t.toString())},{deleteSession:DY,getStatistics:BY,initSession:jY}=W(),FY=new Map([[0,"🆕"],[10,"🐹"],[20,"🐇"],[30,"🐰"],[40,"💡"],[50,"🏆"],[60,"🏅"],[70,"🥉"],[80,"🥈"],[90,"🥇"],[100,"🔥"],[110,"🎓"],[120,"🤖"],[130,"👾"],[150,"🌍"],[180,"💜"],[200,"💙"],[250,"🧡"],[300,"💚"],[350,"💛"],[400,"💖"],[450,"💝"],[500,"🖤"],[550,"❤️"],[600,"🧠"]]),UY=e=>{const t=Array.from(FY.keys()).filter((t=>t<=e));if(t.length>0){const e=t[t.length-1];return FY.get(e)}return""},zY=e=>{if("🆕"===e)return{points:10,badge:"🐹"};let t,n,r=!1;for(const[i,o]of FY){if(r){t=i,n=o;break}o===e&&(r=!0)}return n&&t?{points:t,badge:n}:void 0},HY=e=>{let t=0;for(const[n,r]of FY)if(r===e){t=n;break}return t},VY=e=>{const t=Math.round(e),n=UY(t);return{points:t,badge:n,pointsForCurrentBadge:HY(n),nextBadge:zY(n)}};var WY=a("agy8n");u=a("85Hg2"),WY=a("agy8n");const GY={en:["January","February","March","April","May","June","July","August","September","October","November","December"],it:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"]},qY=(0,u.memo)((({defaultDate:e,onChange:t,disabled:n=!1})=>{const{t:i,i18n:o}=Te(),[a,l]=(0,u.useState)(r(WY)(e||Date.now()));return(0,u.useEffect)((()=>{t(a)}),[a,t]),r(WY).locale(o.language),(0,s.jsxs)("div",{className:"memori--date-selector",children:[(0,s.jsx)("div",{className:"memori--date-selector__select",children:(0,s.jsxs)(Xb,{value:a,onChange:e=>{l(e)},disabled:n,name:"day",children:[(0,s.jsxs)(Xb.Label,{className:"memori--date-selector__select-label",children:[i("day"),":"]}),(0,s.jsxs)(Xb.Button,{"aria-label":i("day"),className:"memori--date-selector__select-button",children:[(0,s.jsx)("span",{className:"memori--date-selector__select--value",children:a.date()}),(0,s.jsx)("span",{className:"memori--date-selector__select--icon",children:(0,s.jsx)(Zb,{})})]}),(0,s.jsx)(Jf,{as:u.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,s.jsx)(Xb.Options,{className:"memori--date-selector__select-options",children:[...Array(31).keys()].map((e=>(0,s.jsx)(Xb.Option,{value:a.clone().date(e+1),className:"memori--date-selector__select-option",children:e+1},e)))})})]})}),(0,s.jsx)("div",{className:"memori--date-selector__select",children:(0,s.jsxs)(Xb,{value:a,onChange:e=>{l(e)},disabled:n,name:"month",children:[(0,s.jsxs)(Xb.Label,{className:"memori--date-selector__select-label",children:[i("month"),":"]}),(0,s.jsxs)(Xb.Button,{"aria-label":i("month"),className:"memori--date-selector__select-button",children:[(0,s.jsx)("span",{className:"memori--date-selector__select--value",children:GY["it"===o.language?"it":"en"][a.month()]}),(0,s.jsx)("span",{className:"memori--date-selector__select--icon",children:(0,s.jsx)(Zb,{})})]}),(0,s.jsx)(Jf,{as:u.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,s.jsx)(Xb.Options,{className:"memori--date-selector__select-options",children:GY["it"===o.language?"it":"en"].map((e=>(0,s.jsx)(Xb.Option,{className:"memori--date-selector__select-option",value:a.clone().month(GY["it"===o.language?"it":"en"].findIndex((t=>t===e))),children:e},e)))})})]})}),(0,s.jsx)("div",{className:"memori--date-selector__select",children:(0,s.jsxs)(Xb,{value:a,onChange:e=>{l(e)},disabled:n,name:"year",children:[(0,s.jsxs)(Xb.Label,{className:"memori--date-selector__select-label",children:[i("year"),":"]}),(0,s.jsxs)(Xb.Button,{"aria-label":i("year"),className:"memori--date-selector__select-button",children:[(0,s.jsx)("span",{className:"memori--date-selector__select--value",children:a.year()}),(0,s.jsx)("span",{className:"memori--date-selector__select--icon",children:(0,s.jsx)(Zb,{})})]}),(0,s.jsx)(Jf,{as:u.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,s.jsx)(Xb.Options,{className:"memori--date-selector__select-options",children:[...Array(r(WY)().year()-1899).keys()].sort(((e,t)=>t-e)).map((e=>(0,s.jsx)(Xb.Option,{value:a.clone().year(e+1900),className:"memori--date-selector__select-option",children:e+1900},e)))})})]})})]})}));qY.displayName="DateSelector";var KY=qY;u=a("85Hg2");var YY=({visible:e=!1,onClose:t,minAge:n})=>{const{t:i}=Te(),[o,a]=(0,u.useState)(),[l,c]=(0,u.useState)(),d=(0,u.useCallback)((()=>{if(!o)return Qd.error(i("requiredField")),void c(i("requiredField")||"Required field");if(r(WY)().diff(o,"years")<n)return Qd.error(i("underageTwinSession",{age:n})),void c(i("underageTwinSession",{age:n})||`You must be at least ${n} years old to interact with this Twin`);t(o.toISOString())}),[o,n,t,i]);return(0,s.jsxs)(hp,{open:e,title:i("ageVerification"),className:"age-verification-modal",closable:!0,onClose:()=>t(),children:[(0,s.jsx)("p",{children:i("ageVerificationText",{minAge:n})}),(0,s.jsxs)("form",{className:"age-verification-form",onSubmit:e=>{e.preventDefault(),d()},children:[(0,s.jsx)("div",{className:"form-item",children:(0,s.jsxs)("fieldset",{name:"birthDate",children:[(0,s.jsx)("legend",{className:"sr-only",children:i("birthDate")}),(0,s.jsx)(KY,{defaultDate:new Date(Date.now()),onChange:e=>{a(e)}}),(0,s.jsx)("p",{className:"form-item-help",children:i("birthDateHelper")}),l&&(0,s.jsx)("p",{className:"form-item-error",children:l})]})}),(0,s.jsx)("div",{className:"form-item form-submit",children:(0,s.jsx)(Zd,{primary:!0,htmlType:"submit",className:"age-verification-submit",disabled:!o,children:i("confirm")})})]})]})};u=a("85Hg2"),Jd=a("4IUwl");var JY=({open:e=!1,onClose:t,className:n,title:i,description:o,children:a,footer:l,loading:c=!1,side:d="right",closable:f=!0,width:h="100%",widthMd:p="80%",widthLg:m="60%"})=>(0,s.jsx)(Jf,{appear:!0,show:e,as:r(u).Fragment,children:(0,s.jsxs)(up,{open:e,onClose:t,className:r(Jd)("memori-drawer",n),children:[(0,s.jsx)(Jf.Child,{as:r(u).Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,s.jsx)("div",{className:"memori-drawer--backdrop"})}),(0,s.jsx)("div",{className:"memori-drawer--container",children:(0,s.jsx)("div",{className:"memori-drawer--container-scrollable",children:(0,s.jsx)(Jf.Child,{as:r(u).Fragment,enter:"ease-out duration-300",enterFrom:"max-w-0 opacity-0",enterTo:"max-w-100 opacity-100",leave:"ease-in duration-200",leaveFrom:"max-w-100 opacity-100",leaveTo:"max-w-0 opacity-0",children:(0,s.jsxs)(up.Panel,{className:r(Jd)("memori-drawer--panel",{"memori-drawer--panel-left":"left"===d,"memori-drawer--with-footer":!!l}),children:[(0,s.jsx)("style",{dangerouslySetInnerHTML:{__html:`\n .memori-drawer--panel {\n --memori-drawer--width: ${h};\n --memori-drawer--width-lg: ${m};\n --memori-drawer--width-md: ${p};\n }\n `}}),f&&(0,s.jsx)("div",{className:"memori-drawer--close",children:(0,s.jsx)(Zd,{shape:"circle",outlined:!0,icon:(0,s.jsx)(fp,{}),onClick:()=>t(!1)})}),(0,s.jsxs)(dp,{spinning:c,children:[i&&(0,s.jsx)(up.Title,{className:"memori-drawer--title",children:i}),o&&(0,s.jsx)(up.Description,{className:"memori-drawer--description",children:o}),a,l&&(0,s.jsx)("div",{className:"memori-drawer--footer",children:l})]})]})})})})]})});Jd=a("4IUwl");var QY=({label:e,className:t,disabled:n=!1,checked:i,children:o,onChange:a,name:l,...c})=>(0,s.jsxs)("label",{className:r(Jd)("memori-checkbox",t,{"memori-checkbox--disabled":n}),children:[(0,s.jsxs)("span",{className:"memori-checkbox--input-wrapper",children:[(0,s.jsx)("input",{type:"checkbox",...c,name:l,disabled:n,defaultChecked:i,className:"memori-checkbox--input",onChange:a}),(0,s.jsx)("span",{className:"memori-checkbox--inner"})]}),(0,s.jsx)("span",{className:"memori-checkbox--text",children:e})]});const XY=[2,3,5,10,15,20,30,60];var ZY=({open:e,layout:t="DEFAULT",onClose:n,continuousSpeech:r,continuousSpeechTimeout:i,setContinuousSpeech:o,setContinuousSpeechTimeout:a,controlsPosition:l,setControlsPosition:c})=>{const{t:u}=Te();return(0,s.jsxs)(JY,{className:"memori-settings-drawer",open:e,onClose:n,title:u("widget.settings")||"Settings",description:u("write_and_speak.settingsHeaderLabel"),children:[(0,s.jsx)("div",{className:"memori-settings-drawer--field",children:(0,s.jsx)(QY,{label:u("write_and_speak.continuousSpeechLabel"),checked:r,onChange:e=>{o(e.target.checked),LY("continuousSpeech",e.target.checked),e.target.checked||"hidden"!==l||(c("bottom"),LY("controlsPosition","bottom"))}})}),(0,s.jsx)("div",{className:"memori-settings-drawer--field",children:(0,s.jsx)($b,{label:u("write_and_speak.secondsLabel")||"Seconds",placeholder:u("write_and_speak.secondsLabel")||"Seconds",options:XY.map((e=>({value:e,label:e}))),value:i,onChange:e=>{a(e),LY("continuousSpeechTimeout",e)}})}),"TOTEM"===t&&(0,s.jsxs)("div",{className:"memori-settings-drawer--field controls",children:[(0,s.jsxs)("label",{htmlFor:"#controlsPosition",children:[u("write_and_speak.controlsPosition")||"Controls",":"]}),(0,s.jsxs)(Sb,{id:"controlsPosition",name:"controlsPosition",value:l,defaultValue:l,className:"memori-settings-drawer--controlsposition-radio",onChange:e=>{c(e),LY("controlsPosition",e)},children:[(0,s.jsx)(Sb.Option,{value:"center",className:"memori-settings-drawer--controlsposition-radio-button",children:({checked:e})=>(0,s.jsx)(Zd,{primary:e,children:u("center")||"Center"})}),(0,s.jsx)(Sb.Option,{value:"bottom",className:"memori-settings-drawer--controlsposition-radio-button",children:({checked:e})=>(0,s.jsx)(Zd,{primary:e,children:u("bottom")||"Bottom"})}),!!r&&(0,s.jsx)(Sb.Option,{value:"hidden",className:"memori-settings-drawer--controlsposition-radio-button",children:({checked:e})=>(0,s.jsx)(Zd,{primary:e,children:u("hidden")||"Hidden"})})]})]})]})};let $Y,eJ,tJ,nJ,rJ;window.getMemoriState=e=>{var t,n,r,i,o;let a=e?document.querySelector(`.memori-widget[data-memori-integration="${e}"]`)||(null===(n=null===(t=document.querySelector("memori-client"))||void 0===t?void 0:t.shadowRoot)||void 0===n?void 0:n.querySelector(".memori-widget[data-memori-integration]")):document.querySelector(".memori-widget")||(null===(i=null===(r=document.querySelector("memori-client"))||void 0===r?void 0:r.shadowRoot)||void 0===i?void 0:i.querySelector(".memori-widget"));if(!a)return null;let s=null===(o=a.dataset)||void 0===o?void 0:o.memoriEngineState;return s?JSON.parse(s):null},window.typeMessage=e=>{var t,n;let r=document.querySelector("fieldset#chat-fieldset textarea")||(null===(n=null===(t=document.querySelector("memori-client"))||void 0===t?void 0:t.shadowRoot)||void 0===n?void 0:n.querySelector("fieldset#chat-fieldset textarea"));r&&(!function(e,t){var n,r,i,o;const a=null===(r=null===(n=null==Object?void 0:Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,"value"))||void 0===r?void 0:r.set,s=Object.getPrototypeOf(e),l=null===(o=null===(i=null==Object?void 0:Object.getOwnPropertyDescriptor)||void 0===i?void 0:i.call(Object,s,"value"))||void 0===o?void 0:o.set;l&&a&&a!==l?l.call(e,t):a&&a.call(e,t)}(r,e),r.dispatchEvent(new Event("input",{bubbles:!0})),setTimeout((()=>{var e,t;let n=document.querySelector("button.memori-chat-inputs--send")||(null===(t=null===(e=document.querySelector("memori-client"))||void 0===e?void 0:e.shadowRoot)||void 0===t?void 0:t.querySelector("button.memori-chat-inputs--send"));n&&n.click()}),100))};var iJ=({memori:e,memoriConfigs:t,memoriLang:n,integration:i,layout:o="DEFAULT",showInstruct:a=!1,showShare:l=!0,preview:c=!1,embed:d=!1,showInputs:f=!0,showDates:h=!1,showContextPerLine:p=!1,showSettings:m=!0,height:g="100vh",secret:v,baseUrl:y="https://app.twincreator.com",apiUrl:b="https://backend.memori.ai",initialContextVars:w,initialQuestion:x,ogImage:S,sessionID:M,tenant:_,personification:A,authToken:E,AZURE_COGNITIVE_SERVICES_TTS_KEY:C,onStateChange:k})=>{var T,I,O,R,P,N,L,D,B,j,F,U,z,H,V,G,q,K;const{t:Y,i18n:J}=Te(),[Q,X]=(0,u.useState)(!1);(0,u.useEffect)((()=>{X(!0)}),[]);const Z=W(b),{initSession:$,postTextEnteredEvent:ee,postPlaceChangedEvent:te,postTimeoutEvent:ne,postTagChangedEvent:re,getSession:ie,getContentQualityIndexes:oe}=Z,[ae,se]=(0,u.useState)(!1),[le,ce]=(0,u.useState)(!1),[ue,de]=(0,u.useState)(!1),fe=null===(R=null===(O=null===(I=null===(T=null==t?void 0:t.find((t=>t.memoriConfigID===e.memoriConfigurationID)))||void 0===T?void 0:T.culture)||void 0===I?void 0:I.split("-"))||void 0===O?void 0:O[0])||void 0===R?void 0:R.toUpperCase(),[he,pe]=(0,u.useState)(null!==(B=null!==(D=null!==(L=null!=n?n:null===(N=null===(P=null==e?void 0:e.culture)||void 0===P?void 0:P.split("-"))||void 0===N?void 0:N[0])&&void 0!==L?L:fe)&&void 0!==D?D:J.language)&&void 0!==B?B:"IT"),me=(null==i?void 0:i.customData)?JSON.parse(i.customData):null,ge=!!(null==me?void 0:me.multilanguage),[ve,ye]=(0,u.useState)(!1),[be,we]=(0,u.useState)(!1),xe=o||(null==me?void 0:me.layout)||"DEFAULT",[Se,Me]=(0,u.useState)(!1),[_e,Ae]=(0,u.useState)(!1),[Ee,Ce]=(0,u.useState)(!1),[ke,Ie]=(0,u.useState)(!1),[Oe,Re]=(0,u.useState)(!1),[Pe,Ne]=(0,u.useState)(!0),[Le,De]=(0,u.useState)(2),[Be,je]=(0,u.useState)(!1),[Fe,Ue]=(0,u.useState)("center");(0,u.useEffect)((()=>{je(!!tJ)}),[tJ]),(0,u.useEffect)((()=>{Re(NY("muteSpeaker",!1)),Ne(NY("continuousSpeech",!0)),De(NY("continuousSpeechTimeout",2)),Ue(NY("controlsPosition","center"))}),[]);const[ze,He]=(0,u.useState)(v),[Ve,We]=(0,u.useState)(),[Ge,qe]=(0,u.useState)(null),[Ke,Ye]=(0,u.useState)(),Je=async(e,t)=>{var n;const r=null!=t?t:ut;if(e&&r){const{currentState:t,...i}=await te({sessionId:r,placeName:e.placeName,latitude:e.latitude,longitude:e.longitude,uncertaintyKm:null!==(n=e.uncertainty)&&void 0!==n?n:0});t&&0===i.resultCode&&pt({...ft,...t})}},[Qe,Xe]=(0,u.useState)(""),[Ze,$e]=(0,u.useState)(!1),[et,tt]=(0,u.useState)([]),nt=e=>{tt((t=>[...t,{...e}]))},rt=async(t,n,r,i=!0,o)=>{var a,s,l,c,u;if(!ut||!(null==t?void 0:t.length))return;nt({text:t,translatedText:o,fromUser:!0,media:null!=n?n:[],initial:!!r}),we(!0);const d=null!==(c=null!==(l=null===(s=null===(a=e.culture)||void 0===a?void 0:a.split("-"))||void 0===s?void 0:s[0])&&void 0!==l?l:J.language)&&void 0!==c?c:"IT";let f=t;if(i&&!ae&&ge&&he.toUpperCase()!==d.toUpperCase()){f=(await Sg(t,d,he,y)).text}const{currentState:h,...p}=await ee({sessionId:null!=r?r:ut,text:f});if(0===p.resultCode&&h){const t=null!==(u=h.emission)&&void 0!==u?u:null==ft?void 0:ft.emission;if("X4"===h.state&&e.giverTag){const{currentState:t,...n}=await re(ut,e.giverTag);0===n.resultCode?(pt(t),t.emission&&(nt({text:t.emission,media:t.media,fromUser:!1}),Tt(t.emission))):(console.error(p,n),Qd.error(Y(ZF(n.resultCode))))}else if("X2d"===h.state&&e.giverTag){const{currentState:t,...n}=await ee({sessionId:null!=r?r:ut,text:Math.random().toString().substring(2,8)});if(0===n.resultCode){const{currentState:t,...n}=await re(ut,e.giverTag);0===n.resultCode?(pt(t),t.emission&&(nt({text:t.emission,media:t.media,fromUser:!1}),Tt(t.emission))):(console.error(p,n),Qd.error(Y(ZF(n.resultCode))))}else console.error(p,n),Qd.error(Y(ZF(n.resultCode)))}else he.toLowerCase()!==d.toLowerCase()&&t&&!ae&&ge?it(h,he).then((e=>{e.emission&&Tt(e.emission)})):(pt({...h,emission:t}),t&&(nt({text:t,media:h.media,fromUser:!1,generatedByAI:!!h.completion}),Tt(t)))}else 404===p.resultCode&&(tt((e=>[...e.slice(0,e.length-1)])),gt(!1,ze||e.secretToken,Ve,ae&&e.giverTag?e.giverTag:void 0,ae&&e.giverPIN?e.giverPIN:void 0,w,x).then((e=>{console.info("session timeout"),(null==e?void 0:e.sessionID)&&setTimeout((()=>{rt(t,n,null==e?void 0:e.sessionID)}),500)})));we(!1)},it=async(t,n)=>{var r,i,o,a,s,l,c;const u=null!==(a=null!==(o=null===(i=null===(r=e.culture)||void 0===r?void 0:r.split("-"))||void 0===i?void 0:i[0])&&void 0!==o?o:J.language)&&void 0!==a?a:"IT",d=null!==(s=t.emission)&&void 0!==s?s:null==ft?void 0:ft.emission;let f={...t},h=null;if(d&&!ae&&u.toUpperCase()!==n.toUpperCase()&&ge){const e=await Sg(d,n,u,y);if(t.hints&&t.hints.length>0){const r=await Promise.all((null!==(l=t.hints)&&void 0!==l?l:[]).map((async e=>{var t;const r=await Sg(e,n,u,y);return{text:null!==(t=null==r?void 0:r.text)&&void 0!==t?t:e,originalText:e}})));f={...t,emission:e.text,translatedHints:r}}else f={...t,emission:e.text,hints:null!==(c=t.hints)&&void 0!==c?c:"G1"===t.state?null==ft?void 0:ft.hints:[]};e.text.length>0&&(h={text:e.text,media:t.media,fromUser:!1,generatedByAI:!!t.completion})}else f={...t,emission:d},d&&(h={text:d,media:t.media,fromUser:!1});return pt(f),h&&nt(h),f},ot=e.ageRestriction?e.ageRestriction:e.nsfw?18:e.enableCompletions?14:0,[at,st]=(0,u.useState)(),[lt,ct]=(0,u.useState)(!1),[ut,dt]=(0,u.useState)(M),[ft,ht]=(0,u.useState)(),pt=e=>{ht(e),k&&k(e)},mt=async t=>{var n;if("PUBLIC"!==e.privacyType&&!e.secretToken&&!ze&&!Ve)return void qe("password");let r=NY("birthDate",void 0);if(at||r||!ot){ye(!0);try{if(!e.giverTag&&(null===(n=e.receivedInvitations)||void 0===n?void 0:n.length)){let t=e.receivedInvitations.find((e=>"GIVER"===e.type&&"ACCEPTED"===e.state));t&&(e.giverTag=t.tag,e.giverPIN=t.pin)}const r=await $(t);if((null==r?void 0:r.sessionID)&&(null==r?void 0:r.currentState)&&0===r.resultCode)return dt(r.sessionID),Ke&&Je(Ke,r.sessionID),ye(!1),{dialogState:r.currentState,sessionID:r.sessionID};(null==r?void 0:r.resultMessage.startsWith("This Memori is aged restricted"))?(console.error(r),Qd.error(Y("underageTwinSession",{age:ot})),de(!0)):(console.error(r),Qd.error(Y(ZF(null==r?void 0:r.resultCode))),de(!0))}catch(e){console.error(e),new Error("Error fetching session")}}else ct(!0)},gt=async(t=!1,n,r,i,o,a,s,l)=>{var c;ye(!0);try{let u=NY("birthDate",void 0);const{sessionID:d,currentState:f,...h}=await $({memoriID:null!==(c=e.engineMemoriID)&&void 0!==c?c:"",password:n,recoveryTokens:r,tag:i,pin:o,initialContextVars:a,initialQuestion:s,birthDate:l||u||void 0});if(d&&f&&0===h.resultCode)return dt(d),t&&(pt(f),f.emission&&(et.length<=1?tt([{text:f.emission,media:f.media,fromUser:!1}]):nt({text:f.emission,media:f.media,fromUser:!1}))),Ke&&Je(Ke,d),ye(!1),{dialogState:f,sessionID:d};(null==h?void 0:h.resultMessage.startsWith("This Memori is aged restricted"))?(console.error(h),Qd.error(Y("underageTwinSession",{age:ot})),de(!0)):(console.error(h),Qd.error(Y(ZF(h.resultCode))),de(!0))}catch(e){console.error(e)}return ye(!1),null},vt=async(t,n,r,i)=>{var o;if(!t||!n)return console.error("CHANGETAG/Session not found"),Promise.reject("Session not found");try{const{currentState:t,resultCode:a}=await re(n,null!=r?r:Ag);if(0===a){let s=0;if(r!==Ag&&i&&("X1a"===t.state||"X1b"===t.state)){const{resultCode:e}=await ee({sessionId:n,text:null!=i?i:""});s=e}if(0===s){const{currentState:e,...t}=await ie(n);if(0===t.resultCode&&e)return{currentState:e,sessionId:n,...t}}else if([400,401,403,404,500].includes(a)){console.warn("[APPCONTEXT/CHANGETAG]",a);let t=NY("birthDate",void 0);mt({memoriID:null!==(o=e.engineMemoriID)&&void 0!==o?o:"",password:v||e.secretToken,tag:e.giverTag,pin:e.giverPIN,initialContextVars:w,initialQuestion:x,birthDate:at||t||void 0})}else if(t)return{currentState:t,sessionId:n,resultCode:a}}}catch(e){let t=e;return console.error("[APPCONTEXT/CHANGETAG]",t),Promise.reject(t)}return null};(0,u.useEffect)((()=>()=>{ft&&(null==ft?void 0:ft.currentTag)===e.giverTag||(async()=>{ut&&e.giverTag&&e.giverPIN&&(tt([]),await vt(e.engineMemoriID,ut,e.giverTag,e.giverPIN))})()}),[]);const[yt,bt]=(0,u.useState)(),wt=(0,u.useRef)(),xt=()=>{yt&&(clearTimeout(yt),bt(void 0)),(null==wt?void 0:wt.current)&&(clearTimeout(wt.current),wt.current=void 0)},St=()=>{xt(),!(null==ft?void 0:ft.acceptsTimeout)||tJ||Be||Qe.length||Ze||_t()},Mt=async()=>{var e;if(tJ||Be||Qe.length||Ze)St();else if(ut&&Se&&(null==ft?void 0:ft.acceptsTimeout)){const{currentState:t,...n}=await ne(ut);if(0===n.resultCode&&t){const n=t.emission;!ae&&ge&&he!==(null==J?void 0:J.language)&&n&&n.length>0?it({...t,emission:n},he).then((e=>{e.emission&&Tt(e.emission)})):n&&n.length>0&&(nt({text:n,media:t.media,fromUser:!1,generatedByAI:!!t.completion}),Tt(n),pt({...t,hints:null!==(e=t.hints)&&void 0!==e?e:"G1"===t.state?null==ft?void 0:ft.hints:[]}))}}},_t=()=>{let e=null==ft?void 0:ft.timeout;if(!e){let t=40,n=25;if(e=Math.floor(Math.random()*(t-n))+n,null==ft?void 0:ft.emission){e+=ft.emission.length/26.5}}let t=setTimeout(Mt,1e3*e);bt(t),wt.current=t};(0,u.useEffect)((()=>{(Qe.length||Be)&&xt(),ut&&!Qe.length&&St()}),[null==ft?void 0:ft.acceptsTimeout,null==ft?void 0:ft.timeout,null==ft?void 0:ft.state,Be,ut,et,Qe]),(0,u.useEffect)((()=>()=>{Me(!1),ce(!1),xt(),wt.current=void 0}),[]);const At=(0,u.useCallback)((t=>{var n,r,i,o;let a="";switch((null!==(o=null!==(i=null!=t?t:null===(r=null===(n=e.culture)||void 0===n?void 0:n.split("-"))||void 0===r?void 0:r[0])&&void 0!==i?i:J.language)&&void 0!==o?o:"IT").toUpperCase()){case"IT":a=""+("MALE"===e.voiceType?"it-IT-DiegoNeural":"it-IT-ElsaNeural");break;case"DE":a=""+("MALE"===e.voiceType?"de-DE-ConradNeural":"de-DE-KatjaNeural");break;case"EN":a=""+("MALE"===e.voiceType?"en-GB-RyanNeural":"en-GB-SoniaNeural");break;case"ES":a=""+("MALE"===e.voiceType?"es-ES-AlvaroNeural":"es-ES-ElviraNeural");break;case"FR":a=""+("MALE"===e.voiceType?"fr-FR-HenriNeural":"fr-FR-DeniseNeural");break;case"PT":a=""+("MALE"===e.voiceType?"pt-PT-DuarteNeural":"pt-PT-RaquelNeural");break;case"UK":a=""+("MALE"===e.voiceType?"uk-UA-OstapNeural":"uk-UA-PolinaNeural");break;case"RU":a=""+("MALE"===e.voiceType?"ru-RU-DmitryNeural":"ru-RU-SvetlanaNeural");break;default:a=""+("MALE"===e.voiceType?"it-IT-DiegoNeural":"it-IT-IsabellaNeural")}return a}),[e.voiceType,J.language,e.culture]),Et=t=>{var n,r;let i="";switch((t||(null===(r=null===(n=e.culture)||void 0===n?void 0:n.split("-"))||void 0===r?void 0:r[0])||J.language||"IT").toUpperCase()){case"IT":default:i="it-IT";break;case"DE":i="de-DE";break;case"EN":i="en-GB";break;case"ES":i="es-ES";break;case"FR":i="fr-FR";break;case"PT":i="pt-PT";break;case"UK":i="uk-UK";break;case"RU":i="ru-RU"}return i},[Ct,kt]=(0,u.useState)();(0,u.useEffect)((()=>{(async()=>{try{const e=await fetch(`${y||"https://app.twincreator.com"}/api/lexiconmap`);return await e.json()}catch(e){console.error(e)}})().then((e=>{kt(e)}))}),[]);const Tt=e=>{if(!C)return;if(Ft(),c)return;if(Oe)return void(Pe&&Dt());nJ&&nJ.pause();let t=window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome"),n=/iPad|iPhone|iPod/.test(navigator.userAgent);if("interrupted"===rJ.state)return void rJ.resume().then((()=>Tt(e)));if(n&&t&&(rJ.suspend(),Be))try{tJ&&(tJ.close(),tJ=null),nJ&&(nJ.pause(),nJ.close()),rJ&&rJ.destination.disconnect()}catch(e){console.error("stopAudio error: ",e)}if("closed"===rJ.state){rJ=new ra;let e=rJ.createBuffer(1,1e4,22050),t=rJ.createBufferSource();t.buffer=e,t.connect(rJ.destination)}else if("suspended"===rJ.state){It(),rJ=new ra;let e=rJ.createBuffer(1,1e4,22050),t=rJ.createBufferSource();t.buffer=e,t.connect(rJ.destination)}if(!tJ){nJ=new _d.SpeakerAudioDestination;let e=Id.fromSpeakerOutput(nJ);tJ=new Vd.SpeechSynthesizer(eJ,e)}const r=rJ.createBufferSource();nJ.onAudioEnd=()=>{je(!1),r.disconnect(),Vt()},je(!0),tJ.speakSsmlAsync(`<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xmlns:emo="http://www.w3.org/2009/10/emotionml" xml:lang="${Et(he)}"><voice name="${At(he)}"><s>${((e,t)=>{var n;if(!Ct)return e;const r={...null!==(n=Ct.common)&&void 0!==n?n:{},...(null==_?void 0:_.id)&&Ct[_.id]?Ct[_.id]:{}},i=Object.keys(r).map((e=>{var n;return{word:e,phoneme:null!==(n=r[e][t])&&void 0!==n?n:r[e].default}}));return i.reduce(((e,{word:t,phoneme:n})=>e.replace(new RegExp(t,"gi"),`<phoneme alphabet="ipa" ph="${n}">${t}</phoneme>`)),e)})((e=>{const t=document.createElement("textarea");return t.textContent=e,t.innerHTML})(e),he.toLowerCase())}</s></voice></speak>`,(i=>{if(i)try{rJ.decodeAudioData(i.audioData,(function(e){r.buffer=e,r.connect(rJ.destination),(et.length<1||t&&n)&&r.start(0)})),rJ.onstatechange=()=>{"suspended"===rJ.state||"closed"===rJ.state?r.disconnect():"interrupted"===rJ.state&&rJ.resume()},rJ.resume(),tJ&&(tJ.close(),tJ=null)}catch(t){console.error("speak error: ",t),window.speechSynthesis.speak(new SpeechSynthesisUtterance(e)),je(!1),tJ&&(tJ.close(),tJ=null)}else rJ.resume(),je(!1)}),(t=>{console.error("speak:",t),window.speechSynthesis.speak(new SpeechSynthesisUtterance(e)),je(!1)})),we(!1)},It=()=>{je(!1);try{tJ&&(tJ.close(),tJ=null),rJ&&rJ.close(),nJ&&(nJ.pause(),nJ.close())}catch(e){console.error("stopAudio error: ",e)}};(0,u.useEffect)((()=>{let e=document.querySelector("#chat-fieldset textarea");e&&e.focus()}),[null==ft?void 0:ft.emission]);const[Ot,Rt]=(0,u.useState)(""),Pt=()=>Rt(""),[Nt,Lt]=(0,u.useState)(null),Dt=()=>{let e=setTimeout((async()=>{Ut();const e=Bm(Ot);e.length>0?(rt(e),Pt(),Xe("")):Ze&&St()}),1e3*Le);Lt(e)},Bt=()=>{Nt&&(clearTimeout(Nt),Lt(null))};(0,u.useEffect)((()=>{Bt(),Pe&&Dt(),St()}),[Ot]);const jt=()=>{if(C){Ut(),Rt("");try{navigator.mediaDevices.getUserMedia({audio:!0}).then((function(e){Ae(!0),eJ||(eJ=Cc.fromSubscription(C,"eastus"),eJ.speechRecognitionLanguage=Et(he),eJ.speechSynthesisLanguage=Et(he),eJ.speechSynthesisVoiceName=At(he));const t=Id.fromDefaultMicrophoneInput();$Y=new Pd.SpeechRecognizer(eJ,t),$e(!0),$Y.recognized=(e,t)=>{if(t.result.text)if(t.result.reason===Pl.RecognizedSpeech){let e=t.result.text;if(Rt(e||""),(null==e?void 0:e.length)>0){const t=Bm(e);t.length>0&&Xe(t)}}else t.result.reason===Pl.NoMatch&&console.debug("NOMATCH: Speech could not be recognized.")},$Y.canceled=(e,t)=>{t.reason===ol.Error&&(console.debug(`"CANCELED: ErrorCode=${t.errorCode}`),console.debug(`"CANCELED: ErrorDetails=${t.errorDetails}`),console.debug("CANCELED: Did you set the speech resource key and region values?")),Ft()},$Y.sessionStopped=(e,t)=>{Ft()},$Y.startContinuousRecognitionAsync()})).catch(console.error)}catch(e){console.error(e)}}},Ft=()=>{$Y&&($Y.stopContinuousRecognitionAsync(),$Y.close(),$Y=null),$e(!1)},Ut=()=>{Ae(!1),Ft(),Bt()};(0,u.useEffect)((()=>()=>Ut()),[]),(0,u.useEffect)((()=>{"Z0"===(null==ft?void 0:ft.state)&&Ut()}),[null==ft?void 0:ft.state]);const[zt,Ht]=(0,u.useState)(!1),Vt=(0,u.useCallback)((e=>{Be&&tJ&&(tJ.close(),tJ=null),!Pe||!_e&&zt||(Ht(!0),jt())}),[Pe,_e]);(0,u.useEffect)((()=>{et.length>1&&!Be&&Pe&&(_e||!zt)?jt():Be&&Ze&&Ft()}),[Be]),(0,u.useEffect)((()=>(document.addEventListener("endSpeakStartListen",Vt),()=>{document.removeEventListener("endSpeakStartListen",Vt)})),[Vt]),(0,u.useEffect)((()=>{Ze&&(Ut(),Pt(),Xe(""),jt())}),[fe]);const[Wt,Gt]=(0,u.useState)("keypress");(0,u.useEffect)((()=>{const e=NY("sendOnEnter","keypress");Gt(e)}),[]),(0,u.useEffect)((()=>{LY("sendOnEnter",Wt)}),[Wt]);const[qt,Kt]=(0,u.useState)(),Yt=null==me?void 0:me.globalBackground,Jt=Yt?`url(${Yt})`:null,Qt=i?{"--memori-chat-bubble-bg":"#fff",...me&&!a?{"--memori-text-color":null!==(j=me.textColor)&&void 0!==j?j:"#000"}:{},...(null==me?void 0:me.buttonBgColor)?{"--memori-button-bg":me.buttonBgColor,"--memori-primary":me.buttonBgColor}:{},...(null==me?void 0:me.buttonTextColor)?{"--memori-button-text":me.buttonTextColor}:{},...(null==me?void 0:me.blurBackground)?{"--memori-blur-background":"5px"}:{"--memori-blur-background":"0px"},...(null==me?void 0:me.innerBgColor)?{"--memori-inner-bg":`rgba(${"dark"===me.innerBgColor?"0, 0, 0":"255, 255, 255"}, ${null!==(F=me.innerBgAlpha)&&void 0!==F?F:.4})`,"--memori-inner-content-pad":"1.5rem","--memori-nav-bg-image":"none","--memori-nav-bg":`rgba(${"dark"===me.innerBgColor?"0, 0, 0":"255, 255, 255"}, ${null!==(U=null==me?void 0:me.innerBgAlpha)&&void 0!==U?U:.4})`}:{"--memori-inner-content-pad":"0px"}}:{},Xt=`\n ${c?"#preview":":root"}, .memori-widget {\n ${Object.entries(Qt).map((([e,t])=>`${e}: ${t};`)).join("\n")}\n }\n `,Zt=void 0===(null==me?void 0:me.showAIicon)||(null==me?void 0:me.showAIicon),[$t,en]=(0,u.useState)(!1);(0,u.useEffect)((()=>{(window.innerWidth>=768&&"FULLPAGE"===xe||"FULLPAGE"!==xe)&&en(!0)}),[]);const[tn,nn]=(0,u.useState)();(0,u.useEffect)((()=>{e.engineMemoriID&&(async e=>{let t,n;try{const{contentQualityIndex:r,answerQualityIndex:i,unansweredQuestions:o,...a}=await oe(e);0===a.resultCode&&(t=r,n=o)}catch(e){let t=e;console.error("[APPCONTEXT/QUERYGAMIFICATIONPOINTS]",t)}return{points:null!=t?t:0,unansweredQuestions:null!=n?n:0}})(e.engineMemoriID).then((e=>{nn(VY(e.points))})).catch(console.error)}),[e.engineMemoriID]),(0,u.useEffect)((()=>{if(null==me?void 0:me.seoTitle){let e=document.createElement("meta");e.setAttribute("property","og:title"),e.setAttribute("content",me.seoTitle),document.head.append(e)}if(null==me?void 0:me.seoDescription){let e=document.createElement("meta");e.setAttribute("property","og:description"),e.setAttribute("content",me.seoDescription),document.head.append(e)}if(null==me?void 0:me.seoUrl){let e=document.createElement("meta");e.setAttribute("property","og:url"),e.setAttribute("content",me.seoUrl),document.head.append(e)}let t=S||e.avatarURL;if((null==me?void 0:me.seoImageShowAvatar)&&t){let e=document.createElement("meta");e.setAttribute("property","og:image"),e.setAttribute("content",t),document.head.append(e)}}),[me,e.avatarURL,S]);const rn=async t=>{const n=(null==t?void 0:t.sessionID)||ut,r=(null==t?void 0:t.dialogState)||ft;ce(!0);let i=document.getElementById("memori-audio"),o=window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome");i&&o&&(i.muted=!1,i.play().catch((e=>{console.error("error playing intro audio",e)})));let a=NY("birthDate",void 0),s=at||a||void 0;if(!n&&"PUBLIC"!==e.privacyType&&!e.secretToken&&!ze&&!Ve||!n&&ue)return qe("password"),void ce(!1);if(n||!ot||s){if(!n){ce(!1),de(!1);const t=await mt({memoriID:e.engineMemoriID,password:v||e.secretToken,tag:null==A?void 0:A.tag,pin:null==A?void 0:A.pin,initialContextVars:w,initialQuestion:x,birthDate:s});return void((null==t?void 0:t.dialogState)?(tt([]),it(t.dialogState,he).then((e=>{e.emission&&Tt(e.emission)})).finally((()=>{Me(!0)}))):await rn(t||void 0))}if(M){const{currentState:t,...r}=await ie(n);if(0!==r.resultCode||!t)return console.debug("session expired, opening new session"),de(!0),dt(void 0),ce(!1),void await rn();if(tt([]),ae&&e.giverTag&&(null==ft?void 0:ft.currentTag)!==e.giverTag)try{console.debug("change tag #0"),await vt(e.engineMemoriID,n,"-");const t=await vt(e.engineMemoriID,n,e.giverTag,e.giverPIN);if(!t||0!==t.resultCode)throw console.error("session #1",t),new Error("No session");it(t.currentState,he).then((e=>{e.emission&&Tt(e.emission)})).finally((()=>{Me(!0)}))}catch(t){console.error("session #2",t),gt(!0,null==e?void 0:e.secretToken,void 0,null==e?void 0:e.giverTag,null==e?void 0:e.giverPIN,w,x,s).then((()=>{Me(!0)}))}else if(!ae&&A&&(null==ft?void 0:ft.currentTag)!==A.tag)try{console.debug("change tag #3"),await vt(e.engineMemoriID,n,"-");const t=await vt(e.engineMemoriID,n,A.tag,A.pin);if(!t||0!==t.resultCode)throw console.error("session #4",t),new Error("No session");it(t.currentState,he).then((e=>{e.emission&&Tt(e.emission)})).finally((()=>{Me(!0)}))}catch(t){console.error("session #5",t),gt(!0,null==e?void 0:e.secretToken,void 0,A.tag,A.pin,w,x,s).then((()=>{Me(!0)}))}else if(ae||A||(null==ft?void 0:ft.currentTag)===Ag)it(t,he).then((e=>{e.emission&&Tt(e.emission)})).finally((()=>{Me(!0)}));else try{console.debug("change tag #6"),await vt(e.engineMemoriID,n,"-");const t=await vt(e.engineMemoriID,n,Ag);if(!t||0!==t.resultCode)throw console.error("session #7",t),new Error("No session");it(t.currentState,he).then((e=>{e.emission&&Tt(e.emission)})).finally((()=>{Me(!0)}))}catch(t){console.error("session #8",t),gt(!0,null==e?void 0:e.secretToken,void 0,void 0,void 0,w,x,s).then((()=>{Me(!0)}))}}else tt([]),it(r,he).then((e=>{e.emission&&Tt(e.emission)})).finally((()=>{Me(!0)}))}else ct(!0),ce(!1)},[on,an]=(0,u.useState)(E);(0,u.useEffect)((()=>{const t=document.querySelector(`memori-client[memoriname="${e.name}"]`)||document.querySelector(`memori-client[memoriid="${e.memoriID}"]`)||document.querySelector("memori-client");if(!t)return;const n=new MutationObserver(((e,t)=>{var n,r,i;for(const t of e)"attributes"===t.type&&"authtoken"===(null===(n=t.attributeName)||void 0===n?void 0:n.toLowerCase())&&("MEMORI-CLIENT"===t.target.nodeName?an(t.target.getAttribute("authtoken")||void 0):an((null===(i=null===(r=t.target)||void 0===r?void 0:r.parentElement)||void 0===i?void 0:i.getAttribute("authtoken"))||void 0))}));return n.observe(t,{attributes:!0,childList:!1,subtree:!1}),()=>{n.disconnect()}}),[]);const sn=(0,s.jsx)(QF,{memori:e,history:et,showShare:l,position:Ke,setShowPositionDrawer:Ce,setShowSettingsDrawer:Ie,showSpeaker:!!C,speakerMuted:Oe,setSpeakerMuted:e=>{if(Re(e),e)It();else{rJ=new ra;let e=rJ.createBuffer(1,1e4,22050),t=rJ.createBufferSource();t.buffer=e,t.connect(rJ.destination)}},showSettings:m,hasUserActivatedSpeak:Se,showReload:"TOTEM"===xe}),ln=(0,s.jsx)(Gj,{memori:e,integration:i,integrationConfig:me,tenant:_,instruct:ae,avatar3dVisible:$t,setAvatar3dVisible:en,hasUserActivatedSpeak:Se,isPlayingAudio:Be,loading:be,baseUrl:y,apiUrl:b}),cn=(0,s.jsx)(ew,{memori:e,tenant:_,gamificationLevel:tn,language:fe,userLang:he,setUserLang:pe,baseUrl:y,apiUrl:b,position:Ke,openPositionDrawer:()=>Ce(!0),integrationConfig:me,instruct:ae,sessionId:ut,clickedStart:le,onClickStart:rn,initializeTTS:()=>{if(!C)return;eJ=Cc.fromSubscription(C,"eastus"),eJ.speechSynthesisLanguage=Et(he),eJ.speechSynthesisVoiceName=At(he),eJ.speechRecognitionLanguage=Et(he),Dm()&&(eJ.speechSynthesisOutputFormat=hc.Audio16Khz32KBitRateMonoMp3),rJ=new ra;let e=rJ.createBuffer(1,1e4,22050),t=rJ.createBufferSource();t.buffer=e,t.connect(rJ.destination),nJ=new _d.SpeakerAudioDestination;let n=Id.fromSpeakerOutput(nJ);tJ=new Vd.SpeechSynthesizer(eJ,n)}}),un=ut?(0,s.jsx)(Ib,{memori:e,sessionID:ut,tenant:_,translateTo:ge&&he.toUpperCase()!==(null===(q=null!==(G=null!==(V=null===(H=null===(z=e.culture)||void 0===z?void 0:z.split("-"))||void 0===H?void 0:H[0])&&void 0!==V?V:J.language)&&void 0!==G?G:"IT")||void 0===q?void 0:q.toUpperCase())?he:void 0,baseUrl:y,apiUrl:b,memoriTyping:be,history:"TOTEM"===o?et.slice(-2):et,authToken:on,dialogState:ft,setDialogState:pt,pushMessage:nt,simulateUserPrompt:(e,t)=>{Ft(),It(),rt(e,void 0,void 0,!1,t)},showDates:h,showContextPerLine:p,showAIicon:Zt,client:Z,selectReceiverTag:async t=>{var n;if(ut)try{const{currentState:r,...i}=await re(ut,t);if(0===i.resultCode)if(nt({text:t,fromUser:!0}),"X4"===r.state&&e.giverTag){const{currentState:t,...n}=await Z.postTagChangedEvent(ut,e.giverTag);0===n.resultCode?(pt(t),t.emission&&nt({text:t.emission,media:t.media,fromUser:!1})):(console.error(n),Qd.error(Y(ZF(n.resultCode))))}else pt(r),r.emission&&nt({text:r.emission,media:r.media,fromUser:!1});else console.error(i,t,null===(n=null==ft?void 0:ft.knownTags)||void 0===n?void 0:n[t]),Qd.error(Y(ZF(i.resultCode)))}catch(e){let t=e;console.error(t),Qd.error(t.message)}},preview:c,sendOnEnter:Wt,setSendOnEnter:Gt,attachmentsMenuOpen:qt,setAttachmentsMenuOpen:Kt,instruct:ae,showInputs:f,showMicrophone:!!C,userMessage:Qe,onChangeUserMessage:e=>{if(!e||"\n"===e||""===e.trim())return Xe(""),void St();Xe(e),xt()},sendMessage:e=>{It(),Ft(),rt(e),Xe(""),Pt()},stopListening:Ut,startListening:jt,stopAudio:It,resetTranscript:Pt,listening:Ze,isPlayingAudio:Be}):null,dn=i&&Jt?(0,s.jsx)("div",{className:"memori--global-background",children:(0,s.jsx)("div",{className:"memori--global-background-image",style:{backgroundImage:Jt}})}):(0,s.jsx)("div",{className:"memori--global-background no-background-image"}),fn=i?(0,s.jsx)("style",{dangerouslySetInnerHTML:{__html:Xt}}):null,hn=(0,s.jsx)(qj,{canInstruct:!!e.giverTag,instruct:ae,onChangeMode:e=>{se("instruct"===e),Me(!1),ce(!1)}}),pn=(0,s.jsx)(IY,{tenant:_,userLang:he}),mn="TOTEM"===xe?RY:OY;return(0,s.jsxs)("div",{className:r(Jd)("memori","memori-widget",`memori-layout-${o.toLowerCase()}`,`memori-controls-${Fe.toLowerCase()}`,{"memori--preview":c,"memori--embed":d,"memori--with-integration":i,"memori--with-speechkey":!!C,"memori--active":Se}),"data-memori-name":null==e?void 0:e.name,"data-memori-id":null==e?void 0:e.engineMemoriID,"data-memori-secondary-id":null==e?void 0:e.memoriID,"data-memori-session-id":ut,"data-memori-integration":null==i?void 0:i.integrationID,"data-memori-engine-state":JSON.stringify({...ft,sessionID:ut}),style:{height:g},children:[(0,s.jsx)(mn,{header:sn,avatar:ln,chat:un,startPanel:cn,integrationStyle:fn,integrationBackground:dn,changeMode:hn,poweredBy:pn,sessionId:ut,hasUserActivatedSpeak:Se,showInstruct:a,loading:ve}),(0,s.jsx)("audio",{id:"memori-audio",style:{display:"none"},src:"https://app.twincreator.com/intro.mp3"}),Q&&(0,s.jsx)(Lm,{withModal:!0,pwdOrTokens:Ge,openModal:!!Ge,setPwdOrTokens:qe,showTokens:"SECRET"===e.privacyType,onFinish:async t=>{t.password&&He(t.password),t.tokens&&We(t.tokens),gt(!ut,t.password,t.tokens,ae?e.giverTag:void 0,ae?e.giverPIN:void 0,w,x,at).then((e=>{qe(null),rn(e||void 0)})).catch((()=>{qe(null),de(!0)}))},minimumNumberOfRecoveryTokens:null!==(K=null==e?void 0:e.minimumNumberOfRecoveryTokens)&&void 0!==K?K:1}),Q&&(0,s.jsx)(YY,{visible:lt,minAge:ot,onClose:t=>{t?(st(t),LY("birthDate",t),gt(!ut,null==e?void 0:e.secretToken,void 0,ae?e.giverTag:void 0,ae?e.giverPIN:void 0,w,x,t).then((e=>{ct(!1),rn(e||void 0)})).catch((()=>{ct(!1),de(!0)}))):(ct(!1),ce(!1))}}),ke&&(0,s.jsx)(ZY,{layout:xe,open:!!ke,onClose:()=>Ie(!1),continuousSpeech:Pe,continuousSpeechTimeout:Le,setContinuousSpeech:Ne,setContinuousSpeechTimeout:De,controlsPosition:Fe,setControlsPosition:Ue}),ut&&(0,s.jsx)(TY,{apiURL:b,visible:"link"===qt,onCancel:()=>Kt(void 0),onOk:async e=>{if(!ut)return;let t={mediumID:"",mimeType:"text/html",url:e.url,title:e.title};nt({text:Y("media.insertThisLink",{url:t.url,title:t.title}),fromUser:!0,media:[t]});try{const{currentState:e,...n}=await Z.postMediumSelectedEvent(ut,t);e&&0===n.resultCode?(pt(e),e.emission&&(nt({text:e.emission,media:e.media,fromUser:!1}),Tt(e.emission))):(console.error(n,e,t),Qd.error(Y(ZF(n.resultCode),{ns:"common"})))}catch(e){let t=e;console.error(t),Qd.error(t.message)}Kt(void 0)}}),on&&ut&&(null==_?void 0:_.id)&&(0,s.jsx)(kY,{apiURL:b,visible:"media"===qt,authToken:on,tenantID:null==_?void 0:_.id,sessionID:ut,uploadAssetURL:Z.backend.getUploadAssetURL(on,e.memoriID),deleteAsset:Z.backend.deleteAsset,onCancel:()=>Kt(void 0),onOk:async e=>{if(!ut)return;let t={mediumID:"",mimeType:e.mimeType,url:e.assetURL,title:e.title||e.assetID};nt({text:Y("media.insertThisMediaMsg"),fromUser:!0,media:[t]});try{const{currentState:e,...n}=await Z.postMediumSelectedEvent(ut,t);e&&0===n.resultCode?(pt(e),e.emission&&(nt({text:e.emission,media:e.media,fromUser:!1}),Tt(e.emission))):(console.error(n,e,t),Qd.error(Y(ZF(n.resultCode),{ns:"common"})))}catch(e){let t=e;console.error(t),Qd.error(t.message)}Kt(void 0)}})]})};function oJ(e){return oJ="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},oJ(e)}function aJ(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function sJ(e,t){if("object"!==oJ(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==oJ(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function lJ(e){var t=sJ(e,"string");return"symbol"===oJ(t)?t:String(t)}function cJ(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,lJ(r.key),r)}}function uJ(e,t,n){return t&&cJ(e.prototype,t),n&&cJ(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function dJ(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function fJ(e,t){return fJ=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},fJ(e,t)}function hJ(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&fJ(e,t)}function pJ(e,t){if(t&&("object"===oJ(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return dJ(e)}function mJ(e){return mJ=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},mJ(e)}function gJ(e,t,n){return(t=lJ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vJ(e){if(Array.isArray(e))return e}function yJ(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function bJ(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function wJ(e,t){if(e){if("string"==typeof e)return bJ(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bJ(e,t):void 0}}function xJ(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function SJ(e){return vJ(e)||yJ(e)||wJ(e)||xJ()}function MJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _J(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?MJ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):MJ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var AJ={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},EJ=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};aJ(this,e),this.init(t,n)}return uJ(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||AJ,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,n,r){return r&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(n).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,_J(_J({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}(),CJ=new EJ,kJ=function(){function e(){aJ(this,e),this.observers={}}return uJ(e,[{key:"on",value:function(e,t){var n=this;return e.split(" ").forEach((function(e){n.observers[e]=n.observers[e]||[],n.observers[e].push(t)})),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter((function(e){return e!==t})):delete this.observers[e])}},{key:"emit",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(this.observers[e]){var i=[].concat(this.observers[e]);i.forEach((function(e){e.apply(void 0,n)}))}if(this.observers["*"]){var o=[].concat(this.observers["*"]);o.forEach((function(t){t.apply(t,[e].concat(n))}))}}}]),e}();function TJ(){var e,t,n=new Promise((function(n,r){e=n,t=r}));return n.resolve=e,n.reject=t,n}function IJ(e){return null==e?"":""+e}function OJ(e,t,n){e.forEach((function(e){t[e]&&(n[e]=t[e])}))}function RJ(e,t,n){function r(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function i(){return!e||"string"==typeof e}for(var o="string"!=typeof t?[].concat(t):t.split(".");o.length>1;){if(i())return{};var a=r(o.shift());!e[a]&&n&&(e[a]=new n),e=Object.prototype.hasOwnProperty.call(e,a)?e[a]:{}}return i()?{}:{obj:e,k:r(o.shift())}}function PJ(e,t,n){var r=RJ(e,t,Object);r.obj[r.k]=n}function NJ(e,t){var n=RJ(e,t),r=n.obj,i=n.k;if(r)return r[i]}function LJ(e,t,n){var r=NJ(e,n);return void 0!==r?r:NJ(t,n)}function DJ(e,t,n){for(var r in t)"__proto__"!==r&&"constructor"!==r&&(r in e?"string"==typeof e[r]||e[r]instanceof String||"string"==typeof t[r]||t[r]instanceof String?n&&(e[r]=t[r]):DJ(e[r],t[r],n):e[r]=t[r]);return e}function BJ(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var jJ={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function FJ(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return jJ[e]})):e}var UJ="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,zJ=[" ",",","?","!",";"];function HJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function VJ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?HJ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):HJ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function WJ(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mJ(e);if(t){var i=mJ(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return pJ(this,n)}}function GJ(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var r=t.split(n),i=e,o=0;o<r.length;++o){if(!i)return;if("string"==typeof i[r[o]]&&o+1<r.length)return;if(void 0===i[r[o]]){for(var a=2,s=r.slice(o,o+a).join(n),l=i[s];void 0===l&&r.length>o+a;)a++,l=i[s=r.slice(o,o+a).join(n)];if(void 0===l)return;if(null===l)return null;if(t.endsWith(s)){if("string"==typeof l)return l;if(s&&"string"==typeof l[s])return l[s]}var c=r.slice(o+a).join(n);return c?GJ(l,c,n):void 0}i=i[r[o]]}return i}}var qJ=function(e){hJ(n,e);var t=WJ(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return aJ(this,n),r=t.call(this),UJ&&kJ.call(dJ(r)),r.data=e||{},r.options=i,void 0===r.options.keySeparator&&(r.options.keySeparator="."),void 0===r.options.ignoreJSONStructure&&(r.options.ignoreJSONStructure=!0),r}return uJ(n,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,o=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure,a=[e,t];n&&"string"!=typeof n&&(a=a.concat(n)),n&&"string"==typeof n&&(a=a.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(a=e.split("."));var s=NJ(this.data,a);return s||!o||"string"!=typeof n?s:GJ(this.data&&this.data[e]&&this.data[e][t],n,i)}},{key:"addResource",value:function(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},o=this.options.keySeparator;void 0===o&&(o=".");var a=[e,t];n&&(a=a.concat(o?n.split(o):n)),e.indexOf(".")>-1&&(r=t,t=(a=e.split("."))[1]),this.addNamespaces(t),PJ(this.data,a,r),i.silent||this.emit("added",e,t,n,r)}},{key:"addResources",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var i in n)"string"!=typeof n[i]&&"[object Array]"!==Object.prototype.toString.apply(n[i])||this.addResource(e,t,i,n[i],{silent:!0});r.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},a=[e,t];e.indexOf(".")>-1&&(r=n,n=t,t=(a=e.split("."))[1]),this.addNamespaces(t);var s=NJ(this.data,a)||{};r?DJ(s,n,i):s=VJ(VJ({},s),n),PJ(this.data,a,s),o.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?VJ(VJ({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((function(e){return t[e]&&Object.keys(t[e]).length>0}))}},{key:"toJSON",value:function(){return this.data}}]),n}(kJ),KJ={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,r,i){var o=this;return e.forEach((function(e){o.processors[e]&&(t=o.processors[e].process(t,n,r,i))})),t}};function YJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function JJ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?YJ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YJ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function QJ(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mJ(e);if(t){var i=mJ(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return pJ(this,n)}}var XJ={},ZJ=function(e){hJ(n,e);var t=QJ(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return aJ(this,n),r=t.call(this),UJ&&kJ.call(dJ(r)),OJ(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,dJ(r)),r.options=i,void 0===r.options.keySeparator&&(r.options.keySeparator="."),r.logger=CJ.create("translator"),r}return uJ(n,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");var r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=t.ns||this.options.defaultNS||[],o=n&&e.indexOf(n)>-1,a=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||function(e,t,n){t=t||"",n=n||"";var r=zJ.filter((function(e){return t.indexOf(e)<0&&n.indexOf(e)<0}));if(0===r.length)return!0;var i=new RegExp("(".concat(r.map((function(e){return"?"===e?"\\?":e})).join("|"),")")),o=!i.test(e);if(!o){var a=e.indexOf(n);a>0&&!i.test(e.substring(0,a))&&(o=!0)}return o}(e,n,r));if(o&&!a){var s=e.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:e,namespaces:i};var l=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(l[0])>-1)&&(i=l.shift()),e=l.join(r)}return"string"==typeof i&&(i=[i]),{key:e,namespaces:i}}},{key:"translate",value:function(e,t,r){var i=this;if("object"!==oJ(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var o=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,a=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,s=this.extractFromKey(e[e.length-1],t),l=s.key,c=s.namespaces,u=c[c.length-1],d=t.lng||this.language,f=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&"cimode"===d.toLowerCase()){if(f){var h=t.nsSeparator||this.options.nsSeparator;return o?(p.res="".concat(u).concat(h).concat(l),p):"".concat(u).concat(h).concat(l)}return o?(p.res=l,p):l}var p=this.resolve(e,t),m=p&&p.res,g=p&&p.usedKey||l,v=p&&p.exactUsedKey||l,y=Object.prototype.toString.apply(m),b=["[object Number]","[object Function]","[object RegExp]"],w=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,x=!this.i18nFormat||this.i18nFormat.handleAsObject,S="string"!=typeof m&&"boolean"!=typeof m&&"number"!=typeof m;if(x&&m&&S&&b.indexOf(y)<0&&("string"!=typeof w||"[object Array]"!==y)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var M=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,m,JJ(JJ({},t),{},{ns:c})):"key '".concat(l," (").concat(this.language,")' returned an object instead of string.");return o?(p.res=M,p):M}if(a){var _="[object Array]"===y,A=_?[]:{},E=_?v:g;for(var C in m)if(Object.prototype.hasOwnProperty.call(m,C)){var k="".concat(E).concat(a).concat(C);A[C]=this.translate(k,JJ(JJ({},t),{joinArrays:!1,ns:c})),A[C]===k&&(A[C]=m[C])}m=A}}else if(x&&"string"==typeof w&&"[object Array]"===y)(m=m.join(w))&&(m=this.extendTranslation(m,e,t,r));else{var T=!1,I=!1,O=void 0!==t.count&&"string"!=typeof t.count,R=n.hasDefaultValue(t),P=O?this.pluralResolver.getSuffix(d,t.count,t):"",N=t["defaultValue".concat(P)]||t.defaultValue;!this.isValidLookup(m)&&R&&(T=!0,m=N),this.isValidLookup(m)||(I=!0,m=l);var L=t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey,D=L&&I?void 0:m,B=R&&N!==m&&this.options.updateMissing;if(I||T||B){if(this.logger.log(B?"updateKey":"missingKey",d,u,l,B?N:m),a){var j=this.resolve(l,JJ(JJ({},t),{},{keySeparator:!1}));j&&j.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var F=[],U=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&U&&U[0])for(var z=0;z<U.length;z++)F.push(U[z]);else"all"===this.options.saveMissingTo?F=this.languageUtils.toResolveHierarchy(t.lng||this.language):F.push(t.lng||this.language);var H=function(e,n,r){var o=R&&r!==m?r:D;i.options.missingKeyHandler?i.options.missingKeyHandler(e,u,n,o,B,t):i.backendConnector&&i.backendConnector.saveMissing&&i.backendConnector.saveMissing(e,u,n,o,B,t),i.emit("missingKey",e,u,n,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&O?F.forEach((function(e){i.pluralResolver.getSuffixes(e,t).forEach((function(n){H([e],l+n,t["defaultValue".concat(n)]||N)}))})):H(F,l,N))}m=this.extendTranslation(m,e,t,p,r),I&&m===l&&this.options.appendNamespaceToMissingKey&&(m="".concat(u,":").concat(l)),(I||T)&&this.options.parseMissingKeyHandler&&(m="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(u,":").concat(l):l,T?m:void 0):this.options.parseMissingKeyHandler(m))}return o?(p.res=m,p):m}},{key:"extendTranslation",value:function(e,t,n,r,i){var o=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,JJ(JJ({},this.options.interpolation.defaultVariables),n),r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(JJ(JJ({},n),{interpolation:JJ(JJ({},this.options.interpolation),n.interpolation)}));var a,s="string"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(s){var l=e.match(this.interpolator.nestingRegexp);a=l&&l.length}var c=n.replace&&"string"!=typeof n.replace?n.replace:n;if(this.options.interpolation.defaultVariables&&(c=JJ(JJ({},this.options.interpolation.defaultVariables),c)),e=this.interpolator.interpolate(e,c,n.lng||this.language,n),s){var u=e.match(this.interpolator.nestingRegexp);a<(u&&u.length)&&(n.nest=!1)}!1!==n.nest&&(e=this.interpolator.nest(e,(function(){for(var e=arguments.length,r=new Array(e),a=0;a<e;a++)r[a]=arguments[a];return i&&i[0]===r[0]&&!n.context?(o.logger.warn("It seems you are nesting recursively key: ".concat(r[0]," in key: ").concat(t[0])),null):o.translate.apply(o,r.concat([t]))}),n)),n.interpolation&&this.interpolator.reset()}var d=n.postProcess||this.options.postProcess,f="string"==typeof d?[d]:d;return null!=e&&f&&f.length&&!1!==n.applyPostProcessor&&(e=KJ.handle(f,e,t,this.options&&this.options.postProcessPassResolved?JJ({i18nResolved:r},n):n,this)),e}},{key:"resolve",value:function(e){var t,n,r,i,o,a=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!a.isValidLookup(t)){var l=a.extractFromKey(e,s),c=l.key;n=c;var u=l.namespaces;a.options.fallbackNS&&(u=u.concat(a.options.fallbackNS));var d=void 0!==s.count&&"string"!=typeof s.count,f=d&&!s.ordinal&&0===s.count&&a.pluralResolver.shouldUseIntlApi(),h=void 0!==s.context&&("string"==typeof s.context||"number"==typeof s.context)&&""!==s.context,p=s.lngs?s.lngs:a.languageUtils.toResolveHierarchy(s.lng||a.language,s.fallbackLng);u.forEach((function(e){a.isValidLookup(t)||(o=e,!XJ["".concat(p[0],"-").concat(e)]&&a.utils&&a.utils.hasLoadedNamespace&&!a.utils.hasLoadedNamespace(o)&&(XJ["".concat(p[0],"-").concat(e)]=!0,a.logger.warn('key "'.concat(n,'" for languages "').concat(p.join(", "),'" won\'t get resolved as namespace "').concat(o,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),p.forEach((function(n){if(!a.isValidLookup(t)){i=n;var o,l=[c];if(a.i18nFormat&&a.i18nFormat.addLookupKeys)a.i18nFormat.addLookupKeys(l,c,n,e,s);else{var u;d&&(u=a.pluralResolver.getSuffix(n,s.count,s));var p="".concat(a.options.pluralSeparator,"zero");if(d&&(l.push(c+u),f&&l.push(c+p)),h){var m="".concat(c).concat(a.options.contextSeparator).concat(s.context);l.push(m),d&&(l.push(m+u),f&&l.push(m+p))}}for(;o=l.pop();)a.isValidLookup(t)||(r=o,t=a.getResource(n,e,o,s))}})))}))}})),{res:t,usedKey:n,exactUsedKey:r,usedLng:i,usedNS:o}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,t.length)&&void 0!==e[n])return!0;return!1}}]),n}(kJ);function $J(e){return e.charAt(0).toUpperCase()+e.slice(1)}var eQ=function(){function e(t){aJ(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=CJ.create("languageUtils")}return uJ(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map((function(e){return e.toLowerCase()})):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=$J(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=$J(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=$J(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,n=this;return e?(e.forEach((function(e){if(!t){var r=n.formatLanguageCode(e);n.options.supportedLngs&&!n.isSupportedCode(r)||(t=r)}})),!t&&this.options.supportedLngs&&e.forEach((function(e){if(!t){var r=n.getLanguagePartFromCode(e);if(n.isSupportedCode(r))return t=r;t=n.options.supportedLngs.find((function(e){if(0===e.indexOf(r))return e}))}})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,r=this.getFallbackCodes(t||this.options.fallbackLng||[],e),i=[],o=function(e){e&&(n.isSupportedCode(e)?i.push(e):n.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):"string"==typeof e&&o(this.formatLanguageCode(e)),r.forEach((function(e){i.indexOf(e)<0&&o(n.formatLanguageCode(e))})),i}}]),e}(),tQ=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],nQ={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},rQ=["v1","v2","v3"],iQ={zero:0,one:1,two:2,few:3,many:4,other:5};function oQ(){var e={};return tQ.forEach((function(t){t.lngs.forEach((function(n){e[n]={numbers:t.nr,plurals:nQ[t.fc]}}))})),e}var aQ=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};aJ(this,e),this.languageUtils=t,this.options=n,this.logger=CJ.create("pluralResolver"),this.options.compatibilityJSON&&"v4"!==this.options.compatibilityJSON||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=oQ()}return uJ(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map((function(e){return"".concat(t).concat(e)}))}},{key:"getSuffixes",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.getRule(e,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort((function(e,t){return iQ[e]-iQ[t]})).map((function(e){return"".concat(t.options.prepend).concat(e)})):r.numbers.map((function(r){return t.getSuffix(e,r,n)})):[]}},{key:"getSuffix",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.getRule(e,n);return r?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(r.select(t)):this.getSuffixRetroCompatible(r,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var n=this,r=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),i=e.numbers[r];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===i?i="plural":1===i&&(i=""));var o=function(){return n.options.prepend&&i.toString()?n.options.prepend+i.toString():i.toString()};return"v1"===this.options.compatibilityJSON?1===i?"":"number"==typeof i?"_plural_".concat(i.toString()):o():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?o():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}},{key:"shouldUseIntlApi",value:function(){return!rQ.includes(this.options.compatibilityJSON)}}]),e}();function sQ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function lQ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?sQ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sQ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var cQ=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};aJ(this,e),this.logger=CJ.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return uJ(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:FJ,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?BJ(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?BJ(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?BJ(t.nestingPrefix):t.nestingPrefixEscaped||BJ("$t("),this.nestingSuffix=t.nestingSuffix?BJ(t.nestingSuffix):t.nestingSuffixEscaped||BJ(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,r){var i,o,a,s=this,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function c(e){return e.replace(/\$/g,"$$$$")}var u=function(e){if(e.indexOf(s.formatSeparator)<0){var i=LJ(t,l,e);return s.alwaysFormat?s.format(i,void 0,n,lQ(lQ(lQ({},r),t),{},{interpolationkey:e})):i}var o=e.split(s.formatSeparator),a=o.shift().trim(),c=o.join(s.formatSeparator).trim();return s.format(LJ(t,l,a),c,n,lQ(lQ(lQ({},r),t),{},{interpolationkey:a}))};this.resetRegExp();var d=r&&r.missingInterpolationHandler||this.options.missingInterpolationHandler,f=r&&r.interpolation&&void 0!==r.interpolation.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return c(e)}},{regex:this.regexp,safeValue:function(e){return s.escapeValue?c(s.escape(e)):c(e)}}].forEach((function(t){for(a=0;i=t.regex.exec(e);){var n=i[1].trim();if(void 0===(o=u(n)))if("function"==typeof d){var l=d(e,i,r);o="string"==typeof l?l:""}else if(r&&r.hasOwnProperty(n))o="";else{if(f){o=i[0];continue}s.logger.warn("missed to pass in variable ".concat(n," for interpolating ").concat(e)),o=""}else"string"==typeof o||s.useRawValueToEscape||(o=IJ(o));var c=t.safeValue(o);if(e=e.replace(i[0],c),f?(t.regex.lastIndex+=o.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,++a>=s.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var n,r,i=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=lQ({},o);function s(e,t){var n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;var r=e.split(new RegExp("".concat(n,"[ ]*{"))),i="{".concat(r[1]);e=r[0];var o=(i=this.interpolate(i,a)).match(/'/g),s=i.match(/"/g);(o&&o.length%2==0&&!s||s.length%2!=0)&&(i=i.replace(/'/g,'"'));try{a=JSON.parse(i),t&&(a=lQ(lQ({},t),a))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(n).concat(i)}return delete a.defaultValue,e}for(a.applyPostProcessor=!1,delete a.defaultValue;n=this.nestingRegexp.exec(e);){var l=[],c=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){var u=n[1].split(this.formatSeparator).map((function(e){return e.trim()}));n[1]=u.shift(),l=u,c=!0}if((r=t(s.call(this,n[1].trim(),a),a))&&n[0]===e&&"string"!=typeof r)return r;"string"!=typeof r&&(r=IJ(r)),r||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),r=""),c&&(r=l.reduce((function(e,t){return i.format(e,t,o.lng,lQ(lQ({},o),{},{interpolationkey:n[1].trim()}))}),r.trim())),e=e.replace(n[0],r),this.regexp.lastIndex=0}return e}}]),e}();function uQ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function dQ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?uQ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):uQ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function fQ(e){var t={};return function(n,r,i){var o=r+JSON.stringify(i),a=t[o];return a||(a=e(r,i),t[o]=a),a(n)}}var hQ=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};aJ(this,e),this.logger=CJ.create("formatter"),this.options=t,this.formats={number:fQ((function(e,t){var n=new Intl.NumberFormat(e,t);return function(e){return n.format(e)}})),currency:fQ((function(e,t){var n=new Intl.NumberFormat(e,dQ(dQ({},t),{},{style:"currency"}));return function(e){return n.format(e)}})),datetime:fQ((function(e,t){var n=new Intl.DateTimeFormat(e,dQ({},t));return function(e){return n.format(e)}})),relativetime:fQ((function(e,t){var n=new Intl.RelativeTimeFormat(e,dQ({},t));return function(e){return n.format(e,t.range||"day")}})),list:fQ((function(e,t){var n=new Intl.ListFormat(e,dQ({},t));return function(e){return n.format(e)}}))},this.init(t)}return uJ(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}},n=t.interpolation;this.formatSeparator=n.formatSeparator?n.formatSeparator:n.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=fQ(t)}},{key:"format",value:function(e,t,n,r){var i=this,o=t.split(this.formatSeparator).reduce((function(e,t){var o=function(e){var t=e.toLowerCase().trim(),n={};if(e.indexOf("(")>-1){var r=e.split("(");t=r[0].toLowerCase().trim();var i=r[1].substring(0,r[1].length-1);"currency"===t&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):"relativetime"===t&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach((function(e){if(e){var t=SJ(e.split(":")),r=t[0],i=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");n[r.trim()]||(n[r.trim()]=i),"false"===i&&(n[r.trim()]=!1),"true"===i&&(n[r.trim()]=!0),isNaN(i)||(n[r.trim()]=parseInt(i,10))}}))}return{formatName:t,formatOptions:n}}(t),a=o.formatName,s=o.formatOptions;if(i.formats[a]){var l=e;try{var c=r&&r.formatParams&&r.formatParams[r.interpolationkey]||{},u=c.locale||c.lng||r.locale||r.lng||n;l=i.formats[a](e,u,dQ(dQ(dQ({},s),r),c))}catch(e){i.logger.warn(e)}return l}return i.logger.warn("there was no format function for ".concat(a)),e}),e);return o}}]),e}();function pQ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function mQ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pQ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pQ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function gQ(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mJ(e);if(t){var i=mJ(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return pJ(this,n)}}var vQ=function(e){hJ(n,e);var t=gQ(n);function n(e,r,i){var o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return aJ(this,n),o=t.call(this),UJ&&kJ.call(dJ(o)),o.backend=e,o.store=r,o.services=i,o.languageUtils=i.languageUtils,o.options=a,o.logger=CJ.create("backendConnector"),o.waitingReads=[],o.maxParallelReads=a.maxParallelReads||10,o.readingCalls=0,o.maxRetries=a.maxRetries>=0?a.maxRetries:5,o.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,o.state={},o.queue=[],o.backend&&o.backend.init&&o.backend.init(i,a.backend,a),o}return uJ(n,[{key:"queueLoad",value:function(e,t,n,r){var i=this,o={},a={},s={},l={};return e.forEach((function(e){var r=!0;t.forEach((function(t){var s="".concat(e,"|").concat(t);!n.reload&&i.store.hasResourceBundle(e,t)?i.state[s]=2:i.state[s]<0||(1===i.state[s]?void 0===a[s]&&(a[s]=!0):(i.state[s]=1,r=!1,void 0===a[s]&&(a[s]=!0),void 0===o[s]&&(o[s]=!0),void 0===l[t]&&(l[t]=!0)))})),r||(s[e]=!0)})),(Object.keys(o).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(o),pending:Object.keys(a),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(l)}}},{key:"loaded",value:function(e,t,n){var r=e.split("|"),i=r[0],o=r[1];t&&this.emit("failedLoading",i,o,t),n&&this.store.addResourceBundle(i,o,n),this.state[e]=t?-1:2;var a={};this.queue.forEach((function(n){var r,s,l,c,u,d;r=n.loaded,s=o,c=RJ(r,[i],Object),u=c.obj,d=c.k,u[d]=u[d]||[],l&&(u[d]=u[d].concat(s)),l||u[d].push(s),function(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}(n,e),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach((function(e){a[e]||(a[e]={});var t=n.loaded[e];t.length&&t.forEach((function(t){void 0===a[e][t]&&(a[e][t]=!0)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",a),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:i,wait:o,callback:a}):(this.readingCalls++,this.backend[n](e,t,(function(s,l){if(r.readingCalls--,r.waitingReads.length>0){var c=r.waitingReads.shift();r.read(c.lng,c.ns,c.fcName,c.tried,c.wait,c.callback)}s&&l&&i<r.maxRetries?setTimeout((function(){r.read.call(r,e,t,n,i+1,2*o,a)}),o):a(s,l)}))):a(null,{})}},{key:"prepareLoading",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var o=this.queueLoad(e,t,r,i);if(!o.toLoad.length)return o.pending.length||i(),null;o.toLoad.forEach((function(e){n.loadOne(e)}))}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split("|"),i=r[0],o=r[1];this.read(i,o,"read",void 0,void 0,(function(r,a){r&&t.logger.warn("".concat(n,"loading namespace ").concat(o," for language ").concat(i," failed"),r),!r&&a&&t.logger.log("".concat(n,"loaded namespace ").concat(o," for language ").concat(i),a),t.loaded(e,r,a)}))}},{key:"saveMissing",value:function(e,t,n,r,i){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null!=n&&""!==n&&(this.backend&&this.backend.create&&this.backend.create(e,t,n,r,null,mQ(mQ({},o),{},{isUpdate:i})),e&&e[0]&&this.store.addResource(e[0],t,n,r))}}]),n}(kJ);function yQ(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===oJ(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===oJ(e[2])||"object"===oJ(e[3])){var n=e[3]||e[2];Object.keys(n).forEach((function(e){t[e]=n[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,n,r){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function bQ(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function wQ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function xQ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wQ(Object(n),!0).forEach((function(t){gJ(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wQ(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function SQ(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=mJ(e);if(t){var i=mJ(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return pJ(this,n)}}function MQ(){}function _Q(e){Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((function(t){"function"==typeof e[t]&&(e[t]=e[t].bind(e))}))}var AQ=function(e){hJ(n,e);var t=SQ(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;if(aJ(this,n),e=t.call(this),UJ&&kJ.call(dJ(e)),e.options=bQ(r),e.services={},e.logger=CJ,e.modules={external:[]},_Q(dJ(e)),i&&!e.isInitialized&&!r.isClone){if(!e.options.initImmediate)return e.init(r,i),pJ(e,dJ(e));setTimeout((function(){e.init(r,i)}),0)}return e}return uJ(n,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var r=yQ();function i(e){return e?"function"==typeof e?new e:e:null}if(this.options=xQ(xQ(xQ({},r),this.options),bQ(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=xQ(xQ({},r.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){var o;this.modules.logger?CJ.init(i(this.modules.logger),this.options):CJ.init(null,this.options),this.modules.formatter?o=this.modules.formatter:"undefined"!=typeof Intl&&(o=hQ);var a=new eQ(this.options);this.store=new qJ(this.options.resources,this.options);var s=this.services;s.logger=CJ,s.resourceStore=this.store,s.languageUtils=a,s.pluralResolver=new aQ(a,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!o||this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format||(s.formatter=i(o),s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new cQ(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new vQ(i(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];e.emit.apply(e,[t].concat(r))})),this.modules.languageDetector&&(s.languageDetector=i(this.modules.languageDetector),s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=i(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new ZJ(this.services,this.options),this.translator.on("*",(function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];e.emit.apply(e,[t].concat(r))})),this.modules.external.forEach((function(t){t.init&&t.init(e)}))}if(this.format=this.options.interpolation.format,n||(n=MQ),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&"dev"!==l[0]&&(this.options.lng=l[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");var c=["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"];c.forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}}));var u=["addResource","addResources","addResourceBundle","removeResourceBundle"];u.forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments),e}}));var d=TJ(),f=function(){var t=function(t,r){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),d.resolve(r),n(t,r)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?f():setTimeout(f,0),d}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:MQ,r=n,i="string"==typeof e?e:this.language;if("function"==typeof e&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i&&"cimode"===i.toLowerCase())return r();var o=[],a=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach((function(e){o.indexOf(e)<0&&o.push(e)}))};if(i)a(i);else{var s=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);s.forEach((function(e){return a(e)}))}this.options.preload&&this.options.preload.forEach((function(e){return a(e)})),this.services.backendConnector.load(o,this.options.ns,(function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),r(e)}))}else r(null)}},{key:"reloadResources",value:function(e,t,n){var r=TJ();return e||(e=this.languages),t||(t=this.options.ns),n||(n=MQ),this.services.backendConnector.reload(e,t,(function(e){r.resolve(),n(e)})),r}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&KJ.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var n=this.languages[t];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var r=TJ();this.emit("languageChanging",e);var i=function(e){n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.resolvedLanguage=void 0,n.setResolvedLanguage(e)},o=function(o){e||o||!n.services.languageDetector||(o=[]);var a="string"==typeof o?o:n.services.languageUtils.getBestMatchFromCodes(o);a&&(n.language||i(a),n.translator.language||n.translator.changeLanguage(a),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage(a)),n.loadResources(a,(function(e){!function(e,o){o?(i(o),n.translator.changeLanguage(o),n.isLanguageChangingTo=void 0,n.emit("languageChanged",o),n.logger.log("languageChanged",o)):n.isLanguageChangingTo=void 0,r.resolve((function(){return n.t.apply(n,arguments)})),t&&t(e,(function(){return n.t.apply(n,arguments)}))}(e,a)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(o):o(e):o(this.services.languageDetector.detect()),r}},{key:"getFixedT",value:function(e,t,n){var r=this,i=function e(t,i){var o;if("object"!==oJ(i)){for(var a=arguments.length,s=new Array(a>2?a-2:0),l=2;l<a;l++)s[l-2]=arguments[l];o=r.options.overloadTranslationOptionHandler([t,i].concat(s))}else o=xQ({},i);o.lng=o.lng||e.lng,o.lngs=o.lngs||e.lngs,o.ns=o.ns||e.ns,o.keyPrefix=o.keyPrefix||n||e.keyPrefix;var c=r.options.keySeparator||".",u=o.keyPrefix?"".concat(o.keyPrefix).concat(c).concat(t):t;return r.t(u,o)};return"string"==typeof e?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=n,i}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var r=this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===r.toLowerCase())return!0;var a=function(e,n){var r=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===r||2===r};if(n.precheck){var s=n.precheck(this,a);if(void 0!==s)return s}return!!this.hasResourceBundle(r,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!a(r,e)||i&&!a(o,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,r=TJ();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){n.options.ns.indexOf(e)<0&&n.options.ns.push(e)})),this.loadResources((function(e){r.resolve(),t&&t(e)})),r):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=TJ();"string"==typeof e&&(e=[e]);var r=this.options.preload||[],i=e.filter((function(e){return r.indexOf(e)<0}));return i.length?(this.options.preload=r.concat(i),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:MQ,i=xQ(xQ(xQ({},this.options),t),{isClone:!0}),o=new n(i);void 0===t.debug&&void 0===t.prefix||(o.logger=o.logger.clone(t));var a=["store","services","language"];return a.forEach((function(t){o[t]=e[t]})),o.services=xQ({},this.services),o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o.translator=new ZJ(o.services,o.options),o.translator.on("*",(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];o.emit.apply(o,[e].concat(n))})),o.init(i,r),o.translator.options=o.options,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),n}(kJ);gJ(AQ,"createInstance",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return new AQ(e,t)}));var EQ=AQ.createInstance();EQ.createInstance=AQ.createInstance;EQ.createInstance,EQ.init,EQ.loadResources,EQ.reloadResources,EQ.use,EQ.changeLanguage,EQ.getFixedT,EQ.t,EQ.exists,EQ.setDefaultNamespace,EQ.hasLoadedNamespace,EQ.loadNamespaces,EQ.loadLanguages;var CQ,kQ=EQ;CQ=JSON.parse('{"yes":"Si","no":"No","confirm":"Conferma","apply":"Applica","cancel":"Annulla","show":"Mostra","hide":"Nascondi","send":"Invia","close":"Chiudi","edit":"Modifica","delete":"Elimina","loading":"Caricamento","expand":"Espandi","fullscreenEnter":"Passa a schermo intero","fullscreenExit":"Esci da schermo intero","center":"Centro","bottom":"In basso","hidden":"Nascosto","day":"Giorno","month":"Mese","year":"Anno","copy":"Copia","copyToClipboard":"Copia negli appunti","showOriginalText":"Mostra originale","showTranslatedText":"Mostra traduzione","memoriBlockedTitle":"Bloccato","memoriBlockedUntil":"Memori bloccato fino al {{date}}","memoriBlockedAnon":"Attualmente \\"{{name}}\\" non può rispondere, torna qui il {{date}}","memoriBlockedReasonExceedChats":"perchè ha superato la soglia mensile di chat ammesse.","memoriBlockedGiverHelper":"Puoi sempre gestirlo in qualità di amministratore, ma altri utenti non potranno interrogarlo.","generatedByAI":"Risposta generata da IA, può talvolta generare informazioni non corrette","completionsEnabled":"IA evoluta, può rispondere con risposte generate automaticamente che talvolta potrebbero contenere informazioni non corrette","birthDate":"Data di nascita","birthDateHelper":"Ti chiediamo la data di nascita esclusivamente per abilitare o disabilitare le funzionalità che hanno restrizioni in base all\'età","underage":"Devi avere almeno {{age}} anni per registrarti.","underageTwinSession":"Devi avere almeno {{age}} anni per interagire con questo Twin.","ageVerification":"Verifica dell\'età","ageVerificationText":"Per interagire con questo Twin, devi aver almeno {{minAge}} anni.","nsfw":"NSFW: Questo Twin contiene contenuti per adulti","auth":{"useRecoveryTokens":"Utilizza i token di recupero","tokens":"Token","addToken":"Aggiungi token","usePassword":"Utilizza la password","atLeast":"Almeno"},"widget":{"instruct":"Istruisci","test":"Prova","sound":"Audio","position":"Posizione","settings":"Impostazioni","share":"Condividi","sendOnKeypress":"Premi Invio per inviare","sendOnClick":"Clicca sul bottone di invio","goToIntegrationsToCustomizeAvatar":"Per personalizzare l\'avatar, vai a Condividimi e configura la pagina pubblica"},"write_and_speak":{"micButtonPopover":"Premi il pulsante per parlare","micButtonPopoverListening":"Premi il pulsante per smettere di parlare","pageInstructExplanation":"Per insegnarmi nuove cose clicca sul pulsante ISTRUISCIMI per cominciare","pageTryMeExplanation":"Per parlare con me clicca sul pulsante INIZIAMO per cominciare","instructButton":"ISTRUISCIMI","tryMeButton":"INIZIAMO","chatHistory":"Cronologia chat","exportChatHistory":"Esporta la cronologia chat","exportChatHistoryMessage":"Vuoi esportare la cronologia chat?","chatBotButtonText":"CLICCA QUI PER APRIRE LA CHAT","conversationStartedLabel":"Conversazione avvenuta il","settingsHeaderLabel":"Configura qui il memori se vuoi impostare una conversazione continua. Setta i secondi di silenzio prima dell\'invio.","continuousSpeechLabel":"Conversazione continua","secondsLabel":"Secondi","controlsPosition":"Posizione dei controlli","tryMeHeaderLabel":"PROVA","unknownPosition":"Posizione sconosciuta","fieldPlace":"Indica la posizione (es \'Milano\')","showMapLinkFor":"Visualizza sulla mappa la posizione","useMyPosition":"Usa la mia posizione","myPosition":"Posizione corrente","updatingPosition":"Aggiorno la posizione...","placeNotFound":"Luogo sconosciuto!","requirePosition":"Inserisci la posizione prima di iniziare","attachmentsLabel":"Arricchisci il tuo messaggio","iWantToTalkToIn":"Voglio parlare con {{name}} in"},"media":{"title":"Titolo","editAttributes":"Modifica attributi media","uploadMimeTypeNotAllowed":"Il tipo di file non è permesso","uploadSizeLimitMessage":"Il file caricato è troppo grande (max {{size}}MB)","uploadWrongResolutionMessage":"La risoluzione deve essere {{width}}x{{height}} pixel","memoriNameAlreadyUsed":"Hai già un Twin con questo nome","uploadHelperImages":"Caricare un file con estensione png, jpg, jpeg o gif e con dimensione massima di {{size}}MB","uploadHelper":"Caricare un file di dimensione massima di {{size}}MB","uploadError":"Errore nel caricamento","square":"quadrato","scaleRatio":"Proporzioni","addMediaLabel":"Aggiungi media","insertThisMediaMsg":"Inserisci questi media","mediaUploadMessage":"Clicca per caricare un nuovo media","addLinkLabel":"Aggiungi un link","linkKey":"URL","linkValue":"Titolo link","insertThisLink":"Inserisci un link a {{url}} con titolo {{title}}"},"gamification":{"level":"Livello","points":"punti","memoriReachedLevel":"è diventato più evoluto ed ha raggiunto il livello","levelGoToStatistics":"{{memori}} è al livello {{level}} con {{points}} punti. Clicca per andare alle statistiche.","congratulationsNewLevel":"Congratulazioni, hai raggiunto un nuovo livello!","congratulationsNewLevelDescription":"Il tuo Memori è diventato più evoluto con {{points}} punti, guarda le","statistics":"statistiche"},"success":"Operazione andata a buon fine","Error":"Errore","internal server error":"Ops, scusa... qualcosa è andato storto nel server","error":"Errore","error.loading":"Errore durante il caricamento dei contenuti.","error.notFound":"Ops, non abbiamo trovato ciò che cercavi.","error.generic":"Ops, qualcosa è andato storto.","error.serverNotResponding":"Stiamo facendo manutenzione o rilasciando aggiornamenti. Riprova più tardi.","error.unprocessableEntity":"Errore durante il salvataggio dei dati. Ricontrolla i dati inseriti.","error.goBackTo":"Prova a tornare alla","error.reloadPage":"Ricarica la pagina","error.tryAgain":"Riprova","error.unauthorized":"Non sei autorizzato a visualizzare questo contenuto.","errors":{"TENANT_NOT_FOUND":"Tenant non trovato","TENANT_REGISTRATION_DISABLED":"La registrazione su questa piattaforma è disabilitata","TENANT_MISSING_NAME":"Tenant: nome mancante","TENANT_MAX_USERS_REACHED":"Numero massimo di utenti raggiunto","TENANT_MAX_ADMINS_REACHED":"Numero massimo di utenti amministratori raggiunto","USER_NOT_CONFIRMED":"Utente ancora non confermato","USER_NOT_FOUND":"Utente non trovato","USER_OR_PASSWORD_INVALID":"Utente o password non validi","USER_MUST_CHANGE_PASSWORD":"Devi cambiare la password","USER_MUST_ENTER_VERIFICATION_CODE":"Devi inserire il codice di verifica","USER_MISSING_TENANT":"Utente: tenant mancante","USER_MISSING_NAME":"Utente: nome mancante","USER_MISSING_PASSWORD":"Utente: password mancante","USER_MISSING_EMAIL":"Utente: email mancante","USER_MISSING_VERIFICATION_CODE":"Utente: codice di verifica mancante","USER_NAME_ALREADY_USED":"Nome utente già in uso","USER_PASSWORD_NOT_CONFORMING_TO_POLICY":"La password non rispetta le regole di sicurezza","USER_EMAIL_ALREADY_USED":"Email già in uso","USER_EMAIL_INVALID":"Email non valida","USER_VERIFICATION_CODE_INVALID":"Codice di verifica non valido","USER_MISSING_NAME_OR_EMAIL":"Nome utente o email mancante","USER_NAME_INVALID":"Nome utente non valido","USER_HAS_ONE_OR_MORE_MEMORI":"L\'utente ha uno o più memori","USER_MISSING_NEW_PASSWORD":"Utente: nuova password mancante","USER_NOTHING_TO_DO":"Niente da fare","USER_CANT_CREATE_MEMORI":"Utente non abilitato a creare Memori","USER_MAX_MEMORI_REACHED":"Massimo numero di Memori raggiunto","USER_CANT_EDIT_INTEGRATIONS":"Utente non abilitato a gestire integrazioni","MEMORI_NOT_FOUND":"Memori non trovato","MEMORI_NOT_ACCESSIBLE":"Memori non accessibile","MEMORI_ONLY_OWNER_CAN_CHANGE_GIVER_TAG_AND_PIN":"Solo il proprietario può cambiare il tag e il pin","SESSION_NOT_FOUND":"Sessione non trovata","SESSION_IS_NOT_ADMINISTRATIVE":"Sessione non amministrativa","MEMORI_MISSING_CONFIGURATION":"Memori: configurazione mancante","MEMORI_CONFIGURATION_NOT_FOUND":"Memori: configurazione non trovata","MEMORI_INVALID_PRIVACY_TYPE":"Memori: tipo di privacy non valido","MEMORI_MISSING_PASSWORD":"Memori: password mancante","MEMORI_INVALID_TOTAL_NUMBER_OF_RECOVERY_TOKENS":"Memori: numero totale di token di recupero non valido","MEMORI_INVALID_MINIMUM_NUMBER_OF_RECOVERY_TOKENS":"Memori: numero minimo di token di recupero non valido","MEMORI_INVALID_VOICE_TYPE":"Memori: tipo di voce non valido","MEMORI_MISSING_NAME":"Memori: nome mancante","MEMORI_MISSING_PASSWORD_OR_RECOVERY_TOKENS":"Memori: password o token di recupero mancanti","MEMORI_INVALID_ID":"Memori: ID non valido","MEMORI_NAME_ALREADY_USED":"Nome memori già in uso","MEMORI_INVALID_PIN":"Memori: PIN non valido","MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION":"Memori: cambio TAG e PIN richiedono operazioni separate","MEMORI_NO_PASSWORD_WHEN_PUBLIC":"Memori: password non richiesta su Memori pubblico","MEMORI_TRANSFER_MISSING_DESTINATION_USER":"Trasferimento: utente di destinazione mancante","MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID":"Trasferimento: ID utente di destinazione non valido","MEMORI_TRANSFER_DESTINATION_USER_DATA_INCONSISTENT":"Trasferimento: dati utente di destinazione non validi","MEMORI_TRANSFER_NOTHING_TO_DO":"Trasferimento: alcuna operazione da fare","MEMORI_CONFIGURATION_CANT_BE_CHANGED":"Memori: la configurazione non può essere modificata","MEMORI_MISSING_NEW_PASSWORD":"Memori: nuova password mancante","INTEGRATION_NOT_FOUND":"Integrazione non trovata","MEMORI_SESSIONS_INVALID_DATE_FROM_FORMAT":"Formato non valido data a partire da","MEMORI_SESSIONS_INVALID_DATE_TO_FORMAT":"Formato non valido data fino a","INTEGRATION_INVALID_TYPE":"Tipo integrazione non valido","INTEGRATION_ALREADY_EXISTS":"Integrazione già esistente","INTEGRATION_MEMORI_IS_NOT_PUBLIC":"Memori non pubblici non possono essere integrati","INTEGRATION_MISSING_INVOCATION_TEXT":"Integrazione: testo di invocazione mancante","INTEGRATION_MISSING_DEVICE_EMAILS":"Integrazione: email del dispositivo mancante","INTEGRATION_MEMORI_IS_EMPTY":"Memori vuoti non possono essere integrati","INTEGRATION_MISSING_PRIVACY_POLICY":"Integrazione: privacy policy mancante","INTEGRATION_MISSING_CATEGORY":"Categoria integrazione mancante","INTEGRATION_MISSING_DESCRIPTION":"Descrizione integrazione mancante","INTEGRATION_INVALID_INVOCATION_TEXT":"Testo di invocazione non valido","INTEGRATION_GOOGLE_NO_MORE_AVAILABLE":"Google Home non più disponibile","UPLOAD_REQUIRES_MULTIPART_ENCODING":"L\'upload richiede l\'encoding multipart","UPLOAD_MISSING_CONTENT_TYPE_BOUNDARY":"Upload: manca il content type boundary","UPLOAD_MAX_LENGTH_EXCEEDED":"Upload: dimensione massima superata","UPLOAD_FILE_IS_EMPTY":"Upload: file vuoto","UPLOAD_INVALID_FILE_TYPE_OR_SIGNATURE":"Upload: tipo di file o firma non validi","UPLOAD_MISSING_FILE_NAME":"Upload: nome file mancante","UPLOAD_INVALID_MEMORY_ID":"Upload: ID contenuto non valido","UPLOAD_MISSING_FILE_CONTENT":"Upload: contenuto file mancante","ASSET_NOT_FOUND":"Asset non trovato","ASSET_NOT_ACCESSIBLE":"Asset non accessibile","ASSET_MISSING_SESSION_ID":"Asset: ID sessione mancante","ASSET_INVALID_FILE_NAME":"Asset: nome file non valido","INVITATION_NOT_FOUND":"Invito non trovato","INVITATION_NOT_ACCESSIBLE":"Invito non accessibile","INVITATION_ALREADY_ACCEPTED":"Invito già accettato","INVITATION_ALREADY_REJECTED":"Invito già rifiutato","INVITATION_MISSING_DESTINATION_EMAIL":"Invito: email di destinazione mancante","INVITATION_DESTINATION_EMAIL_INVALID":"Invito: email di destinazione non valida","INVITATION_MISSING_TAG":"Invito: tag mancante","INVITATION_MISSING_PIN":"Invito: PIN mancante","INVITATION_INVALID_PIN":"Invito: PIN non valido","INVITATION_INVALID_TYPE":"Invito: tipo non valido","INVITATION_MISSING_DESTINATION_NAME":"Invito: nome destinatario mancante","INVITATION_TAG_PIN_CANT_BE_CHANGED":"Invito: tag e pin non possono essere cambiati","INVITATION_CANT_BE_CHANGED":"Invito: non può essere modificato","ACTIONLOG_INVALID_USER_ID":"ID utente non valido","ACTIONLOG_INVALID_DATE_FROM_FORMAT":"Data a partire da: formato non valido","ACTIONLOG_INVALID_DATE_TO_FORMAT":"Data fino a: formato non valido","ACTIONLOG_INVALID_MEMORI_ID":"ID Memori non valido","CONSUMPTIONLOG_INVALID_TYPE":"Tipo di log non valido","CONSUMPTIONLOG_INVALID_DATE_FROM_FORMAT":"Data a partire da: formato non valido","CONSUMPTIONLOG_INVALID_DATE_TO_FORMAT":"Data fino a: formato non valido","CONSUMPTIONLOG_INVALID_USER_ID":"ID utente non valido","CONSUMPTIONLOG_INVALID_MEMORI_ID":"Memori ID non valido"}}');const TQ={en:{translation:r(JSON.parse('{"yes":"Yes","no":"No","confirm":"Confirm","apply":"Apply","cancel":"Cancel","show":"Show","hide":"Hide","send":"Send","close":"Close","edit":"Edit","delete":"Delete","loading":"Loading","expand":"Expand","fullscreenEnter":"Enter fullscreen","fullscreenExit":"Exit fullscreen","center":"Center","bottom":"Bottom","hidden":"Hidden","day":"Day","month":"Month","year":"Year","copy":"Copy","copyToClipboard":"Copy to clipboard","showOriginalText":"Show original","showTranslatedText":"Show translation","memoriBlockedTitle":"Blocked","memoriBlockedUntil":"Memori blocked until {{date}}","memoriBlockedAnon":"Currently \\"{{name}}\\" can\'t answer, come back here on {{date}}","memoriBlockedReasonExceedChats":"because it has exceeded the monthly threshold of allowed chats.","memoriBlockedGiverHelper":"You can still manage it as administrator, but other users will not be able to interact with it.","generatedByAI":"Answer generated by AI, may occasionally generate incorrect informations","completionsEnabled":"Advanced AI, can respond with automatically generated answers that may sometimes contain incorrect information","birthDate":"Birth date","birthDateHelper":"We ask for your birth date only to enable or disable functionalities that have age restrictions","underage":"You must be at least {{age}} years old to sign up.","underageTwinSession":"You must be at least {{age}} years old to interact with this Twin.","ageVerification":"Age verification","ageVerificationText":"To interact with this Twin, you must be at least {{minAge}} years old.","nsfw":"NSFW: This Twin contains adult contents","auth":{"useRecoveryTokens":"Use recovery tokens","tokens":"Tokens","addToken":"Add token","usePassword":"Use password","atLeast":"At least"},"widget":{"instruct":"Instruct","test":"Test","sound":"Sound","position":"Position","settings":"Settings","share":"Share","sendOnKeypress":"Hit Enter to send","sendOnClick":"Click on Submit","goToIntegrationsToCustomizeAvatar":"To customize the avatar, go to Share and customize the public page"},"write_and_speak":{"micButtonPopover":"Click the button to speak","micButtonPopoverListening":"Click the button to stop speak","pageInstructExplanation":"To teach me new things click on the INSTRUCT ME button to get started","pageTryMeExplanation":"To talk to me click on the START button to get started","instructButton":"INSTRUCT ME","tryMeButton":"START","chatHistory":"Chat history","exportChatHistory":"Export chat history","exportChatHistoryMessage":"Do you want to export chat history?","chatBotButtonText":"CLICK HERE TO OPEN CHATBOT","conversationStartedLabel":"Conversation started on","settingsHeaderLabel":"Setup here if you want to set the memori as continuous speech, and change the silence seconds if you want to customize them.","continuousSpeechLabel":"Continuous speech","secondsLabel":"Set seconds","controlsPosition":"Controls position","tryMeHeaderLabel":"TRY","unknownPosition":"Unknown position","fieldPlace":"Write the place (eg \'Milano\')","showMapLinkFor":"Show the position on the map","useMyPosition":"Use my position","myPosition":"Your position","updatingPosition":"Updating position...","placeNotFound":"Place not found!","requirePosition":"Insert your position before start","attachmentsLabel":"Enrich your message","iWantToTalkToIn":"I want to talk to {{name}} in"},"media":{"title":"Title","editAttributes":"Edit media attributes","uploadMimeTypeNotAllowed":"The file type is not allowed","uploadSizeLimitMessage":"The uploaded size is too big (max {{size}}MB)","uploadWrongResolutionMessage":"The resolution must be {{width}}x{{height}} pixel","memoriNameAlreadyUsed":"You already have a Twin with this name","uploadHelperImages":"Upload a file with extension png, jpg, jpeg or gif, and having at maximum a size of {{size}}MB","uploadHelper":"Upload a file having at maximum a size of {{size}}MB","uploadError":"Upload failed","square":"square","scaleRatio":"Scale ratio","addMediaLabel":"Add a media","insertThisMediaMsg":"Insert these media","mediaUploadMessage":"Click to load a new media","addLinkLabel":"Add a link","linkKey":"URL","linkValue":"Link title","insertThisLink":"Insert a link to {{url}} with title {{title}}"},"gamification":{"level":"Level","points":"points","memoriReachedLevel":"became more evolved and reached level","levelGoToStatistics":"{{memori}} is at level {{level}} with {{points}} points. Click to go to statistics.","congratulationsNewLevel":"Congratulations, you have reached a new level!","congratulationsNewLevelDescription":"Your Memori became more evolved with {{points}} points, look at the","statistics":"statistics"},"success":"Success","Error":"Error","internal server error":"Oupsie, sorry... Something went wrong on the server","error":"Error","error.loading":"Error while loading content.","error.generic":"Oupsie, sorry... something went wrong.","error.serverNotResponding":"We are doing maintenance or releasing updates. Please try again later.","error.notFound":"Oupsie, we didn\'t find the page you were looking for.","error.goBackTo":"You can try to go back to the","error.reloadPage":"Reload the page","error.tryAgain":"Try again","error.unauthorized":"You are unauthorized to view this content.","error.unprocessableEntity":"Error while processing the request. Check the data you entered.","errors":{"TENANT_NOT_FOUND":"Tenant not found","TENANT_REGISTRATION_DISABLED":"Registration on this platform is disabled","TENANT_MISSING_NAME":"Tenant: name missing","TENANT_MAX_USERS_REACHED":"Maximum number of users reached","TENANT_MAX_ADMINS_REACHED":"Maximum number of admin users reached","USER_NOT_CONFIRMED":"User still not confirmed","USER_NOT_FOUND":"User not found","USER_OR_PASSWORD_INVALID":"Invalid user or password","USER_MUST_CHANGE_PASSWORD":"You must change your password","USER_MUST_ENTER_VERIFICATION_CODE":"You must enter the verification code","USER_MISSING_TENANT":"User: missing tenant","USER_MISSING_NAME":"User: name is missing","USER_MISSING_PASSWORD":"User: password missing","USER_MISSING_EMAIL":"User: Missing email","USER_MISSING_VERIFICATION_CODE":"User: Missing verification code","USER_NAME_ALREADY_USED":"User name already in use","USER_PASSWORD_NOT_CONFORMING_TO_POLICY":"The password does not meet the security rules","USER_EMAIL_ALREADY_USED":"Email already in use","USER_EMAIL_INVALID":"Invalid email","USER_VERIFICATION_CODE_INVALID":"Invalid verification code","USER_MISSING_NAME_OR_EMAIL":"Missing username or email","USER_NAME_INVALID":"Invalid user name","USER_HAS_ONE_OR_MORE_MEMORI":"The user has one or more memories","USER_MISSING_NEW_PASSWORD":"User: new password missing","USER_NOTHING_TO_DO":"Nothing to do","USER_CANT_CREATE_MEMORI":"User not allowed to create Memori","USER_MAX_MEMORI_REACHED":"Maximum number of Memori reached","USER_CANT_EDIT_INTEGRATIONS":"User not allowed to manage integrations","MEMORI_NOT_FOUND":"Memori not found","MEMORI_NOT_ACCESSIBLE":"Memori not accessible","MEMORI_ONLY_OWNER_CAN_CHANGE_GIVER_TAG_AND_PIN":"Only owner can change tag or pin","SESSION_NOT_FOUND":"Session not found","SESSION_IS_NOT_ADMINISTRATIVE":"Non-administrative session","MEMORI_MISSING_CONFIGURATION":"Memori: missing configuration","MEMORI_CONFIGURATION_NOT_FOUND":"Memories: configuration not found","MEMORI_INVALID_PRIVACY_TYPE":"Memories: invalid privacy type","MEMORI_MISSING_PASSWORD":"Memori: missing password","MEMORI_INVALID_TOTAL_NUMBER_OF_RECOVERY_TOKENS":"Memories: total number of invalid recovery tokens","MEMORI_INVALID_MINIMUM_NUMBER_OF_RECOVERY_TOKENS":"Memories: minimum number of invalid recovery tokens","MEMORI_INVALID_VOICE_TYPE":"Memories: invalid voice type","MEMORI_MISSING_NAME":"Memories: missing name","MEMORI_MISSING_PASSWORD_OR_RECOVERY_TOKENS":"Memories: missing password or recovery token","MEMORI_INVALID_ID":"Memories: invalid ID","MEMORI_NAME_ALREADY_USED":"Memory name already in use","MEMORI_INVALID_PIN":"Memories: Invalid PIN","MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION":"Memories: TAG and PIN change require separate operations","MEMORI_NO_PASSWORD_WHEN_PUBLIC":"Memories: no password required when public","MEMORI_TRANSFER_MISSING_DESTINATION_USER":"Transfer: missing destination user","MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID":"Transfer: invalid destination user ID","MEMORI_TRANSFER_DESTINATION_USER_DATA_INCONSISTENT":"Transfer: invalid destination user data","MEMORI_TRANSFER_NOTHING_TO_DO":"Transfer: nothing to do","MEMORI_CONFIGURATION_CANT_BE_CHANGED":"Memories: configuration cannot be changed","MEMORI_MISSING_NEW_PASSWORD":"Memories: new password missing","INTEGRATION_NOT_FOUND":"Integration not found","MEMORI_SESSIONS_INVALID_DATE_FROM_FORMAT":"Invalid date from format","MEMORI_SESSIONS_INVALID_DATE_TO_FORMAT":"Invalid date to format","INTEGRATION_INVALID_TYPE":"Invalid integration type","INTEGRATION_ALREADY_EXISTS":"Integration already exists","INTEGRATION_MEMORI_IS_NOT_PUBLIC":"Non-public memories cannot be integrated","INTEGRATION_MISSING_INVOCATION_TEXT":"Integration: missing invocation text","INTEGRATION_MISSING_DEVICE_EMAILS":"Integration: missing device email","INTEGRATION_MEMORI_IS_EMPTY":"Empty memories cannot be integrated","INTEGRATION_MISSING_PRIVACY_POLICY":"Integration: privacy policy missing","INTEGRATION_MISSING_CATEGORY":"Integration category missing","INTEGRATION_MISSING_DESCRIPTION":"Missing integration description","INTEGRATION_INVALID_INVOCATION_TEXT":"Invalid invocation text","INTEGRATION_GOOGLE_NO_MORE_AVAILABLE":"Google Home no more available","UPLOAD_REQUIRES_MULTIPART_ENCODING":"Upload requires multipart encoding","UPLOAD_MISSING_CONTENT_TYPE_BOUNDARY":"Upload: missing content type boundary","UPLOAD_MAX_LENGTH_EXCEEDED":"Upload: maximum size exceeded","UPLOAD_FILE_IS_EMPTY":"Upload: empty file","UPLOAD_INVALID_FILE_TYPE_OR_SIGNATURE":"Upload: invalid file type or signature","UPLOAD_MISSING_FILE_NAME":"Upload: missing file name","UPLOAD_INVALID_MEMORY_ID":"Upload: Invalid content ID","UPLOAD_MISSING_FILE_CONTENT":"Upload: Missing file content","ASSET_NOT_FOUND":"Asset not found","ASSET_NOT_ACCESSIBLE":"Asset not accessible","ASSET_MISSING_SESSION_ID":"Asset: missing session ID","ASSET_INVALID_FILE_NAME":"Asset: invalid file name","INVITATION_NOT_FOUND":"Invitation not found","INVITATION_NOT_ACCESSIBLE":"Invitation not accessible","INVITATION_ALREADY_ACCEPTED":"Invitation already accepted","INVITATION_ALREADY_REJECTED":"Invitation already rejected","INVITATION_MISSING_DESTINATION_EMAIL":"Invitation: missing destination email","INVITATION_DESTINATION_EMAIL_INVALID":"Invitation: destination email invalid","INVITATION_MISSING_TAG":"Invitation: missing tag","INVITATION_MISSING_PIN":"Invitation: PIN missing","INVITATION_INVALID_PIN":"Invitation: invalid PIN","INVITATION_INVALID_TYPE":"Invitation: invalid type","INVITATION_MISSING_DESTINATION_NAME":"Invitation: destination name missing","INVITATION_TAG_PIN_CANT_BE_CHANGED":"Invitation: tag and pin can\'t be changed","INVITATION_CANT_BE_CHANGED":"Intation: can\'t be changed","ACTIONLOG_INVALID_USER_ID":"Invalid user ID","ACTIONLOG_INVALID_DATE_FROM_FORMAT":"Date from: invalid format","ACTIONLOG_INVALID_DATE_TO_FORMAT":"Date to: invalid format","ACTIONLOG_INVALID_MEMORI_ID":"Invalid Memori ID","CONSUMPTIONLOG_INVALID_TYPE":"Invalid log type","CONSUMPTIONLOG_INVALID_DATE_FROM_FORMAT":"Date from: invalid format","CONSUMPTIONLOG_INVALID_DATE_TO_FORMAT":"Date to: invalid format","CONSUMPTIONLOG_INVALID_USER_ID":"Invalid user ID","CONSUMPTIONLOG_INVALID_MEMORI_ID":"Invalid Memori ID"}}'))},it:{translation:r(CQ)}};kQ.use(ye).init({resources:TQ,lng:"en",fallbackLng:"it",supportedLngs:["en","it"],nonExplicitSupportedLngs:!0,interpolation:{escapeValue:!1}});var IQ=kQ;const OQ=({ownerUserName:e,ownerUserID:t,memoriName:n,memoriID:r,integrationID:i,tenantID:o,secretToken:a,sessionID:l,layout:c="DEFAULT",showShare:d=!0,showSettings:f=!0,showInstruct:h=!1,height:p="100%",baseURL:m,apiURL:g="https://backend.memori.ai",tag:v,pin:y,context:b,initialQuestion:w,uiLang:x,spokenLang:S,authToken:M,AZURE_COGNITIVE_SERVICES_TTS_KEY:_,onStateChange:A})=>{var E,C,k;const[T,I]=(0,u.useState)(),{t:O}=Te();if(!(r&&t||n&&e))throw new Error("Identifier pair required: please provide either memoriID and ownerUserID or memoriName and ownerUserName");const R=W(g),P=(0,u.useCallback)((async()=>{if(r&&t){const{memori:e,...n}=await R.backend.getMemoriByUserAndId(o,t,r);0===n.resultCode&&e?I(e):console.error("[MEMORI]",n,e)}else if(n&&e){const{memori:t,...r}=await R.backend.getMemori(o,e,n);0===r.resultCode&&t?I(t):console.error("[MEMORI]",r,t)}}),[r,t,n,e,o]);return(0,u.useEffect)((()=>{P()}),[P,o]),(0,u.useEffect)((()=>{if(x)IQ.changeLanguage(x.toLowerCase());else{const{lng:e,fallbackLng:t}=(()=>{const e=navigator.language;if(e){let t=e.split("-")[0];if(["en","it"].includes(t))return{lng:t,fallbackLng:"en"===t?"it":"en"}}return{lng:"en",fallbackLng:"it"}})();IQ.changeLanguage(e).catch((()=>{IQ.changeLanguage(t)}))}}),[x]),T?(0,s.jsx)(iJ,{layout:c,height:p,baseUrl:m||(o.startsWith("https://")?o:`https://${o}`),apiUrl:g,memori:{...T,secretToken:a},memoriLang:null!=S?S:null===(C=null===(E=T.culture)||void 0===E?void 0:E.split("-"))||void 0===C?void 0:C[0],tenant:{id:o,theme:"twincreator",config:{name:o,showNewUser:!1,requirePosition:!!T.needsPosition}},secret:a,sessionID:l,showShare:d,showSettings:f,showInstruct:h,integration:null===(k=null==T?void 0:T.integrations)||void 0===k?void 0:k.find((e=>i?e.integrationID===i:!!e.publish&&"LANDING_EXPERIENCE"===e.type)),initialContextVars:b,initialQuestion:w,authToken:M,AZURE_COGNITIVE_SERVICES_TTS_KEY:_,onStateChange:A,...v&&y?{personification:{tag:v,pin:y}}:{}}):(0,s.jsx)("div",{children:(0,s.jsxs)("p",{style:{textAlign:"center",margin:"2rem auto"},children:[O("loading"),"..."]})})};OQ.propTypes={memoriName:r(l).string,memoriID:r(l).string,ownerUserName:r(l).string,ownerUserID:r(l).string,integrationID:r(l).string,tenantID:r(l).string.isRequired,secretToken:r(l).string,sessionID:r(l).string,showShare:r(l).bool,showSettings:r(l).bool,showInstruct:r(l).bool,layout:r(l).oneOf(["DEFAULT","FULLPAGE","TOTEM"]),height:r(l).oneOfType([r(l).string,r(l).number]),baseURL:r(l).string,apiURL:r(l).string,tag:r(l).string,pin:r(l).string,context:r(l).objectOf(r(l).any),initialQuestion:r(l).string,uiLang:r(l).oneOf(["en","it"]),spokenLang:r(l).string,authToken:r(l).string,AZURE_COGNITIVE_SERVICES_TTS_KEY:r(l).string,onStateChange:r(l).func};var RQ=OQ;class PQ extends HTMLElement{connectedCallback(){const e=document.createElement("div"),t=document.createElement("div");t.setAttribute("id","memori-root"),e.appendChild(t),this.appendChild(e);const n=Object.keys(RQ.propTypes).reduce(((e,t)=>(this.hasAttribute(t)&&(e[t]=this.getAttribute(t)),e)),{}),i=this.getAttribute("tenantId"),o=this.getAttribute("context")?.split(",")?.reduce(((e,t)=>{const[n,r]=t.split(":").map((e=>e.trim()));return{...e,[n]:r}}),{});i?r(c).render((0,s.jsx)(RQ,{...n,context:o,tenantID:i}),t):console.error("No tenantId attribute found")}}customElements.define("memori-client",PQ)})();
|